删除账号
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:food_health/api/dto/user_profile_dto.dart';
|
||||
import 'package:food_health/api/endpoints/user_api.dart';
|
||||
import 'package:food_health/config/theme/custom_colors.dart';
|
||||
import 'package:food_health/providers/app_store.dart';
|
||||
import 'package:food_health/router/config/route_paths.dart';
|
||||
@@ -27,10 +30,63 @@ class _UserCardState extends State<UserCard> {
|
||||
widget.onEdit();
|
||||
}
|
||||
|
||||
void _handLogout() {
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.logout();
|
||||
context.go(RoutePaths.login);
|
||||
///退出登陆
|
||||
void _handLogout() async {
|
||||
await showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text("Log Out?"),
|
||||
content: Text("Are you sure you want to log out? You’ll need to sign in again to access your account."),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text("Cancel"),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text("Log Out"),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.logout();
|
||||
context.go(RoutePaths.login);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///注销账号
|
||||
void _handDelete() async {
|
||||
await showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: Text("Delete Account?"),
|
||||
content: Text("Are you sure you want to delete your account? You won’t be able to recover your account."),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
child: Text("Cancel"),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text("Delete"),
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
EasyLoading.show();
|
||||
await deleteAccountApi();
|
||||
EasyLoading.dismiss();
|
||||
var appStore = context.read<AppStore>();
|
||||
appStore.logout();
|
||||
context.go(RoutePaths.login);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -89,6 +145,16 @@ class _UserCardState extends State<UserCard> {
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer),
|
||||
onTap: _handLogout,
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
child: InkWell(
|
||||
onTap: _handDelete,
|
||||
child: Text(
|
||||
"Delete Account ",
|
||||
style: TextStyle(color: Colors.red, fontSize: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user