permission fixes
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
android:label="Nearle Daily"
|
android:label="Nearle Daily"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:requestLegacyExternalStorage="true"
|
|
||||||
android:enableOnBackInvokedCallback="true"
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,48 @@ class CustomerRequestProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Submit an account deletion request (reuses the same request pipeline
|
||||||
|
/// used for support tickets, tagged so the backend/support team can
|
||||||
|
/// identify and action it as a deletion instead of general support).
|
||||||
|
Future<bool> sendAccountDeletionRequest() async {
|
||||||
|
isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
int? customerId = prefs.getInt('customerId');
|
||||||
|
|
||||||
|
if (customerId == null) {
|
||||||
|
isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
throw Exception("Something went wrong");
|
||||||
|
}
|
||||||
|
|
||||||
|
final model = CustomerRequestModel(
|
||||||
|
referencedate: DateTime.now().toUtc().toIso8601String().split('.').first + 'Z',
|
||||||
|
referencetype: "account_deletion",
|
||||||
|
customerid: customerId,
|
||||||
|
tenantid: 0,
|
||||||
|
locationid: 0,
|
||||||
|
subject: "Account Deletion Request",
|
||||||
|
remarks: "Customer has requested deletion of their account and associated data.",
|
||||||
|
status: 0,
|
||||||
|
apptypeid: 98,
|
||||||
|
);
|
||||||
|
|
||||||
|
final result = await _repository.createCustomerRequest(model);
|
||||||
|
|
||||||
|
isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
if (result != null && result is Map<String, dynamic> && result["status"] != false) {
|
||||||
|
debugPrint("✅ Account deletion request submitted: $result");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
debugPrint("❌ Account deletion request failed: $result");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch customer requests (status)
|
/// Fetch customer requests (status)
|
||||||
Future<void> fetchCustomerRequests({int pageNo = 1, int pageSize = 10}) async {
|
Future<void> fetchCustomerRequests({int pageNo = 1, int pageSize = 10}) async {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import 'package:nearledaily/view/authentication/login_view.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
|
|
||||||
|
import '../../domain/provider/profile/create_request.dart';
|
||||||
|
|
||||||
import '../../constants/color_constants.dart';
|
import '../../constants/color_constants.dart';
|
||||||
import '../../constants/font_constants.dart';
|
import '../../constants/font_constants.dart';
|
||||||
import '../../controllers/account_controller/profile.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() {
|
Widget accountListShimmerSingleBox() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
|
|||||||
Reference in New Issue
Block a user