Skip to content

Commit 168d925

Browse files
author
yangshangzhi
committed
feat:优化界面
1 parent 3664d93 commit 168d925

File tree

9 files changed

+157
-80
lines changed

9 files changed

+157
-80
lines changed

lib/page/component/index.dart

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/router/index.dart';
3-
import 'package:efox_flutter/store/models/main_state_model.dart';
3+
import 'package:efox_flutter/store/models/main_state_model.dart'
4+
show MainStateModel;
5+
import 'package:efox_flutter/lang/application.dart' show Application;
6+
import 'package:efox_flutter/lang/app_translations.dart' show AppTranslations;
7+
import 'package:efox_flutter/components/header.dart' as Header;
48
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
59
import 'package:efox_flutter/config/theme.dart' show AppTheme;
610

@@ -25,6 +29,38 @@ class _IndexState extends State<Index> {
2529
this._mapList = WidgetRoot.getAllWidgets();
2630
}
2731

32+
List<Widget> appBarActions(model) {
33+
return [
34+
PopupMenuButton(
35+
icon: Icon(
36+
Icons.more_vert,
37+
),
38+
onSelected: (local) {
39+
Application().onLocaleChanged(Locale(local));
40+
print('local=$local');
41+
},
42+
itemBuilder: (context) => [
43+
PopupMenuItem(
44+
child: Row(
45+
children: <Widget>[
46+
Text('中文'),
47+
],
48+
),
49+
value: 'zh',
50+
),
51+
PopupMenuItem(
52+
child: Row(
53+
children: <Widget>[
54+
Text('english'),
55+
],
56+
),
57+
value: 'en',
58+
),
59+
],
60+
),
61+
];
62+
}
63+
2864
renderPanel(model, widgetsItem, index) {
2965
String nameSpaces = widgetsItem.nameSpaces;
3066
List _tmpWidgetList = widgetsItem.widgetList;
@@ -95,25 +131,35 @@ class _IndexState extends State<Index> {
95131
}
96132

97133
Widget build(BuildContext context) {
98-
return SingleChildScrollView(
99-
physics: BouncingScrollPhysics(),
100-
// padding: EdgeInsets.all(10),
101-
child: ExpansionPanelList(
102-
animationDuration: Duration(milliseconds: 500),
103-
children: List.generate(
104-
_mapList.length,
105-
(_index) {
106-
return renderPanel(model, _mapList[_index], _index);
134+
// 实例化语言包
135+
AppTranslations lang = AppTranslations.of(context);
136+
return Scaffold(
137+
appBar: AppBar(
138+
title: Header.Index(
139+
lang.t('nav_title_0'),
140+
),
141+
actions: appBarActions(model),
142+
),
143+
body: SingleChildScrollView(
144+
physics: BouncingScrollPhysics(),
145+
// padding: EdgeInsets.all(10),
146+
child: ExpansionPanelList(
147+
animationDuration: Duration(milliseconds: 500),
148+
children: List.generate(
149+
_mapList.length,
150+
(_index) {
151+
return renderPanel(model, _mapList[_index], _index);
152+
},
153+
),
154+
expansionCallback: (index, flag) {
155+
if (flag) {
156+
index = -1;
157+
}
158+
setState(() {
159+
this._isExpandedIndex = index;
160+
});
107161
},
108162
),
109-
expansionCallback: (index, flag) {
110-
if (flag) {
111-
index = -1;
112-
}
113-
setState(() {
114-
this._isExpandedIndex = index;
115-
});
116-
},
117163
),
118164
);
119165
}

lib/page/home.dart

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import 'package:flutter/material.dart';
2-
import 'package:efox_flutter/lang/application.dart';
3-
import 'package:efox_flutter/lang/app_translations.dart';
4-
import 'package:flutter_screenutil/flutter_screenutil.dart' show ScreenUtil;
2+
import 'package:efox_flutter/lang/app_translations.dart' show AppTranslations;
53
import 'package:efox_flutter/store/store.dart' show Store;
64

7-
import 'package:efox_flutter/components/header.dart' as Header;
85
import 'component/index.dart' as TabIndex;
96
import 'mine/index.dart' as MyIndex;
107

@@ -47,50 +44,11 @@ class _IndexState extends State<Index> {
4744
);
4845
}
4946

50-
List<Widget> appBarActions(model) {
51-
return [
52-
PopupMenuButton(
53-
icon: Icon(
54-
Icons.more_vert,
55-
),
56-
onSelected: (local) {
57-
Application().onLocaleChanged(Locale(local));
58-
print('local=$local');
59-
},
60-
itemBuilder: (context) => [
61-
PopupMenuItem(
62-
child: Row(
63-
children: <Widget>[
64-
Text('中文'),
65-
],
66-
),
67-
value: 'zh',
68-
),
69-
PopupMenuItem(
70-
child: Row(
71-
children: <Widget>[
72-
Text('english'),
73-
],
74-
),
75-
value: 'en',
76-
),
77-
],
78-
),
79-
];
80-
}
81-
8247
@override
8348
Widget build(BuildContext context) {
84-
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
85-
// 实例化语言包
86-
AppTranslations lang = AppTranslations.of(context);
8749
return Store.connect(
8850
builder: (context, child, model) {
8951
return Scaffold(
90-
appBar: AppBar(
91-
title: Header.Index(lang.t('title'),),
92-
actions: appBarActions(model),
93-
),
9452
bottomNavigationBar: _bottomNavigationBar(model),
9553
body: PageView(
9654
controller: _pageController,

lib/page/mine/index.dart

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,89 @@ class Index extends StatelessWidget {
44
final dynamic model;
55
Index({Key key, this.model}) : super(key: key);
66

7+
final List<dynamic> _list = [
8+
{
9+
'name': '切换语言',
10+
'icon': 59540, // language
11+
},
12+
{
13+
'name': '更新版本',
14+
'icon': 58919, // sync
15+
}
16+
];
17+
18+
actionsEvent(int index) {
19+
print('index $index');
20+
}
21+
722
@override
823
Widget build(BuildContext context) {
9-
return Container(
10-
child: Row(
11-
children: [
12-
RaisedButton(
13-
child:
14-
Text('当前为${model.config.state.isPro ? '线上' : '线下'}环境,点击进行切换'),
15-
onPressed: () {
16-
model.dispatch('config', 'setEnv');
17-
},
18-
),
19-
],
20-
),
24+
return LayoutBuilder(
25+
builder: (context, constraints) {
26+
return NestedScrollView(
27+
headerSliverBuilder: (context, flag) {
28+
return [
29+
SliverOverlapAbsorber(
30+
handle:
31+
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
32+
child: SliverAppBar(
33+
pinned: true,
34+
expandedHeight: 150,
35+
centerTitle: true,
36+
flexibleSpace: FlexibleSpaceBar(
37+
collapseMode: CollapseMode.pin,
38+
title: Text(
39+
'Welcome to Flutter',
40+
),
41+
),
42+
),
43+
),
44+
];
45+
},
46+
body: Builder(builder: (context) {
47+
return CustomScrollView(
48+
slivers: <Widget>[
49+
// SliverOverlapInjector与SliverOverlapAbsorber是相对成立的,
50+
// 若不增加SliverOverlapInjector,则下方的list顶部会被上方headerSliverBuilder所创建的组件遮住,
51+
// 增加后,类似clear:both效果,使得布局能顺畅衔接
52+
SliverOverlapInjector(
53+
// This is the flip side of the SliverOverlapAbsorber above.
54+
handle:
55+
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
56+
),
57+
SliverList(
58+
delegate: SliverChildBuilderDelegate(
59+
(context, index) {
60+
return ListTile(
61+
onTap: () {
62+
this.actionsEvent(index);
63+
},
64+
leading: Icon(
65+
IconData(
66+
_list[index]['icon'],
67+
fontFamily: 'MaterialIcons',
68+
matchTextDirection: true,
69+
),
70+
),
71+
title: Text('${_list[index]['name']}'),
72+
);
73+
},
74+
childCount: _list.length,
75+
),
76+
),
77+
],
78+
);
79+
}),
80+
);
81+
},
2182
);
2283
}
2384
}
85+
86+
// RaisedButton(
87+
// child:
88+
// Text('当前为${model.config.state.isPro ? '线上' : '线下'}环境,点击进行切换'),
89+
// onPressed: () {
90+
// model.dispatch('config', 'setEnv');
91+
// },
92+
// )

lib/widget/animate/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ List widgetMap = [
130130
nameSpaces: nameSpaces,
131131
widgetList: widgets,
132132
typeName: 'Animate',
133-
code: 58353,
133+
code: 58162, // toys
134134
)
135135
];

lib/widget/gestures/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ List widgetMap = [
4646
nameSpaces: nameSpaces,
4747
widgetList: widgets,
4848
typeName: 'Gestures',
49-
code: 58353,
49+
code: 59667, // touch_app
5050
)
5151
];

lib/widget/scrollview/index.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import 'package:efox_flutter/store/objects/widget_info.dart';
22
import 'gridview/index.dart' as gridview;
3-
import 'listview/index.dart' as listview;
3+
// import 'listview/index.dart' as listview;
4+
import '../regular/listview/index.dart' as listview;
45
import 'scrollable/index.dart' as scrollable;
56
import 'customscrollview/index.dart' as customscrollview;
67
import 'singlechildscrollview/index.dart' as singlechildscrollview;
78
import 'scrollbar/index.dart' as scrollbar;
89
import 'scrollcontroller/index.dart' as scrollcontroller;
910
import 'nestedscrollview/index.dart' as nestedscrollview;
1011

12+
1113
const nameSpaces = '/scrollview_';
1214

1315
List widgets = [
@@ -58,6 +60,6 @@ List widgetMap = [
5860
nameSpaces: nameSpaces,
5961
widgetList: widgets,
6062
typeName: 'ScrollComponents',
61-
code: 58353,
63+
code: 57427, // sort_by_alpha
6264
)
6365
];

lib/widget/vision/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ List widgetMap = [
8282
nameSpaces: nameSpaces,
8383
widgetList: widgets,
8484
typeName: 'Vision',
85-
code: 58353,
85+
code: 58408, // transform
8686
)
8787
];

locale/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"title": "Components",
2+
"nav_title_0": "Components",
3+
"nav_title_1": "My",
34
"title_component": "Components",
45
"title_my": "My",
56
"widgetType": {

locale/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"title": "组件",
2+
"nav_title_0": "组件",
3+
"nav_title_1": "我的",
34
"title_component": "组件",
45
"title_my": "我的",
56
"widgetType": {

0 commit comments

Comments
 (0)