Skip to content

Commit 9efee88

Browse files
authored
Merge pull request #8 from efoxTeam/ysz
2 parents b81ff8f + 24e89fa commit 9efee88

File tree

10 files changed

+105
-58
lines changed

10 files changed

+105
-58
lines changed

app.apk

5.55 MB
Binary file not shown.

lib/components/exampleComp.dart

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/store/models/main_state_model.dart' show MainStateModel;
3+
import 'package:efox_flutter/store/STORE.dart' show STORE;
24

35
class ExampleComp extends StatelessWidget {
46
final Widget child;
@@ -7,16 +9,20 @@ class ExampleComp extends StatelessWidget {
79

810
@override
911
Widget build(BuildContext context) {
10-
return Container(
11-
height: 420.0,
12-
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
13-
decoration: BoxDecoration(
14-
border: Border.all(
15-
color: Colors.deepOrange,
16-
width: 1.0
17-
),
18-
),
19-
child: this.child,
12+
return STORE.connect(
13+
builder: (context, child, MainStateModel model) {
14+
return Container(
15+
height: 420.0,
16+
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
17+
decoration: BoxDecoration(
18+
border: Border.all(
19+
color: Color(model.theme.mainColor),
20+
width: 1.0
21+
),
22+
),
23+
child: this.child,
24+
);
25+
},
2026
);
2127
}
2228
}

lib/components/widgetLodingComp.dart

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class WidgetComp extends StatelessWidget {
3939
}
4040
});
4141
// 增加
42-
if (this.demoChild != null){
42+
if (this.demoChild != null) {
4343
this.demoChild.forEach((Widget item) {
4444
_bodyList.add(ExampleComp(child: item));
4545
});
4646
}
47-
47+
4848
return Scaffold(
4949
appBar: AppBar(
5050
title: Text(this.name),
@@ -53,14 +53,6 @@ class WidgetComp extends StatelessWidget {
5353
icon: Icon(
5454
Icons.favorite_border,
5555
),
56-
onPressed: () {
57-
FluroRouter.router.navigateTo(context, '/webview?url=${Uri.encodeComponent(this.codeUrl)}');
58-
},
59-
),
60-
IconButton(
61-
icon: Icon(
62-
Icons.code,
63-
),
6456
onPressed: () async {
6557
String mdStr = await FileUtils.readLocaleFile(this.mdUrl);
6658
Navigator.of(context).push(MaterialPageRoute(
@@ -75,6 +67,37 @@ class WidgetComp extends StatelessWidget {
7567
));
7668
},
7769
),
70+
IconButton(
71+
icon: Icon(
72+
Icons.code,
73+
),
74+
onPressed: () async {
75+
FluroRouter.router.navigateTo(context,
76+
'/webview?url=${Uri.encodeComponent(this.codeUrl)}');
77+
},
78+
),
79+
PopupMenuButton(
80+
onSelected: (index) {
81+
print('index ${index.runtimeType}');
82+
if (index == 0) {
83+
FluroRouter.router.navigateTo(context,
84+
'/webview?url=${Uri.encodeComponent('https://github.com/efoxTeam/flutter-ui')}');
85+
}
86+
},
87+
itemBuilder: (context) {
88+
return [
89+
PopupMenuItem(
90+
child: Row(children: [
91+
Icon(
92+
Icons.swap_horiz,
93+
),
94+
Text('官网'),
95+
]),
96+
value: 0,
97+
),
98+
];
99+
},
100+
),
78101
],
79102
),
80103
body: this.renderWidget(context),
@@ -126,10 +149,11 @@ class WidgetComp extends StatelessWidget {
126149
);
127150
}
128151
// 加载完成后返回页面
129-
return ListView(
130-
padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
131-
shrinkWrap: true,
132-
children: this._bodyList,
152+
return Scrollbar(
153+
child: ListView(
154+
padding: EdgeInsets.all(10.0),
155+
children: this._bodyList,
156+
),
133157
);
134158
}
135159
}

lib/main.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ class MainAppState extends State<MainApp> {
5959
],
6060
title: 'Flutter Demo',
6161
theme: ThemeData(
62-
primarySwatch: Colors.deepOrange,
62+
primarySwatch: Colors.indigo,
63+
textTheme: TextTheme(
64+
display1: TextStyle(
65+
color: Colors.red,
66+
),
67+
)
6368
),
6469
onGenerateRoute: FluroRouter.router.generator,
6570
),

lib/page/home.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import 'package:efox_flutter/lang/app_translations.dart';
44
//
55
import 'package:efox_flutter/store/STORE.dart';
66

7-
//
8-
import 'tabbar/index.dart';
7+
import 'tabbar/index.dart' as TabIndex;
98

109
class HomePage extends StatefulWidget {
1110
@override
@@ -19,25 +18,25 @@ class _HomePageState extends State<HomePage>
1918
super.initState();
2019
}
2120

