feat: Implement group management features with Firestore integration and loading states

This commit is contained in:
Dayron
2025-10-09 11:13:12 +02:00
parent 8c515e64ba
commit 3f9195d67a
4 changed files with 182 additions and 16 deletions

View File

@@ -0,0 +1,26 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:travel_mate/models/group.dart';
class GroupService {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
Stream<List<Group>> getGroupsStream() {
return _firestore.collection('groups').snapshots().map((snapshot) {
return snapshot.docs.map((doc) {
return Group.fromMap(doc.data(), doc.id);
}).toList();
});
}
Future<void> createGroup(Group group) async {
await _firestore.collection('groups').add(group.toMap());
}
Future<void> updateGroup(Group group) async {
await _firestore.collection('groups').doc(group.id).update(group.toMap());
}
Future<void> deleteGroup(String groupId) async {
await _firestore.collection('groups').doc(groupId).delete();
}
}