shop_page.dart
7.5 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import 'package:flutter/material.dart';
import 'package:one_poem/account/account_router.dart';
import 'package:one_poem/components/user_entity.dart';
import 'package:one_poem/mvp/base_page.dart';
import 'package:one_poem/res/resources.dart';
import 'package:one_poem/routers/fluro_navigator.dart';
import 'package:one_poem/setting/setting_router.dart';
import 'package:one_poem/shop/iview/shop_iview.dart';
import 'package:one_poem/shop/presenter/shop_presenter.dart';
import 'package:one_poem/shop/provider/user_provider.dart';
import 'package:one_poem/util/image_utils.dart';
import 'package:one_poem/util/theme_utils.dart';
import 'package:one_poem/widgets/load_image.dart';
import 'package:provider/provider.dart';
import '../shop_router.dart';
/// design/6店铺-账户/index.html#artboard0
class ShopPage extends StatefulWidget {
const ShopPage({
Key? key,
this.isAccessibilityTest = false,
}) : super(key : key);
final bool isAccessibilityTest;
@override
_ShopPageState createState() => _ShopPageState();
}
class _ShopPageState extends State<ShopPage> with BasePageMixin<ShopPage, ShopPagePresenter>, AutomaticKeepAliveClientMixin<ShopPage> implements ShopIMvpView {
final List<String> _menuTitle = ['账户流水', '资金管理', '提现账号'];
final List<String> _menuImage = ['zhls', 'zjgl', 'txzh'];
final List<String> _menuDarkImage = ['dark_zhls', 'dark_zjgl', 'dark_txzh'];
UserProvider provider = UserProvider();
@override
void setUser(UserEntity? user) {
provider.setUser(user);
}
@override
bool get isAccessibilityTest => widget.isAccessibilityTest;
@override
Widget build(BuildContext context) {
super.build(context);
final Color? _iconColor = ThemeUtils.getIconColor(context);
final Widget line = Container(
height: 0.6,
width: double.infinity,
margin: const EdgeInsets.only(left: 16.0),
child: Gaps.line,
);
return ChangeNotifierProvider<UserProvider>(
create: (_) => provider,
child: Scaffold(
appBar: AppBar(
actions: <Widget>[
IconButton(
tooltip: '消息',
onPressed: () {
NavigatorUtils.push(context, ShopRouter.messagePage);
},
icon: LoadAssetImage(
'shop/message',
key: const Key('message'),
width: 24.0,
height: 24.0,
color: _iconColor,
),
),
IconButton(
tooltip: '设置',
onPressed: () {
NavigatorUtils.push(context, SettingRouter.settingPage);
},
icon: LoadAssetImage(
'shop/setting',
key: const Key('setting'),
width: 24.0,
height: 24.0,
color: _iconColor,
),
)
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Gaps.vGap12,
Consumer<UserProvider>(
builder: (_, provider, child) {
final Widget header = Stack(
children: <Widget>[
const SizedBox(width: double.infinity, height: 56.0),
const Text(
'官方直营店',
style: TextStyles.textBold24,
),
Positioned(
right: 0.0,
child: CircleAvatar(
radius: 28.0,
backgroundColor: Colors.transparent,
backgroundImage: ImageUtils.getImageProvider(provider.user?.avatar, holderImg: 'shop/tx'),
),
),
child!,
],
);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: MergeSemantics(
child: header,
),
);
},
child: Positioned(
top: 38.0,
left: 0.0,
child: Row(
children: const <Widget>[
LoadAssetImage('shop/zybq', width: 40.0, height: 16.0,),
Gaps.hGap8,
Text('店铺账号:15000000000', style: TextStyles.textSize12)
],
),
),
),
Gaps.vGap24,
line,
Gaps.vGap24,
const MergeSemantics(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'账户',
style: TextStyles.textBold18,
),
),
),
_ShopFunctionModule(
data: _menuTitle,
image: _menuImage,
darkImage: _menuDarkImage,
onItemClick: (index) {
if (index == 0) {
NavigatorUtils.push(context, AccountRouter.accountPage);
} else if (index == 1) {
NavigatorUtils.push(context, AccountRouter.accountPage);
} else if (index == 2) {
NavigatorUtils.push(context, AccountRouter.accountPage);
}
},
),
line,
Gaps.vGap24,
const MergeSemantics(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'店铺',
style: TextStyles.textBold18,
),
),
),
/// 使用Flexible防止溢出
Flexible(
child: _ShopFunctionModule(
data: const ['店铺设置'],
image: const ['dpsz'],
darkImage: const ['dark_dpsz'],
onItemClick: (index) {
NavigatorUtils.push(context, ShopRouter.shopSettingPage);
},
),
),
],
),
),
);
}
@override
bool get wantKeepAlive => true;
@override
ShopPagePresenter createPresenter() => ShopPagePresenter();
}
class _ShopFunctionModule extends StatelessWidget {
const _ShopFunctionModule({
Key? key,
required this.onItemClick,
required this.data,
required this.image,
required this.darkImage,
}): super(key: key);
final Function(int index) onItemClick;
final List<String> data;
final List<String> image;
final List<String> darkImage;
@override
Widget build(BuildContext context) {
return GridView.builder(
shrinkWrap: true,
padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 12.0),
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 1.18,
),
itemCount: data.length,
itemBuilder: (_, index) {
return InkWell(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
LoadAssetImage(context.isDark ? 'shop/${darkImage[index]}' : 'shop/${image[index]}', width: 32.0),
Gaps.vGap4,
Text(
data[index],
style: TextStyles.textSize12,
)
],
),
onTap: () {
onItemClick(index);
},
);
},
);
}
}