From 79c4404b0ab79fc432c09700dcdd4cdbfba61258 Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 <50428976+WaseemAbbasi22@users.noreply.github.com> Date: Mon, 22 Jun 2026 16:48:37 +0300 Subject: [PATCH] delete button implemented --- lib/new_views/pages/settings_page.dart | 166 +++++++++++++++---------- 1 file changed, 102 insertions(+), 64 deletions(-) diff --git a/lib/new_views/pages/settings_page.dart b/lib/new_views/pages/settings_page.dart index 0222afe6..b043d41a 100644 --- a/lib/new_views/pages/settings_page.dart +++ b/lib/new_views/pages/settings_page.dart @@ -9,9 +9,13 @@ import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; +import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/helper/utils.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; +import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; +import 'package:test_sa/views/widgets/dialogs/dialog.dart'; import 'package:test_sa/views/widgets/item_views/info_header_widget.dart'; import '../common_widgets/default_app_bar.dart'; @@ -100,76 +104,110 @@ class _SettingsPageState extends State { return Scaffold( appBar: DefaultAppBar(title: context.translation.settings), body: Column( - mainAxisSize: MainAxisSize.min, - spacing: 12, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + Column( + mainAxisSize: MainAxisSize.min, + spacing: 12, children: [ - InfoHeader16Widget(context.translation.arabic), - AdvancedSwitch( - controller: langController, - initialValue: langController!.value, - activeColor: AppColor.green50.withValues(alpha: .25), - inactiveColor: AppColor.neutral10, - thumb: CircleAvatar(backgroundColor: langController!.value ? AppColor.green50 : AppColor.switchBgColor), - borderRadius: const BorderRadius.all(Radius.circular(30)), - width: 42.toScreenWidth, - height: 24.toScreenHeight, - - /// TODO : remove the below attribute to enable the switch - //enabled: false, - disabledOpacity: 1, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InfoHeader16Widget(context.translation.arabic), + AdvancedSwitch( + controller: langController, + initialValue: langController!.value, + activeColor: AppColor.green50.withValues(alpha: .25), + inactiveColor: AppColor.neutral10, + thumb: CircleAvatar(backgroundColor: langController!.value ? AppColor.green50 : AppColor.switchBgColor), + borderRadius: const BorderRadius.all(Radius.circular(30)), + width: 42.toScreenWidth, + height: 24.toScreenHeight, + + /// TODO : remove the below attribute to enable the switch + //enabled: false, + disabledOpacity: 1, + ), + ], ), - ], - ), - // 16.height, - const Divider().defaultStyle(context), - // 16.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InfoHeader16Widget(context.translation.lightTheme), - AdvancedSwitch( - controller: themeController, - initialValue: themeController!.value, - activeColor: AppColor.green50.withValues(alpha: .25), - inactiveColor: AppColor.neutral10, - thumb: CircleAvatar(backgroundColor: themeController!.value ? AppColor.green50 : AppColor.switchBgColor), - borderRadius: const BorderRadius.all(Radius.circular(30)), - width: 42.toScreenWidth, - height: 24.toScreenHeight, - disabledOpacity: 1, + // 16.height, + const Divider().defaultStyle(context), + // 16.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InfoHeader16Widget(context.translation.lightTheme), + AdvancedSwitch( + controller: themeController, + initialValue: themeController!.value, + activeColor: AppColor.green50.withValues(alpha: .25), + inactiveColor: AppColor.neutral10, + thumb: CircleAvatar(backgroundColor: themeController!.value ? AppColor.green50 : AppColor.switchBgColor), + borderRadius: const BorderRadius.all(Radius.circular(30)), + width: 42.toScreenWidth, + height: 24.toScreenHeight, + disabledOpacity: 1, + ), + ], ), + // 16.height, + const Divider().defaultStyle(context), + // 16.height, + FutureBuilder( + future: _settingProvider!.auth.isDeviceSupported(), + builder: (cxt, snapshot) { + bool isDeviceSupported = false; + if (snapshot.hasData) { + isDeviceSupported = snapshot.data as bool; + } + + if (!isDeviceSupported) { + return Text("Your device did not support Fingerprint/Face ID.", style: AppTextStyles.tinyFont.copyWith(color: AppColor.red30)); + } + + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InfoHeader16Widget("Fingerprint/Face ID"), + customSwitch(localAuth).onPress(() { + checkForLocalAuth(localAuth); + }), + ], + ); + }), ], - ), - // 16.height, - const Divider().defaultStyle(context), - // 16.height, - FutureBuilder( - future: _settingProvider!.auth.isDeviceSupported(), - builder: (cxt, snapshot) { - bool isDeviceSupported = false; - if (snapshot.hasData) { - isDeviceSupported = snapshot.data as bool; - } - - if (!isDeviceSupported) { - return Text("Your device did not support Fingerprint/Face ID.", style: AppTextStyles.tinyFont.copyWith(color: AppColor.red30)); - } - - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InfoHeader16Widget("Fingerprint/Face ID"), - customSwitch(localAuth).onPress(() { - checkForLocalAuth(localAuth); - }), - ], - ); - }), + ).toShadowContainer(context, borderRadius: 16, padding: 16).paddingAll(16), + // 12.height, + AppFilledButton( + label: "Delete Account", + buttonColor: AppColor.red30, + onPressed: () async { + bool result = await showDialog( + context: context, + builder: (_) => AAlertDialog( + title: "Confirm".addTranslation, + content: "By deleting your account, all your data will be permanently removed. Are you sure you want to proceed?".addTranslation, + ), + ); + + if (result) { + Utils.showLoading(context); + await Future.delayed(const Duration(seconds: 2)); + Utils.hideLoading(context); + + // final userProvider = Provider.of(context, listen: false); + // bool isSuccess = await userProvider.logout(context); + // if (isSuccess) { + // Provider.of(context, listen: false).resetSettings(); + // userProvider.reset(); + // Navigator.of(context).pop(); + // Navigator.of(context).pop(); + // Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true); + // } + } + }, + ).paddingAll(16), ], - ).toShadowContainer(context, borderRadius: 16, padding: 16).paddingAll(16), + ), ); }