1+ import 'package:call_manager/about_screen.dart' ;
2+ import 'package:call_manager/utils/page_transitions.dart' ;
3+ import 'package:cloud_firestore/cloud_firestore.dart' ;
4+ import 'package:dynamic_theme/dynamic_theme.dart' ;
5+ import 'package:firebase_auth/firebase_auth.dart' ;
6+ import 'package:flutter/material.dart' ;
7+ import 'package:groovin_material_icons/groovin_material_icons.dart' ;
8+ import 'package:modal_drawer_handle/modal_drawer_handle.dart' ;
9+ import 'package:rounded_modal/rounded_modal.dart' ;
10+ import 'package:call_manager/globals.dart' as globals;
11+
12+ class BottomSheets {
13+ BuildContext context;
14+
15+ BottomSheets (this .context);
16+
17+ void changeBrightness () {
18+ DynamicTheme .of (context).setBrightness (Theme .of (context).brightness == Brightness .dark? Brightness .light: Brightness .dark);
19+ }
20+
21+ void showBottomAppBarSheet () {
22+ showRoundedModalBottomSheet (
23+ color: Theme .of (context).canvasColor,
24+ context: context,
25+ builder: (builder){
26+ return Container (
27+ child: SingleChildScrollView (
28+ child: Column (
29+ mainAxisSize: MainAxisSize .min,
30+ children: < Widget > [
31+ Padding (
32+ padding: const EdgeInsets .only (top: 8.0 ),
33+ child: ModalDrawerHandle (),
34+ ),
35+ ListTile (
36+ leading: CircleAvatar (
37+ child: Text (globals.loggedInUser.displayName[0 ], style: TextStyle (color: Colors .white),),
38+ backgroundColor: Colors .blue[700 ],
39+ ),
40+ title: Text (globals.loggedInUser.displayName),
41+ subtitle: Text (globals.loggedInUser.email),
42+ /*leading: Icon(Icons.account_circle, size: 45.0,),
43+ title: Text(globals.loggedInUser.displayName),
44+ subtitle: Text(globals.loggedInUser.email),*/
45+ ),
46+ Divider (
47+ color: Colors .grey,
48+ height: 0.0 ,
49+ ),
50+ Material (
51+ child: ListTile (
52+ title: Text ("Delete All Calls" ),
53+ leading: Icon (Icons .clear_all),
54+ onTap: () {
55+ Navigator .pop (context);
56+ showDialog (
57+ context: context,
58+ builder: (_) => AlertDialog (
59+ title: Text ("Delete All Calls" ),
60+ content: Text ("Are you sure you want to delete all calls? This cannot be undone." ),
61+ actions: < Widget > [
62+ FlatButton (
63+ onPressed: (){
64+ Navigator .pop (context);
65+ },
66+ child: Text ("No" ),
67+ ),
68+ FlatButton (
69+ onPressed: () async {
70+ Navigator .pop (context);
71+ CollectionReference ref = Firestore .instance.collection ("Users" ).document (globals.loggedInUser.uid).collection ("Calls" );
72+ QuerySnapshot s = await ref.getDocuments ();
73+ if (s.documents.length == 0 ){
74+ final snackBar = SnackBar (
75+ content: Text ("There are no calls to delete" ),
76+ action: SnackBarAction (
77+ label: 'Dismiss' ,
78+ onPressed: () {
79+
80+ }
81+ ),
82+ duration: Duration (seconds: 3 ),
83+ );
84+ Scaffold .of (context).showSnackBar (snackBar);
85+ } else {
86+ for (int i = 0 ; i < s.documents.length; i++ ) {
87+ DocumentReference d = s.documents[i].reference;
88+ d.delete ();
89+ }
90+ }
91+ },
92+ child: Text ("Yes" ),
93+ ),
94+ ],
95+ ),
96+ );
97+ },
98+ ),
99+ ),
100+ Material (
101+ child: ListTile (
102+ leading: Icon (Icons .brightness_6),
103+ title: Text ("Toggle Dark Theme" ),
104+ onTap: () {
105+ changeBrightness ();
106+ Navigator .pop (context);
107+ },
108+ ),
109+ ),
110+ Material (
111+ child: ListTile (
112+ title: Text ("Log Out" ),
113+ leading: Icon (GroovinMaterialIcons .logout),
114+ onTap: (){
115+ Navigator .pop (context);
116+ showDialog (
117+ context: context,
118+ builder: (_) => AlertDialog (
119+ title: Text ("Log Out" ),
120+ content: Text ("Are you sure you want to log out?" ),
121+ actions: < Widget > [
122+ FlatButton (
123+ onPressed: (){
124+ Navigator .pop (context);
125+ },
126+ child: Text ("No" ),
127+ ),
128+ FlatButton (
129+ onPressed: (){
130+ FirebaseAuth .instance.signOut ();
131+ Navigator .of (context).pushNamedAndRemoveUntil ('/' ,(Route <dynamic > route) => false );
132+ },
133+ child: Text ("Yes" ),
134+ ),
135+ ],
136+ ),
137+ );
138+ },
139+ ),
140+ ),
141+ Divider (
142+ color: Colors .grey,
143+ height: 0.0 ,
144+ ),
145+ Material (
146+ child: ListTile (
147+ title: Text ("About" ),
148+ leading: Icon (Icons .info_outline),
149+ onTap: (){
150+ Navigator .pop (context);
151+ //Navigator.of(context).pushNamed("/AboutScreen");
152+ Navigator .push (
153+ context,
154+ SlideLeftRoute (widget: AboutScreen ())
155+ );
156+ },
157+ ),
158+ ),
159+ ],
160+ ),
161+ ),
162+ );
163+ }
164+ );
165+ }
166+ }
0 commit comments