1
+
2
+ import 'package:flutter/material.dart' ;
3
+ import 'package:get/get.dart' ;
4
+ import 'package:get/get_core/src/get_main.dart' ;
5
+ import 'package:ultimate_alarm_clock/app/modules/home/controllers/home_controller.dart' ;
6
+
7
+ import '../../../utils/constants.dart' ;
8
+ import '../../../utils/utils.dart' ;
9
+ import '../controllers/theme_controller.dart' ;
10
+ import 'package:ultimate_alarm_clock/app/modules/settings/controllers/settings_controller.dart' ;
11
+
12
+ class CustomizeUndoDuration extends StatelessWidget {
13
+ HomeController homeController = Get .find <HomeController >();
14
+ CustomizeUndoDuration ({
15
+ super .key ,
16
+ required this .themeController,
17
+ required this .height,
18
+ required this .width,
19
+ });
20
+ final ThemeController themeController;
21
+ final double width;
22
+ final double height;
23
+
24
+ @override
25
+ Widget build (BuildContext context) {
26
+ int duration;
27
+ return InkWell (
28
+ onTap: () {
29
+ Utils .hapticFeedback ();
30
+ duration = homeController.duration.value;
31
+ Get .defaultDialog (
32
+ onWillPop: () async {
33
+ Get .back ();
34
+ // Resetting the value to its initial state
35
+ homeController.duration.value = duration;
36
+ return true ;
37
+ },
38
+ titlePadding: const EdgeInsets .symmetric (vertical: 20 , horizontal: 5 ),
39
+ backgroundColor: themeController.isLightMode.value
40
+ ? kLightSecondaryBackgroundColor
41
+ : ksecondaryBackgroundColor,
42
+ title: 'Customize Undo Duration' .tr,
43
+ titleStyle: Theme .of (context).textTheme.displaySmall,
44
+ content: Obx (
45
+ () => Column (
46
+ children: [
47
+ Text (
48
+ '${homeController .duration .value } seconds' .tr,
49
+ style: Theme .of (context).textTheme.displaySmall,
50
+ ),
51
+ Slider (
52
+ value: homeController.selecteddurationDouble.value,
53
+ onChanged: (double value) {
54
+ homeController.selecteddurationDouble.value = value;
55
+ homeController.duration.value = value.toInt ();
56
+
57
+ },
58
+ min: 0.0 ,
59
+ max: 20.0 ,
60
+ divisions: 20 ,
61
+ label: homeController.duration.value.toString (),
62
+ ),
63
+ // Replace the volMin Slider with RangeSlider
64
+
65
+ ElevatedButton (
66
+ onPressed: () {
67
+ Get .back ();
68
+ },
69
+ style: ElevatedButton .styleFrom (
70
+ backgroundColor: kprimaryColor,
71
+ ),
72
+ child: Text (
73
+ 'Apply Duration' .tr,
74
+ style: TextStyle (
75
+ color: themeController.isLightMode.value
76
+ ? kLightSecondaryTextColor
77
+ : ksecondaryTextColor,
78
+ ),
79
+ ),
80
+ ),
81
+ ],
82
+ ),
83
+ ),
84
+ );
85
+ },
86
+ child: Container (
87
+ width: width * 0.91 ,
88
+ height: height * 0.09 ,
89
+ decoration: Utils .getCustomTileBoxDecoration (
90
+ isLightMode: themeController.isLightMode.value,
91
+ ),
92
+ child: Center (
93
+ child: Padding (
94
+ padding: EdgeInsets .only (left: 10 , right: 10 ),
95
+ child: ListTile (
96
+ tileColor: themeController.isLightMode.value
97
+ ? kLightSecondaryBackgroundColor
98
+ : ksecondaryBackgroundColor,
99
+ title: Text (
100
+ 'Undo Duration' .tr,
101
+ style: TextStyle (
102
+ color: themeController.isLightMode.value
103
+ ? kLightPrimaryTextColor
104
+ : kprimaryTextColor,
105
+ fontSize: 15
106
+ ),
107
+ ),
108
+ trailing: Wrap (
109
+ crossAxisAlignment: WrapCrossAlignment .center,
110
+ children: [
111
+ Obx (
112
+ () => Text (
113
+ '${homeController .duration .value .round ().toInt ()} seconds' ,
114
+ style: Theme .of (context).textTheme.bodyMedium! .copyWith (
115
+ color: themeController.isLightMode.value
116
+ ? kLightPrimaryTextColor
117
+ : kprimaryTextColor,
118
+ fontSize: 13
119
+ ),
120
+ ),
121
+ ),
122
+ Icon (
123
+ Icons .chevron_right,
124
+ color: themeController.isLightMode.value
125
+ ? kLightPrimaryDisabledTextColor
126
+ : kprimaryDisabledTextColor,
127
+ ),
128
+ ],
129
+ ),
130
+ ),
131
+ ),
132
+ )
133
+ )
134
+ );
135
+ }
136
+
137
+ }
0 commit comments