22-
Widget menu() {
21+
Widget menu(MainStateModel model) {
2322
return Container(
2423
decoration: BoxDecoration(
2524
border: Border(
2625
top: BorderSide(
27-
color: Colors.deepOrange,
26+
color: Color(model.theme.mainColor),
2827
),
2928
),
3029
),
3130
child: TabBar(
3231
indicator: BoxDecoration(
3332
border: Border(
3433
top: BorderSide(
35-
color: Colors.deepOrange,
34+
color: Color(model.theme.mainColor),
3635
),
3736
),
3837
),
39-
labelColor: Colors.deepOrange,
40-
unselectedLabelColor: Colors.orangeAccent,
38+
labelColor: Color(model.theme.mainColor),
39+
unselectedLabelColor: Color(model.theme.secondColor),
4140
indicatorSize: TabBarIndicatorSize.tab,
4241
indicatorColor: Colors.transparent,
4342
tabs: [
@@ -103,10 +102,10 @@ class _HomePageState extends State<HomePage>
103102
),
104103
],
105104
),
106-
bottomNavigationBar: menu(),
105+
bottomNavigationBar: menu(model),
107106
body: TabBarView(
108107
children: <Widget>[
109-
ComponentsPage(),
108+
TabIndex.ComponentsPage(),
110109
Center(
111110
child: new GridView.count(
112111
// Create a grid with 2 columns. If you change the scrollDirection to

lib/page/tabbar/index.dart

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
2-
import 'package:efox_flutter/lang/app_translations.dart';
2+
// import 'package:efox_flutter/lang/app_translations.dart';
33
import 'package:efox_flutter/router/index.dart';
4+
import 'package:efox_flutter/store/models/main_state_model.dart';
5+
import 'package:efox_flutter/store/STORE.dart' show STORE;
46
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
57

68
class ComponentsPage extends StatefulWidget {
@@ -14,13 +16,13 @@ class _ComponentsPageState extends State<ComponentsPage>
1416
@override
1517
initState() {
1618
super.initState();
17-
this.mapList = WidgetRoot.getAllWidgets();
19+
this.mapList = WidgetRoot.getAllWidgets();
1820
}
1921

2022
/**
2123
* 渲染折叠板
2224
*/
23-
Widget renderExpanel(item) {
25+
Widget renderExpanel(MainStateModel model, item) {
2426
List _tmpWidgetList = item.widgetList;
2527
return ExpansionTile(
2628
title: Text(
@@ -29,9 +31,9 @@ class _ComponentsPageState extends State<ComponentsPage>
2931
leading: Icon(
3032
IconData(item.code ?? 58353,
3133
fontFamily: 'MaterialIcons', matchTextDirection: true),
32-
color: Colors.deepOrange,
34+
color: Color(model.theme.secondColor),
3335
),
34-
backgroundColor: Colors.white12,
36+
backgroundColor: Colors.white70,
3537
children: [
3638
GridView.count(
3739
shrinkWrap: true,
@@ -44,11 +46,10 @@ class _ComponentsPageState extends State<ComponentsPage>
4446
return Container(
4547
decoration: BoxDecoration(
4648
border: Border(
47-
bottom: BorderSide(
48-
width: .1,
49-
color: Colors.orange.shade300,
50-
)
51-
),
49+
bottom: BorderSide(
50+
width: .1,
51+
color: Color(model.theme.mainColor),
52+
)),
5253
),
5354
child: Column(
5455
mainAxisAlignment: MainAxisAlignment.center,
@@ -59,10 +60,11 @@ class _ComponentsPageState extends State<ComponentsPage>
5960
IconData(_tmpWidgetList[index].code ?? 59101,
6061
fontFamily: 'MaterialIcons',
6162
matchTextDirection: true),
62-
color: Colors.deepOrange,
63+
color: Color(model.theme.mainColor),
6364
),
6465
onPressed: () {
65-
FluroRouter.router.navigateTo(context, _tmpWidgetList[index].routerName);
66+
FluroRouter.router.navigateTo(
67+
context, _tmpWidgetList[index].routerName);
6668
},
6769
),
6870
Text(_tmpWidgetList[index].name),
@@ -78,21 +80,20 @@ class _ComponentsPageState extends State<ComponentsPage>
7880
}
7981

8082
Widget build(BuildContext context) {
81-
AppTranslations lang = AppTranslations.of(context);
82-
print('lang${lang}');
83-
return Scrollbar(
84-
child: SingleChildScrollView(
85-
child: Container(
86-
padding: EdgeInsets.all(10.0),
83+
return STORE.connect(
84+
builder: (context, child, model) {
85+
return SingleChildScrollView(
86+
physics: BouncingScrollPhysics(),
87+
padding: EdgeInsets.all(10),
8788
child: Column(
8889
children: mapList.map(
8990
(item) {
90-
return renderExpanel(item);
91+
return renderExpanel(model, item);
9192
},
9293
).toList(),
9394
),
94-
),
95-
),
95+
);
96+
},
9697
);
9798
}
9899
}

lib/store/models/main_state_model.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 'package:scoped_model/scoped_model.dart';
22
import 'user_model.dart';
3+
import 'theme_model.dart';
34

45
///主数据模型,需要全局使用的数据在这里添加模型
5-
class MainStateModel extends Model with UserModel {
6+
class MainStateModel extends Model with UserModel, AppThemeModel {
67
MainStateModel() {
78
// 初始化实例数据
89
}

lib/store/models/theme_model.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:scoped_model/scoped_model.dart';
2+
3+
class AppTheme {
4+
int mainColor = 0xFF1A237E;
5+
int secondColor = 0xFF283593;
6+
}
7+
8+
mixin AppThemeModel on Model {
9+
AppTheme _appTheme = new AppTheme();
10+
get theme => _appTheme;
11+
}

lib/store/models/user_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:scoped_model/scoped_model.dart';
22
import '../objects/user_info.dart';
33

4-
class UserModel extends Model {
4+
mixin UserModel on Model {
55
UserInfo _userInfo = UserInfo();
66
get userInfo => _userInfo;
77

lib/widget/scrollview/gridview/demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Example extends StatelessWidget {
2424
return Container(
2525
decoration: BoxDecoration(
2626
border: Border.all(
27-
color: Colors.redAccent,
27+
color: Colors.lightBlue,
2828
),
2929
),
3030
child: Center(

0 commit comments

Comments
 (0)