Skip to content

Commit e7399d2

Browse files
author
yangshangzhi
committed
优化结构
1 parent 6cd91c4 commit e7399d2

File tree

14 files changed

+57
-39
lines changed

14 files changed

+57
-39
lines changed

lib/components/widgetComp.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class IndexState extends State<Index> {
7171
});
7272
}
7373

74-
print('end $_bodyList');
7574
setState(() {
7675
this.loading = false;
7776
});

lib/main.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,26 @@ class MainAppState extends State<MainApp> {
5959
],
6060
title: 'Flutter Demo',
6161
theme: ThemeData(
62-
primarySwatch: Colors.indigo,
62+
// primarySwatch: Colors.blue,
63+
textTheme: TextTheme(
64+
body1: TextStyle(
65+
// color: Colors.black,
66+
// fontWeight: FontWeight.bold,
67+
),
68+
),
69+
platform: TargetPlatform.iOS,
70+
iconTheme: IconThemeData(
71+
size: 32,
72+
color: Colors.grey.shade900,
73+
opacity: 0.85,
74+
),
75+
primaryIconTheme: IconThemeData(
76+
color: Colors.black,
77+
),
78+
accentColor: Colors.grey,
79+
accentColorBrightness: Brightness.light,
80+
primaryColor: Colors.grey.shade50, // appbar背景
81+
scaffoldBackgroundColor: Colors.grey.shade50, // 整体的scaffold背景颜色
6382
),
6483
onGenerateRoute: FluroRouter.router.generator,
6584
),

