11import 'package:flutter/material.dart' ;
2- import 'package:efox_flutter/store/index.dart' show Store;
32import 'package:efox_flutter/components/markdownComp.dart' as MarkDownComp;
43import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
5- import 'package:efox_flutter/components/baseComp.dart' as BaseComp;
64import 'package:efox_flutter/components/exampleComp.dart' as ExampleComp;
75import 'package:efox_flutter/components/updatingComp.dart' as UpdatingComp;
86import 'package:efox_flutter/utils/file.dart' as FileUtils;
9- import 'package:efox_flutter/utils/loadAsset.dart' as LoadAssetUtils;
107import 'package:efox_flutter/router/index.dart' show FluroRouter;
118import 'package:efox_flutter/config/theme.dart' show AppTheme;
129import 'package:efox_flutter/utils/share.dart' as AppShare;
1310import 'package:efox_flutter/widget/author_list.dart' as AuthorList;
1411import 'package:efox_flutter/store/objects/author_info.dart' show AuthorInfo;
12+ import 'package:efox_flutter/store/index.dart' show AuthorModel, ConfigModel, Provide;
1513
1614class Index extends StatefulWidget {
1715 final List <Widget > demoChild;
@@ -42,12 +40,11 @@ class IndexState extends State<Index> {
4240 }
4341
4442 authorTile (nameKey) {
45- AuthorInfo info = this .model.author.state [nameKey];
43+ AuthorInfo info = Provide . value < AuthorModel >(context).list [nameKey];
4644 return Container (
4745 child: ListTile (
4846 onTap: () {
49- FluroRouter .router.navigateTo (context,
50- '/webview?title=${'GitHub-' + info .name }&url=${Uri .encodeComponent (info .url )}' );
47+ FluroRouter .webview (context: context, title: 'GitHub-' + info.name, url: Uri .encodeComponent (info.url));
5148 },
5249 leading: CircleAvatar (
5350 backgroundImage: NetworkImage (
@@ -78,12 +75,11 @@ class IndexState extends State<Index> {
7875 this ._bodyList.length = 0 ;
7976 String mdText = await this .getMdFile (widget.mdUrl);
8077 String nameKey = AuthorList .list[widget.title];
81- print ('name $nameKey ' );
8278 if (nameKey != null ) {
8379 this ._bodyList.add (authorTile (nameKey));
8480 this ._bodyList.add (Divider ());
8581 }
86- if (mdText.length > 30 || ! this .model.config.state.isPro ) {
82+ if (mdText.length > 30 ) {
8783 this ._bodyList.add (await MarkDownComp .Index (mdText));
8884 // demo
8985 if (widget.demoChild != null && widget.demoChild.length > 0 ) {
@@ -101,59 +97,36 @@ class IndexState extends State<Index> {
10197
10298 @override
10399 Widget build (BuildContext context) {
104- return Store .connect (builder: (context, child, model) {
105- this .model = model;
106- return Scaffold (
107- appBar: AppBar (
108- //title: Text(this.title),
109- elevation: 0 ,
110- backgroundColor: Color (AppTheme .secondColor),
111- actions: this .getActions (
112- context,
113- ),
114- leading: IconButton (
115- icon: Icon (Icons .arrow_back),
116- //color: Theme.of(context).primaryTextTheme.title.color,
117- color: Color (AppTheme .blackColor),
118- onPressed: () => Navigator .pop (context),
119- ),
100+ return Scaffold (
101+ appBar: AppBar (
102+ elevation: 0 ,
103+ backgroundColor: Color (AppTheme .secondColor),
104+ actions: this .getActions (
105+ context,
120106 ),
121- body: this .loading ? this .renderLoading () : this .renderWidget (),
122- );
123- });
107+ leading: IconButton (
108+ icon: Icon (Icons .arrow_back),
109+ color: Color (AppTheme .blackColor),
110+ onPressed: () => Navigator .pop (context),
111+ ),
112+ ),
113+ body: this .loading ? this .renderLoading () : this .renderWidget (),
114+ );
124115 }
125116
126- openPage (context) async {
127- String url = widget.mdUrl;
128- // 加载页面
129- if (this .model.config.state.isPro) {
130- FluroRouter .router.navigateTo (context,
131- '/webview?title=${widget .title }&url=${Uri .encodeComponent (this .model .config .state .env .githubAssetOrigin + url .replaceAll (RegExp ('/index.md' ), '' ).replaceAll ('docs' , 'lib' ))}' );
117+ Future getMdFile (url) async {
118+ // bool productionEnv = Provide.value<ConfigModel>(context).isPro;
119+ bool productionEnv = false ;
120+ if (productionEnv) {
121+ return await FileUtils .readRemoteFile (url);
132122 } else {
133- // 加载本地
134- String mdStr = await FileUtils .readLocaleFile (url);
135- Navigator .of (context).push (
136- MaterialPageRoute (builder: (BuildContext context) {
137- return BaseComp .Index (
138- title: widget.title,
139- child: (context, child, model) {
140- return MarkDownComp .Index (mdStr);
141- },
142- );
143- }),
144- );
123+ return await FileUtils .readLocaleFile (url);
145124 }
146125 }
147126
148- Future getMdFile (url) async {
149- String mdStr = (await LoadAssetUtils .loadMarkdownAssets (url)).toString ();
150- return mdStr;
151- }
152-
153127 getActions (context) {
154128 return [
155129 IconButton (
156- //color: Theme.of(context).primaryTextTheme.title.color,
157130 color: Color (AppTheme .blackColor),
158131 icon: Icon (
159132 Icons .insert_link,
@@ -165,22 +138,13 @@ class IndexState extends State<Index> {
165138 );
166139 },
167140 ),
168- /* IconButton(
169- icon: Icon(
170- Icons.code,
171- ),
172- onPressed: () async {
173- this.openPage(context);
174- },
175- ), */
176141 IconButton (
177142 icon: Icon (Icons .share),
178- //color: Theme.of(context).primaryTextTheme.title.color,
179143 color: Color (AppTheme .blackColor),
180144 onPressed: () {
181- final String msg =
182- this .model.config.state. env.githubAssetOrigin + widget.mdUrl ;
183- AppShare .shareText (msg );
145+ dynamic origin =
146+ Provide . value < ConfigModel >(context). env.githubAssetOrigin;
147+ AppShare .shareText (origin + widget.mdUrl );
184148 },
185149 ),
186150 ];
0 commit comments