@@ -21,13 +21,9 @@ class GuardianAngel extends StatelessWidget {
2121 Widget build (BuildContext context) {
2222 // Check if using Firestore and the current user is the owner
2323 // 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;
3127 var smsPerm = await Permission .sms.request ().isGranted;
3228
3329 if (phonePerm && smsPerm) {
@@ -36,8 +32,7 @@ class GuardianAngel extends StatelessWidget {
3632 shape: RoundedRectangleBorder (
3733 borderRadius: BorderRadius .circular (18 ),
3834 ),
39- backgroundColor: themeController
40- .secondaryBackgroundColor.value,
35+ backgroundColor: themeController.secondaryBackgroundColor.value,
4136 child: Padding (
4237 padding: const EdgeInsets .all (8.0 ),
4338 child: Column (
@@ -46,8 +41,7 @@ class GuardianAngel extends StatelessWidget {
4641 Padding (
4742 padding: const EdgeInsets .all (8.0 ),
4843 child: InternationalPhoneNumberInput (
49- textFieldController: controller
50- .contactTextEditingController,
44+ textFieldController: controller.contactTextEditingController,
5145 onInputChanged: (value) {},
5246 onInputValidated: (value) {},
5347 spaceBetweenSelectorAndTextField: 0 ,
@@ -62,12 +56,8 @@ class GuardianAngel extends StatelessWidget {
6256 ),
6357 Padding (
6458 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 ,
7161 ),
7262 child: Row (
7363 children: [
@@ -84,28 +74,33 @@ class GuardianAngel extends StatelessWidget {
8474 ),
8575 );
8676 }
87- },
88- title: Row (
77+ }
78+
79+ return Column (
8980 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+ ),
9894 ),
9995 ),
10096 ),
101- ),
10297 Obx (
10398 () => IconButton (
10499 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+ ),
109104 onPressed: () {
110105 Utils .showModal (
111106 context: context,
@@ -133,7 +128,13 @@ class GuardianAngel extends StatelessWidget {
133128 activeColor: ksecondaryColor,
134129 onChanged: (value) async {
135130 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+ }
137138 },
138139 );
139140 },
@@ -238,4 +239,4 @@ class GuardianAngel extends StatelessWidget {
238239 ),
239240 );
240241 }
241- }
242+ }
0 commit comments