Skip to content

Commit 777fcc4

Browse files
author
yangshangzhi
committed
优化结构
1 parent e6be789 commit 777fcc4

File tree

8 files changed

+21
-133
lines changed

8 files changed

+21
-133
lines changed

lib/components/widgetComp.dart

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import 'package:efox_flutter/utils/file.dart' as FileUtils;
88
import 'package:efox_flutter/router/index.dart' show FluroRouter;
99

1010
class Index extends StatefulWidget {
11-
final dynamic modelChild;
12-
final List mdList;
1311
final List<Widget> demoChild;
1412
final String originCodeUrl;
1513
final String codeUrl;
@@ -18,8 +16,6 @@ class Index extends StatefulWidget {
1816
Index({
1917
Key key,
2018
this.name,
21-
this.modelChild,
22-
this.mdList,
2319
this.demoChild,
2420
this.originCodeUrl,
2521
this.codeUrl,
@@ -29,8 +25,6 @@ class Index extends StatefulWidget {
2925
@override
3026
State<StatefulWidget> createState() => IndexState(
3127
name: name,
32-
modelChild: modelChild,
33-
mdList: mdList,
3428
demoChild: demoChild,
3529
originCodeUrl: originCodeUrl,
3630
codeUrl: codeUrl,
@@ -46,7 +40,7 @@ class IndexState extends State<Index> {
4640
final String codeUrl;
4741
final String mdUrl;
4842
final String name;
49-
bool loading = false;
43+
bool loading = true;
5044
dynamic model;
5145

5246
IndexState({
@@ -63,40 +57,45 @@ class IndexState extends State<Index> {
6357
@override
6458
void initState() {
6559
super.initState();
66-
if (this.mdList != null && this.mdList.length > 0) {
67-
this.init();
68-
this.loading = true;
69-
}
60+
this.init();
7061
}
7162

7263
void init() async {
7364
this._bodyList.length = 0;
74-
// for (var i in this.mdList) {
75-
// this
76-
// ._bodyList
77-
// .insert(0, await MarkDownComp.Index(await this.getMdFile(i)));
78-
// }
79-
await this.mdList.reversed.forEach((item) async {
80-
this._bodyList.insert(0, await MarkDownComp.Index(await this.getMdFile(item)));
81-
});
65+
this._bodyList.add(await MarkDownComp.Index(await this.getMdFile(this.mdUrl)));
8266

8367
// 增加
8468
if (this.demoChild != null) {
8569
this.demoChild.forEach((Widget item) {
8670
this._bodyList.add(ExampleComp.Index(child: item));
8771
});
8872
}
73+
8974
print('end $_bodyList');
9075
setState(() {
9176
this.loading = false;
9277
});
9378
}
9479

80+
@override
81+
Widget build(BuildContext context) {
82+
return STORE.connect(builder: (context, child, model) {
83+
this.model = model;
84+
return Scaffold(
85+
appBar: AppBar(
86+
title: Text(this.name),
87+
actions: this.getActions(context, model),
88+
),
89+
body: this.loading ? this.renderLoading() : this.renderWidget(),
90+
);
91+
});
92+
}
93+
9594
openPage(context, model, String url) async {
9695
// 加载页面
9796
if (model.configInfo.isPro) {
9897
FluroRouter.router.navigateTo(context,
99-
'/webview?url=${Uri.encodeComponent(model.configInfo.assetOrigin + url)}');
98+
'/webview?url=${Uri.encodeComponent(this.model.configInfo.config['GitHubAssetOrigin'] + url)}');
10099
} else {
101100
// 加载本地
102101
String mdStr = await FileUtils.readLocaleFile(url);
@@ -113,20 +112,6 @@ class IndexState extends State<Index> {
113112
}
114113
}
115114

116-
@override
117-
Widget build(BuildContext context) {
118-
return STORE.connect(builder: (context, child, model) {
119-
this.model = model;
120-
return Scaffold(
121-
appBar: AppBar(
122-
title: Text(this.name),
123-
actions: this.getActions(context, model),
124-
),
125-
body: this.loading ? this.renderLoading() : this.renderWidget(),
126-
);
127-
});
128-
}
129-
130115
Future getMdFile(url) async {
131116
String mdStr = await FileUtils.readLocaleFile(url);
132117
return mdStr;

lib/config/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'development.dart' as Development;
22
import 'production.dart' as Production;
33

4-
const bool isPro = true;
4+
const bool isPro = false;
55

66
Map<String, dynamic> env = isPro ? Production.Config : Development.Config;

lib/widget/regular/column/index.dart

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3-
import 'package:efox_flutter/utils/file.dart' as FileUitls;
43
import 'demo.dart' as Demo;
54
import 'demo_expanded.dart' as DemoExpanded;
65

@@ -17,34 +16,13 @@ class Index extends StatefulWidget {
1716
}
1817

1918
class _IndexState extends State<Index> {
20-
bool loading = true;
21-
String ___MD___ = mdUrl;
22-
23-
@override
24-
void initState() {
25-
super.initState();
26-
this.initMd();
27-
}
28-
29-
initMd() async {
30-
String mdStr = await FileUitls.readLocaleFile(___MD___);
31-
setState(() {
32-
this.___MD___ = mdStr;
33-
loading = false;
34-
});
35-
}
3619
@override
3720
Widget build(BuildContext context) {
3821
return WidgetComp.Index(
3922
name: Index.name,
4023
codeUrl: codeUrl,
4124
originCodeUrl: originCodeUrl,
4225
mdUrl: mdUrl,
43-
modelChild: (context, child, model) {
44-
return [
45-
___MD___
46-
];
47-
},
4826
demoChild: <Widget>[
4927
Demo.Index(),
5028
DemoExpanded.Index()

lib/widget/regular/container/index.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3-
import 'package:efox_flutter/utils/file.dart' as FileUitls;
43
import 'demo.dart' as Demo;
54

65
String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Container-class.html';
@@ -16,36 +15,13 @@ class Index extends StatefulWidget {
1615
}
1716

1817
class _IndexState extends State<Index> {
19-
bool loading = true;
20-
String ___MD___ = mdUrl;
21-
22-
@override
23-
void initState() {
24-
// TODO: implement initState
25-
super.initState();
26-
this.initMd();
27-
}
28-
29-
initMd() async {
30-
String mdStr = await FileUitls.readLocaleFile(___MD___);
31-
setState(() {
32-
this.___MD___ = mdStr;
33-
loading = false;
34-
});
35-
}
36-
3718
@override
3819
Widget build(BuildContext context) {
3920
return WidgetComp.Index(
4021
name: Index.name,
4122
codeUrl: codeUrl,
4223
originCodeUrl: originCodeUrl,
4324
mdUrl: mdUrl,
44-
modelChild: (context, child, model) {
45-
return [
46-
___MD___
47-
];
48-
},
4925
demoChild: <Widget>[
5026
Demo.Index()
5127
],

lib/widget/regular/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'column/index.dart' as Column;
44
import 'container/index.dart' as Container;
55
import 'padding/index.dart' as Padding;
66

7-
const nameSpaces = '/Regular_';
7+
const nameSpaces = '/regular_';
88

99
List widgets = [
1010
ItemInfo(

lib/widget/regular/padding/index.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3-
import 'package:efox_flutter/utils/file.dart' as FileUtils;
43
import 'demo.dart' as Demo;
54

65
String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/Padding-class.html';
@@ -16,36 +15,13 @@ class Index extends StatefulWidget {
1615
}
1716

1817
class _IndexState extends State<Index> {
19-
bool loading = true;
20-
String ___MD___ = mdUrl;
21-
22-
@override
23-
void initState() {
24-
// TODO: implement initState
25-
super.initState();
26-
this.initMd();
27-
}
28-
29-
initMd() async {
30-
String mdStr = await FileUtils.readLocaleFile(___MD___);
31-
setState(() {
32-
this.___MD___ = mdStr;
33-
loading = false;
34-
});
35-
}
36-
3718
@override
3819
Widget build(BuildContext context) {
3920
return WidgetComp.Index(
4021
name: Index.name,
4122
codeUrl: codeUrl,
4223
originCodeUrl: originCodeUrl,
4324
mdUrl: mdUrl,
44-
modelChild: (context, child, model) {
45-
return [
46-
___MD___
47-
];
48-
},
4925
demoChild: <Widget>[
5026
Demo.Index()
5127
],

lib/widget/regular/row/index.dart

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
33
import 'demo.dart' as Demo;
44
import 'demo_expanded.dart' as DemoExpanded;
5-
import 'package:efox_flutter/utils/file.dart' as FileUtils;
65

76
String _mdUrl = 'docs/widget/regular/row/index.md';
87

@@ -18,20 +17,6 @@ class Index extends StatefulWidget {
1817
}
1918

2019
class _IndexState extends State<Index> {
21-
String ___MD___ = _mdUrl;
22-
23-
@override
24-
void initState() {
25-
super.initState();
26-
this.initMd();
27-
}
28-
29-
initMd() async {
30-
String mdStr = await FileUtils.readLocaleFile(___MD___);
31-
setState(() {
32-
this.___MD___ = mdStr;
33-
});
34-
}
3520

3621
@override
3722
Widget build(BuildContext context) {
@@ -40,11 +25,6 @@ class _IndexState extends State<Index> {
4025
codeUrl: Index.codeUrl,
4126
originCodeUrl: Index.originCodeUrl,
4227
mdUrl: Index.mdUrl,
43-
modelChild: (context, child, model) {
44-
return [
45-
___MD___,
46-
];
47-
},
4828
demoChild: [
4929
Demo.Index(),
5030
DemoExpanded.Index()

lib/widget/scrollview/gridview/index.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@ class Index extends StatefulWidget {
1919
}
2020

2121
class _IndexState extends State<Index> {
22-
23-
@override
24-
void initState() {
25-
super.initState();
26-
}
27-
2822
@override
2923
Widget build(BuildContext context) {
3024
return WidgetComp.Index(
3125
name: Index.name,
3226
codeUrl: codeUrl,
3327
originCodeUrl: originCodeUrl,
3428
mdUrl: mdUrl,
35-
mdList: [mdUrl],
3629
demoChild: [
3730
DemoCount.Index(),
3831
DemoExtent.Index(),

0 commit comments

Comments
 (0)