From 797e4f4dc12fe8038c41e2e76a49e3d51be0a21e Mon Sep 17 00:00:00 2001 From: Amay Dixit <65495380+amaydixit11@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:42:14 +0530 Subject: [PATCH] Snooze Tile Bottom Overflow & NumberPicker Error Fix: wrapped Column widget in a sized box to prevent overflow, then handled 0 or negative values for snooze duration to fix number picker error (#632) --- .../views/shake_to_dismiss_tile.dart | 6 +- .../views/snooze_duration_tile.dart | 93 +++++++++++-------- 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/lib/app/modules/addOrUpdateAlarm/views/shake_to_dismiss_tile.dart b/lib/app/modules/addOrUpdateAlarm/views/shake_to_dismiss_tile.dart index 6d1a5fc7..ae918f1b 100644 --- a/lib/app/modules/addOrUpdateAlarm/views/shake_to_dismiss_tile.dart +++ b/lib/app/modules/addOrUpdateAlarm/views/shake_to_dismiss_tile.dart @@ -49,7 +49,8 @@ class ShakeToDismiss extends StatelessWidget { // ' - no more lazy snoozing :)', description: 'shakeDescription'.tr, iconData: Icons.vibration_sharp, - isLightMode: themeController.currentTheme.value == ThemeMode.light, + isLightMode: + themeController.currentTheme.value == ThemeMode.light, ); }, ), @@ -122,7 +123,8 @@ class ShakeToDismiss extends StatelessWidget { .textTheme .displaySmall! .copyWith( - color: themeController.secondaryTextColor.value, + color: themeController + .secondaryTextColor.value, ), ), ), diff --git a/lib/app/modules/addOrUpdateAlarm/views/snooze_duration_tile.dart b/lib/app/modules/addOrUpdateAlarm/views/snooze_duration_tile.dart index a04aed24..627df9a3 100644 --- a/lib/app/modules/addOrUpdateAlarm/views/snooze_duration_tile.dart +++ b/lib/app/modules/addOrUpdateAlarm/views/snooze_duration_tile.dart @@ -36,49 +36,64 @@ class SnoozeDurationTile extends StatelessWidget { backgroundColor: themeController.secondaryBackgroundColor.value, title: 'Select duration'.tr, titleStyle: Theme.of(context).textTheme.displaySmall, - content: Obx( - () => Column( - children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - NumberPicker( - value: controller.snoozeDuration.value, - minValue: 1, - maxValue: 1440, - onChanged: (value) { - Utils.hapticFeedback(); - controller.snoozeDuration.value = value; - }, + content: SizedBox( + height: MediaQuery.of(context).size.height * 0.3, + child: Obx( + () => Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + NumberPicker( + value: controller.snoozeDuration.value <= 0 + ? 1 + : controller.snoozeDuration + .value, // Handle 0 or negative values + minValue: 1, + maxValue: 1440, + onChanged: (value) { + Utils.hapticFeedback(); + controller.snoozeDuration.value = value; + }, + ), + Text( + controller.snoozeDuration.value > 1 + ? 'minutes'.tr + : 'minute'.tr, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: ElevatedButton( + onPressed: () { + Utils.hapticFeedback(); + Get.back(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: kprimaryColor, ), - Text( - controller.snoozeDuration.value > 1 - ? 'minutes'.tr - : 'minute'.tr, + child: Text( + 'Done'.tr, + style: Theme.of(context) + .textTheme + .displaySmall! + .copyWith( + color: themeController.secondaryTextColor.value, + ), ), - ], - ), - ), - ElevatedButton( - onPressed: () { - Utils.hapticFeedback(); - Get.back(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: kprimaryColor, - ), - child: Text( - 'Done'.tr, - style: Theme.of(context).textTheme.displaySmall!.copyWith( - color: themeController.secondaryTextColor.value, - ), + ), ), - ), - ], + ], + ), ), + // ), ), ); },