permission fixes
This commit is contained in:
@@ -9,6 +9,8 @@ import 'package:nearledaily/view/authentication/login_view.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import '../../domain/provider/profile/create_request.dart';
|
||||
|
||||
import '../../constants/color_constants.dart';
|
||||
import '../../constants/font_constants.dart';
|
||||
import '../../controllers/account_controller/profile.dart';
|
||||
@@ -291,7 +293,15 @@ class _AccountPageState extends State<AccountPage> {
|
||||
|
||||
|
||||
),
|
||||
// _divider(),
|
||||
_divider(),
|
||||
_tile(
|
||||
icon: Icons.delete_outline,
|
||||
title: "Delete Account",
|
||||
isLogout: true,
|
||||
onTap: () {
|
||||
showDeleteAccountDialog();
|
||||
},
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
@@ -634,6 +644,151 @@ class _AccountPageState extends State<AccountPage> {
|
||||
}
|
||||
|
||||
|
||||
/// DELETE ACCOUNT DIALOG (mirrors showLogoutDialog)
|
||||
void showDeleteAccountDialog() {
|
||||
Get.dialog(
|
||||
Dialog(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(22),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
height: 64,
|
||||
width: 64,
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.red,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
size: 30,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
ReusableTextWidget(
|
||||
text: "Delete Account",
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
ReusableTextWidget(
|
||||
text:
|
||||
"We'll submit a request to permanently delete your account and data. This cannot be undone. Continue?",
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
color: Colors.black54,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: primaryColor,
|
||||
side: BorderSide(color: primaryColor),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
child: ReusableTextWidget(
|
||||
text: "Cancel",
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
elevation: 4,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
|
||||
bool success = false;
|
||||
try {
|
||||
success = await CustomerRequestProvider()
|
||||
.sendAccountDeletionRequest();
|
||||
} catch (e) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Get.snackbar(
|
||||
"Error",
|
||||
"Couldn't submit your deletion request. Please try again or contact support.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Get.snackbar(
|
||||
"Request submitted",
|
||||
"Your account deletion request has been received. Our team will process it shortly.",
|
||||
);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String fcmToken = prefs.getString('fcmToken') ?? '';
|
||||
String deviceId =
|
||||
prefs.getString('currentDeviceId') ?? '';
|
||||
await prefs.clear();
|
||||
await prefs.setString('fcmToken', fcmToken);
|
||||
await prefs.setString('currentDeviceId', deviceId);
|
||||
|
||||
Get.deleteAll();
|
||||
GlobalBinding().dependencies();
|
||||
Get.offAll(() => Login_view());
|
||||
},
|
||||
child: ReusableTextWidget(
|
||||
text: "Delete",
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget accountListShimmerSingleBox() {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
|
||||
Reference in New Issue
Block a user