@@ -4,7 +4,9 @@ import 'package:airoute/airoute.dart';
44import 'package:flip_panel/flip_panel.dart' ;
55import 'package:flutter/cupertino.dart' ;
66import 'package:flutter/material.dart' ;
7+ import 'package:flutter_app_sample/component/main/main_view_model.dart' ;
78import 'package:flutter_app_sample/global_view_model.dart' ;
9+ import 'package:provider/provider.dart' ;
810
911import '../../common/helper/tip_helper.dart' ;
1012import '../../common/helper/tip_type.dart' ;
@@ -67,6 +69,7 @@ class _MainState extends State<MainPage> {
6769 "Wave" ,
6870 "IconAnim" ,
6971 "Overlay" ,
72+ "Loading" ,
7073 ];
7174 return _sortTitles;
7275 }
@@ -94,6 +97,7 @@ class _MainState extends State<MainPage> {
9497 "/MainWavePage" ,
9598 "/MainIconAnimPage" ,
9699 "/MainOverlayPage" ,
100+ "/MainLoadingPage" ,
97101 ];
98102 return _sortRouteNames;
99103 }
@@ -127,6 +131,11 @@ class _MainState extends State<MainPage> {
127131 return _bottomNavigationWidgets;
128132 }
129133
134+ _setState (bool value) {
135+ _drawerOpenedRight = value;
136+ MainViewModel .getInstance ().notify ();
137+ }
138+
130139 ///
131140 ///获取列表
132141 ListView _getListView () {
@@ -206,7 +215,7 @@ class _MainState extends State<MainPage> {
206215 return items;
207216 }
208217
209- Drawer _getDrawer () {
218+ Drawer _getDrawer ({ bool leftDraw = true } ) {
210219 return Drawer (
211220 child: SingleChildScrollView (
212221 physics: BouncingScrollPhysics (),
@@ -282,24 +291,24 @@ class _MainState extends State<MainPage> {
282291 },
283292 trailing: Icon (Icons .arrow_right),
284293 ),
285- Divider (),
286- ListTile (
287- leading: Icon (
288- Icons .more_horiz,
289- color: Colors .blue,
290- ),
291- title: Text ("更多功能" ),
292- subtitle: Text (
293- "紧急上线中..." ,
294- ),
295- onTap: () {
296- TipHelper .showTip (
297- context: context,
298- tipType: TipType .WARN ,
299- message: "紧急上线中..." );
300- },
301- trailing: Icon (Icons .arrow_right),
302- ),
294+ // Divider(),
295+ // ListTile(
296+ // leading: Icon(
297+ // Icons.more_horiz,
298+ // color: Colors.blue,
299+ // ),
300+ // title: Text("更多功能"),
301+ // subtitle: Text(
302+ // "紧急上线中...",
303+ // ),
304+ // onTap: () {
305+ // TipHelper.showTip(
306+ // context: context,
307+ // tipType: TipType.WARN,
308+ // message: "紧急上线中...");
309+ // },
310+ // trailing: Icon(Icons.arrow_right),
311+ // ),
303312 Divider (),
304313 ExpansionTile (
305314 title: Text ("小标签" ),
@@ -348,25 +357,37 @@ class _MainState extends State<MainPage> {
348357 children: < Widget > [
349358 Wrap (
350359 children: < Widget > [
351- ListTile (
352- onTap: () {
353- setState (
354- () {
355- _drawerOpenedRight = ! _drawerOpenedRight;
356- },
357- );
358- },
359- leading: Text ("开启右侧侧滑" ),
360- trailing: Switch (
361- value: _drawerOpenedRight,
362- onChanged: (bool value) {
363- setState (
364- () {
365- _drawerOpenedRight = value;
366- },
367- );
368- },
369- ),
360+ IgnorePointer (
361+ ignoring: (! leftDraw && _drawerOpenedRight),
362+ child: (! leftDraw && _drawerOpenedRight)
363+ ? ColorFiltered (
364+ colorFilter: ColorFilter .mode (
365+ Colors .grey, BlendMode .srcIn),
366+ child: ListTile (
367+ onTap: () {
368+ _setState (! _drawerOpenedRight);
369+ },
370+ leading: Text ("开启右侧侧滑" ),
371+ trailing: Switch (
372+ value: _drawerOpenedRight,
373+ onChanged: (bool value) {
374+ _setState (value);
375+ },
376+ ),
377+ ),
378+ )
379+ : ListTile (
380+ onTap: () {
381+ _setState (! _drawerOpenedRight);
382+ },
383+ leading: Text ("开启右侧侧滑" ),
384+ trailing: Switch (
385+ value: _drawerOpenedRight,
386+ onChanged: (bool value) {
387+ _setState (value);
388+ },
389+ ),
390+ ),
370391 ),
371392 ],
372393 ),
@@ -442,6 +463,23 @@ class _MainState extends State<MainPage> {
442463 children: < Widget > [
443464 Wrap (
444465 children: < Widget > [
466+ ListTile (
467+ onTap: () {
468+ setState (() {
469+ TipHelper .showTip (
470+ context: null , message: "努力开发中..." );
471+ });
472+ },
473+ title: Text ("常亮" ),
474+ trailing: IgnorePointer (
475+ ignoring: true ,
476+ child: Switch (
477+ value: false ,
478+ onChanged: (bool value) {
479+ setState (() {});
480+ },
481+ ),
482+ )),
445483 ListTile (
446484 onTap: () {
447485 Airoute .pushNamed (
@@ -492,24 +530,34 @@ class _MainState extends State<MainPage> {
492530
493531 @override
494532 Widget build (BuildContext context) {
495- return Scaffold (
496- appBar: AppBar (
497- title: Text (
498- "${_bottomNavigationTitles .elementAt (_bottomNavigationSelectedIndex )}" ),
499- ),
500- drawer: _getDrawer (),
501- endDrawer: _drawerOpenedRight == true ? _getDrawer () : null ,
502- body: Center (
503- child: getBottomNavigationWidgets ()
504- .elementAt (_bottomNavigationSelectedIndex),
505- ),
506- bottomNavigationBar: BottomNavigationBar (
507- showSelectedLabels: true ,
508- showUnselectedLabels: true ,
509- elevation: 5.0 ,
510- currentIndex: _bottomNavigationSelectedIndex,
511- items: _getBottomNavigationBar (),
512- onTap: _bottomNavigationTap,
533+ return MultiProvider (
534+ providers: [
535+ ChangeNotifierProvider (
536+ create: (context) => MainViewModel .getInstance ()),
537+ ],
538+ child: Consumer <MainViewModel >(
539+ builder: (context, model, child) {
540+ return Scaffold (
541+ appBar: AppBar (
542+ title: Text (
543+ "${_bottomNavigationTitles .elementAt (_bottomNavigationSelectedIndex )}" ),
544+ ),
545+ drawer: _getDrawer (leftDraw: true ),
546+ endDrawer: _drawerOpenedRight ? _getDrawer (leftDraw: false ) : null ,
547+ body: Center (
548+ child: getBottomNavigationWidgets ()
549+ .elementAt (_bottomNavigationSelectedIndex),
550+ ),
551+ bottomNavigationBar: BottomNavigationBar (
552+ showSelectedLabels: true ,
553+ showUnselectedLabels: true ,
554+ elevation: 5.0 ,
555+ currentIndex: _bottomNavigationSelectedIndex,
556+ items: _getBottomNavigationBar (),
557+ onTap: _bottomNavigationTap,
558+ ),
559+ );
560+ },
513561 ),
514562 );
515563 }
0 commit comments