From 9ead94be3ae0e5c700620832cb9a6d839d1b1e1b Mon Sep 17 00:00:00 2001 From: KenZR Date: Tue, 19 Mar 2019 13:14:15 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0Android=20Crashlytic?= =?UTF-8?q?s=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 8 ++++++-- android/build.gradle | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 2ab784b..7108555 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -82,7 +82,11 @@ dependencies { androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' //firebase - implementation 'com.google.firebase:firebase-core:16.0.7' + implementation 'com.google.firebase:firebase-core:16.0.8' + //Crashlytics SDK + implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' } //firebase -apply plugin: 'com.google.gms.google-services' \ No newline at end of file +apply plugin: 'com.google.gms.google-services' +//Crashlytics SDK +apply plugin: 'io.fabric' \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 131b586..eb44602 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,12 +2,18 @@ buildscript { repositories { google() jcenter() + //Crashlytics SDK + maven { + url 'https://maven.fabric.io/public' + } } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.2' //firebase classpath 'com.google.gms:google-services:4.2.0' + //Crashlytics SDK + classpath 'io.fabric.tools:gradle:1.26.1' } } @@ -15,6 +21,10 @@ allprojects { repositories { google() jcenter() + //Crashlytics SDK + maven { + url 'https://maven.google.com/' + } } } From 5bb7581566d46931386862cd2d26a72028da7051 Mon Sep 17 00:00:00 2001 From: KenZR Date: Tue, 19 Mar 2019 17:25:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config/theme.dart | 5 +- lib/page/component/tabs.dart | 186 +++++++++++++++++++++++++++++++++++ lib/page/home.dart | 6 +- lib/page/mine/index.dart | 34 ++++--- 4 files changed, 215 insertions(+), 16 deletions(-) create mode 100644 lib/page/component/tabs.dart diff --git a/lib/config/theme.dart b/lib/config/theme.dart index 4746a6c..967ab66 100644 --- a/lib/config/theme.dart +++ b/lib/config/theme.dart @@ -6,6 +6,7 @@ class AppTheme { static int thirdColor = 0xFFFAFAFA; static int greyColor = 0x8A000000; static int blackColor = 0xFF000000; + static int lineColor = 0xFFEEEEEE; static ThemeData themData = ThemeData( textTheme: TextTheme( body1: TextStyle( @@ -13,7 +14,7 @@ class AppTheme { // fontWeight: FontWeight.bold, ), ), - platform: TargetPlatform.iOS, + //platform: TargetPlatform.iOS, iconTheme: IconThemeData( size: 32, color: Color(thirdColor), @@ -25,6 +26,6 @@ class AppTheme { ), accentColor: Colors.grey, // 选中颜色 primaryColor: Color(mainColor), // appbar背景 - scaffoldBackgroundColor: Color(thirdColor), // 整体的scaffold背景颜色 + scaffoldBackgroundColor: Color(secondColor), // 整体的scaffold背景颜色 ); } diff --git a/lib/page/component/tabs.dart b/lib/page/component/tabs.dart new file mode 100644 index 0000000..e59b3b3 --- /dev/null +++ b/lib/page/component/tabs.dart @@ -0,0 +1,186 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/store/models/main_state_model.dart' + show MainStateModel; +import 'package:efox_flutter/config/theme.dart' show AppTheme; +import 'package:efox_flutter/widget/index.dart' as WidgetRoot; +import 'package:efox_flutter/router/index.dart' show FluroRouter; +import 'package:efox_flutter/lang/index.dart' show AppLocalizations; +import 'package:efox_flutter/components/headerComp.dart' as Header; + +class Index extends StatefulWidget { + final MainStateModel model; + Index({Key key, this.model}) : super(key: key); + @override + _IndexState createState() => new _IndexState(); +} + +class _IndexState extends State + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { + List _mapList = WidgetRoot.getAllWidgets(); + int _currentIndex = -1; + TabController _tabController; + + @override + bool get wantKeepAlive => true; + + @override + initState() { + super.initState(); + _tabController = new TabController(vsync: this, length: _mapList.length); + _tabController.addListener(() { + if (_currentIndex != _tabController.index) { + _currentIndex = _tabController.index; + } + }); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + final GlobalKey _scaffoldKey = new GlobalKey(); + + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + /* appBar: AppBar( + title: Header.Index( + AppLocalizations.$t('nav_title_0'), + ), + actions: appBarActions(), + ), */ + appBar: PreferredSize( + preferredSize: Size.fromHeight(kToolbarHeight), + child: Container( + color: Color(AppTheme.mainColor), + child: SafeArea( + child: this._TabBar(), + ), + ), + ), + body: Column( + children: [ + //this._TabBar(), + this._TabView() + ], + )); + } + + Widget _TabBar() { + return TabBar( + controller: _tabController, + isScrollable: true, + tabs: _mapList.map((v) { + return new Tab( + text: v.typeName, + /* icon: Icon( + IconData( + v.code, + fontFamily: 'MaterialIcons', + matchTextDirection: true, + ), + ), */ + ); + }).toList()); + } + + Widget _TabView() { + return Expanded( + child: new TabBarView( + controller: _tabController, + children: List.generate(_mapList.length, (index) { + return this.Grids(_mapList[index], index); + })), + ); + } + + Widget Grids(widgetsItem, index) { + String nameSpaces = widgetsItem.nameSpaces; + List _tmpWidgetList = widgetsItem.widgetList; + + return Container( + child: GridView.count( + childAspectRatio: 1.3, + padding: EdgeInsets.fromLTRB(4, 0, 4, 0), + shrinkWrap: true, + physics: ScrollPhysics(), + crossAxisCount: 3, + children: List.generate( + _tmpWidgetList.length, + (index) { + return Container( + decoration: BoxDecoration( + border: + Border.all(color: Color(AppTheme.lineColor), width: 0.5)), + child: FlatButton( + color: Color(AppTheme.secondColor), + splashColor: Color(AppTheme.mainColor), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Icon( + IconData( + _tmpWidgetList[index].code, + fontFamily: 'MaterialIcons', + matchTextDirection: true, + ), + color: Color(AppTheme.mainColor), + size: 32, + ), + Text( + '${_tmpWidgetList[index].title}', + //overflow: TextOverflow.ellipsis, + style: + TextStyle(fontSize: 14, fontWeight: FontWeight.w300), + ) + ], + ), + onPressed: () { + FluroRouter.router.navigateTo( + context, + nameSpaces + _tmpWidgetList[index].title, + ); + }, + ), + ); + }, + ), + ), + ); + } + + List appBarActions() { + return [ + PopupMenuButton( + icon: Icon( + Icons.more_vert, + ), + onSelected: (local) { + AppLocalizations.changeLanguage(Locale(local)); + print('local=$local'); + }, + itemBuilder: (context) => [ + PopupMenuItem( + child: Row( + children: [ + Text('中文'), + ], + ), + value: 'zh', + ), + PopupMenuItem( + child: Row( + children: [ + Text('english'), + ], + ), + value: 'en', + ), + ], + ), + ]; + } +} diff --git a/lib/page/home.dart b/lib/page/home.dart index ae6a0f6..54f6c09 100644 --- a/lib/page/home.dart +++ b/lib/page/home.dart @@ -3,7 +3,8 @@ import 'package:efox_flutter/lang/index.dart' show AppLocalizations; import 'package:efox_flutter/store/index.dart' show Store; import 'package:efox_flutter/controller/index.dart' as Controller; -import 'component/index.dart' as TabIndex; +//import 'component/index.dart' as TabIndex; +import 'component/tabs.dart' as TabIndex; import 'mine/index.dart' as MyIndex; class Index extends StatefulWidget { @@ -35,7 +36,8 @@ class _IndexState extends State { title: Text(AppLocalizations.$t('title_component')), icon: Icon(Icons.dashboard)), BottomNavigationBarItem( - title: Text(AppLocalizations.$t('title_my')), icon: Icon(Icons.person_outline)), + title: Text(AppLocalizations.$t('title_my')), + icon: Icon(Icons.person_outline)), ], type: BottomNavigationBarType.fixed, currentIndex: _currentIndex, diff --git a/lib/page/mine/index.dart b/lib/page/mine/index.dart index 3b66005..b1266eb 100644 --- a/lib/page/mine/index.dart +++ b/lib/page/mine/index.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/lang/index.dart' show AppLocalizations; import 'package:efox_flutter/router/index.dart' show FluroRouter; +import 'package:efox_flutter/config/theme.dart' show AppTheme; class _IndexState extends State { @override @@ -16,7 +17,9 @@ class _IndexState extends State { 'index': 0 }, { - 'name': widget.model.config.state.isPro ? AppLocalizations.$t('mine.loadLocal') : AppLocalizations.$t('mine.loadNetwork'), + 'name': widget.model.config.state.isPro + ? AppLocalizations.$t('mine.loadLocal') + : AppLocalizations.$t('mine.loadNetwork'), 'icon': 57539, // import_export 'index': 2, }, @@ -86,18 +89,25 @@ class _IndexState extends State { (context, index) { dynamic item = list[index]; if (item['show'] ?? true) { - return ListTile( - onTap: () { - this.actionsEvent(item['index']); - }, - leading: Icon( - IconData( - item['icon'], - fontFamily: 'MaterialIcons', - matchTextDirection: true, + return Column( + children: [ + ListTile( + onTap: () { + this.actionsEvent(item['index']); + }, + leading: Icon( + IconData( + item['icon'], + fontFamily: 'MaterialIcons', + matchTextDirection: true, + ), + ), + title: Text('${item['name']}'), ), - ), - title: Text('${item['name']}'), + Divider( + color: Color(AppTheme.lineColor), + ) + ], ); } else { return Container(); From 60dfffd10eba1b0cd2c72af37146e5a39b786e40 Mon Sep 17 00:00:00 2001 From: wanwusangzhi <609780590@qq.com> Date: Tue, 19 Mar 2019 17:29:06 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0pageview=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/widget/navigator/pageview/index.md | 27 ++++ .../widget/navigator/popupmenubutton/index.md | 35 ++++- .../demo_with_pageview.dart | 67 +++++---- lib/widget/navigator/index.dart | 6 + lib/widget/navigator/pageview/demo.dart | 135 ++++++++++++++++++ lib/widget/navigator/pageview/index.dart | 26 ++++ .../navigator/popupmenubutton/demo.dart | 83 ++++++++++- pubspec.yaml | 1 + 8 files changed, 347 insertions(+), 33 deletions(-) create mode 100644 docs/widget/navigator/pageview/index.md create mode 100644 lib/widget/navigator/pageview/demo.dart create mode 100644 lib/widget/navigator/pageview/index.dart diff --git a/docs/widget/navigator/pageview/index.md b/docs/widget/navigator/pageview/index.md new file mode 100644 index 0000000..bb90c0b --- /dev/null +++ b/docs/widget/navigator/pageview/index.md @@ -0,0 +1,27 @@ +## **PageView** +> 创建一个整屏滚动的滚动列表,逐页滚动 + + +### 构造函数 +``` +PageView({ + Key key, + Axis scrollDirection: Axis.horizontal, + bool reverse: false, + PageController controller, + ScrollPhysics physics, + bool pageSnapping: true, + ValueChanged onPageChanged, + List children: const [], + DragStartBehavior dragStartBehavior: DragStartBehavior.down +}) +``` + +### 属性介绍 +- children:页面列表,每个子元素对应一个当前页。 +- scrollDirection: Axis.horizontal/Axis.vertical, 默认是水平方向,可选择垂直方向滚动 +- reverse: 滚动方向取反操作 +- controller: 操作页面滚动行为类,可以通过PageController实例后的对象进行指定页面跳转,可携带特效跳转等。PageController.jumpToPage(index) +- physics: 滚动属性,可参考滚动类别中的gridview等相近属性介绍 +- pageSnapping: 默认true,切换时,自动逐页跳转。当自定义滚动行为时,可设置为false,禁止页面捕获。 +- onPageChanged: 页面切换时,回调函数,返回页面下标值 diff --git a/docs/widget/navigator/popupmenubutton/index.md b/docs/widget/navigator/popupmenubutton/index.md index 83532f6..7a448e5 100644 --- a/docs/widget/navigator/popupmenubutton/index.md +++ b/docs/widget/navigator/popupmenubutton/index.md @@ -1 +1,34 @@ -## **文档完善中** \ No newline at end of file +## **PopupMenuButton** + +### 构造函数 +``` +PopupMenuButton({ + Key key, + @required PopupMenuItemBuilder itemBuilder, + T initialValue, + PopupMenuItemSelected onSelected, + PopupMenuCanceled onCanceled, + String tooltip, + double elevation: 8.0, + EdgeInsetsGeometry padding: const EdgeInsets.all(8.0), + Widget child, + Icon icon, + Offset offset: Offset.zero +}) +``` + +### 属性介绍 +- itemBuilder: (_) => { return [PopupMenuItem(), PopupMenuItem(),]} + > PopupMenuItem: 菜单子组件 + ``` + PopupMenuItem({ + Key key, + T value, + bool enabled: true, + double height: _kMenuItemHeight, + @required Widget child + }) + ``` +- onSelected: 选中后返回PopupMenuItem中value的值 +- child: 有默认图标,可以修改为其它显示内容。 + diff --git a/lib/widget/navigator/bottomnavigationbar/demo_with_pageview.dart b/lib/widget/navigator/bottomnavigationbar/demo_with_pageview.dart index 108b07e..2281d63 100644 --- a/lib/widget/navigator/bottomnavigationbar/demo_with_pageview.dart +++ b/lib/widget/navigator/bottomnavigationbar/demo_with_pageview.dart @@ -6,12 +6,14 @@ class Index extends StatefulWidget { } class _IndexState extends State { + int _index = 0; + PageController _pageController; @override void initState() { super.initState(); + _pageController = PageController(); } - int _index = 0; @override Widget build(BuildContext context) { return Scaffold( @@ -19,39 +21,41 @@ class _IndexState extends State { title: Text('BottomNavigationBar'), ), body: PageView( - onPageChanged: (index) { - setState(() { - _index = index; - }); - }, - children: [ - Center( - child: Column( - children: [ - Text('页面一'), - Text('左右滑动切换页面哦~~~'), - ], - ), + controller: _pageController, + onPageChanged: (index) { + setState(() { + _index = index; + }); + }, + children: [ + Center( + child: Column( + children: [ + Text('页面一'), + Text('左右滑动切换页面哦~~~'), + ], ), - Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('页面二'), - Text('左右滑动切换页面哦~~~'), - ], - ), + ), + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('页面二'), + Text('左右滑动切换页面哦~~~'), + ], ), - Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text('页面三'), - Text('左右滑动切换页面哦~~~'), - ], - ), + ), + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text('页面三'), + Text('左右滑动切换页面哦~~~'), + ], ), - ]), + ), + ], + ), bottomNavigationBar: BottomNavigationBar( currentIndex: _index, type: BottomNavigationBarType.shifting, @@ -59,6 +63,7 @@ class _IndexState extends State { setState(() { _index = index; }); + _pageController.jumpToPage(index); }, fixedColor: Colors.red, iconSize: 28, diff --git a/lib/widget/navigator/index.dart b/lib/widget/navigator/index.dart index 5746f20..9d38f01 100644 --- a/lib/widget/navigator/index.dart +++ b/lib/widget/navigator/index.dart @@ -6,6 +6,7 @@ import 'drawer/index.dart' as drawer; import 'floatingactionbutton/index.dart' as floatingactionbutton; import 'materialapp/index.dart' as materialapp; import 'navigator/index.dart' as navigator; +import 'pageview/index.dart' as pageview; import 'popupmenubutton/index.dart' as popupmenubutton; import 'tabbar/index.dart' as tabbar; import 'tabbarview/index.dart' as tabbarview; @@ -69,6 +70,11 @@ List widgets = [ code: 59484, // assessment title: navigator.Index.title, ), + ItemInfo( + widget: pageview.Index(), + code: 59488, // assessment + title: pageview.Index.title, + ), ]; List widgetMap = [ diff --git a/lib/widget/navigator/pageview/demo.dart b/lib/widget/navigator/pageview/demo.dart new file mode 100644 index 0000000..e2b7167 --- /dev/null +++ b/lib/widget/navigator/pageview/demo.dart @@ -0,0 +1,135 @@ +import 'package:flutter/material.dart'; + +class Index extends StatefulWidget { + @override + State createState() => _IndexState(); +} + +class _IndexState extends State { + int _index = 0; + bool _scrollDirection = true; + bool _pageSnapping = true; + + PageController _pageController; + @override + void initState() { + super.initState(); + _pageController = PageController(); + } + + String getScrollDirectionText () { + return _scrollDirection ? '左右' : '上下'; + } + + Axis getScrollDirection () { + return _scrollDirection ? Axis.horizontal : Axis.vertical; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('PageView'), + ), + body: PageView( + pageSnapping: _pageSnapping, // 与滚动行为相关 + reverse: false, // 滚动反方向 + scrollDirection: getScrollDirection(), + controller: _pageController, + onPageChanged: (index) { + setState(() { + _index = index; + }); + }, + children: [ + Center( + child: Column( + children: [ + Text('页面一'), + Text('${getScrollDirectionText()}滑动切换页面哦~~~'), + RaisedButton( + child: Text('当前为${getScrollDirectionText()}滑动,可点击切换'), + onPressed: () { + setState(() { + _scrollDirection = !_scrollDirection; + }); + }, + ), + ], + ), + ), + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('页面二'), + Text('${getScrollDirectionText()}滑动切换页面哦~~~'), + RaisedButton( + child: Text('当前为属性值pageSnapping为${_pageSnapping},${_pageSnapping ? '滚动时,默认被捕获' : '由用户自行滚动'},可点击切换'), + onPressed: () { + setState(() { + _pageSnapping = !_pageSnapping; + }); + }, + ), + ], + ), + ), + Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text('页面三'), + Text('${getScrollDirectionText()}滑动切换页面哦~~~'), + ], + ), + ), + ], + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: _index, + type: BottomNavigationBarType.shifting, + onTap: (index) { + setState(() { + _index = index; + }); + _pageController.jumpToPage(index); + }, + fixedColor: Colors.red, + iconSize: 28, + items: [ + BottomNavigationBarItem( + title: Text( + '导航一', + style: TextStyle(color: Colors.red), + ), + icon: Icon( + Icons.navigate_before, + color: Colors.redAccent, + ), + ), + BottomNavigationBarItem( + title: Text( + '导航二', + style: TextStyle(color: Colors.red), + ), + icon: Icon( + Icons.notifications_active, + color: Colors.redAccent, + ), + ), + BottomNavigationBarItem( + title: Text( + '导航三', + style: TextStyle(color: Colors.red), + ), + icon: Icon( + Icons.navigate_next, + color: Colors.redAccent, + ), + ), + ], + ), + ); + } +} diff --git a/lib/widget/navigator/pageview/index.dart b/lib/widget/navigator/pageview/index.dart new file mode 100644 index 0000000..28a357f --- /dev/null +++ b/lib/widget/navigator/pageview/index.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp; +import 'demo.dart' as Demo; + +class Index extends StatefulWidget { + static String title = 'PageView'; + static String mdUrl = 'docs/widget/navigator/pageview/index.md'; + static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/PageView-class.html'; + + @override + _IndexState createState() => new _IndexState(); +} + +class _IndexState extends State { + @override + Widget build(BuildContext context) { + return WidgetComp.Index( + title: Index.title, + originCodeUrl: Index.originCodeUrl, + mdUrl: Index.mdUrl, + demoChild: [ + Demo.Index(), + ], + ); + } +} diff --git a/lib/widget/navigator/popupmenubutton/demo.dart b/lib/widget/navigator/popupmenubutton/demo.dart index acbff37..a35de0e 100644 --- a/lib/widget/navigator/popupmenubutton/demo.dart +++ b/lib/widget/navigator/popupmenubutton/demo.dart @@ -6,9 +6,36 @@ class Index extends StatefulWidget { } class _IndexState extends State { + final GlobalKey _menuKey = GlobalKey(); + PopupMenuButton popButton; + dynamic _value; + @override void initState() { super.initState(); + popButton = PopupMenuButton( + onSelected: (val) { + setState(() { + _value = val; + }); + }, + child: Icon(Icons.settings), + key: _menuKey, + itemBuilder: (context) => [ + PopupMenuItem( + value: '设置1', + child: Row( + children: [ + Icon( + Icons.settings, + color: Colors.red, + ), + Text("设置1"), + ], + ), + ), + ], + ); } @override @@ -16,9 +43,63 @@ class _IndexState extends State { return Scaffold( appBar: AppBar( title: Text('PopupMenuButton'), + actions: [ + PopupMenuButton( + onSelected: (val) { + print('点击后接收到的key $val'); + setState(() { + _value = val; + }); + }, + itemBuilder: (context) { + return [ + PopupMenuItem( + value: '设置2', + child: Row( + children: [ + Text("设置2"), + Icon( + Icons.settings, + color: Colors.red, + ), + ], + ), + ), + PopupMenuItem( + value: '设置3', + child: Text('设置3'), + ) + ]; + }, + ), + ], ), body: Center( - child: Text('更新中'), + child: Column( + children: [ + ListTile( + trailing: popButton, + // onTap: () { + // dynamic _state = _menuKey.currentState; + // print('showButtonMenu $_state'); + // // _state.showButtonMenu(); + // }, + ), + Text( + '当ListTile绑定了trailing属性,就可以通过currentState.showButtonMenu()触发', + textAlign: TextAlign.center, + ), + RaisedButton( + child: Text("点击显示PopupMenu"), + onPressed: () { + dynamic _state = _menuKey.currentState; + print('showButtonMenu $_state'); + _state.showButtonMenu(); + }, + ), + Text('${_value !=null ? '你点击了 ' + _value : '当前未选择内容'}'), + ], + ), ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index f827675..9ad003f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -108,6 +108,7 @@ flutter: - docs/widget/navigator/floatingactionbutton/ - docs/widget/navigator/materialapp/ - docs/widget/navigator/navigator/ + - docs/widget/navigator/pageview/ - docs/widget/navigator/popupmenubutton/ - docs/widget/navigator/tabbar/ - docs/widget/navigator/tabbarview/ From daa0f06ec7a9e7bd5543bd12a5b3c25f51682dc9 Mon Sep 17 00:00:00 2001 From: KenZR Date: Tue, 19 Mar 2019 18:02:20 +0800 Subject: [PATCH 4/7] =?UTF-8?q?refact:=E5=8D=87=E7=BA=A7=E5=AE=89=E5=8D=93?= =?UTF-8?q?=20compileSdkVersion=20=E5=88=B0=2028=20=E6=94=AF=E6=8C=81andro?= =?UTF-8?q?id=20x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 10 +++++----- android/gradle.properties | 2 ++ lib/page/component/tabs.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7108555..4448699 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 27 + compileSdkVersion 28 lintOptions { disable 'InvalidPackage' @@ -42,10 +42,10 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.flutter.beer" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { @@ -79,8 +79,8 @@ flutter { dependencies { testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' //firebase implementation 'com.google.firebase:firebase-core:16.0.8' //Crashlytics SDK diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..4d3226a 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/lib/page/component/tabs.dart b/lib/page/component/tabs.dart index e59b3b3..f3cb78f 100644 --- a/lib/page/component/tabs.dart +++ b/lib/page/component/tabs.dart @@ -70,6 +70,7 @@ class _IndexState extends State Widget _TabBar() { return TabBar( + indicatorColor: Color(AppTheme.secondColor), controller: _tabController, isScrollable: true, tabs: _mapList.map((v) { diff --git a/pubspec.yaml b/pubspec.yaml index f827675..1f953d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ description: A new Flutter project. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # Read more about versioning at semver.org. -version: 1.0.0+1 +version: 1.0.1+1 environment: sdk: ">=2.1.0 <3.0.0" From 5ffde01857836d6b38648f33c129da02d5b84d89 Mon Sep 17 00:00:00 2001 From: KenZR Date: Tue, 19 Mar 2019 19:24:00 +0800 Subject: [PATCH 5/7] =?UTF-8?q?refact:=E5=A2=9E=E5=8A=A0=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/component/tabs.dart | 4 ++-- lib/widget/navigator/index.dart | 6 +++--- locale/en.json | 13 +++++++++++-- locale/zh.json | 13 +++++++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/page/component/tabs.dart b/lib/page/component/tabs.dart index f3cb78f..8036bb1 100644 --- a/lib/page/component/tabs.dart +++ b/lib/page/component/tabs.dart @@ -5,7 +5,7 @@ import 'package:efox_flutter/config/theme.dart' show AppTheme; import 'package:efox_flutter/widget/index.dart' as WidgetRoot; import 'package:efox_flutter/router/index.dart' show FluroRouter; import 'package:efox_flutter/lang/index.dart' show AppLocalizations; -import 'package:efox_flutter/components/headerComp.dart' as Header; +//import 'package:efox_flutter/components/headerComp.dart' as Header; class Index extends StatefulWidget { final MainStateModel model; @@ -75,7 +75,7 @@ class _IndexState extends State isScrollable: true, tabs: _mapList.map((v) { return new Tab( - text: v.typeName, + text: AppLocalizations.$t(v.typeName), /* icon: Icon( IconData( v.code, diff --git a/lib/widget/navigator/index.dart b/lib/widget/navigator/index.dart index 9d38f01..e8e706b 100644 --- a/lib/widget/navigator/index.dart +++ b/lib/widget/navigator/index.dart @@ -37,7 +37,7 @@ List widgets = [ ), ItemInfo( widget: drawer.Index(), - code: 58928, // airline_seat_flat + code: 58928, // airline_seat_flat title: drawer.Index.title, ), ItemInfo( @@ -62,7 +62,7 @@ List widgets = [ ), ItemInfo( widget: popupmenubutton.Index(), - code: 57440, // art_track + code: 57440, // art_track title: popupmenubutton.Index.title, ), ItemInfo( @@ -81,7 +81,7 @@ List widgetMap = [ ItemListInfo( nameSpaces: nameSpaces, widgetList: widgets, - typeName: 'navigator', + typeName: 'Navigator', code: 58717, ) ]; diff --git a/locale/en.json b/locale/en.json index b09f79a..ab16a26 100644 --- a/locale/en.json +++ b/locale/en.json @@ -6,7 +6,7 @@ "widgetType": { "regularLayout": "common layout" }, - "common" : { + "common": { "changeLanguage": "显示中文", "changeVersion": "checkVersion", "compProgress": "Components Progress" @@ -15,5 +15,14 @@ "loadNetwork": "Load Network Document Resources", "loadLocal": "Load Local Document Resources" }, - "loading": "Loading" + "loading": "Loading", + "ScrollComponents": "ScrollComponents", + "Common": "Common", + "Form": "Form", + "Regular": "Regular", + "Navigator": "Navigator", + "BulletBox": "BulletBox", + "Animate": "Animate", + "Gestures": "Gestures", + "Vision": "Vision" } \ No newline at end of file diff --git a/locale/zh.json b/locale/zh.json index c644e29..9e98179 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -6,7 +6,7 @@ "widgetType": { "regularLayout": "常规布局" }, - "common" : { + "common": { "changeLanguage": "Switch to English", "changeVersion": "更新版本", "compProgress": "组件进度" @@ -15,5 +15,14 @@ "loadNetwork": "加载网络文档资源", "loadLocal": "加载本地文档资源" }, - "loading": "加载中" + "loading": "加载中", + "ScrollComponents": "滚动", + "Common": "通用", + "Form": "表单", + "Regular": "布局", + "Navigator": "导航", + "BulletBox": "窗口", + "Animate": "动画", + "Gestures": "手势", + "Vision": "视觉" } \ No newline at end of file From 0e53181d7e6c5afa91fb60a9cb2012ba01a7e7d2 Mon Sep 17 00:00:00 2001 From: wanwusangzhi <609780590@qq.com> Date: Tue, 19 Mar 2019 19:51:38 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96tab=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/component/tabs.dart | 1 - lib/page/home.dart | 3 +- lib/page/mine/index_1.dart | 206 +++++++++++++++++++++++ lib/store/models/config_state_model.dart | 2 +- locale/en.json | 8 + locale/zh.json | 12 +- 6 files changed, 227 insertions(+), 5 deletions(-) create mode 100644 lib/page/mine/index_1.dart diff --git a/lib/page/component/tabs.dart b/lib/page/component/tabs.dart index e59b3b3..0a7e29c 100644 --- a/lib/page/component/tabs.dart +++ b/lib/page/component/tabs.dart @@ -5,7 +5,6 @@ import 'package:efox_flutter/config/theme.dart' show AppTheme; import 'package:efox_flutter/widget/index.dart' as WidgetRoot; import 'package:efox_flutter/router/index.dart' show FluroRouter; import 'package:efox_flutter/lang/index.dart' show AppLocalizations; -import 'package:efox_flutter/components/headerComp.dart' as Header; class Index extends StatefulWidget { final MainStateModel model; diff --git a/lib/page/home.dart b/lib/page/home.dart index 54f6c09..56ee524 100644 --- a/lib/page/home.dart +++ b/lib/page/home.dart @@ -4,8 +4,9 @@ import 'package:efox_flutter/store/index.dart' show Store; import 'package:efox_flutter/controller/index.dart' as Controller; //import 'component/index.dart' as TabIndex; +// import 'mine/index.dart' as MyIndex; import 'component/tabs.dart' as TabIndex; -import 'mine/index.dart' as MyIndex; +import 'mine/index_1.dart' as MyIndex; class Index extends StatefulWidget { @override diff --git a/lib/page/mine/index_1.dart b/lib/page/mine/index_1.dart new file mode 100644 index 0000000..80928d7 --- /dev/null +++ b/lib/page/mine/index_1.dart @@ -0,0 +1,206 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/lang/index.dart' show AppLocalizations; +import 'package:efox_flutter/router/index.dart' show FluroRouter; +import 'package:efox_flutter/config/theme.dart' show AppTheme; + +class _IndexState extends State { + @override + void initState() { + super.initState(); + } + + List _getList() { + return [ + { + 'name': AppLocalizations.$t('common_mine_1.language'), + 'icon': 59540, // language + 'index': 0 + }, + { + 'name': AppLocalizations.$t('common_mine_1.environment'), + 'icon': 57539, // import_export + 'index': 1, + }, + { + 'name': AppLocalizations.$t('common_mine_1.compProgress'), + 'icon': 57709, // low_priority + 'index': 2 + } + ]; + } + + actionsEvent(int index) { + print('index $index'); + switch (index) { + case 0: + this.openLanguageSelectMenu(); + break; + case 1: + this.openEnvSelectMenu(); + break; + case 2: + FluroRouter.router.navigateTo( + context, + '/webview?url=${Uri.encodeComponent(widget.model.config.state.env.githubWeb)}&title=${Uri.encodeComponent(AppLocalizations.$t('common.compProgress'))}', + ); + break; + } + } + + void pop([message]) { + Navigator.pop(context); + if (message != null) { + Scaffold.of(context).showSnackBar(new SnackBar( + content: new Text(message), + )); + } + } + + /** + * 国际化 + */ + void openLanguageSelectMenu() async { + await showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: Wrap( + children: [ + ListTile( + leading: Icon(Icons.label_outline), + title: Text( + AppLocalizations.$t('common_mine_1.cn'), + ), + onTap: () { + AppLocalizations.changeLanguage(Locale('zh')); + this.pop(AppLocalizations.$t('common_mine_1.success')); + }, + ), + ListTile( + leading: Icon(Icons.label_outline), + title: Text(AppLocalizations.$t('common_mine_1.en')), + onTap: () { + AppLocalizations.changeLanguage(Locale('en')); + this.pop(AppLocalizations.$t('common_mine_1.success')); + }, + ), + ], + ), + ); + }, + ); + } + + /** + * 环境选择 + */ + void openEnvSelectMenu() async { + await showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: Wrap( + children: [ + ListTile( + leading: Icon(Icons.label_outline), + title: Text( + AppLocalizations.$t('mine.loadNetwork'), + ), + onTap: () { + widget.model.dispatch('config', 'setEnv', true); + this.pop(AppLocalizations.$t('common_mine_1.success')); + }, + ), + ListTile( + leading: Icon(Icons.label_outline), + title: Text(AppLocalizations.$t('mine.loadLocal')), + onTap: () { + widget.model.dispatch('config', 'setEnv', false); + this.pop(AppLocalizations.$t('common_mine_1.success')); + }, + ), + ], + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(10), + bottomRight: Radius.circular(10) + ), + color: Colors.red, + ), + height: 240, + child: Stack( + alignment: const FractionalOffset(0.8, 0.8), + children: [ + Row( + children: [ + Image.network( + 'https://raw.githubusercontent.com/efoxTeam/flutter-ui/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png', + width: 80.0, + height: 80.0, + fit: BoxFit.cover, + ), + SizedBox( + width: 10, + ), + Text( + 'Hello Guest', + style: TextStyle(color: Colors.white), + ) + ], + ) + ], + ), + ), + ListView.builder( + shrinkWrap: true, + itemCount: _getList().length * 2, + itemBuilder: (context, index) { + double _index = index / 2; + if (index % 2 == 0) { + dynamic item = _getList()[_index.toInt()]; + return ListTile( + onTap: () { + actionsEvent(item['index']); + }, + leading: Icon( + IconData( + item['icon'], + fontFamily: 'MaterialIcons', + matchTextDirection: true, + ), + ), + title: Text(item['name']), + ); + } else { + return Divider( + color: Color(AppTheme.lineColor), + ); + } + }, + ), + ], + ), + ); + } +} + +class Index extends StatefulWidget { + final dynamic model; + + Index({Key key, this.model}) : super(key: key); + + @override + _IndexState createState() => _IndexState(); +} diff --git a/lib/store/models/config_state_model.dart b/lib/store/models/config_state_model.dart index 8ae30c9..1e5adee 100644 --- a/lib/store/models/config_state_model.dart +++ b/lib/store/models/config_state_model.dart @@ -32,7 +32,7 @@ class ConfigModel { switch (name) { case 'setEnv': - _appConfigInfo.isPro = !_appConfigInfo.isPro; + _appConfigInfo.isPro = payload; break; case 'setVersion': _appConfigInfo.version = await this.getVersion(); diff --git a/locale/en.json b/locale/en.json index b09f79a..55a53e6 100644 --- a/locale/en.json +++ b/locale/en.json @@ -11,6 +11,14 @@ "changeVersion": "checkVersion", "compProgress": "Components Progress" }, + "common_mine_1" : { + "cn": "CN", + "en": "EN", + "language": "Select Language", + "environment": "Select Environment", + "compProgress": "Components Progress", + "success": "Success To Change " + }, "mine": { "loadNetwork": "Load Network Document Resources", "loadLocal": "Load Local Document Resources" diff --git a/locale/zh.json b/locale/zh.json index c644e29..efb3770 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -11,9 +11,17 @@ "changeVersion": "更新版本", "compProgress": "组件进度" }, + "common_mine_1" : { + "cn": "CN", + "en": "EN", + "language": "选择语言", + "environment": "选择环境", + "compProgress": "组件进度", + "success": "切换成功" + }, "mine": { - "loadNetwork": "加载网络文档资源", - "loadLocal": "加载本地文档资源" + "loadNetwork": "网络优良,可选择加载线上文档资源", + "loadLocal": "网络较差时,可选择加载本地文档资源" }, "loading": "加载中" } \ No newline at end of file From 95433de46abcae1e675256ac1fd615b43f7f7082 Mon Sep 17 00:00:00 2001 From: KenZR Date: Tue, 19 Mar 2019 20:01:09 +0800 Subject: [PATCH 7/7] =?UTF-8?q?style:=E4=BC=98=E5=8C=96my?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/widgetComp.dart | 8 +++---- lib/page/mine/index_1.dart | 38 ++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/lib/components/widgetComp.dart b/lib/components/widgetComp.dart index 4283169..45df4f3 100644 --- a/lib/components/widgetComp.dart +++ b/lib/components/widgetComp.dart @@ -64,9 +64,7 @@ class IndexState extends State { this._bodyList.length = 0; String mdText = await this.getMdFile(this.mdUrl); if (mdText.length > 30 || !this.model.config.state.isPro) { - this - ._bodyList - .add(await MarkDownComp.Index(mdText)); + this._bodyList.add(await MarkDownComp.Index(mdText)); // demo if (this.demoChild != null && this.demoChild.length > 0) { this.demoChild.forEach((Widget item) { @@ -87,9 +85,9 @@ class IndexState extends State { this.model = model; return Scaffold( appBar: AppBar( - title: Header.Index( + /* title: Header.Index( this.title, - ), + ), */ actions: this.getActions( context, ), diff --git a/lib/page/mine/index_1.dart b/lib/page/mine/index_1.dart index 80928d7..c6c4e77 100644 --- a/lib/page/mine/index_1.dart +++ b/lib/page/mine/index_1.dart @@ -128,7 +128,41 @@ class _IndexState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( + return Scaffold( + appBar: AppBar( + title: Text(AppLocalizations.$t('nav_title_1')), + elevation: 0, + centerTitle: true, + ), + body: ListView.builder( + shrinkWrap: true, + itemCount: _getList().length * 2, + itemBuilder: (context, index) { + double _index = index / 2; + if (index % 2 == 0) { + dynamic item = _getList()[_index.toInt()]; + return ListTile( + onTap: () { + actionsEvent(item['index']); + }, + leading: Icon( + IconData( + item['icon'], + fontFamily: 'MaterialIcons', + matchTextDirection: true, + ), + ), + title: Text(item['name']), + ); + } else { + return Divider( + color: Color(AppTheme.lineColor), + ); + } + }, + ), + ); + /* return SingleChildScrollView( child: Column( children: [ Container( @@ -192,7 +226,7 @@ class _IndexState extends State { ), ], ), - ); + ); */ } }