Skip to content

Commit

Permalink
resolving the no ringtone selected bug (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
superiorsd10 authored Dec 10, 2023
1 parent 0ba16eb commit d19311f
Showing 1 changed file with 165 additions and 142 deletions.
307 changes: 165 additions & 142 deletions lib/app/modules/settings/views/custom_ringtone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,161 +24,184 @@ class CustomRingtone extends StatelessWidget {

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () async {
Utils.hapticFeedback();
RingtoneModel? customRingtone = await IsarDb.getCustomRingtone();
return Obx(
() => InkWell(
onTap: () async {
Utils.hapticFeedback();
RingtoneModel? customRingtone = await IsarDb.getCustomRingtone();

if (customRingtone != null) {
controller.customRingtoneName.value = customRingtone.ringtoneName;
}
if (customRingtone != null) {
controller.customRingtoneName.value = customRingtone.ringtoneName;
}

controller.customRingtoneStatus.value =
await SecureStorageProvider().readCustomRingtoneStatus();
controller.customRingtoneStatus.value =
await SecureStorageProvider().readCustomRingtoneStatus();

Get.defaultDialog(
titlePadding: const EdgeInsets.symmetric(vertical: 20),
backgroundColor: themeController.isLightMode.value
? kLightSecondaryBackgroundColor
: ksecondaryBackgroundColor,
title: 'Custom Ringtone',
titleStyle: Theme.of(context).textTheme.displaySmall,
content: Obx(
() => Column(
children: [
RadioListTile.adaptive(
title: Text(
'Disable',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
),
),
value: CustomRingtoneStatus.disabled,
groupValue: controller.customRingtoneStatus.value,
fillColor: const MaterialStatePropertyAll(kprimaryColor),
onChanged: (value) {
Utils.hapticFeedback();
controller.customRingtoneStatus.value =
CustomRingtoneStatus.disabled;
controller.customRingtoneName.value =
'Custom Ringtone Disabled!';
controller.saveCustomRingtoneStatus();
},
),
RadioListTile.adaptive(
title: Text(
'Enable',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
),
Get.defaultDialog(
titlePadding: const EdgeInsets.symmetric(vertical: 20),
backgroundColor: themeController.isLightMode.value
? kLightSecondaryBackgroundColor
: ksecondaryBackgroundColor,
barrierDismissible: controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled &&
controller.customRingtoneName.value ==
'Custom Ringtone Disabled!'
? false
: true,
onWillPop: () async {
return controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled &&
controller.customRingtoneName.value ==
'Custom Ringtone Disabled!' ? false : true;
},
title: 'Custom Ringtone',
titleStyle: Theme.of(context).textTheme.displaySmall,
content: Obx(
() => Column(
children: [
RadioListTile.adaptive(
title: Text(
'Disable',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
),
),
value: CustomRingtoneStatus.disabled,
groupValue: controller.customRingtoneStatus.value,
fillColor: const MaterialStatePropertyAll(kprimaryColor),
onChanged: (value) {
Utils.hapticFeedback();
controller.customRingtoneStatus.value =
CustomRingtoneStatus.disabled;
controller.customRingtoneName.value =
'Custom Ringtone Disabled!';
controller.saveCustomRingtoneStatus();
},
),
value: CustomRingtoneStatus.enabled,
groupValue: controller.customRingtoneStatus.value,
fillColor: const MaterialStatePropertyAll(kprimaryColor),
onChanged: (value) async {
Utils.hapticFeedback();
controller.customRingtoneStatus.value =
CustomRingtoneStatus.enabled;
RingtoneModel? customRingtone =
await IsarDb.getCustomRingtone();
RadioListTile.adaptive(
title: Text(
'Enable',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: kprimaryTextColor,
),
),
value: CustomRingtoneStatus.enabled,
groupValue: controller.customRingtoneStatus.value,
fillColor: const MaterialStatePropertyAll(kprimaryColor),
onChanged: (value) async {
Utils.hapticFeedback();
controller.customRingtoneStatus.value =
CustomRingtoneStatus.enabled;
RingtoneModel? customRingtone =
await IsarDb.getCustomRingtone();

if (customRingtone != null) {
controller.customRingtoneName.value =
customRingtone.ringtoneName;
}
controller.saveCustomRingtoneStatus();
},
),
Visibility(
visible: controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
OutlinedButton(
onPressed: () async {
Utils.hapticFeedback();
await controller.saveCustomRingtone();
},
child: Obx(() {
bool isRingtoneSelected =
controller.customRingtoneName.value !=
'Custom Ringtone Disabled!' &&
controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled;
if (customRingtone != null) {
controller.customRingtoneName.value =
customRingtone.ringtoneName;
}
controller.saveCustomRingtoneStatus();
},
),
Visibility(
visible: controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: () async {
Utils.hapticFeedback();
await controller.saveCustomRingtone();
},
child: Obx(() {
bool isRingtoneSelected =
controller.customRingtoneName.value !=
'Custom Ringtone Disabled!' &&
controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled;

return Text(
isRingtoneSelected
? 'Change Ringtone'
: 'Choose Ringtone',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
color: kprimaryColor,
),
);
}),
),
const SizedBox(
height: 10,
),
Text(controller.customRingtoneName.value),
],
return Text(
isRingtoneSelected
? 'Change Ringtone'
: 'Choose Ringtone',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
color: kprimaryColor,
),
);
}),
),
const SizedBox(
height: 10,
),
Text(controller.customRingtoneName.value),
],
),
),
),
const SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () {
Utils.hapticFeedback();
Get.back();
},
style: ElevatedButton.styleFrom(
backgroundColor: kprimaryColor,
const SizedBox(
height: 30,
),
child: Text(
'Done',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: ksecondaryTextColor,
),
ElevatedButton(
onPressed: controller.customRingtoneStatus.value ==
CustomRingtoneStatus.enabled &&
controller.customRingtoneName.value ==
'Custom Ringtone Disabled!'
? null
: () {
Utils.hapticFeedback();
Get.back();
},
style: ElevatedButton.styleFrom(
backgroundColor: kprimaryColor,
disabledBackgroundColor: themeController.isLightMode.value
? kLightPrimaryDisabledTextColor
: kprimaryDisabledTextColor,
),
child: Text(
'Done',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.isLightMode.value
? kLightPrimaryTextColor
: ksecondaryTextColor,
),
),
),
],
),
),
);
},
child: Container(
width: width * 0.91,
height: height * 0.1,
decoration: Utils.getCustomTileBoxDecoration(
isLightMode: themeController.isLightMode.value,
),
child: Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Custom Ringtone',
style: Theme.of(context).textTheme.bodyLarge,
),
Icon(
Icons.arrow_forward_ios_sharp,
color: themeController.isLightMode.value
? kLightPrimaryTextColor.withOpacity(0.4)
: kprimaryTextColor.withOpacity(0.2),
),
],
),
),
);
},
child: Container(
width: width * 0.91,
height: height * 0.1,
decoration: Utils.getCustomTileBoxDecoration(
isLightMode: themeController.isLightMode.value,
),
child: Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Custom Ringtone',
style: Theme.of(context).textTheme.bodyLarge,
),
Icon(
Icons.arrow_forward_ios_sharp,
color: themeController.isLightMode.value
? kLightPrimaryTextColor.withOpacity(0.4)
: kprimaryTextColor.withOpacity(0.2),
),
],
),
),
),
);
Expand Down

0 comments on commit d19311f

Please sign in to comment.