Skip to content

Commit

Permalink
Feature: Add increment snooze timer buttons (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohnishdeshpande authored Mar 10, 2024
1 parent bae50ea commit b7fef55
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class AlarmControlController extends GetxController {
return latestAlarm;
}

void addMinutes(int incrementMinutes) {
minutes.value += incrementMinutes;
}

void startSnooze() async {
Vibration.cancel();
vibrationTimer!.cancel();
Expand Down
60 changes: 53 additions & 7 deletions lib/app/modules/alarmRing/views/alarm_ring_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import 'package:get/get.dart';
import 'package:ultimate_alarm_clock/app/modules/settings/controllers/theme_controller.dart';
Expand All @@ -12,6 +13,32 @@ class AlarmControlView extends GetView<AlarmControlController> {

ThemeController themeController = Get.find<ThemeController>();

TextButton getAddSnoozeButtons(
BuildContext context, int snoozeMinutes, String title) {
return TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
themeController.isLightMode.value
? kLightSecondaryBackgroundColor
: ksecondaryBackgroundColor,
),
),
child: Text(
title.tr,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
fontWeight: FontWeight.w600,
),
),
onPressed: () {
Utils.hapticFeedback();
controller.addMinutes(snoozeMinutes);
},
);
}

@override
Widget build(BuildContext context) {
var width = Get.width;
Expand Down Expand Up @@ -152,6 +179,23 @@ class AlarmControlView extends GetView<AlarmControlController> {
.displayLarge!
.copyWith(fontSize: 50),
),
const SizedBox(
height: 20,
width: 0,
),
Obx(
() => Visibility(
visible: controller.isSnoozing.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
getAddSnoozeButtons(context, 1, '+1 min'),
getAddSnoozeButtons(context, 2, '+2 min'),
getAddSnoozeButtons(context, 5, '+5 min'),
],
),
),
),
],
),
),
Expand Down Expand Up @@ -193,13 +237,15 @@ class AlarmControlView extends GetView<AlarmControlController> {
),
child: Text(
'Snooze'.tr,
style:
Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
fontWeight: FontWeight.w600,
),
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
fontWeight: FontWeight.w600,
),
),
onPressed: () {
Utils.hapticFeedback();
Expand Down

0 comments on commit b7fef55

Please sign in to comment.