account_logoff_page.dart
5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import 'package:appframe/bloc/setting/account_logoff_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
class AccountLogoffPage extends StatelessWidget {
const AccountLogoffPage({super.key});
@override
Widget build(BuildContext context) {
final Map<String, dynamic>? extraData = GoRouterState.of(context).extra as Map<String, dynamic>?;
var phone = extraData?['phone'] ?? '';
return BlocProvider(
create: (context) => AccountLogoffCubit(AccountLogoffState(phone: phone)),
child: BlocConsumer<AccountLogoffCubit, AccountLogoffState>(
builder: (context, state) {
final accountLogoffCubit = context.read<AccountLogoffCubit>();
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text('注销用户', style: TextStyle(color: Colors.white, fontSize: 18)),
centerTitle: true,
backgroundColor: Color(0xFF7691FA),
iconTheme: IconThemeData(
color: Colors.white,
),
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(60),
child: Column(
children: [
SizedBox(height: 60),
Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Color(0xFFFFF3F3),
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Color(0xFFFFCDD2)),
),
child: Row(
children: [
Icon(
Icons.warning_amber_rounded,
color: Color(0xFFE74C3C),
size: 24,
),
SizedBox(width: 12),
Expanded(
child: Text(
'注销后,您的所有数据将被永久删除且无法恢复,请谨慎操作!',
style: TextStyle(
fontSize: 14,
color: Color(0xFFE74C3C),
height: 1.5,
),
),
),
],
),
),
SizedBox(height: 20),
SizedBox(
width: double.infinity,
height: 47,
child: ElevatedButton(
onPressed: state.isLoading
? null
: () {
accountLogoffCubit.logoff();
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFE74C3C),
foregroundColor: Colors.white,
textStyle: TextStyle(fontSize: 19),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(23.5),
),
disabledBackgroundColor: Color(0xFFCCCCCC),
),
child: state.isLoading
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Text(
'确认注销',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w400,
color: Color(0xFFFFFFFF),
),
strutStyle: StrutStyle(height: 22 / 19),
),
),
),
],
),
),
),
);
},
listener: (context, state) {
if (state.showSnackBar) {
_showTip(context, state.snackBarMsg);
}
},
),
);
}
void _showTip(BuildContext context, String tip) {
OverlayEntry overlayEntry = OverlayEntry(
builder: (context) => Positioned(
top: 200,
left: 20,
right: 20,
child: Material(
color: Colors.transparent,
child: Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(8),
),
child: Text(
tip,
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
);
Overlay.of(context).insert(overlayEntry);
Future.delayed(Duration(seconds: 2), () {
overlayEntry.remove();
});
}
}