From 2f34e4595a10b67c4d6c9755f15c8987cf989cda Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Sun, 27 Sep 2020 17:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=B7=E6=8A=A5=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 26 ++- example/ios/Podfile | 1 + example/ios/Podfile.lock | 25 ++- .../invited_friends/invited_friends.dart | 152 ++++++++++++++++-- lib/pages/launch_page/launch_page.dart | 30 +++- lib/pages/main_page/main_page.dart | 52 +++--- lib/register.dart | 18 ++- pubspec.yaml | 1 + 8 files changed, 250 insertions(+), 55 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index a0e029c..cf9c2fa 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -55,6 +55,30 @@ "packageUri": "lib/", "languageVersion": "2.0" }, + { + "name": "connectivity", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity-0.4.9+3", + "packageUri": "lib/", + "languageVersion": "2.1" + }, + { + "name": "connectivity_for_web", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity_for_web-0.3.1+2", + "packageUri": "lib/", + "languageVersion": "2.6" + }, + { + "name": "connectivity_macos", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity_macos-0.1.0+5", + "packageUri": "lib/", + "languageVersion": "2.1" + }, + { + "name": "connectivity_platform_interface", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity_platform_interface-1.0.6", + "packageUri": "lib/", + "languageVersion": "2.1" + }, { "name": "convert", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/convert-2.1.1", @@ -554,7 +578,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-25T12:38:03.249342Z", + "generated": "2020-09-27T08:39:36.051865Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/example/ios/Podfile b/example/ios/Podfile index 69ed5c5..7d0f561 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,6 +1,7 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' source 'http://repo.baichuan-ios.taobao.com/baichuanSDK/AliBCSpecs.git' +source 'https://github.com/CocoaPods/Specs.git' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index b0fe556..8250e30 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,6 +4,13 @@ PODS: - AliLinkPartnerSDK (4.0.0.24) - BCUserTrack (5.2.0.18-appkeys): - UTDID + - connectivity (0.0.1): + - Flutter + - Reachability + - connectivity_for_web (0.1.0): + - Flutter + - connectivity_macos (0.0.1): + - Flutter - device_info (0.0.1): - Flutter - Flutter (1.0.0) @@ -44,6 +51,7 @@ PODS: - Flutter - path_provider_windows (0.0.1): - Flutter + - Reachability (3.2) - securityGuard (5.4.191) - shared_preferences (0.0.1): - Flutter @@ -85,6 +93,9 @@ PODS: - Flutter DEPENDENCIES: + - connectivity (from `.symlinks/plugins/connectivity/ios`) + - connectivity_for_web (from `.symlinks/plugins/connectivity_for_web/ios`) + - connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`) - device_info (from `.symlinks/plugins/device_info/ios`) - Flutter (from `Flutter`) - flutter_alibc (from `.symlinks/plugins/flutter_alibc/ios`) @@ -124,11 +135,19 @@ SPEC REPOS: - securityGuard - UTDID - WindVane + https://github.com/CocoaPods/Specs.git: + - Reachability trunk: - FMDB - TOCropViewController EXTERNAL SOURCES: + connectivity: + :path: ".symlinks/plugins/connectivity/ios" + connectivity_for_web: + :path: ".symlinks/plugins/connectivity_for_web/ios" + connectivity_macos: + :path: ".symlinks/plugins/connectivity_macos/ios" device_info: :path: ".symlinks/plugins/device_info/ios" Flutter: @@ -191,6 +210,9 @@ SPEC CHECKSUMS: AlibcTradeSDK: 9a3e7af6cd648dd1f85684e82694c213fe48dad2 AliLinkPartnerSDK: c5778cdfdcee7bfe342238d39a77766184d36a46 BCUserTrack: 49251c6fb7c65cbbc221a492bbd3f3e142f1fb0f + connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 + connectivity_for_web: 2b8584556930d4bd490d82b836bcf45067ce345b + connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec flutter_alibc: 0e2a29e7c1de759672d87a260051240d209964b9 @@ -207,6 +229,7 @@ SPEC CHECKSUMS: path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0 path_provider_windows: a2b81600c677ac1959367280991971cb9a1edb3b + Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 securityGuard: 9c04c44a3b663f36e15064042abfc107fa07133c shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 @@ -226,6 +249,6 @@ SPEC CHECKSUMS: zhiying_base_widget: 00868c0d2723a3a425c18b27204fbc67e3f7e59d zhiying_comm: 0daef4a480f4f4dbea3e11b615f3264aafea924b -PODFILE CHECKSUM: 9d32dfabb033b26968c1f3c861e00bd0fcc5665d +PODFILE CHECKSUM: 1a8daf665c989cd04294c52f08548c3a236358d1 COCOAPODS: 1.9.3 diff --git a/lib/pages/invited_friends/invited_friends.dart b/lib/pages/invited_friends/invited_friends.dart index 88511c7..1853c69 100644 --- a/lib/pages/invited_friends/invited_friends.dart +++ b/lib/pages/invited_friends/invited_friends.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; // 邀请好友 @@ -17,6 +18,16 @@ class _InvitedFriendsPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: _createNav(), + backgroundColor: Colors.redAccent, + body: Column( + children: [ + Expanded( + child: _createSwiper(), + ), + _createTeacher(), + _createBottom(), + ], + ), ); } @@ -29,22 +40,22 @@ class _InvitedFriendsPageState extends State { style: BorderStyle.none, ), ), - backgroundColor: HexColor.fromHex('#ffffff'), + backgroundColor: Colors.white, leading: Navigator.canPop(context) ? GestureDetector( - child: Container( - padding: EdgeInsets.zero, - child: Icon( - Icons.arrow_back_ios, - size: 20, - ), - ), - onTap: () { - if (Navigator.canPop(context)) { - Navigator.pop(context); - } - }, - ) + child: Container( + padding: EdgeInsets.zero, + child: Icon( + Icons.arrow_back_ios, + size: 20, + ), + ), + onTap: () { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + }, + ) : Container(), middle: Text( '邀请好友', @@ -62,4 +73,117 @@ class _InvitedFriendsPageState extends State { ), ); } + + Widget _createSwiper() { + return Container( + width: double.infinity, + child: Swiper( + itemBuilder: (BuildContext context, int index) { + return new Image.network( + "http://via.placeholder.com/288x188", + fit: BoxFit.fill, + ); + }, + itemCount: 10, + viewportFraction: 0.8, + scale: 0.9, + ), + ); + } + + Widget _createTeacher() { + return Container( + width: double.infinity, + margin: EdgeInsets.only(top: 20, left: 30, right: 30), + padding: EdgeInsets.only(left: 13, right: 3), + height: 36, + decoration: BoxDecoration( + color: Color(0x80ffffff), + borderRadius: BorderRadius.circular(18), + ), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 10), + width: 18, + height: 18, + color: Colors.redAccent, + ), + Expanded( + child: Text( + '联系导师教你更多赚钱秘籍', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 13, + color: Color(0xff333333), + ), + ), + ), + Container( + width: 88, + height: 30, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(15)), + child: Center( + child: Text( + '联系导师', + style: TextStyle( + fontSize: 13, + color: Color(0xff333333), + ), + ), + ), + ), + ], + ), + ); + } + + Widget _createBottom() { + return SafeArea( + top: false, + child: Container( + margin: EdgeInsets.all(12.5), + padding: EdgeInsets.all(10), + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(18), + boxShadow: [ + BoxShadow( + offset: Offset(0, 5), //x,y轴 + color: Colors.black12.withOpacity(0.1), //投影颜色 + blurRadius: 10 //,投影距离 + ) + ], + ), + child: Column( + children: [ + Row( + children: List.generate(3, (index) { + return Expanded( + child: Container( + margin: EdgeInsets.only(left: 8, right: 8), + height: 28, + decoration: BoxDecoration( + color: Colors.redAccent, + borderRadius: BorderRadius.circular(14), + ), + ), + ); + }), + ), + Padding( + padding: EdgeInsets.only(top: 10), + child: Text( + '您的好友下载APP并使用的您的邀请码成功登录之后,Ta将成为您的粉丝,粉丝下单,您也可以获得收益哦!', + style: TextStyle(fontSize: 13, color: Color(0xff999999)), + ), + ), + ], + ), + ), + ); + } } diff --git a/lib/pages/launch_page/launch_page.dart b/lib/pages/launch_page/launch_page.dart index 62a7640..c8aa453 100644 --- a/lib/pages/launch_page/launch_page.dart +++ b/lib/pages/launch_page/launch_page.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; import 'package:zhiying_comm/util/application.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:connectivity/connectivity.dart'; // 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题 class LaunchPage extends StatefulWidget { @@ -15,18 +17,34 @@ class LaunchPage extends StatefulWidget { class _LaunchPageState extends State { @override void initState() { - Application.init().then((_) { - if (widget.builder != null) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: widget.builder)); + Connectivity().checkConnectivity().then((connectivityResult) { + if (connectivityResult == ConnectivityResult.mobile || + connectivityResult == ConnectivityResult.wifi) { + // I am connected to a wifi network. + Logger.debug('ConnectivityResult.wifi'); + print('ConnectivityResult.wifi'); + Application.init().then((_) { + if (widget.builder != null) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: widget.builder)); + } else { + Navigator.of(context).pushReplacement( + MaterialPageRoute(builder: (context) => HomePage())); + } + }).catchError((err) { + Logger.error(err); + }); } else { - Navigator.of(context).pushReplacement( - MaterialPageRoute(builder: (context) => HomePage())); + Logger.debug('unknow'); + print('unknow'); } }); + + super.initState(); } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 40457a5..3057731 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -93,25 +93,27 @@ class _MainPageContainerState extends State<_MainPageContainer> { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Color(0xfff9f9f9), - floatingActionButton: _floatWidget, - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - body: MediaQuery.removePadding( - removeTop: true, - context: context, - child: SmartRefresher( - enablePullDown: true, - enablePullUp: false, - header: WaterDropHeader(), - controller: _refreshController, - onLoading: _onLoading, - child: Container( - width: double.infinity, - child: StreamBuilder>>( - stream: _bloc.outData, - builder: (BuildContext context, AsyncSnapshot snapshot) { - return Stack( + return StreamBuilder>>( + stream: _bloc.outData, + builder: (BuildContext context, AsyncSnapshot snapshot) { + List widgets = _createContent(context, snapshot.data ?? []); + return Scaffold( + backgroundColor: Color(0xfff9f9f9), + floatingActionButton: _floatWidget, + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, + body: MediaQuery.removePadding( + removeTop: true, + context: context, + child: SmartRefresher( + enablePullDown: true, + enablePullUp: false, + header: WaterDropHeader(), + controller: _refreshController, + onLoading: _onLoading, + child: Container( + width: double.infinity, + child: Stack( fit: StackFit.passthrough, children: [ MineHeaderBgWidget( @@ -119,15 +121,15 @@ class _MainPageContainerState extends State<_MainPageContainer> { ), CustomScrollView( controller: _controller, - slivers: _createContent(context, snapshot.data ?? []), + slivers: widgets, ) ], - ); - }, + ), + ), ), - )), - ), - ); + ), + ); + }); } List _createContent( diff --git a/lib/register.dart b/lib/register.dart index b19852e..f7711af 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,4 +1,5 @@ import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart'; +import 'package:zhiying_base_widget/pages/invited_friends/invited_friends.dart'; import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart'; import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; import 'package:zhiying_base_widget/pages/mine_detail_page/mine_detail_page.dart'; @@ -11,7 +12,6 @@ import 'package:zhiying_base_widget/pages/setting_page/setting_page.dart'; import 'package:zhiying_base_widget/pages/sreach_result_page/sreach_result_page.dart'; import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart'; import 'package:zhiying_base_widget/pages/webview/base_webview.dart'; -import 'package:zhiying_base_widget/pages/invited_friends/invited_friends.dart'; import 'package:zhiying_base_widget/widgets/goods_details/footer/goods_details_footer_widget.dart'; import 'package:zhiying_base_widget/widgets/goods_details/price/goods_details_price_widget.dart'; import 'package:zhiying_base_widget/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart'; @@ -55,8 +55,10 @@ class BaseWidgetRegister { } static void registInit() { - Application.addMethod(() { - return BaseSettingModel.init(); + Application.addMethod(() async { + if (await BaseSettingModel.init() == null) { + throw Future.error('BaseSettingModel 初始化失败'); + } }); } @@ -85,16 +87,16 @@ class BaseWidgetRegister { PageFactory.regist( 'pub.flutter.account_security', (model) => SecurityPage(model)); PageFactory.regist('pub.flutter.account_security_alipay', - (model) => SecurityBindAlipayPage(model)); + (model) => SecurityBindAlipayPage(model)); // 登录密码 PageFactory.regist('pub.flutter.account_security_password', - (model) => SecurityPassword(model)); + (model) => SecurityPassword(model)); // 修改手机号 PageFactory.regist('pub.flutter.account_security_mobile', - (model) => SecurityMobile(model)); + (model) => SecurityMobile(model)); // 邀请好友 - PageFactory.regist('pub.flutter.invite_friends', - (model) => InvitedFriendsPage(model)); + PageFactory.regist( + 'pub.flutter.invite_friends', (model) => InvitedFriendsPage(model)); } // 注册控件 diff --git a/pubspec.yaml b/pubspec.yaml index c3d8a68..0ac7293 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,6 +18,7 @@ dependencies: flutter_cupertino_date_picker: ^1.0.26+2 image_picker: ^0.6.7+3 tab_indicator_styler: 1.0.0 + connectivity: ^0.4.9+3 image_cropper: git: url: 'http://192.168.0.138:3000/FnuoOS_Flutter_Components/Image_Cropper.git'