Commit b636880 1 parent c30a89b commit b636880 Copy full SHA for b636880
File tree 2 files changed +26
-6
lines changed
lib/app/modules/addOrUpdateAlarm
2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ class AddOrUpdateAlarmController extends GetxController {
79
79
final RxInt snoozeDuration = 1. obs;
80
80
var customRingtoneName = 'Default' .obs;
81
81
var customRingtoneNames = [].obs;
82
+ var previousRingtone= '' ;
82
83
final noteController = TextEditingController ();
83
84
final RxString note = '' .obs;
84
85
final deleteAfterGoesOff = false .obs;
@@ -842,7 +843,7 @@ class AddOrUpdateAlarmController extends GetxController {
842
843
RingtoneModel customRingtone = RingtoneModel (
843
844
ringtoneName: customRingtoneName.value,
844
845
ringtonePath: savedFilePath,
845
- currentCounterOfUsage: 0 ,
846
+ currentCounterOfUsage: 1 ,
846
847
);
847
848
await IsarDb .addCustomRingtone (customRingtone);
848
849
}
Original file line number Diff line number Diff line change @@ -99,10 +99,33 @@ class ChooseRingtoneTile extends StatelessWidget {
99
99
itemBuilder: (context, index) {
100
100
return Obx (
101
101
() => ListTile (
102
- onTap: () {
102
+ onTap: () async {
103
+ controller.previousRingtone =
104
+ controller.customRingtoneName.value;
105
+
103
106
controller.customRingtoneName.value =
104
107
controller
105
108
.customRingtoneNames[index];
109
+
110
+ if (controller
111
+ .customRingtoneName.value !=
112
+ controller.previousRingtone) {
113
+ await AudioUtils
114
+ .updateRingtoneCounterOfUsage (
115
+ customRingtoneName: controller
116
+ .customRingtoneName.value,
117
+ counterUpdate:
118
+ CounterUpdate .increment,
119
+ );
120
+
121
+ await AudioUtils
122
+ .updateRingtoneCounterOfUsage (
123
+ customRingtoneName:
124
+ controller.previousRingtone,
125
+ counterUpdate:
126
+ CounterUpdate .decrement,
127
+ );
128
+ }
106
129
},
107
130
tileColor: controller
108
131
.customRingtoneName ==
@@ -208,10 +231,6 @@ class ChooseRingtoneTile extends StatelessWidget {
208
231
ElevatedButton (
209
232
onPressed: () async {
210
233
Utils .hapticFeedback ();
211
- await AudioUtils .updateRingtoneCounterOfUsage (
212
- customRingtoneName: controller.customRingtoneName.value,
213
- counterUpdate: CounterUpdate .increment,
214
- );
215
234
Get .back ();
216
235
},
217
236
style: ElevatedButton .styleFrom (
You can’t perform that action at this time.
0 commit comments