File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,29 @@ class IndexState extends State<Index> {
116116    );
117117  }
118118
119+   showCode (context) async  {
120+     if  (Store .value <ConfigModel >(context).isPro) {
121+       // 线上文档 
122+       FluroRouter .router.navigateTo (
123+         context,
124+         'webview?title=${widget .title }&url=${Uri .encodeComponent (Store .value <ConfigModel >(context ).env .githubAssetOrigin +widget .mdUrl )}' 
125+         );
126+     } else  {
127+       // 加载本地 
128+       String  mdStr =  await  AssetUtils .readLocaleFile (widget.mdUrl);
129+       Navigator .of (context).push (
130+         MaterialPageRoute (builder:  (BuildContext  build) {
131+           return  Scaffold (
132+             appBar:  AppBar (title:  Text (widget.title),),
133+             body:  ListView (
134+               children:  < Widget > [markdown_comp.Index (mdStr)],
135+             ),
136+           );
137+         })
138+       );
139+     }
140+   }
141+ 
119142  Future  getMdFile (url) async  {
120143    // bool productionEnv = Store.value<ConfigModel>(context).isPro; 
121144    bool  productionEnv =  false ;
@@ -128,6 +151,15 @@ class IndexState extends State<Index> {
128151
129152  getActions (context) {
130153    return  [
154+       IconButton (
155+         color:  Color (AppTheme .blackColor),
156+         icon:  Icon (
157+           Icons .code
158+         ),
159+         onPressed:  () async  {
160+           this .showCode (context);
161+         },
162+       ),
131163      IconButton (
132164        color:  Color (AppTheme .blackColor),
133165        icon:  Icon (
Original file line number Diff line number Diff line change @@ -111,6 +111,18 @@ class _IndexState extends State<Index> {
111111            Divider (
112112              color:  Color (AppTheme .lineColor),
113113            ),
114+             ListTile (
115+               onTap:  () {
116+                 Store .value <ConfigModel >(context).$setIsPro ();
117+               },
118+               leading:  Icon (Icons .verified_user),
119+               title:  Text (
120+                 Store .value <ConfigModel >(context).isPro ?  '线上环境'  :  '本地环境' 
121+               ),
122+             ),
123+             Divider (
124+               color:  Color (AppTheme .lineColor),
125+             ),
114126            (Platform .isAndroid)
115127                ?  ListTile (
116128                    onTap:  () {
Original file line number Diff line number Diff line change @@ -32,4 +32,9 @@ class ConfigModel extends ConfigInfo with ChangeNotifier {
3232    notifyListeners ();
3333  }
3434
35+   Future  $setIsPro () async  {
36+     isPro =  ! isPro;
37+     notifyListeners ();
38+   }
39+ 
3540}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments