@@ -21,13 +21,9 @@ class GuardianAngel extends StatelessWidget {
21
21
Widget build (BuildContext context) {
22
22
// Check if using Firestore and the current user is the owner
23
23
// and if not using, just show the tile
24
-
25
- return Column (
26
- children: [
27
- ListTile (
28
- onTap: () async {
29
- var phonePerm =
30
- await Permission .phone.request ().isGranted;
24
+
25
+ Future <void > showGuardianDialog () async {
26
+ var phonePerm = await Permission .phone.request ().isGranted;
31
27
var smsPerm = await Permission .sms.request ().isGranted;
32
28
33
29
if (phonePerm && smsPerm) {
@@ -36,8 +32,7 @@ class GuardianAngel extends StatelessWidget {
36
32
shape: RoundedRectangleBorder (
37
33
borderRadius: BorderRadius .circular (18 ),
38
34
),
39
- backgroundColor: themeController
40
- .secondaryBackgroundColor.value,
35
+ backgroundColor: themeController.secondaryBackgroundColor.value,
41
36
child: Padding (
42
37
padding: const EdgeInsets .all (8.0 ),
43
38
child: Column (
@@ -46,8 +41,7 @@ class GuardianAngel extends StatelessWidget {
46
41
Padding (
47
42
padding: const EdgeInsets .all (8.0 ),
48
43
child: InternationalPhoneNumberInput (
49
- textFieldController: controller
50
- .contactTextEditingController,
44
+ textFieldController: controller.contactTextEditingController,
51
45
onInputChanged: (value) {},
52
46
onInputValidated: (value) {},
53
47
spaceBetweenSelectorAndTextField: 0 ,
@@ -62,12 +56,8 @@ class GuardianAngel extends StatelessWidget {
62
56
),
63
57
Padding (
64
58
padding: EdgeInsets .symmetric (
65
- vertical: controller
66
- .homeController.scalingFactor *
67
- 8 ,
68
- horizontal: controller
69
- .homeController.scalingFactor *
70
- 4 ,
59
+ vertical: controller.homeController.scalingFactor * 8 ,
60
+ horizontal: controller.homeController.scalingFactor * 4 ,
71
61
),
72
62
child: Row (
73
63
children: [
@@ -84,28 +74,33 @@ class GuardianAngel extends StatelessWidget {
84
74
),
85
75
);
86
76
}
87
- },
88
- title: Row (
77
+ }
78
+
79
+ return Column (
89
80
children: [
90
- FittedBox (
91
- fit: BoxFit .scaleDown,
92
- alignment: Alignment .centerLeft,
93
- child: Obx (
94
- () => Text (
95
- 'Guardian Angel' .tr,
96
- style: TextStyle (
97
- color: themeController.primaryTextColor.value,
81
+ ListTile (
82
+ onTap: showGuardianDialog,
83
+ title: Row (
84
+ children: [
85
+ FittedBox (
86
+ fit: BoxFit .scaleDown,
87
+ alignment: Alignment .centerLeft,
88
+ child: Obx (
89
+ () => Text (
90
+ 'Guardian Angel' .tr,
91
+ style: TextStyle (
92
+ color: themeController.primaryTextColor.value,
93
+ ),
98
94
),
99
95
),
100
96
),
101
- ),
102
97
Obx (
103
98
() => IconButton (
104
99
icon: Icon (
105
- Icons .info_sharp,
106
- size: 21 ,
107
- color: themeController.primaryTextColor.value.withOpacity (0.3 ),
108
- ),
100
+ Icons .info_sharp,
101
+ size: 21 ,
102
+ color: themeController.primaryTextColor.value.withOpacity (0.3 ),
103
+ ),
109
104
onPressed: () {
110
105
Utils .showModal (
111
106
context: context,
@@ -133,7 +128,13 @@ class GuardianAngel extends StatelessWidget {
133
128
activeColor: ksecondaryColor,
134
129
onChanged: (value) async {
135
130
Utils .hapticFeedback ();
136
- controller.isGuardian.value = value;
131
+ if (value) {
132
+ await showGuardianDialog ();
133
+ } else {
134
+ controller.isGuardian.value = false ;
135
+ controller.guardian.value = '' ;
136
+ controller.contactTextEditingController.clear ();
137
+ }
137
138
},
138
139
);
139
140
},
@@ -238,4 +239,4 @@ class GuardianAngel extends StatelessWidget {
238
239
),
239
240
);
240
241
}
241
- }
242
+ }
0 commit comments