Skip to content

Commit 2340809

Browse files
authored
feat: Add Exit Preview button to Alarm Control Screen (#641)
* Update alarm_ring_view.dart added exit preview button * Update alarm_ring_view.dart
1 parent 556f270 commit 2340809

File tree

1 file changed

+177
-151
lines changed

1 file changed

+177
-151
lines changed

lib/app/modules/alarmRing/views/alarm_ring_view.dart

Lines changed: 177 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/widgets.dart';
3-
43
import 'package:get/get.dart';
54
import 'package:ultimate_alarm_clock/app/modules/settings/controllers/theme_controller.dart';
65
import 'package:ultimate_alarm_clock/app/utils/constants.dart';
@@ -17,7 +16,7 @@ class AlarmControlView extends GetView<AlarmControlController> {
1716
Obx getAddSnoozeButtons(
1817
BuildContext context, int snoozeMinutes, String title) {
1918
return Obx(
20-
() => TextButton(
19+
() => TextButton(
2120
style: ButtonStyle(
2221
backgroundColor: MaterialStateProperty.all(
2322
themeController.secondaryBackgroundColor.value,
@@ -40,10 +39,9 @@ class AlarmControlView extends GetView<AlarmControlController> {
4039

4140
@override
4241
Widget build(BuildContext context) {
43-
// var width = Get.width;
44-
// var height = Get.height;
4542
final double width = MediaQuery.of(context).size.width;
4643
final double height = MediaQuery.of(context).size.height;
44+
4745
return PopScope(
4846
canPop: false,
4947
onPopInvoked: (bool didPop) {
@@ -60,169 +58,197 @@ class AlarmControlView extends GetView<AlarmControlController> {
6058
},
6159
child: SafeArea(
6260
child: Scaffold(
63-
floatingActionButtonLocation:
64-
FloatingActionButtonLocation.centerDocked,
65-
floatingActionButton: Column(
66-
mainAxisAlignment: MainAxisAlignment.end,
61+
body: Stack(
6762
children: [
68-
Padding(
69-
padding: const EdgeInsets.all(18.0),
70-
child: Obx(
71-
() => SizedBox(
72-
height: height * 0.06,
73-
width: width * 0.8,
74-
child: controller.showButton.value
75-
? TextButton(
76-
style: ButtonStyle(
77-
backgroundColor: MaterialStateProperty.all(
78-
kprimaryColor,
63+
Center(
64+
child: Column(
65+
mainAxisAlignment: MainAxisAlignment.spaceAround,
66+
children: [
67+
Obx(
68+
() => Column(
69+
children: [
70+
Text(
71+
controller.formattedDate.value,
72+
style: Theme.of(context).textTheme.bodyLarge,
73+
),
74+
const SizedBox(
75+
height: 10,
76+
width: 0,
77+
),
78+
Text(
79+
(controller.isSnoozing.value)
80+
? "${controller.minutes.toString().padLeft(2, '0')}"
81+
// ignore: lines_longer_than_80_chars
82+
":${controller.seconds.toString().padLeft(2, '0')}"
83+
: '${controller.timeNow[0]} '
84+
'${controller.timeNow[1]}',
85+
style: Theme.of(context)
86+
.textTheme
87+
.displayLarge!
88+
.copyWith(fontSize: 50),
89+
),
90+
const SizedBox(
91+
height: 20,
92+
width: 0,
93+
),
94+
Obx(
95+
() => Visibility(
96+
visible: controller.isSnoozing.value,
97+
child: Row(
98+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
99+
children: [
100+
getAddSnoozeButtons(context, 1, '+1 min'),
101+
getAddSnoozeButtons(context, 2, '+2 min'),
102+
getAddSnoozeButtons(context, 5, '+5 min'),
103+
],
79104
),
80105
),
81-
child: Text(
82-
Utils.isChallengeEnabled(
83-
controller.currentlyRingingAlarm.value,
84-
)
85-
? 'Start Challenge'.tr
86-
: 'Dismiss'.tr,
87-
style: Theme.of(context)
88-
.textTheme
89-
.displaySmall!
90-
.copyWith(
91-
color: themeController.secondaryTextColor.value,
106+
),
107+
],
108+
),
109+
),
110+
Obx(
111+
() {
112+
return Visibility(
113+
visible: controller
114+
.currentlyRingingAlarm.value.note.isNotEmpty,
115+
child: Text(
116+
controller.currentlyRingingAlarm.value.note,
117+
style: Theme.of(context)
118+
.textTheme
119+
.bodyMedium!
120+
.copyWith(
121+
color: themeController.primaryTextColor.value,
122+
fontSize: 20,
123+
fontWeight: FontWeight.w100,
124+
fontStyle: FontStyle.italic,
125+
),
126+
),
127+
);
128+
},
129+
),
130+
Obx(
131+
() => Visibility(
132+
visible: !controller.isSnoozing.value,
133+
child: Obx(
134+
() => Padding(
135+
padding: Get.arguments != null
136+
? const EdgeInsets.symmetric(vertical: 90.0)
137+
: EdgeInsets.zero,
138+
child: SizedBox(
139+
height: height * 0.07,
140+
width: width * 0.5,
141+
child: TextButton(
142+
style: ButtonStyle(
143+
backgroundColor: MaterialStateProperty.all(
144+
themeController.secondaryBackgroundColor.value,
92145
),
146+
),
147+
child: Text(
148+
'Snooze'.tr,
149+
style: Theme.of(context)
150+
.textTheme
151+
.bodyMedium!
152+
.copyWith(
153+
color: themeController.primaryTextColor.value,
154+
fontWeight: FontWeight.w600,
155+
),
156+
),
157+
onPressed: () {
158+
Utils.hapticFeedback();
159+
controller.startSnooze();
160+
},
161+
),
93162
),
94-
onPressed: () {
95-
Utils.hapticFeedback();
96-
if (controller
97-
.currentlyRingingAlarm.value.isGuardian) {
98-
controller.guardianTimer.cancel();
99-
}
100-
if (Utils.isChallengeEnabled(
101-
controller.currentlyRingingAlarm.value,
102-
)) {
103-
Get.toNamed(
104-
'/alarm-challenge',
105-
arguments:
106-
controller.currentlyRingingAlarm.value,
107-
);
108-
} else {
109-
Get.offNamed(
110-
'/bottom-navigation-bar',
111-
arguments:
112-
controller.currentlyRingingAlarm.value,
113-
);
114-
}
115-
},
116-
)
117-
: const SizedBox(),
118-
),
119-
),
120-
),
121-
],
122-
),
123-
body: Center(
124-
child: Column(
125-
mainAxisAlignment: MainAxisAlignment.spaceAround,
126-
children: [
127-
Obx(
128-
() => Column(
129-
children: [
130-
Text(
131-
controller.formattedDate.value,
132-
style: Theme.of(context).textTheme.bodyLarge,
133-
),
134-
const SizedBox(
135-
height: 10,
136-
width: 0,
137-
),
138-
Text(
139-
(controller.isSnoozing.value)
140-
? "${controller.minutes.toString().padLeft(2, '0')}"
141-
// ignore: lines_longer_than_80_chars
142-
":${controller.seconds.toString().padLeft(2, '0')}"
143-
: '${controller.timeNow[0]} '
144-
'${controller.timeNow[1]}',
145-
style: Theme.of(context)
146-
.textTheme
147-
.displayLarge!
148-
.copyWith(fontSize: 50),
149-
),
150-
const SizedBox(
151-
height: 20,
152-
width: 0,
153-
),
154-
Obx(
155-
() => Visibility(
156-
visible: controller.isSnoozing.value,
157-
child: Row(
158-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
159-
children: [
160-
getAddSnoozeButtons(context, 1, '+1 min'),
161-
getAddSnoozeButtons(context, 2, '+2 min'),
162-
getAddSnoozeButtons(context, 5, '+5 min'),
163-
],
164163
),
165164
),
166165
),
167-
],
168-
),
169-
),
170-
Obx(
171-
() {
172-
return Visibility(
173-
visible: controller
174-
.currentlyRingingAlarm.value.note.isNotEmpty,
175-
child: Text(
176-
controller.currentlyRingingAlarm.value.note,
177-
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
178-
color: themeController.primaryTextColor.value,
179-
fontSize: 20,
180-
fontWeight: FontWeight.w100,
181-
fontStyle: FontStyle.italic,
182-
),
183-
),
184-
);
185-
},
166+
),
167+
],
186168
),
187-
Obx(
169+
),
170+
171+
172+
Positioned(
173+
bottom: 80,
174+
left: width * 0.1,
175+
right: width * 0.1,
176+
child: Obx(
188177
() => Visibility(
189-
visible: !controller.isSnoozing.value,
190-
child: Obx(
191-
() => Padding(
192-
padding: Get.arguments != null
193-
? const EdgeInsets.symmetric(vertical: 90.0)
194-
: EdgeInsets.zero,
195-
child: SizedBox(
196-
height: height * 0.07,
197-
width: width * 0.5,
198-
child: TextButton(
199-
style: ButtonStyle(
200-
backgroundColor: MaterialStateProperty.all(
201-
themeController.secondaryBackgroundColor.value,
202-
),
203-
),
204-
child: Text(
205-
'Snooze'.tr,
206-
style: Theme.of(context)
207-
.textTheme
208-
.bodyMedium!
209-
.copyWith(
210-
color: themeController.primaryTextColor.value,
211-
fontWeight: FontWeight.w600,
212-
),
213-
),
214-
onPressed: () {
215-
Utils.hapticFeedback();
216-
controller.startSnooze();
217-
},
178+
visible: controller.showButton.value,
179+
child: SizedBox(
180+
height: height * 0.07,
181+
width: width * 0.8,
182+
child: TextButton(
183+
style: ButtonStyle(
184+
backgroundColor: MaterialStateProperty.all(
185+
kprimaryColor,
218186
),
219187
),
188+
onPressed: () {
189+
Utils.hapticFeedback();
190+
if (controller.currentlyRingingAlarm.value.isGuardian) {
191+
controller.guardianTimer.cancel();
192+
}
193+
if (Utils.isChallengeEnabled(
194+
controller.currentlyRingingAlarm.value,
195+
)) {
196+
Get.toNamed(
197+
'/alarm-challenge',
198+
arguments: controller.currentlyRingingAlarm.value,
199+
);
200+
} else {
201+
Get.offNamed(
202+
'/bottom-navigation-bar',
203+
arguments: controller.currentlyRingingAlarm.value,
204+
);
205+
}
206+
},
207+
child: Text(
208+
Utils.isChallengeEnabled(
209+
controller.currentlyRingingAlarm.value,
210+
)
211+
? 'Start Challenge'.tr
212+
: 'Dismiss'.tr,
213+
style: Theme.of(context)
214+
.textTheme
215+
.bodyLarge!
216+
.copyWith(
217+
color: themeController.secondaryTextColor.value,
218+
fontWeight: FontWeight.bold,
219+
),
220+
),
220221
),
221222
),
222223
),
223224
),
224-
],
225-
),
225+
),
226+
227+
228+
Positioned(
229+
bottom: 0,
230+
left: 0,
231+
right: 0,
232+
child: Container(
233+
width: double.infinity,
234+
height: 60,
235+
color: Colors.red,
236+
child: TextButton(
237+
onPressed: () {
238+
Utils.hapticFeedback();
239+
Get.offNamed('/bottom-navigation-bar');
240+
},
241+
child: Text(
242+
'Exit Preview'.tr,
243+
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
244+
color: Colors.white,
245+
fontWeight: FontWeight.bold,
246+
),
247+
),
248+
),
249+
),
250+
),
251+
],
226252
),
227253
),
228254
),

0 commit comments

Comments
 (0)