diff --git a/lib/src/common/widgets/coustome_snack_bar.dart b/lib/src/common/widgets/coustome_snack_bar.dart index f1cbb14..5fa50b5 100644 --- a/lib/src/common/widgets/coustome_snack_bar.dart +++ b/lib/src/common/widgets/coustome_snack_bar.dart @@ -5,8 +5,9 @@ class CoustomeSnackBar extends SnackBar { {Key? key, required Widget content, bool isFailed = false}) : super( key: key, - backgroundColor: - (isFailed) ? Colors.red : Theme.of(context).primaryColor, + backgroundColor: (isFailed) + ? Theme.of(context).errorColor + : Theme.of(context).primaryColor, padding: const EdgeInsets.only( left: 20, right: 8, diff --git a/lib/src/features/content/controllers/edit_mode.dart b/lib/src/features/content/controllers/edit_mode.dart new file mode 100644 index 0000000..23aa5cc --- /dev/null +++ b/lib/src/features/content/controllers/edit_mode.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class EditMode with ChangeNotifier { + bool _enabled = false; + bool get enabled => _enabled; + bool get notEnabled => !_enabled; + set setEnabled(bool value) { + if (_enabled == value) return; + _enabled = value; + notifyListeners(); + } +} diff --git a/lib/src/features/content/pages/content.dart b/lib/src/features/content/pages/content.dart new file mode 100644 index 0000000..a973845 --- /dev/null +++ b/lib/src/features/content/pages/content.dart @@ -0,0 +1,158 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:gst_todo/src/common/widgets/coustome_snack_bar.dart'; +import 'package:gst_todo/src/features/content/controllers/edit_mode.dart'; + +class ContentPage extends StatefulWidget { + const ContentPage({Key? key, required this.documentSnapshot}) + : super(key: key); + final QueryDocumentSnapshot> documentSnapshot; + + @override + _ContentPageState createState() => _ContentPageState(); +} + +class _ContentPageState extends State { + final EditMode _editMode = EditMode(); + late final TextEditingController _textController; + @override + void initState() { + _textController = + TextEditingController(text: widget.documentSnapshot.data()["text"]); + super.initState(); + } + + @override + void dispose() { + super.dispose(); + _editMode.dispose(); + _textController.dispose(); + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _editMode, + builder: (context, child) { + return Scaffold( + appBar: AppBar( + title: const Text("Content"), + ), + body: StreamBuilder>>( + stream: widget.documentSnapshot.reference.snapshots(), + initialData: widget.documentSnapshot, + builder: (context, snapshot) { + return Container( + color: Theme.of(context).disabledColor.withOpacity(0.2), + child: Column( + children: [ + Expanded( + child: ListView( + padding: const EdgeInsets.all(10), + children: [ + Container( + decoration: BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.circular(10), + ), + constraints: const BoxConstraints(minHeight: 120), + child: Padding( + padding: + EdgeInsets.all(_editMode.enabled ? 15 : 25), + child: Builder(builder: (context) { + if (_editMode.enabled) { + return TextField( + controller: _textController, + maxLines: null, + style: const TextStyle( + fontSize: 18, + ), + decoration: InputDecoration( + contentPadding: const EdgeInsets.all(10), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.black, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ); + } else { + return SelectableText( + "${snapshot.data!.data()!["text"]}", + style: const TextStyle(fontSize: 18), + ); + } + }), + ), + ), + ], + ), + ), + Container( + color: Theme.of(context).cardColor, + child: Row( + children: [ + if (_editMode.enabled) ...[ + Expanded( + child: TextButton( + onPressed: () { + _editMode.setEnabled = _editMode.notEnabled; + }, + child: const Text( + "Cancle", + ), + style: TextButton.styleFrom( + primary: Theme.of(context).errorColor, + ), + ), + ), + Expanded( + child: TextButton( + onPressed: () { + if (_textController.text.isEmpty) { + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + CoustomeSnackBar( + context, + content: const Text( + "! Text is Empty. Failed"), + isFailed: true, + ), + ); + return; + } + snapshot.data!.reference + .update({"text": _textController.text}); + _editMode.setEnabled = _editMode.notEnabled; + }, + child: const Text("Save"), + ), + ), + ], + if (_editMode.notEnabled) ...[ + Expanded( + child: TextButton( + onPressed: () { + _textController.text = + snapshot.data!.data()!["text"] ?? ""; + _editMode.setEnabled = _editMode.notEnabled; + }, + child: const Text("Edit"), + ), + ), + ], + ], + ), + ) + ], + ), + ); + }, + ), + ); + }, + ); + } +} diff --git a/lib/src/features/home/pages/done.dart b/lib/src/features/home/pages/done.dart index 9190d6e..f8e48c9 100644 --- a/lib/src/features/home/pages/done.dart +++ b/lib/src/features/home/pages/done.dart @@ -2,6 +2,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:gst_todo/src/features/home/widgets/edit_university_detail_alert_dialog.dart'; import 'package:gst_todo/src/features/uviversity_details.page/pages/university_pages.dart'; class DoneUniversityPage extends StatefulWidget { @@ -15,72 +16,84 @@ class _DoneUniversityPageState extends State { @override Widget build(BuildContext context) { return StreamBuilder>>( - stream: FirebaseFirestore.instance - .collection("users") - .doc(FirebaseAuth.instance.currentUser!.uid) - .collection("university") - .orderBy("universityName") - .where( - "done", - isEqualTo: true, - ) - .snapshots(includeMetadataChanges: true), - builder: (context, snapshot) { - if (snapshot.hasData) { - if (snapshot.data!.docs.isEmpty) { - return const Center( - child: Text("Empty"), - ); - } - return ListView.builder( - padding: const EdgeInsets.only( - bottom: 70, - ), - itemCount: snapshot.data!.docs.length, - itemBuilder: (context, index) { - return Card( - elevation: 3, - child: InkWell( - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => UniversityDetailPage( - documentSnapshot: snapshot.data!.docs[index], - ), + stream: FirebaseFirestore.instance + .collection("users") + .doc(FirebaseAuth.instance.currentUser!.uid) + .collection("university") + .orderBy("universityName") + .where( + "done", + isEqualTo: true, + ) + .snapshots(includeMetadataChanges: true), + builder: (context, snapshot) { + if (snapshot.hasData) { + if (snapshot.data!.docs.isEmpty) { + return const Center( + child: Text("Empty"), + ); + } + return ListView.builder( + padding: const EdgeInsets.only( + bottom: 70, + ), + itemCount: snapshot.data!.docs.length, + itemBuilder: (context, index) { + return Card( + elevation: 3, + child: InkWell( + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => UniversityDetailPage( + documentSnapshot: snapshot.data!.docs[index], ), - ); - }, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - children: [ - (snapshot.data!.docs[index].metadata.hasPendingWrites) - ? const SizedBox( - width: 20, - ) - : Icon( - Icons.check_box, - color: Theme.of(context).primaryColor, - size: 20, - ), - Expanded( - child: ListTile( - title: Text( - "${snapshot.data!.docs[index].data()["universityName"] ?? "Unkonwn"}"), - ), - ), - ], ), + ); + }, + onLongPress: () { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return EditUniversityAlertDialog( + documentSnapshot: snapshot.data!.docs[index], + ); + }, + ); + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + children: [ + (snapshot.data!.docs[index].metadata.hasPendingWrites) + ? const SizedBox( + width: 20, + ) + : Icon( + Icons.check_box, + color: Theme.of(context).primaryColor, + size: 20, + ), + Expanded( + child: ListTile( + title: Text( + "${snapshot.data!.docs[index].data()["universityName"] ?? "Unkonwn"}"), + ), + ), + ], ), ), - ); - }, - ); - } else { - return const Center( - child: CupertinoActivityIndicator(), - ); - } - }); + ), + ); + }, + ); + } else { + return const Center( + child: CupertinoActivityIndicator(), + ); + } + }, + ); } } diff --git a/lib/src/features/home/pages/pending.dart b/lib/src/features/home/pages/pending.dart index 4d215ac..08969b1 100644 --- a/lib/src/features/home/pages/pending.dart +++ b/lib/src/features/home/pages/pending.dart @@ -2,6 +2,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:gst_todo/src/features/home/widgets/edit_university_detail_alert_dialog.dart'; import 'package:gst_todo/src/features/uviversity_details.page/pages/university_pages.dart'; class PendingUniversityPage extends StatefulWidget { @@ -50,6 +51,17 @@ class _PendingUniversityPageState extends State { ), ); }, + onLongPress: () { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return EditUniversityAlertDialog( + documentSnapshot: snapshot.data!.docs[index], + ); + }, + ); + }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Row( diff --git a/lib/src/features/home/widgets/edit_university_detail_alert_dialog.dart b/lib/src/features/home/widgets/edit_university_detail_alert_dialog.dart new file mode 100644 index 0000000..888d4aa --- /dev/null +++ b/lib/src/features/home/widgets/edit_university_detail_alert_dialog.dart @@ -0,0 +1,92 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:gst_todo/src/common/controllers/error_text_controller.dart'; +import 'package:gst_todo/src/features/uviversity_details.page/services/firebase_service.dart'; + +class EditUniversityAlertDialog extends StatefulWidget { + const EditUniversityAlertDialog({Key? key, required this.documentSnapshot}) + : super(key: key); + final QueryDocumentSnapshot> documentSnapshot; + + @override + _EditUniversityAlertDialogState createState() => + _EditUniversityAlertDialogState(); +} + +class _EditUniversityAlertDialogState extends State { + late final TextEditingController _universityName; + final ErrorTextController _errorTextController = ErrorTextController(); + @override + void initState() { + _universityName = TextEditingController( + text: widget.documentSnapshot.data()["universityName"]); + super.initState(); + } + + @override + void dispose() { + super.dispose(); + _universityName.dispose(); + _errorTextController.dispose(); + } + + @override + Widget build(BuildContext context) { + return CupertinoAlertDialog( + content: Column( + children: [ + CupertinoTextField( + controller: _universityName, + placeholder: "University Name", + keyboardType: TextInputType.name, + ), + AnimatedBuilder( + animation: _errorTextController, + builder: (context, child) { + if (_errorTextController.text != null) { + return Padding( + padding: const EdgeInsets.only(top: 10), + child: Text( + _errorTextController.text!, + style: const TextStyle(color: Colors.red), + ), + ); + } else { + return const SizedBox(); + } + }, + ) + ], + ), + actions: [ + CupertinoActionSheetAction( + isDestructiveAction: true, + onPressed: () async { + await FirebaseService().deletCollection( + widget.documentSnapshot.reference.collection("contents").path); + FirebaseService().deletDoc(widget.documentSnapshot.reference.path); + Navigator.of(context).pop(); + }, + child: const Text("Delete"), + ), + CupertinoActionSheetAction( + onPressed: () { + if (_universityName.text.isEmpty) { + _errorTextController.setText = "University Name is Empty"; + return; + } + _errorTextController.setText = null; + widget.documentSnapshot.reference.update( + { + "universityName": _universityName.text, + }, + ); + Navigator.of(context).pop(); + }, + child: const Text("Save"), + ), + ], + ); + } +} diff --git a/lib/src/features/uviversity_details.page/controllers/selected_item_controller.dart b/lib/src/features/uviversity_details.page/controllers/selected_item_controller.dart new file mode 100644 index 0000000..7803fff --- /dev/null +++ b/lib/src/features/uviversity_details.page/controllers/selected_item_controller.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class SelectedItemController with ChangeNotifier { + List _list = []; + List get list => _list; + set setList(List value) { + if (value == _list) return; + _list = value; + notifyListeners(); + } + + addItem(String value) { + if (_list.contains(value)) return; + _list.add(value); + notifyListeners(); + } + + remove(String value) { + _list.remove(value); + notifyListeners(); + } + + clear() { + if (_list.isEmpty) return; + _list.clear(); + notifyListeners(); + } +} diff --git a/lib/src/features/uviversity_details.page/pages/university_pages.dart b/lib/src/features/uviversity_details.page/pages/university_pages.dart index d18bbd0..c35ad8a 100644 --- a/lib/src/features/uviversity_details.page/pages/university_pages.dart +++ b/lib/src/features/uviversity_details.page/pages/university_pages.dart @@ -1,6 +1,10 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/painting.dart'; +import 'package:gst_todo/src/features/content/pages/content.dart'; +import 'package:gst_todo/src/features/uviversity_details.page/controllers/selected_item_controller.dart'; +import 'package:gst_todo/src/features/uviversity_details.page/services/firebase_service.dart'; class UniversityDetailPage extends StatefulWidget { const UniversityDetailPage({Key? key, required this.documentSnapshot}) @@ -14,32 +18,55 @@ class UniversityDetailPage extends StatefulWidget { class _UniversityDetailPageState extends State { final TextEditingController _text = TextEditingController(); final ScrollController _scrollController = ScrollController(); + final SelectedItemController _selectedItemController = + SelectedItemController(); @override void dispose() { super.dispose(); _text.dispose(); _scrollController.dispose(); + _selectedItemController.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text( - "${widget.documentSnapshot.data()["universityName"] ?? "Unkhown"}"), + title: AnimatedBuilder( + animation: _selectedItemController, + builder: (context, child) { + if (_selectedItemController.list.isNotEmpty) { + return const Text("Select"); + } + return Text( + "${widget.documentSnapshot.data()["universityName"] ?? "Unkhown"}"); + }), actions: [ - StreamBuilder>>( - stream: widget.documentSnapshot.reference.snapshots(), - initialData: widget.documentSnapshot, - builder: (context, snapshot) { - return IconButton( - onPressed: () { - snapshot.data!.reference - .update({"done": !snapshot.data!.data()!["done"]}); - }, - icon: Icon((snapshot.data!.data()!["done"]) - ? Icons.check_box - : Icons.check_box_outline_blank_outlined)); + AnimatedBuilder( + animation: _selectedItemController, + builder: (context, child) { + return StreamBuilder>>( + stream: widget.documentSnapshot.reference.snapshots(), + initialData: widget.documentSnapshot, + builder: (context, snapshot) { + if (_selectedItemController.list.isNotEmpty) { + return TextButton( + onPressed: () {}, + child: Text("${_selectedItemController.list.length}"), + style: TextButton.styleFrom( + primary: + Theme.of(context).scaffoldBackgroundColor), + ); + } + return IconButton( + onPressed: () { + snapshot.data!.reference.update( + {"done": !snapshot.data!.data()!["done"]}); + }, + icon: Icon((snapshot.data!.data()!["done"]) + ? Icons.check_box + : Icons.check_box_outline_blank_outlined)); + }); }), ], ), @@ -47,7 +74,7 @@ class _UniversityDetailPageState extends State { children: [ Expanded( child: Container( - color: Theme.of(context).primaryColorLight, + color: Theme.of(context).primaryColorLight.withOpacity(0.35), child: StreamBuilder>>( stream: widget.documentSnapshot.reference .collection("contents") @@ -60,48 +87,116 @@ class _UniversityDetailPageState extends State { child: Text("Empty"), ); } - return ListView.builder( - itemCount: snapshot.data!.docs.length, - reverse: true, - controller: _scrollController, - itemBuilder: (context, index) { - return Padding( - padding: const EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .scaffoldBackgroundColor, - borderRadius: BorderRadius.circular(20), - ), - child: Padding( - padding: const EdgeInsets.all(14), - child: Text( - "${snapshot.data!.docs[index].data()["text"]}", - softWrap: true, + return AnimatedBuilder( + animation: _selectedItemController, + builder: (context, child) { + return ListView.builder( + padding: const EdgeInsets.only(bottom: 10), + itemCount: snapshot.data!.docs.length, + reverse: true, + controller: _scrollController, + itemBuilder: (context, index) { + bool _isSelected = _selectedItemController.list + .contains(snapshot + .data!.docs[index].reference.path); + return Container( + color: (_isSelected) + ? Theme.of(context).primaryColorLight + : Colors.transparent, + child: InkWell( + onTap: (_selectedItemController + .list.isEmpty) + ? () { + Navigator.of(context) + .push(MaterialPageRoute( + builder: (context) => ContentPage( + documentSnapshot: + snapshot.data!.docs[index], + ), + )); + } + : () { + if (_selectedItemController.list + .contains(snapshot + .data! + .docs[index] + .reference + .path)) { + _selectedItemController.remove( + snapshot.data!.docs[index] + .reference.path); + } else { + _selectedItemController.addItem( + snapshot.data!.docs[index] + .reference.path); + } + }, + onLongPress: () { + if (_selectedItemController.list.contains( + snapshot.data!.docs[index].reference + .path)) { + _selectedItemController.remove(snapshot + .data!.docs[index].reference.path); + } else { + _selectedItemController.addItem(snapshot + .data!.docs[index].reference.path); + } + }, + child: Padding( + padding: const EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.black + .withOpacity(0.2), + blurRadius: 3, + ), + ], + color: (_isSelected) + ? Theme.of(context) + .primaryColor + : Theme.of(context) + .scaffoldBackgroundColor, + borderRadius: + BorderRadius.circular(20), + ), + child: Padding( + padding: + const EdgeInsets.all(14), + child: Text( + "${snapshot.data!.docs[index].data()["text"]}", + softWrap: true, + ), + ), + ), + ), + SizedBox( + width: 50, + child: Icon( + Icons.check_circle_rounded, + color: (snapshot + .data! + .docs[index] + .metadata + .hasPendingWrites) + ? Theme.of(context) + .disabledColor + .withOpacity(0.2) + : Theme.of(context) + .primaryColor, + ), + ) + ], + ), ), - ), - ), - ), - SizedBox( - width: 50, - child: Icon( - Icons.check_circle_rounded, - color: (snapshot.data!.docs[index].metadata - .hasPendingWrites) - ? Theme.of(context) - .disabledColor - .withOpacity(0.2) - : Theme.of(context).primaryColor, - ), - ) - ], - ), - ); - }, - ); + )); + }, + ); + }); } else { return const Center( child: CupertinoActivityIndicator(), @@ -112,70 +207,127 @@ class _UniversityDetailPageState extends State { ), ), Container( - color: Theme.of(context).canvasColor, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only( - top: 8.0, - bottom: 8.0, - left: 8.0, - ), - child: Container( - constraints: const BoxConstraints( - maxHeight: 100, - ), - child: TextField( - controller: _text, - cursorHeight: 25, - style: const TextStyle( - fontSize: 18, + decoration: BoxDecoration( + color: Theme.of(context).canvasColor, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.5), + blurRadius: 10, + spreadRadius: 3, + ) + ], + ), + child: AnimatedBuilder( + animation: _selectedItemController, + builder: (context, child) { + if (_selectedItemController.list.isNotEmpty) { + return Material( + child: SizedBox( + height: 57, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: () { + FirebaseService() + .deletDocs(_selectedItemController.list); + _selectedItemController.clear(); + }, + icon: const Icon(Icons.delete), + ), + ], ), - decoration: const InputDecoration( - isDense: true, - contentPadding: EdgeInsets.all(10), + ), + ); + } + return Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.only( + top: 8.0, + bottom: 8.0, + left: 8.0, + ), + child: Container( + constraints: const BoxConstraints( + maxHeight: 100, + ), + child: TextField( + controller: _text, + cursorHeight: 25, + style: const TextStyle( + fontSize: 18, + ), + decoration: InputDecoration( + fillColor: Theme.of(context) + .disabledColor + .withOpacity(0.05), + isDense: true, + filled: true, + border: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.black, + width: 1, + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.black, + width: 1, + ), + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.black, + width: 1, + ), + ), + contentPadding: const EdgeInsets.all(10), + ), + keyboardType: TextInputType.multiline, + maxLines: null, + ), + ), ), - keyboardType: TextInputType.multiline, - maxLines: null, ), - ), - ), - ), - AnimatedBuilder( - animation: _text, - builder: (context, snapshot) { - return IconButton( - iconSize: 40, - splashRadius: 28, - onPressed: (_text.text.isEmpty) - ? null - : () { - if (_text.text.isEmpty) return; - widget.documentSnapshot.reference - .collection("contents") - .add( - { - "text": _text.text, - "time": FieldValue.serverTimestamp(), - }, - ); - FocusScope.of(context).unfocus(); - _text.clear(); - _scrollController.animateTo(0, - duration: const Duration(milliseconds: 400), - curve: Curves.easeIn); - }, - icon: const Icon( - Icons.send, + AnimatedBuilder( + animation: _text, + builder: (context, snapshot) { + return IconButton( + iconSize: 40, + splashRadius: 28, + onPressed: (_text.text.isEmpty) + ? null + : () { + if (_text.text.isEmpty) return; + widget.documentSnapshot.reference + .collection("contents") + .add( + { + "text": _text.text, + "time": FieldValue.serverTimestamp(), + }, + ); + //FocusScope.of(context).unfocus(); + _text.clear(); + _scrollController.animateTo(0, + duration: + const Duration(milliseconds: 400), + curve: Curves.easeIn); + }, + icon: const Icon( + Icons.send, + ), + color: Theme.of(context).primaryColor, + ); + }, ), - color: Theme.of(context).primaryColor, - ); - }, - ), - ], - ), + ], + ); + }), ), ], ), diff --git a/lib/src/features/uviversity_details.page/services/firebase_service.dart b/lib/src/features/uviversity_details.page/services/firebase_service.dart new file mode 100644 index 0000000..103b2e0 --- /dev/null +++ b/lib/src/features/uviversity_details.page/services/firebase_service.dart @@ -0,0 +1,21 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; + +class FirebaseService { + void deletDoc(String path) async { + await FirebaseFirestore.instance.doc(path).delete(); + } + + Future deletCollection(String path) async { + QuerySnapshot> value = + await FirebaseFirestore.instance.collection(path).get(); + for (var eatch in value.docs) { + eatch.reference.delete(); + } + } + + void deletDocs(List paths) async { + for (var path in paths) { + FirebaseFirestore.instance.doc(path).delete(); + } + } +}