11import 'package:flutter/material.dart' ;
2- import 'package:efox_flutter/config/index.dart' as Config;
32import 'package:efox_flutter/store/STORE.dart' show STORE;
43import 'package:efox_flutter/components/markdownComp.dart' as MarkDownComp;
54import 'package:efox_flutter/lang/app_translations.dart' show AppTranslations;
65import 'package:efox_flutter/components/baseComp.dart' as BaseComp;
76import 'package:efox_flutter/components/exampleComp.dart' as ExampleComp;
87import 'package:efox_flutter/utils/file.dart' as FileUtils;
9- import 'package:efox_flutter/utils/loadAsset.dart' as LoadAssetsUtils;
108import 'package:efox_flutter/router/index.dart' show FluroRouter;
119
1210class Index extends StatefulWidget {
@@ -70,34 +68,30 @@ class IndexState extends State<Index> {
7068 this .loading = true ;
7169 }
7270 }
73-
74- void init () async {
71+
72+ void init () async {
7573 this ._bodyList.length = 0 ;
76- for (var i in mdList) {
77- print ('i $i ' );
78- Future res = Future .sync (() {
79- this .getMdFile (i);
80- });
81- res.then ((a) {
82- print ('======== $a ' );
83- });
84- // this._bodyList.insert(0, MarkDownComp.Index(await this.getMdFile(i)));
85- print ('=======' );
86- }
87- // await mdList.reversed.forEach((item) async {
88- // this._bodyList.insert(0, MarkDownComp.Index(await this.getMdFile(item)));
89- // });
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+ });
9082
9183 // 增加
9284 if (this .demoChild != null ) {
9385 this .demoChild.forEach ((Widget item) {
94- print ('======= ${_bodyList }' );
9586 this ._bodyList.add (ExampleComp .Index (child: item));
9687 });
9788 }
89+ print ('end $_bodyList ' );
90+ setState (() {
91+ this .loading = false ;
92+ });
9893 }
9994
100-
10195 openPage (context, model, String url) async {
10296 // 加载页面
10397 if (model.configInfo.isPro) {
@@ -119,7 +113,6 @@ class IndexState extends State<Index> {
119113 }
120114 }
121115
122-
123116 @override
124117 Widget build (BuildContext context) {
125118 return STORE .connect (builder: (context, child, model) {
@@ -129,19 +122,14 @@ class IndexState extends State<Index> {
129122 title: Text (this .name),
130123 actions: this .getActions (context, model),
131124 ),
132- body: this .loading ? this .renderLoading (): this .renderWidget (),
125+ body: this .loading ? this .renderLoading () : this .renderWidget (),
133126 );
134127 });
135128 }
136129
137- dynamic getMdFile (url) async {
138- if (Config .isPro) {
139- String mdr = await LoadAssetsUtils .loadMarkdownAssets (Config .env['GitHubAssetOrigin' ] + url, Config .isPro);
140- return mdr;
141- } else {
142- String mdStr = await FileUtils .readLocaleFile (url);
143- return mdStr;
144- }
130+ Future getMdFile (url) async {
131+ String mdStr = await FileUtils .readLocaleFile (url);
132+ return mdStr;
145133 }
146134
147135 getActions (context, model) {
@@ -219,7 +207,7 @@ class IndexState extends State<Index> {
219207 ];
220208 }
221209
222- Widget renderLoading () {
210+ Widget renderLoading () {
223211 return Center (
224212 child: Stack (
225213 children: < Widget > [
@@ -250,8 +238,9 @@ class IndexState extends State<Index> {
250238 padding: const EdgeInsets .fromLTRB (16.0 , 16.0 , 16.0 , 0 ),
251239 child: Text (
252240 AppTranslations .of (context).t ('loading' ),
253- style:
254- TextStyle (color: Color (this .model.theme.secondColor), fontSize: 16.0 ),
241+ style: TextStyle (
242+ color: Color (this .model.theme.secondColor),
243+ fontSize: 16.0 ),
255244 ),
256245 )
257246 ],
@@ -262,6 +251,7 @@ class IndexState extends State<Index> {
262251 ),
263252 );
264253 }
254+
265255 Widget renderWidget () {
266256 // 加载完成后返回页面
267257 return Scrollbar (
0 commit comments