Skip to content

Commit

Permalink
profile update fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanSarafDev committed Aug 28, 2024
1 parent dcbf7f3 commit c7c8ce7
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class MainActivity : FlutterActivity() {
ringTime["isWeather"]!! as Int,
ringTime["weatherTypes"]!! as String
)
}else{
println("FLUTTER CALLED CANCEL ALARMS")
cancelAllScheduledAlarms()
}
result.success(null)
} else if (call.method == "cancelAllScheduledAlarms") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ class AddOrUpdateAlarmController extends GetxController {
.textTheme
.displaySmall!
.copyWith(
color: themeController.secondaryTextColor.value,
color:
themeController.secondaryTextColor.value,
),
),
onPressed: () {
Expand All @@ -536,80 +537,80 @@ class AddOrUpdateAlarmController extends GetxController {

if (!cameraStatus.isGranted) {
Get.defaultDialog(
backgroundColor: themeController.secondaryBackgroundColor.value,
title: 'Camera Permission'.tr,
titleStyle: TextStyle(
color: themeController.primaryTextColor.value,
),
titlePadding: const EdgeInsets.only(
top: 25,
left: 10,
),
contentPadding:
const EdgeInsets.only(top: 20, left: 20, right: 20,bottom: 23),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Text(
'Please allow camera access to scan QR codes.'.tr,
textAlign: TextAlign.center,
backgroundColor: themeController.secondaryBackgroundColor.value,
title: 'Camera Permission'.tr,
titleStyle: TextStyle(
color: themeController.primaryTextColor.value,
),
),
],
),
onCancel: () {
Get.back(); // Close the alert box
},
onConfirm: () async {
Get.back(); // Close the alert box
PermissionStatus permissionStatus = await Permission.camera.request();
if (permissionStatus.isGranted) {
// Permission granted, proceed with QR code scanning
showQRDialog();
}
},
confirm: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(kprimaryColor),
),
child: Obx(
() => Text(
'OK',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.secondaryTextColor.value,
titlePadding: const EdgeInsets.only(
top: 25,
left: 10,
),
contentPadding:
const EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 23),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Text(
'Please allow camera access to scan QR codes.'.tr,
textAlign: TextAlign.center,
),
),
),
),
onPressed: () async {
Get.back(); // Close the alert box
PermissionStatus permissionStatus =
await Permission.camera.request();
if (permissionStatus.isGranted) {
// Permission granted, proceed with QR code scanning
showQRDialog();
}
},
),
cancel: Obx(
() => TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
themeController.primaryTextColor.value.withOpacity(0.5),
),
),
child: Text(
'Cancel',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.primaryTextColor.value,
],
),
onCancel: () {
Get.back(); // Close the alert box
},
onConfirm: () async {
Get.back(); // Close the alert box
PermissionStatus permissionStatus = await Permission.camera.request();
if (permissionStatus.isGranted) {
// Permission granted, proceed with QR code scanning
showQRDialog();
}
},
confirm: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(kprimaryColor),
),
),
onPressed: () {
Get.back(); // Close the alert box
},
),
),
);
child: Obx(
() => Text(
'OK',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.secondaryTextColor.value,
),
),
),
onPressed: () async {
Get.back(); // Close the alert box
PermissionStatus permissionStatus =
await Permission.camera.request();
if (permissionStatus.isGranted) {
// Permission granted, proceed with QR code scanning
showQRDialog();
}
},
),
cancel: Obx(
() => TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
themeController.primaryTextColor.value.withOpacity(0.5),
),
),
child: Text(
'Cancel',
style: Theme.of(context).textTheme.displaySmall!.copyWith(
color: themeController.primaryTextColor.value,
),
),
onPressed: () {
Get.back(); // Close the alert box
},
),
),
);
} else {
showQRDialog();
}
Expand Down Expand Up @@ -666,7 +667,9 @@ class AddOrUpdateAlarmController extends GetxController {
void onInit() async {
super.onInit();

profileTextEditingController.text = homeController.selectedProfile.value;
profileTextEditingController.text = homeController.isProfileUpdate.value
? homeController.selectedProfile.value
: "";
emailTextEditingController.text = '';

if (Get.arguments != null) {
Expand Down Expand Up @@ -1334,14 +1337,19 @@ class AddOrUpdateAlarmController extends GetxController {
isCall: isCall.value,
ringOn: isFutureDate.value,
);
var profileId =

if(homeController.isProfileUpdate.value)
{
var profileId =
await IsarDb.profileId(homeController.selectedProfile.value);
print(profileId);
if (profileId != 'null') profileModel.isarId = profileId;
print(profileModel.isarId);
await IsarDb.updateAlarmProfiles(profileTextEditingController.text);
print(profileId);
if (profileId != 'null') profileModel.isarId = profileId;
print(profileModel.isarId);
await IsarDb.updateAlarmProfiles(profileTextEditingController.text);
}
await IsarDb.addProfile(profileModel);
homeController.selectedProfile.value = profileModel.profileName;
storage.writeProfile(profileModel.profileName);
homeController.writeProfileName(profileModel.profileName);
}
}
2 changes: 2 additions & 0 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class HomeController extends GetxController {

final storage = Get.find<GetStorageProvider>();

RxBool isProfileUpdate = false.obs;

loginWithGoogle() async {
// Logging in again to ensure right details if User has linked account
if (await SecureStorageProvider().retrieveUserModel() != null) {
Expand Down
3 changes: 2 additions & 1 deletion lib/app/modules/home/views/profile_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class _ProfileSelectState extends State<ProfileSelect> {
? InkWell(
onTap: () async {
controller.isProfile.value = true;
controller.isProfileUpdate.value = true;
Get.toNamed('/add-update-alarm',
arguments: controller.genFakeAlarmModel());
},
Expand Down Expand Up @@ -101,6 +102,7 @@ class _ProfileSelectState extends State<ProfileSelect> {
controller.profileModel.value =
(await IsarDb.getProfile(
controller.selectedProfile.value))!;
controller.isProfileUpdate.value = false;
Get.toNamed(
'/add-update-alarm',
);
Expand Down Expand Up @@ -160,7 +162,6 @@ class _ProfileSelectState extends State<ProfileSelect> {
borderRadius: BorderRadius.circular(18),
onTap: () {
controller.writeProfileName(profile.profileName);

controller.expandProfile.value = !controller.expandProfile.value;
},
child: Obx(() => Container(
Expand Down

0 comments on commit c7c8ce7

Please sign in to comment.