@@ -8,8 +8,6 @@ import 'package:efox_flutter/utils/file.dart' as FileUtils;
88import 'package:efox_flutter/router/index.dart' show FluroRouter;
99
1010class 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;
0 commit comments