account_page_v2.dart
4.79 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
147
148
149
150
151
import 'package:appframe/bloc/setting/account_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class AccountPageV2 extends StatelessWidget {
const AccountPageV2({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => AccountCubit(AccountState()),
child: BlocConsumer<AccountCubit, AccountState>(
builder: (context, state) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text(
'账号与安全',
style: TextStyle(
color: Color(0xFF333333),
fontSize: 16,
fontWeight: FontWeight.bold,
height: 20 / 16,
),
),
centerTitle: true,
backgroundColor: Colors.white,
elevation: 0,
iconTheme: const IconThemeData(color: Colors.black),
),
body: state.loaded
? _buildBody(context, state)
: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(color: Color(0xFF7691FA)),
SizedBox(height: 16),
Text('加载中...'),
],
),
),
);
},
listener: (context, state) {},
),
);
}
Widget _buildBody(BuildContext context, AccountState state) {
final cubit = context.read<AccountCubit>();
return Column(
children: [
Expanded(
child: ListView(
padding: EdgeInsets.zero,
children: [
const Divider(height: 1, thickness: 0.5, color: Color(0xFFE5E5E5)),
_buildItem(
label: '微信账号',
value: state.name.isNotEmpty ? state.nickname : '未绑定',
showArrow: false,
onTap: null,
),
const Divider(height: 1, thickness: 0.5, color: Color(0xFFE5E5E5)),
_buildItem(
label: '手机号',
value: state.phone.isNotEmpty
? '${state.phone.substring(0, 3)}****${state.phone.substring(7, 11)}'
: '未绑定',
showArrow: true,
onTap: () => cubit.goBind(),
),
const Divider(height: 1, thickness: 0.5, color: Color(0xFFE5E5E5)),
_buildItem(
label: 'Apple账号',
value: state.appleId.isNotEmpty ? '已绑定' : '未绑定',
showArrow: true,
onTap: state.appleId.isEmpty ? () => cubit.appleBind() : () => cubit.goApple(),
),
const Divider(height: 1, thickness: 0.5, color: Color(0xFFE5E5E5)),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15, bottom: 40),
child: SizedBox(
width: double.infinity,
height: 44,
child: OutlinedButton(
onPressed: () => cubit.goLogoff(),
style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF333333),
side: const BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(26),
),
),
child: const Text(
'注销用户',
style: TextStyle(
fontSize: 16,
height: 20 / 16,
color: Color(0xFF333333),
),
),
),
),
),
],
);
}
Widget _buildItem({
required String label,
required String value,
required bool showArrow,
VoidCallback? onTap,
}) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 18),
child: Row(
children: [
Text(
label,
style: const TextStyle(
fontSize: 16,
height: 1.0,
color: Color(0xFF333333),
),
),
const Spacer(),
Text(
value,
style: const TextStyle(
fontSize: 16,
color: Color(0xFF333333),
),
),
if (showArrow) ...const [
SizedBox(width: 7.5),
Icon(Icons.arrow_forward_ios, size: 18, color: Color(0xFFCCCCCC)),
],
],
),
),
);
}
}