lib/page/component/index.dart

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,26 @@ class _IndexState extends State<Index> {
2424
/**
2525
* 渲染折叠板
2626
*/
27-
Widget renderExpanel(MainStateModel model, item) {
28-
List _tmpWidgetList = item.widgetList;
27+
Widget renderExpanel(MainStateModel model, widgetsItem) {
28+
String nameSpaces = widgetsItem.nameSpaces;
29+
List _tmpWidgetList = widgetsItem.widgetList;
2930
return ExpansionTile(
3031
title: Text(
31-
item.typeName,
32+
widgetsItem.typeName,
3233
style: TextStyle(
33-
color: Color(model.theme.textColor),
34+
fontSize: 20,
35+
fontWeight: FontWeight.bold,
3436
),
3537
),
3638
leading: Icon(
37-
IconData(item.code ?? 58353,
38-
fontFamily: 'MaterialIcons', matchTextDirection: true),
39-
color: Color(model.theme.textColor),
39+
IconData(
40+
widgetsItem.code ?? 58353,
41+
fontFamily: 'MaterialIcons',
42+
matchTextDirection: true,
43+
),
44+
color: Color(model.theme.mainColor),
4045
),
41-
backgroundColor: Colors.white70,
46+
backgroundColor: Colors.white,
4247
children: [
4348
GridView.count(
4449
shrinkWrap: true,
@@ -66,20 +71,16 @@ class _IndexState extends State<Index> {
6671
fontFamily: 'MaterialIcons',
6772
matchTextDirection: true,
6873
),
69-
color: Color(model.theme.secondColor),
7074
),
7175
onPressed: () {
7276
FluroRouter.router.navigateTo(
7377
context,
74-
_tmpWidgetList[index].routerName,
78+
nameSpaces + _tmpWidgetList[index].name,
7579
);
7680
},
7781
),
7882
Text(
7983
_tmpWidgetList[index].name,
80-
style: TextStyle(
81-
color: Color(model.theme.secondColor),
82-
),
8384
),
8485
],
8586
),
@@ -98,8 +99,8 @@ class _IndexState extends State<Index> {
9899
padding: EdgeInsets.all(10),
99100
child: Column(
100101
children: mapList.map(
101-
(item) {
102-
return renderExpanel(model, item);
102+
(widgetsItem) {
103+
return renderExpanel(model, widgetsItem);
103104
},
104105
).toList(),
105106
),

lib/page/home.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
2323
decoration: BoxDecoration(
2424
border: Border(
2525
top: BorderSide(
26+
width: .1,
2627
color: Color(model.theme.mainColor),
2728
),
2829
),
@@ -31,6 +32,7 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
3132
indicator: BoxDecoration(
3233
border: Border(
3334
bottom: BorderSide(
35+
width: .2,
3436
color: Color(model.theme.mainColor),
3537
),
3638
),
@@ -40,7 +42,10 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
4042
indicatorSize: TabBarIndicatorSize.tab,
4143
indicatorColor: Color(model.theme.secondColor),
4244
labelStyle: TextStyle(
43-
color: Colors.white, fontWeight: FontWeight.w500, fontSize: 16),
45+
color: Colors.green,
46+
fontWeight: FontWeight.w700,
47+
fontSize: 16,
48+
),
4449
tabs: [
4550
Tab(
4651
text: AppTranslations.of(context).t('title_component'),
@@ -66,7 +71,7 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
6671
PopupMenuButton(
6772
icon: Icon(
6873
Icons.more_vert,
69-
color: Color(model.theme.textColor),
74+
// color: Color(model.theme.textColor),
7075
),
7176
onSelected: (local) {
7277
Application().onLocaleChanged(Locale(local));

lib/router/index.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ class FluroRouter {
2222
router.define('/webview', handler: webviewHandler);
2323

2424
// 组件
25-
WidgetConfig.getAllWidgets().forEach((widgetListInfo) {
26-
widgetListInfo.widgetList.forEach((widgetInfo) {
25+
WidgetConfig.getAllWidgets().forEach((widgetsItem) {
26+
print('widgetsItem $widgetsItem');
27+
widgetsItem.widgetList.forEach((itemInfo) {
2728
router.define(
28-
widgetInfo.routerName,
29+
widgetsItem.nameSpaces + itemInfo.name,
2930
handler: Handler(
3031
handlerFunc: (BuildContext context, Map<String, List> params) {
31-
return widgetInfo.widget;
32+
return itemInfo.widget;
3233
}),
3334
);
3435
});

lib/store/models/theme_model.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import 'package:scoped_model/scoped_model.dart';
22

33
class AppTheme {
4-
int mainColor = 0xFF1A237E;
4+
int mainColor = 0xFF000000;
55
int secondColor = 0xFF1565C0;
66
int thirdColor = 0x8A000000;
7-
int textColor = 0x8A000000;
7+
int textColor = 0xFF00C853;
8+
// int textColor = 0x8A000000;
89
}
910

1011
mixin AppThemeModel on Model {

lib/store/objects/widget_info.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ import 'package:flutter/widgets.dart';
22
class ItemInfo extends Object {
33
int code;
44
String name;
5-
String routerName;
65
Widget widget;
76
String webviewTitle;
87

9-
ItemInfo({this.code, this.name, this.routerName, this.widget, this.webviewTitle});
8+
ItemInfo({this.code, this.name, this.widget, this.webviewTitle});
109

1110
ItemInfo.fromJson(Map<String, dynamic> json) {
1211
code = json['code'];
1312
name = json['name'];
1413
widget = json['widget'];
15-
routerName = json['routerName'];
1614
webviewTitle = json['webviewTitle'];
1715
}
1816
}
1917

2018
class ItemListInfo {
2119
String typeName;
20+
String nameSpaces;
2221
int code;
2322
List widgetList;
2423

25-
ItemListInfo({ this.typeName, this.code, this.widgetList});
24+
ItemListInfo({ this.typeName, this.nameSpaces, this.code, this.widgetList});
2625

2726
ItemListInfo.fromJson(Map<String, dynamic> json) {
2827
typeName = json['typeName'];
28+
nameSpaces = json['nameSpaces'];
2929
code = json['code'];
3030

3131
List _list = [];

lib/widget/regular/column/index.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'demo_expanded.dart' as DemoExpanded;
55

66
class Index extends StatefulWidget {
77
static String name = 'Column';
8-
static String routerName = 'column';
98
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Column-class.html';
109
static String codeUrl = 'docs/widget/regular/column/code.md';
1110
static String mdUrl = 'docs/widget/regular/column/index.md';

lib/widget/regular/container/index.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'demo.dart' as Demo;
55

66
class Index extends StatefulWidget {
77
static String name = 'Container';
8-
static String routerName = 'container';
98
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Container-class.html';
109
static String codeUrl = 'docs/widget/regular/container/code.md';
1110
static String mdUrl = 'docs/widget/regular/container/index.md';

lib/widget/regular/index.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ const nameSpaces = '/regular_';
88

99
List widgets = [
1010
ItemInfo(
11-
routerName: nameSpaces + Row.Index.routerName,
1211
widget: Row.Index(),
1312
code: 59702, // calendar_view_day
1413
name: Row.Index.name,
1514
),
1615
ItemInfo(
17-
routerName: nameSpaces + Column.Index.routerName,
1816
widget: Column.Index(),
1917
code: 59692, // accessibility_new
2018
name: Column.Index.name
2119
),
2220
ItemInfo(
23-
routerName: nameSpaces + Container.Index.routerName,
2421
widget: Container.Index(),
2522
code: 60219, // ac_unit
2623
name: Container.Index.name
2724
),
2825
ItemInfo(
29-
routerName: nameSpaces + Padding.Index.routerName,
3026
widget: Padding.Index(),
3127
code: 59483, // aspect_ratio
3228
name: Padding.Index.name
@@ -35,6 +31,7 @@ List widgets = [
3531

3632
List widgetMap = [
3733
ItemListInfo(
34+
nameSpaces: nameSpaces,
3835
widgetList: widgets,
3936
typeName: 'Regular',
4037
code: 59692,

0 commit comments

Comments
 (0)