diff --git a/app.apk b/app.apk new file mode 100644 index 0000000..91cdfdb Binary files /dev/null and b/app.apk differ diff --git a/lib/components/exampleComp.dart b/lib/components/exampleComp.dart index 9db343b..849afdc 100644 --- a/lib/components/exampleComp.dart +++ b/lib/components/exampleComp.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:efox_flutter/store/models/main_state_model.dart' show MainStateModel; +import 'package:efox_flutter/store/STORE.dart' show STORE; class ExampleComp extends StatelessWidget { final Widget child; @@ -7,16 +9,20 @@ class ExampleComp extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - height: 420.0, - margin: EdgeInsets.fromLTRB(50, 40, 50, 40), - decoration: BoxDecoration( - border: Border.all( - color: Colors.deepOrange, - width: 1.0 - ), - ), - child: this.child, + return STORE.connect( + builder: (context, child, MainStateModel model) { + return Container( + height: 420.0, + margin: EdgeInsets.fromLTRB(50, 40, 50, 40), + decoration: BoxDecoration( + border: Border.all( + color: Color(model.theme.mainColor), + width: 1.0 + ), + ), + child: this.child, + ); + }, ); } } \ No newline at end of file diff --git a/lib/components/widgetLodingComp.dart b/lib/components/widgetLodingComp.dart index 98a69a5..8f0eedd 100644 --- a/lib/components/widgetLodingComp.dart +++ b/lib/components/widgetLodingComp.dart @@ -39,12 +39,12 @@ class WidgetComp extends StatelessWidget { } }); // 增加 - if (this.demoChild != null){ + if (this.demoChild != null) { this.demoChild.forEach((Widget item) { _bodyList.add(ExampleComp(child: item)); }); } - + return Scaffold( appBar: AppBar( title: Text(this.name), @@ -53,14 +53,6 @@ class WidgetComp extends StatelessWidget { icon: Icon( Icons.favorite_border, ), - onPressed: () { - FluroRouter.router.navigateTo(context, '/webview?url=${Uri.encodeComponent(this.codeUrl)}'); - }, - ), - IconButton( - icon: Icon( - Icons.code, - ), onPressed: () async { String mdStr = await FileUtils.readLocaleFile(this.mdUrl); Navigator.of(context).push(MaterialPageRoute( @@ -75,6 +67,37 @@ class WidgetComp extends StatelessWidget { )); }, ), + IconButton( + icon: Icon( + Icons.code, + ), + onPressed: () async { + FluroRouter.router.navigateTo(context, + '/webview?url=${Uri.encodeComponent(this.codeUrl)}'); + }, + ), + PopupMenuButton( + onSelected: (index) { + print('index ${index.runtimeType}'); + if (index == 0) { + FluroRouter.router.navigateTo(context, + '/webview?url=${Uri.encodeComponent('https://github.com/efoxTeam/flutter-ui')}'); + } + }, + itemBuilder: (context) { + return [ + PopupMenuItem( + child: Row(children: [ + Icon( + Icons.swap_horiz, + ), + Text('官网'), + ]), + value: 0, + ), + ]; + }, + ), ], ), body: this.renderWidget(context), @@ -126,10 +149,11 @@ class WidgetComp extends StatelessWidget { ); } // 加载完成后返回页面 - return ListView( - padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), - shrinkWrap: true, - children: this._bodyList, + return Scrollbar( + child: ListView( + padding: EdgeInsets.all(10.0), + children: this._bodyList, + ), ); } } diff --git a/lib/main.dart b/lib/main.dart index b8b55e5..839a91d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -59,7 +59,12 @@ class MainAppState extends State { ], title: 'Flutter Demo', theme: ThemeData( - primarySwatch: Colors.deepOrange, + primarySwatch: Colors.indigo, + textTheme: TextTheme( + display1: TextStyle( + color: Colors.red, + ), + ) ), onGenerateRoute: FluroRouter.router.generator, ), diff --git a/lib/page/home.dart b/lib/page/home.dart index ef729a6..73bd82b 100644 --- a/lib/page/home.dart +++ b/lib/page/home.dart @@ -4,8 +4,7 @@ import 'package:efox_flutter/lang/app_translations.dart'; // import 'package:efox_flutter/store/STORE.dart'; -// -import 'tabbar/index.dart'; +import 'tabbar/index.dart' as TabIndex; class HomePage extends StatefulWidget { @override @@ -19,12 +18,12 @@ class _HomePageState extends State super.initState(); } - Widget menu() { + Widget menu(MainStateModel model) { return Container( decoration: BoxDecoration( border: Border( top: BorderSide( - color: Colors.deepOrange, + color: Color(model.theme.mainColor), ), ), ), @@ -32,12 +31,12 @@ class _HomePageState extends State indicator: BoxDecoration( border: Border( top: BorderSide( - color: Colors.deepOrange, + color: Color(model.theme.mainColor), ), ), ), - labelColor: Colors.deepOrange, - unselectedLabelColor: Colors.orangeAccent, + labelColor: Color(model.theme.mainColor), + unselectedLabelColor: Color(model.theme.secondColor), indicatorSize: TabBarIndicatorSize.tab, indicatorColor: Colors.transparent, tabs: [ @@ -103,10 +102,10 @@ class _HomePageState extends State ), ], ), - bottomNavigationBar: menu(), + bottomNavigationBar: menu(model), body: TabBarView( children: [ - ComponentsPage(), + TabIndex.ComponentsPage(), Center( child: new GridView.count( // Create a grid with 2 columns. If you change the scrollDirection to diff --git a/lib/page/tabbar/index.dart b/lib/page/tabbar/index.dart index 39cf638..5f3e52c 100644 --- a/lib/page/tabbar/index.dart +++ b/lib/page/tabbar/index.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:efox_flutter/lang/app_translations.dart'; +// import 'package:efox_flutter/lang/app_translations.dart'; import 'package:efox_flutter/router/index.dart'; +import 'package:efox_flutter/store/models/main_state_model.dart'; +import 'package:efox_flutter/store/STORE.dart' show STORE; import 'package:efox_flutter/widget/index.dart' as WidgetRoot; class ComponentsPage extends StatefulWidget { @@ -14,13 +16,13 @@ class _ComponentsPageState extends State @override initState() { super.initState(); - this.mapList = WidgetRoot.getAllWidgets(); + this.mapList = WidgetRoot.getAllWidgets(); } /** * 渲染折叠板 */ - Widget renderExpanel(item) { + Widget renderExpanel(MainStateModel model, item) { List _tmpWidgetList = item.widgetList; return ExpansionTile( title: Text( @@ -29,9 +31,9 @@ class _ComponentsPageState extends State leading: Icon( IconData(item.code ?? 58353, fontFamily: 'MaterialIcons', matchTextDirection: true), - color: Colors.deepOrange, + color: Color(model.theme.secondColor), ), - backgroundColor: Colors.white12, + backgroundColor: Colors.white70, children: [ GridView.count( shrinkWrap: true, @@ -44,11 +46,10 @@ class _ComponentsPageState extends State return Container( decoration: BoxDecoration( border: Border( - bottom: BorderSide( - width: .1, - color: Colors.orange.shade300, - ) - ), + bottom: BorderSide( + width: .1, + color: Color(model.theme.mainColor), + )), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -59,10 +60,11 @@ class _ComponentsPageState extends State IconData(_tmpWidgetList[index].code ?? 59101, fontFamily: 'MaterialIcons', matchTextDirection: true), - color: Colors.deepOrange, + color: Color(model.theme.mainColor), ), onPressed: () { - FluroRouter.router.navigateTo(context, _tmpWidgetList[index].routerName); + FluroRouter.router.navigateTo( + context, _tmpWidgetList[index].routerName); }, ), Text(_tmpWidgetList[index].name), @@ -78,21 +80,20 @@ class _ComponentsPageState extends State } Widget build(BuildContext context) { - AppTranslations lang = AppTranslations.of(context); - print('lang${lang}'); - return Scrollbar( - child: SingleChildScrollView( - child: Container( - padding: EdgeInsets.all(10.0), + return STORE.connect( + builder: (context, child, model) { + return SingleChildScrollView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(10), child: Column( children: mapList.map( (item) { - return renderExpanel(item); + return renderExpanel(model, item); }, ).toList(), ), - ), - ), + ); + }, ); } } diff --git a/lib/store/models/main_state_model.dart b/lib/store/models/main_state_model.dart index 6d870fb..47db994 100644 --- a/lib/store/models/main_state_model.dart +++ b/lib/store/models/main_state_model.dart @@ -1,8 +1,9 @@ import 'package:scoped_model/scoped_model.dart'; import 'user_model.dart'; +import 'theme_model.dart'; ///主数据模型,需要全局使用的数据在这里添加模型 -class MainStateModel extends Model with UserModel { +class MainStateModel extends Model with UserModel, AppThemeModel { MainStateModel() { // 初始化实例数据 } diff --git a/lib/store/models/theme_model.dart b/lib/store/models/theme_model.dart new file mode 100644 index 0000000..8adf172 --- /dev/null +++ b/lib/store/models/theme_model.dart @@ -0,0 +1,11 @@ +import 'package:scoped_model/scoped_model.dart'; + +class AppTheme { + int mainColor = 0xFF1A237E; + int secondColor = 0xFF283593; +} + +mixin AppThemeModel on Model { + AppTheme _appTheme = new AppTheme(); + get theme => _appTheme; +} diff --git a/lib/store/models/user_model.dart b/lib/store/models/user_model.dart index b34b03c..1a5880f 100644 --- a/lib/store/models/user_model.dart +++ b/lib/store/models/user_model.dart @@ -1,7 +1,7 @@ import 'package:scoped_model/scoped_model.dart'; import '../objects/user_info.dart'; -class UserModel extends Model { +mixin UserModel on Model { UserInfo _userInfo = UserInfo(); get userInfo => _userInfo; diff --git a/lib/widget/scrollview/gridview/demo.dart b/lib/widget/scrollview/gridview/demo.dart index 7d1c0a2..f1b5a1d 100644 --- a/lib/widget/scrollview/gridview/demo.dart +++ b/lib/widget/scrollview/gridview/demo.dart @@ -24,7 +24,7 @@ class Example extends StatelessWidget { return Container( decoration: BoxDecoration( border: Border.all( - color: Colors.redAccent, + color: Colors.lightBlue, ), ), child: Center(