v1.1.27 deactivate customer

This commit is contained in:
Tibor Bossanyi (Freelancer)
2022-11-26 16:46:06 +01:00
parent dbdcf2f239
commit 98901f2770
10 changed files with 116 additions and 9 deletions
+58
View File
@@ -14,6 +14,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';
import '../util/enums.dart';
import '../util/track.dart';
// ignore: must_be_immutable
class AccountPage extends StatelessWidget with Trans {
// ignore: close_sinks
@@ -152,6 +155,9 @@ class AccountPage extends StatelessWidget with Trans {
),
devices(context, accountBloc),
loginOut(context, accountBloc),
Divider(),
Divider(),
deleteAccount(accountBloc),
//messaging(),
//getMyTrainees(context, accountBloc),
]);
@@ -241,6 +247,29 @@ class AccountPage extends StatelessWidget with Trans {
return element;
}
ListTile deleteAccount(AccountBloc accountBloc) {
return ListTile(
leading: Icon(Icons.delete_forever),
title: TextButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(t("Delete Account"), style: TextStyle(color: Color.fromARGB(255, 202, 10, 10))),
]),
style: TextButton.styleFrom(
backgroundColor: Colors.white70,
disabledForegroundColor: Colors.grey,
),
onPressed: () => {
if (accountBloc.loggedIn)
{
deleteAccountConfirmationDialog(accountBloc),
}
},
),
);
}
Widget getMyTrainees(BuildContext context, AccountBloc accountBloc) {
if (accountBloc.customerRepository.customer == null || accountBloc.customerRepository.customer!.trainer == 0) {
return ListTile(
@@ -303,6 +332,35 @@ class AccountPage extends StatelessWidget with Trans {
));
}
void deleteAccountConfirmationDialog(AccountBloc accountBloc) {
showCupertinoDialog(
useRootNavigator: true,
context: context,
builder: (_) => CupertinoAlertDialog(
title: Text(t("Are you sure to delete your account?")),
content: Column(children: [
Divider(),
Text(t("Your training data, historical data, goals, 1RMs will be completly lost!")),
]),
actions: [
TextButton(
child: Text(t("No")),
onPressed: () => Navigator.pop(context),
),
TextButton(
child: Text(t("Yes")),
onPressed: () => {
if (accountBloc.customerRepository.customer != null && accountBloc.customerRepository.customer!.customerId != null) {
Track().track(TrackingEvent.delete_account),
accountBloc.add(DeleteAccount(customer: accountBloc.customerRepository.customer!)),
},
Navigator.pop(context),
},
)
],
));
}
void confirmationDialog(AccountBloc accountBloc) {
showCupertinoDialog(
useRootNavigator: true,