Skip to content

Commit 760d689

Browse files
authored
Fix Exit Preview Button Visibility During Alarm Ringing (#779)
* Fixed Preveiw Issue * Preveiw Error Fixed * Preveiw Error Fixed * Preveiw Error Fixed * Preveiw Error Fixed * Fixes Preveiw * Fixes Preveiw * Fixes Preveiw
1 parent 49d83a1 commit 760d689

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

lib/app/modules/alarmRing/controllers/alarm_ring_controller.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AlarmControlController extends GetxController {
4848
late double initialVolume;
4949
late Timer guardianTimer;
5050
RxInt guardianCoundown = 120.obs;
51+
RxBool isPreviewMode = false.obs;
5152

5253

5354

@@ -173,7 +174,16 @@ class AlarmControlController extends GetxController {
173174
super.onInit();
174175
startListeningToFlip();
175176

176-
currentlyRingingAlarm.value = Get.arguments;
177+
// Extract alarm and preview flag from arguments
178+
final args = Get.arguments;
179+
if (args is Map) {
180+
currentlyRingingAlarm.value = args['alarm'];
181+
isPreviewMode.value = args['preview'] ?? false;
182+
} else {
183+
currentlyRingingAlarm.value = args;
184+
isPreviewMode.value = false;
185+
}
186+
177187
print('hwyooo ${currentlyRingingAlarm.value.isGuardian}');
178188
IsarDb()
179189
.insertLog('Alarm ringing ${currentlyRingingAlarm.value.alarmTime}');

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -224,29 +224,31 @@ class AlarmControlView extends GetView<AlarmControlController> {
224224
),
225225
),
226226
),
227-
Positioned(
228-
bottom: 0,
229-
left: 0,
230-
right: 0,
231-
child: Container(
232-
width: double.infinity,
233-
height: 60,
234-
color: Colors.red,
235-
child: TextButton(
236-
onPressed: () {
237-
Utils.hapticFeedback();
238-
Get.offNamed('/bottom-navigation-bar');
239-
},
240-
child: Text(
241-
'Exit Preview'.tr,
242-
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
243-
color: Colors.white,
244-
fontWeight: FontWeight.bold,
245-
),
227+
// Exit Preview button - only show in preview mode
228+
if (controller.isPreviewMode.value)
229+
Positioned(
230+
bottom: 0,
231+
left: 0,
232+
right: 0,
233+
child: Container(
234+
width: double.infinity,
235+
height: 60,
236+
color: Colors.red,
237+
child: TextButton(
238+
onPressed: () {
239+
Utils.hapticFeedback();
240+
Get.offNamed('/bottom-navigation-bar');
241+
},
242+
child: Text(
243+
'Exit Preview'.tr,
244+
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
245+
color: Colors.white,
246+
fontWeight: FontWeight.bold,
247+
),
248+
),
246249
),
247250
),
248251
),
249-
),
250252
],
251253
),
252254
),

lib/app/modules/home/views/home_view.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,10 @@ class HomeView extends GetView<HomeController> {
973973
onSelected: (value) async {
974974
Utils.hapticFeedback();
975975
if (value == 0) {
976-
Get.back();
977-
Get.offNamed('/alarm-ring', arguments: alarm);
976+
Get.toNamed('/alarm-ring', arguments: {
977+
'alarm': alarm,
978+
'preview': true
979+
});
978980
} else if (value == 1) {
979981
debugPrint(alarm.isSharedAlarmEnabled.toString());
980982

0 commit comments

Comments
 (0)