diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 79ef042..3eb1970 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -53,8 +53,8 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { //选择要添加的对应cpu类型的.so库。 - abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' - //abiFilters 'armeabi-v7a','x86_64' + abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' + //abiFilters 'armeabi-v7a','x86_64' } } @@ -108,14 +108,14 @@ android { } -// // 应用信息配置 + // 应用信息配置 // productFlavors { // // 智夜生活 // zhiying { // applicationId "cn.zhios.zhiying" -// versionCode 48 +// versionCode 55 // dimension "app" -// versionName '1.3.6' +// versionName '1.3.15' // // 签名信息 // signingConfig signingConfigs.zhiying // } @@ -156,6 +156,7 @@ flutter { source '../..' } + dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.2' @@ -184,6 +185,9 @@ dependencies { implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.16@aar' implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.16@aar' implementation 'com.alibaba:fastjson:1.2.41@jar' + + implementation fileTree(include: ['*.jar'], dir: 'libs') + } diff --git a/example/android/app/libs/AMap_Location_V5.2.0_20200915.jar b/example/android/app/libs/AMap_Location_V5.2.0_20200915.jar new file mode 100644 index 0000000..28c3dae Binary files /dev/null and b/example/android/app/libs/AMap_Location_V5.2.0_20200915.jar differ diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index fc4845f..14397e2 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -26,6 +26,17 @@ + + + + + + + + + + + @@ -36,7 +47,8 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:usesCleartextTraffic="true" - tools:replace="android:name, android:allowBackup"> + android:authorities="${applicationId}.fileprovider" + tools:replace="android:name, android:allowBackup,android:authorities"> - + diff --git a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java index 82e5a81..9e27b1b 100644 --- a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java +++ b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java @@ -85,39 +85,26 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN view.addView(launchImageFrame, params); } - Timer timer=new Timer(); + Timer timer = new Timer(); ///移除启动页 void removeLaunchView() { //此处延时是为了不显示启动页往上顶 - if(timer!=null){ - timer.schedule(new TimerTask() { - @Override - public void run() { - MainActivity.this.runOnUiThread(new Runnable() { - @Override - public void run() { - if (view != null && launchImageFrame != null) { - getWindow().getDecorView().setBackground(new ColorDrawable(Color.parseColor("#000000"))); + + if (view != null && launchImageFrame != null) { + getWindow().getDecorView().setBackground(new ColorDrawable(Color.parseColor("#000000"))); // Animation alphaAnimation = new AlphaAnimation(1, 1); // alphaAnimation.setDuration(100); // alphaAnimation.setFillAfter(true); // launchImageFrame.startAnimation(alphaAnimation); - Log.d("----------------", "----------------------清除启动页---------------"); - view.removeView(launchImageFrame); - launchImageFrame = null; - view = null; - } - } - }); - timer=null; - } - },100); - + Log.d("----------------", "----------------------清除启动页---------------"); + view.removeView(launchImageFrame); + launchImageFrame = null; + view = null; } - } + @Override protected void onNewIntent(@NonNull Intent intent) { super.onNewIntent(intent); @@ -167,10 +154,21 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN @Override public Map getSetting() { Map map = new HashMap(); - map.put("domain", "http://inapi.izhyin.cn/"); //"http://120.76.175.204:8989"); -// map.put("domain", "http://api.zhios.cn/");45678910, +// ///测试 + map.put("domain", "http://inapi.izhyin.cn/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/ map.put("master_id", "123456"); map.put("secret_key", "123456"); + + ///正式 +// map.put("domain", "http://api.zhios.cn/");//45678910,api.zhios.cn84198689 +// map.put("master_id", "99813608"); +// map.put("secret_key", "123456"); + + //客户测试 +// map.put("domain", "http://api.zhiyingos.com/");//45678910,api.zhios.cn84198689 +// map.put("master_id", "13376168"); +// map.put("secret_key", "123456"); + // map.put("token", "123465"); return map; } diff --git a/example/android/settings_aar.gradle b/example/android/settings_aar.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/example/android/settings_aar.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7cf61c7..2e9b0d6 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,8 +4,12 @@ PODS: - AliAuthSDK (1.1.0.41-bc) - AlibcTradeSDK (4.0.1.6) - AliLinkPartnerSDK (4.0.0.24) - - AlipaySDK_No_UTDID_SUN (15.2.0): - - UTDID + - amap_flutter_location (0.0.1): + - AMapLocation (~> 2.6.7) + - Flutter + - AMapFoundation (1.6.5.1) + - AMapLocation (2.6.7): + - AMapFoundation (~> 1.6.4) - BCUserTrack (5.2.0.18-appkeys): - UTDID - connectivity (0.0.1): @@ -32,10 +36,17 @@ PODS: - Flutter - flutter_plugin_android_lifecycle (0.0.1): - Flutter + - flutter_user_agent (1.2.2): + - Flutter + - flutter_webview_plugin (0.0.1): + - Flutter - flutter_xupdate (0.0.1): - Flutter - fluttertoast (0.0.2): - Flutter + - fluwx (0.0.1): + - Flutter + - WechatOpenSDK (= 1.8.7.1) - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) @@ -95,7 +106,7 @@ PODS: - mob_sharesdk/ShareSDKPlatforms/WatermelonVideo (4.3.16): - mob_sharesdk/ShareSDK - MOBFoundation (>= 3.2.9) - - mob_sharesdk/ShareSDKPlatforms/WeChat (4.3.16): + - mob_sharesdk/ShareSDKPlatforms/WeChat_Lite (4.3.16): - mob_sharesdk/ShareSDK - MOBFoundation (>= 3.2.9) - mob_sharesdk/ShareSDKRestoreScene (4.3.16): @@ -116,6 +127,8 @@ PODS: - mobsms (0.0.1): - Flutter - mob_smssdk + - more_picture_share (0.0.1): + - Flutter - mtopSDK (3.0.0.3-BC) - package_info (0.0.1): - Flutter @@ -162,14 +175,13 @@ PODS: - mob_sharesdk/ShareSDKPlatforms/SnapChat - mob_sharesdk/ShareSDKPlatforms/Twitter - mob_sharesdk/ShareSDKPlatforms/WatermelonVideo - - mob_sharesdk/ShareSDKPlatforms/WeChat + - mob_sharesdk/ShareSDKPlatforms/WeChat_Lite - mob_sharesdk/ShareSDKRestoreScene - mob_sharesdk/ShareSDKUI - sqflite (0.0.1): - Flutter - FMDB (~> 2.7.2) - tobias (0.0.1): - - AlipaySDK_No_UTDID_SUN (~> 15.2.0) - Flutter - TOCropViewController (2.5.5) - url_launcher (0.0.1): @@ -183,8 +195,13 @@ PODS: - url_launcher_windows (0.0.1): - Flutter - UTDID (1.1.0.16) + - video_player (0.0.1): + - Flutter + - video_player_web (0.0.1): + - Flutter - webview_flutter (0.0.1): - Flutter + - WechatOpenSDK (1.8.7.1) - WindVane (8.5.0.46-bc11): - WindVane/Basic (= 8.5.0.46-bc11) - WindVane/Core (= 8.5.0.46-bc11) @@ -194,17 +211,24 @@ PODS: - WindVane/WindVane (8.5.0.46-bc11) - zhiying_base_widget (0.0.1): - Flutter - - mob_sharesdk - - mob_sharesdk/ShareSDKExtension - - mob_sharesdk/ShareSDKPlatforms/QQ - - mob_sharesdk/ShareSDKPlatforms/SinaWeibo - - mob_sharesdk/ShareSDKPlatforms/WeChat - - mob_sharesdk/ShareSDKUI + - zhiying_business_college (0.0.1): + - Flutter - zhiying_comm (0.0.1): - Flutter + - zhiying_equity_card (0.0.1): + - Flutter + - zhiying_member_upgrade (0.0.1): + - Flutter + - zhiying_new_user_free (0.0.1): + - Flutter + - zhiying_official (0.0.1): + - Flutter + - zhiying_wechat_teacher (0.0.1): + - Flutter DEPENDENCIES: - ali_auth_wbq (from `.symlinks/plugins/ali_auth_wbq/ios`) + - amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`) - connectivity (from `.symlinks/plugins/connectivity/ios`) - connectivity_for_web (from `.symlinks/plugins/connectivity_for_web/ios`) - connectivity_macos (from `.symlinks/plugins/connectivity_macos/ios`) @@ -213,8 +237,11 @@ DEPENDENCIES: - flutter_alibc (from `.symlinks/plugins/flutter_alibc/ios`) - flutter_native_image (from `.symlinks/plugins/flutter_native_image/ios`) - flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`) + - flutter_user_agent (from `.symlinks/plugins/flutter_user_agent/ios`) + - flutter_webview_plugin (from `.symlinks/plugins/flutter_webview_plugin/ios`) - flutter_xupdate (from `.symlinks/plugins/flutter_xupdate/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) + - fluwx (from `.symlinks/plugins/fluwx/ios`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) - imei_plugin (from `.symlinks/plugins/imei_plugin/ios`) @@ -222,6 +249,7 @@ DEPENDENCIES: - moblink (from `.symlinks/plugins/moblink/ios`) - mobpush_plugin (from `.symlinks/plugins/mobpush_plugin/ios`) - mobsms (from `.symlinks/plugins/mobsms/ios`) + - more_picture_share (from `.symlinks/plugins/more_picture_share/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) @@ -244,9 +272,17 @@ DEPENDENCIES: - url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`) - url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`) - url_launcher_windows (from `.symlinks/plugins/url_launcher_windows/ios`) + - video_player (from `.symlinks/plugins/video_player/ios`) + - video_player_web (from `.symlinks/plugins/video_player_web/ios`) - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) - zhiying_base_widget (from `.symlinks/plugins/zhiying_base_widget/ios`) + - zhiying_business_college (from `.symlinks/plugins/zhiying_business_college/ios`) - zhiying_comm (from `.symlinks/plugins/zhiying_comm/ios`) + - zhiying_equity_card (from `.symlinks/plugins/zhiying_equity_card/ios`) + - zhiying_member_upgrade (from `.symlinks/plugins/zhiying_member_upgrade/ios`) + - zhiying_new_user_free (from `.symlinks/plugins/zhiying_new_user_free/ios`) + - zhiying_official (from `.symlinks/plugins/zhiying_official/ios`) + - zhiying_wechat_teacher (from `.symlinks/plugins/zhiying_wechat_teacher/ios`) SPEC REPOS: http://repo.baichuan-ios.taobao.com/baichuanSDK/AliBCSpecs.git: @@ -258,8 +294,9 @@ SPEC REPOS: - securityGuard - UTDID - WindVane - https://github.com/CocoaPods/Specs: - - AlipaySDK_No_UTDID_SUN + https://github.com/CocoaPods/Specs.git: + - AMapFoundation + - AMapLocation - FMDB - mob_linksdk_pro - mob_pushsdk @@ -269,10 +306,13 @@ SPEC REPOS: - MOBFoundation - Reachability - TOCropViewController + - WechatOpenSDK EXTERNAL SOURCES: ali_auth_wbq: :path: ".symlinks/plugins/ali_auth_wbq/ios" + amap_flutter_location: + :path: ".symlinks/plugins/amap_flutter_location/ios" connectivity: :path: ".symlinks/plugins/connectivity/ios" connectivity_for_web: @@ -289,10 +329,16 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_native_image/ios" flutter_plugin_android_lifecycle: :path: ".symlinks/plugins/flutter_plugin_android_lifecycle/ios" + flutter_user_agent: + :path: ".symlinks/plugins/flutter_user_agent/ios" + flutter_webview_plugin: + :path: ".symlinks/plugins/flutter_webview_plugin/ios" flutter_xupdate: :path: ".symlinks/plugins/flutter_xupdate/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" + fluwx: + :path: ".symlinks/plugins/fluwx/ios" image_cropper: :path: ".symlinks/plugins/image_cropper/ios" image_picker: @@ -307,6 +353,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/mobpush_plugin/ios" mobsms: :path: ".symlinks/plugins/mobsms/ios" + more_picture_share: + :path: ".symlinks/plugins/more_picture_share/ios" package_info: :path: ".symlinks/plugins/package_info/ios" path_provider: @@ -351,19 +399,37 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/url_launcher_web/ios" url_launcher_windows: :path: ".symlinks/plugins/url_launcher_windows/ios" + video_player: + :path: ".symlinks/plugins/video_player/ios" + video_player_web: + :path: ".symlinks/plugins/video_player_web/ios" webview_flutter: :path: ".symlinks/plugins/webview_flutter/ios" zhiying_base_widget: :path: ".symlinks/plugins/zhiying_base_widget/ios" + zhiying_business_college: + :path: ".symlinks/plugins/zhiying_business_college/ios" zhiying_comm: :path: ".symlinks/plugins/zhiying_comm/ios" + zhiying_equity_card: + :path: ".symlinks/plugins/zhiying_equity_card/ios" + zhiying_member_upgrade: + :path: ".symlinks/plugins/zhiying_member_upgrade/ios" + zhiying_new_user_free: + :path: ".symlinks/plugins/zhiying_new_user_free/ios" + zhiying_official: + :path: ".symlinks/plugins/zhiying_official/ios" + zhiying_wechat_teacher: + :path: ".symlinks/plugins/zhiying_wechat_teacher/ios" SPEC CHECKSUMS: ali_auth_wbq: 83e881b20722051dccc9117062f674d736509468 AliAuthSDK: 7018e8f3c8be3382e60f69d3b517c7de34c351e0 AlibcTradeSDK: 9a3e7af6cd648dd1f85684e82694c213fe48dad2 AliLinkPartnerSDK: c5778cdfdcee7bfe342238d39a77766184d36a46 - AlipaySDK_No_UTDID_SUN: ac3f953a08c8ac8eaade23e338862208b885c344 + amap_flutter_location: 3e33b57f1aad80b0dfb4b399de857a1a9f071e62 + AMapFoundation: b67560a6f21aab81c8c12f84616b55a3833b6253 + AMapLocation: a46c30d9930d0f3a3bd21139d8f845d10ac3f01d BCUserTrack: 49251c6fb7c65cbbc221a492bbd3f3e142f1fb0f connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 connectivity_for_web: 2b8584556930d4bd490d82b836bcf45067ce345b @@ -373,8 +439,11 @@ SPEC CHECKSUMS: flutter_alibc: 0e2a29e7c1de759672d87a260051240d209964b9 flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35 + flutter_user_agent: 27c45d034dc31b80948d29998cea52cd3a7bf936 + flutter_webview_plugin: ed9e8a6a96baf0c867e90e1bce2673913eeac694 flutter_xupdate: bdb588f0fe4f6c5e45436b8b0de08d505a50c04e fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b + fluwx: 8d47bee15c7fed07b94c2a12fb2381677232431a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a image_cropper: 3c16d7651730ffe85897f5a1c4e2547e6b54989a image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 @@ -389,6 +458,7 @@ SPEC CHECKSUMS: moblink: 3480a191e86c33f4e84af0cb5d2cc5627e78bf65 mobpush_plugin: 7b5a56692c538bc06e0386916cf7b21f77c1eb09 mobsms: 141956ad151a39a69a47a2ddf2e186405346c4ef + more_picture_share: f5b68ae17896e80168b24a0bc894395a104af0c5 mtopSDK: d6fdf81730342a69be920b576541c7bb81a683d5 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c @@ -406,9 +476,9 @@ SPEC CHECKSUMS: shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 shared_preferences_windows: 36b76d6f54e76ead957e60b49e2f124b4cd3e6ae - sharesdk_plugin: de8d8b87c50d60017472c5da425db1acd2911e0a + sharesdk_plugin: 455844465fc821a8ead9a9851ac928fa877cb379 sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0 - tobias: 46e3fae88556c31a512721b97fc509a015174ebf + tobias: da6d872837de666e33393e7647aa6bc4ccb370b1 TOCropViewController: da59f531f8ac8a94ef6d6c0fc34009350f9e8bfe url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0 @@ -416,10 +486,19 @@ SPEC CHECKSUMS: url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c url_launcher_windows: 683d7c283894db8d1914d3ab2223b20cc1ad95d5 UTDID: c28855683c5ea2e77e597cb14609328f7d470d6e + video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e + video_player_web: da8cadb8274ed4f8dbee8d7171b420dedd437ce7 webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96 + WechatOpenSDK: 6a4d1436c15b3b5fe2a0bd383f3046010186da44 WindVane: 56e096abae757397ccd3accb66a959f3ffcbf949 - zhiying_base_widget: 064547d1dfe4a5832487f275cd4775d6da8f260c + zhiying_base_widget: 00868c0d2723a3a425c18b27204fbc67e3f7e59d + zhiying_business_college: dc3ba7fb32aad4db421aa94dbbc1ef712e7d00cd zhiying_comm: 0daef4a480f4f4dbea3e11b615f3264aafea924b + zhiying_equity_card: 1afe5c3c8e5317dcebf55159b4087cd0d57e49ff + zhiying_member_upgrade: 1207671575ad01ed3336c604e235843a98fa1a0c + zhiying_new_user_free: 1640f83c12643475f03fabffcba13f498e555243 + zhiying_official: 058e85b2792fbc6925b68f9c51f482a21e7400ee + zhiying_wechat_teacher: f93967511de28d14943cd69ba3f02fac0a5fcb00 PODFILE CHECKSUM: b66ec2c625af7ee344f37aae8918540c4b58b5ef diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 2c309d7..71000f8 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -392,7 +392,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -476,7 +475,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -532,7 +530,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 6b18197..1e66d3b 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -41,7 +41,7 @@ if (![[AlibcTradeSDK sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { return YES; } - return NO; + return [super application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } @@ -51,15 +51,18 @@ if (@available(iOS 9.0, *)) { __unused BOOL isHandledByALBBSDK=[[AlibcTradeSDK sharedInstance] application:application openURL:url options:options]; - return isHandledByALBBSDK; + if (isHandledByALBBSDK) + return isHandledByALBBSDK; } else { // Fallback on earlier versions }//处理其他app跳转到自己的app,如果百川处理过会返回YES - return NO; + return [super application:application openURL:url options:options]; } + + @end diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 3b55609..39587e2 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + NSLocationDefaultAccuracyReduced + YES CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -98,6 +100,16 @@ sdkbackf17dcdf22df3bd440fac4c3cbcc76bff + + CFBundleTypeRole + Editor + CFBundleURLName + alipay + CFBundleURLSchemes + + alisdkdemo + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) @@ -164,6 +176,7 @@ fbauth2 fbshareextension alipays + alipay alitrip fleamarket youku @@ -189,6 +202,8 @@ 获取定位权限用于搜索附近的网点和查找附近的油站信息 NSLocationWhenInUseUsageDescription 获取定位权限用于搜索附近的网点和查找附近的油站信息 + NSLocationAlwaysAndWhenInUseUsageDescription + 获取定位权限用于搜索附近的网点和查找附近的油站信息 NSMicrophoneUsageDescription 获取访问麦克风权限录制语音或视频 NSPhotoLibraryAddUsageDescription diff --git a/example/lib/main.dart b/example/lib/main.dart index 0a1fb93..9b6d622 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -21,6 +21,8 @@ import 'package:zhiying_wechat_teacher/register.dart'; import 'package:zhiying_moments/register.dart'; import 'package:zhiying_member_upgrade/register.dart'; import 'package:zhiying_equity_card/zhiying_equity_card.dart'; +import 'package:zhiying_official/register.dart'; +import 'package:zhiying_base_widget/zhiying_base_widget.dart'; void main() { FlutterError.onError = (FlutterErrorDetails details) { @@ -37,21 +39,16 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { - var erroStr=''; + var erroStr = ''; const bool inProduction = const bool.fromEnvironment("dart.vm.product"); - if ( !inProduction) { - erroStr=error.exceptionAsString(); + if (!inProduction) { + erroStr = error.exceptionAsString(); } return Center( child: Text( - "走神了~"+erroStr, - style: Theme - .of(context) - .textTheme - .title - .copyWith(color: Colors.redAccent), + "" + erroStr, + style: Theme.of(context).textTheme.title.copyWith(color: Colors.grey[200]), ), ); } @@ -67,18 +64,19 @@ class _MyAppState extends State { FriendCircleRegister.init(); MemberUpgradeRegister.init(); EquityCardRegister.init(); + OfficialRegister.init(); print('初始化百川'); FlutterAlibc.initAlibc(version: "", appName: "").then((result) { print("白川" + '${result.errorCode} ${result.errorMessage}'); }); MobPushUtil.setCanPush(); + EventUtil.instance.on().listen((event) {}); // app更新插件 AppUpdateUtil.initXUpdate(); } - @override Widget build(BuildContext context) { ErrorWidget.builder = (FlutterErrorDetails errorDetails) { @@ -88,49 +86,54 @@ class _MyAppState extends State { providers: [ ChangeNotifierProvider.value(value: UserInfoNotifier()), ], - child: MaterialApp( - builder: (context,child){ - return MediaQuery( - //设置文字大小不随系统设置改变 - data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), - child: child, - ); - }, - theme: ThemeData( - fontFamily: 'PingFang', - primaryColor: HexColor.fromHex('#FF4242'), - accentColor: HexColor.fromHex('#FF4242'), - ), - routes: { - '/homePage': (BuildContext context) => HomePage(), + child: GestureDetector( + onTap: () { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { + FocusManager.instance.primaryFocus.unfocus(); + } }, - navigatorKey: navigatorKey, - localizationsDelegates: [ - RefreshLocalizations.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - CommonLocalizationsDelegate(), - ], - supportedLocales: [ - const Locale('en'), - const Locale('zh'), - ], - localeResolutionCallback: (Locale locale, Iterable supportedLocales) { - print("change language ${locale.toString()}"); - return locale; - }, - home: GestureDetector( - onTap: () { - FocusScopeNode currentFocus = FocusScope.of(context); - if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { - FocusManager.instance.primaryFocus.unfocus(); - } + child: MaterialApp( + builder: (context, child) { + return MediaQuery( + //设置文字大小不随系统设置改变 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), + child: child, + ); }, - child: LaunchPage( - // builder: (context) => HomePage(), + theme: ThemeData( + fontFamily: 'PingFang', + primaryColor: HexColor.fromHex('#FF4242'), + accentColor: HexColor.fromHex('#FF4242'), ), + routes: { + '/homePage': (BuildContext context) => HomeCenterPage(), + }, + navigatorKey: navigatorKey, + localizationsDelegates: [ + RefreshLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + CommonLocalizationsDelegate(), + ], + supportedLocales: [ + const Locale('en'), + const Locale('zh'), + ], + localeResolutionCallback: (Locale locale, Iterable supportedLocales) { + print("change language ${locale.toString()}"); + return locale; + }, + home: LaunchPage( + // builder: (context) => HomePage(), + ), ), ), ); } } + +// FocusScopeNode currentFocus = FocusScope.of(context); +// if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { +// FocusManager.instance.primaryFocus.unfocus(); +// } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c1d1019..ed6a08a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -30,6 +30,8 @@ dev_dependencies: path: ../../zhiying_business_college zhiying_equity_card: path: ../../zhiying_equity_card + zhiying_official: + path: ../../zhiying_official #微信导师 zhiying_wechat_teacher: #path: ../zhiying_wechat_teacher diff --git a/ios/zhiying_base_widget.podspec b/ios/zhiying_base_widget.podspec index 8b5e9d9..bceb452 100644 --- a/ios/zhiying_base_widget.podspec +++ b/ios/zhiying_base_widget.podspec @@ -16,12 +16,6 @@ A new Flutter plugin. s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'mob_sharesdk' - s.dependency 'mob_sharesdk/ShareSDKExtension' - s.dependency 'mob_sharesdk/ShareSDKUI' - s.dependency 'mob_sharesdk/ShareSDKPlatforms/QQ' - s.dependency 'mob_sharesdk/ShareSDKPlatforms/SinaWeibo' - s.dependency 'mob_sharesdk/ShareSDKPlatforms/WeChat' s.platform = :ios, '8.0' diff --git a/lib/models/app_config_model.dart b/lib/models/app_config_model.dart index 4ab6574..7c654e3 100644 --- a/lib/models/app_config_model.dart +++ b/lib/models/app_config_model.dart @@ -15,7 +15,7 @@ class AppConfigModel { ///新引导页参数 GuideData guideData; - static String appStartDelay="0.5"; + static String appStartDelay = "0.5"; static AppConfigModel _config; @@ -54,7 +54,7 @@ class AppConfigModel { keys = json['keys'] != null ? new AppConfigKeyModel.fromJson(json['keys']) : null; guideImage = json['guide_image'] != null ? new AppConfigGuideModel.fromJson(json['guide_image']) : null; guideData = json['guide_data'] != null ? GuideData.fromJson(json['guide_data']) : null; - appStartDelay=json['app_start_delay']!=null?json['app_start_delay']:'0.5'; + appStartDelay = json['app_start_delay'] != null ? json['app_start_delay'] : '0.5'; } Map toJson() { @@ -75,6 +75,7 @@ class AppConfigKeyModel { AppConfigKeyItemModel weixin; AppConfigKeyItemModel jdIos; AppConfigKeyItemModel jdAndroid; + GDModel gd; AppConfigKeyModel({this.weibo, this.qq, this.weixin, this.jdIos, this.jdAndroid}); @@ -84,6 +85,7 @@ class AppConfigKeyModel { weixin = json['weixin'] != null ? new AppConfigKeyItemModel.fromJson(json['weixin']) : null; jdIos = json['jd_ios'] != null ? new AppConfigKeyItemModel.fromJson(json['jd_ios']) : null; jdAndroid = json['jd_android'] != null ? new AppConfigKeyItemModel.fromJson(json['jd_android']) : null; + gd = json['gd'] != null ? GDModel.fromJson(json['gd']) : null; } Map toJson() { @@ -103,6 +105,10 @@ class AppConfigKeyModel { if (this.jdAndroid != null) { data['jd_android'] = this.jdAndroid.toJson(); } + if (this.gd != null) { + data['gd'] = this.gd.toJson(); + } + return data; } } @@ -216,3 +222,22 @@ class AppConfigGuideModel { return data; } } + +class GDModel { + String androidKey; + String iosKey; + + GDModel({this.androidKey, this.iosKey}); + + GDModel.fromJson(Map json) { + androidKey = json['android_key']; + iosKey = json['ios_key']; + } + + Map toJson() { + final Map data = new Map(); + data['android_key'] = this.androidKey; + data['ios_key'] = this.iosKey; + return data; + } +} diff --git a/lib/pages/custom_page/bloc/custom_item_page_repository.dart b/lib/pages/custom_page/bloc/custom_item_page_repository.dart index 43d241d..1dc43d5 100644 --- a/lib/pages/custom_page/bloc/custom_item_page_repository.dart +++ b/lib/pages/custom_page/bloc/custom_item_page_repository.dart @@ -1,3 +1,6 @@ +import 'dart:async'; + +import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class CustomItemPageRepository { @@ -15,10 +18,16 @@ class CustomItemPageRepository { if (!EmptyUtil.isEmpty(reqUrl)) { var result = await NetUtil.post(reqUrl, method: NetMethod.GET, cache: true); if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - List mobList = !EmptyUtil.isEmpty(data) ? List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA][tabIndex.toString()]) : List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + List mobList = + !EmptyUtil.isEmpty(data) ? List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA][tabIndex.toString()]) : List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); if (!EmptyUtil.isEmpty(mobList)) { + ReloadEvent.com = 0; return mobList.map((e) => Map.from(e)).toList(); } + } else { + Timer(Duration(milliseconds: 1000), () { + EventUtil.instance.fire(ReloadEvent()); + }); } } } catch (e, s) { diff --git a/lib/pages/custom_page/bloc/custom_page_repository.dart b/lib/pages/custom_page/bloc/custom_page_repository.dart index 83cd9a4..8eff7a1 100644 --- a/lib/pages/custom_page/bloc/custom_page_repository.dart +++ b/lib/pages/custom_page/bloc/custom_page_repository.dart @@ -1,5 +1,8 @@ +import 'dart:async'; import 'dart:convert'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; +import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -37,6 +40,12 @@ class CustomPageRepository { } return customPageData; } + }else{ + + Timer(Duration(milliseconds: 1000), (){ + EventUtil.instance.fire(ReloadEvent()); + }); + } } } catch (e, s) { diff --git a/lib/pages/custom_page/custom_item_page.dart b/lib/pages/custom_page/custom_item_page.dart index 83afea4..fe12c86 100644 --- a/lib/pages/custom_page/custom_item_page.dart +++ b/lib/pages/custom_page/custom_item_page.dart @@ -92,7 +92,6 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit _eventBus = EventBus(); _refreshController = RefreshController(initialRefresh: false); _initEvent();_controller.addListener(() { - print(_controller.offset.toString()); if(widget.scroller!=null){ widget?.scroller(_controller.offset); } @@ -166,6 +165,7 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit header: RefreshGifHeader(), // footer: RefreshFooter(), child: CustomScrollView( + physics: BouncingScrollPhysics(), controller: _controller, slivers: _buildContentWidgets(model), ), diff --git a/lib/pages/custom_page/custom_page.dart b/lib/pages/custom_page/custom_page.dart index 454a00e..8e8c075 100644 --- a/lib/pages/custom_page/custom_page.dart +++ b/lib/pages/custom_page/custom_page.dart @@ -60,7 +60,7 @@ class _CommonPageContainer extends StatefulWidget { __CommonPageContainerState createState() => __CommonPageContainerState(); } -class __CommonPageContainerState extends State<_CommonPageContainer> with SingleTickerProviderStateMixin ,AutomaticKeepAliveClientMixin{ +class __CommonPageContainerState extends State<_CommonPageContainer> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController _tabController; // 是否有AppBar @@ -80,7 +80,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single @override void initState() { - backgroundBloc=BackgroundBloc(); + backgroundBloc = BackgroundBloc(); super.initState(); } @@ -94,40 +94,38 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); - return MediaQuery.removePadding( - context: context, - child: BlocConsumer( - listener: (context, state) {}, - buildWhen: (prev, current) { - if (current is CustomPageErrorState) { - return false; - } - if (current is CustomPageRefreshSuccessState) { - // _refreshController.refreshCompleted(resetFooterState: true); - return false; - } - if (current is CustomPageRefreshErrorState) { - // _refreshController.refreshFailed(); - return false; - } - return true; - }, - builder: (context, state) { - /// 有数据 - if (state is CustomPageLoadedState) { - if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); - return _buildMainWidget(state.model, state.backgroundModel); - } - - /// 初始化失败 - if (state is CustomPageInitErrorState) { - return _buildEmptyWidget(); - } - - /// 骨架图 - return _buildSkeletonWidget(); - }, - ), + return BlocConsumer( + listener: (context, state) {}, + buildWhen: (prev, current) { + if (current is CustomPageErrorState) { + return false; + } + if (current is CustomPageRefreshSuccessState) { + // _refreshController.refreshCompleted(resetFooterState: true); + return false; + } + if (current is CustomPageRefreshErrorState) { + // _refreshController.refreshFailed(); + return false; + } + return true; + }, + builder: (context, state) { + /// 有数据 + if (state is CustomPageLoadedState) { + if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); + Logger.log("通用模板数据", state.model); + return _buildMainWidget(state.model, state.backgroundModel); + } + + /// 初始化失败 + if (state is CustomPageInitErrorState) { + return _buildEmptyWidget(); + } + + /// 骨架图 + return _buildSkeletonWidget(); + }, ); } @@ -271,7 +269,11 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single onPressed: () => Navigator.maybePop(context), ), title: Text( - null != data && data.containsKey('app_bar_name') ? data['app_bar_name'] != '自定义页面' ? data['app_bar_name'] : parentTitle : parentTitle, + null != data && data.containsKey('app_bar_name') + ? data['app_bar_name'] != '自定义页面' + ? data['app_bar_name'] + : parentTitle + : parentTitle, style: TextStyle( color: HexColor.fromHex(null != data ? data['app_bar_name_color'] ?? '#333333' : '#333333'), fontSize: 16, @@ -370,16 +372,15 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single return result; } - _buildBackground(BackgroundModel backgroundModel) { if (backgroundModel != null) { var headerBg = backgroundModel.headerBg; return StreamBuilder( stream: backgroundBloc.outData, - builder: (context,asncy){ - return Container( + builder: (context, asncy) { + return Container( constraints: BoxConstraints(minHeight: 0), - height: (double.tryParse(headerBg?.height)??0)+backgroundTopMargin ?? 0, + height: (double.tryParse(headerBg?.height) ?? 0) + backgroundTopMargin ?? 0, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( @@ -389,7 +390,6 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single ); }, ); - } else { return Container(); } @@ -423,7 +423,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single @override // TODO: implement wantKeepAlive - bool get wantKeepAlive =>true; + bool get wantKeepAlive => true; } /// 回到顶部的icon diff --git a/lib/pages/custom_page/event/reload_event.dart b/lib/pages/custom_page/event/reload_event.dart new file mode 100644 index 0000000..344c4dd --- /dev/null +++ b/lib/pages/custom_page/event/reload_event.dart @@ -0,0 +1,12 @@ +// +import 'dart:async'; + +class ReloadEvent { + static int com = 0; + final String id; + + ReloadEvent({this.id}) { + com++; + } + +} diff --git a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart index 96d814a..8af4d0e 100644 --- a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart +++ b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart @@ -27,6 +27,7 @@ import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_m import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class GoodsShareImage extends StatefulWidget { final Map model; @@ -177,15 +178,15 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> with A ); List moreImageList = List(); - try{ + try { moreImageList = List.from(widget?.params['image_url_list']).map((e) => e.toString()).toList(); - }catch(e,s){ + } catch (e, s) { print(e); print(s); } _style.customImage.addAll(moreImageList); - _style.customImage=_style.customImage.reversed.toList(); + _style.customImage = _style.customImage.reversed.toList(); for (int index = 0; index < _style.customImage.length; index++) { String image = _style.customImage[index]; // 分享图片 @@ -344,17 +345,16 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> with A } List paths = await ImageDownloadUtil.download(images); - for(var item in paths){ + for (var item in paths) { Uint8List data = File(item).readAsBytesSync(); isSaveSuccess = await SaveImage.save(imageBytes: data); } if (isSaveSuccess) { Fluttertoast.showToast(msg: '保存成功'); - } else{ + } else { Fluttertoast.showToast(msg: '保存失败'); } - Loading.dismiss(); } @@ -363,11 +363,14 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> with A BuildContext buildContext = _globalKey.currentContext; if (null != buildContext) { RenderRepaintBoundary boundary = buildContext.findRenderObject(); - ui.Image image = await boundary.toImage(pixelRatio: 1.5); + ui.Image image = await boundary.toImage(pixelRatio: 4); // 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba + Loading.show(context); ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); Uint8List pngBytes = byteData.buffer.asUint8List(); - _shareModel.poster = pngBytes; + File file = await EncodeUtil.compressImage(context,images: pngBytes, size: 400); + Loading.dismiss(); + _shareModel.poster = file.readAsBytesSync(); } } else { _shareModel.poster = null; diff --git a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart index 1acc067..1ec6de5 100644 --- a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart +++ b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart @@ -24,8 +24,7 @@ class GoodsShareLink extends StatefulWidget { final String shareType; - const GoodsShareLink(this.model, this.params, this.shareType, {Key key}) - : super(key: key); + const GoodsShareLink(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareLinkState createState() => _GoodsShareLinkState(); @@ -36,8 +35,7 @@ class _GoodsShareLinkState extends State { Widget build(BuildContext context) { return BlocProvider( bloc: GoodsShareContentBloc(), - child: - _GoodsShareLinkContent(widget.model, widget.params, widget.shareType), + child: _GoodsShareLinkContent(widget.model, widget.params, widget.shareType), ); } } @@ -49,16 +47,13 @@ class _GoodsShareLinkContent extends StatefulWidget { // final GoodsShareTempDataModel datas; - const _GoodsShareLinkContent(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const _GoodsShareLinkContent(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareLinkContentState createState() => _GoodsShareLinkContentState(); } -class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> - with AutomaticKeepAliveClientMixin { +class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> with AutomaticKeepAliveClientMixin { GoodsShareImageModel _style; Map _images = Map(); List widgets = List(); @@ -95,6 +90,13 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> if (_content == null || _content == '') { _content = data.shareContent; } + + _shareModel.image = List(); + + _shareModel.title = data?.appName ?? ""; + _shareModel.content=_content; + // _shareModel.image.add(data?.imgUrl ?? ""); + widgets.add(GoodsShareItem( imgHeader: _style?.cssList?.headerImage ?? '', imgCheck: _style?.cssList?.unChooseImage ?? '', @@ -125,10 +127,7 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> onEditorClick: () { Fluttertoast.showToast(msg: '正在开发中'); return; - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => GoodsShareEditor(_style))); + Navigator.push(context, CupertinoPageRoute(builder: (context) => GoodsShareEditor(_style))); }, onTempChange: (temp) { setState(() { @@ -160,34 +159,25 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> child: Container( margin: EdgeInsets.only(bottom: 4), padding: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), - bottomRight: Radius.circular(8))), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))), child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: widgets), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: widgets), ), ), ), - _createBottom(), + _createBottom(data), ], ); }); } - Widget _createBottom() { + Widget _createBottom(GoodsShareTempDataModel data) { Map shareImages = _style?.cssList?.shareLink; if (shareImages == null) { return Container(); } - CustomButtonModel btnCopy = CustomButtonModel.fromJson( - Map.from(shareImages['copy_btn'])); - CustomButtonModel btnShare = CustomButtonModel.fromJson( - Map.from(shareImages['share_btn'])); + CustomButtonModel btnCopy = CustomButtonModel.fromJson(Map.from(shareImages['copy_btn'])); + CustomButtonModel btnShare = CustomButtonModel.fromJson(Map.from(shareImages['share_btn'])); return SafeArea( child: Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), @@ -202,7 +192,11 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> decoration: BoxDecoration( borderRadius: BorderRadius.circular(18), ), - child: CustomButton(btnCopy)), + child: GestureDetector( + onTap: () { + Clipboard.setData(ClipboardData(text: _content)); + }, + child: CustomButton(btnCopy))), btnShare == null ? Container() : GestureDetector( @@ -225,15 +219,16 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> } void _showShare() async { - List images = List(); - for (int index = 0; index < _style.customImage.length; index++) { - if (_images.containsKey(index)) { - images.add(_images[index]); - } - } - if (images.length >= 0) { - _shareModel.image = images; - } + // List images = List(); + // for (int index = 0; index < _style.customImage.length; index++) { + // if (_images.containsKey(index)) { + // images.add(_images[index]); + // } + // } + // if (images.length >= 0) { + // _shareModel.image = images; + // } + showCupertinoModalPopup( context: context, builder: (context) => ShareAlert( diff --git a/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart b/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart index 2d8cbb3..9459fba 100644 --- a/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart +++ b/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart @@ -9,6 +9,9 @@ import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_m import 'package:zhiying_base_widget/widgets/public/custom_button/custom_bottom.dart'; import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:sharesdk_plugin/sharesdk_plugin.dart'; +import 'package:fluwx/fluwx.dart'; class GoodsShareMiniprogram extends StatefulWidget { final Map model; @@ -16,9 +19,7 @@ class GoodsShareMiniprogram extends StatefulWidget { final String shareType; - const GoodsShareMiniprogram(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const GoodsShareMiniprogram(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareMiniprogramState createState() => _GoodsShareMiniprogramState(); @@ -29,8 +30,7 @@ class _GoodsShareMiniprogramState extends State { Widget build(BuildContext context) { return BlocProvider( bloc: GoodsShareContentBloc(), - child: _GoodsShareMiniprogramContent( - widget.model, widget.params, widget.shareType), + child: _GoodsShareMiniprogramContent(widget.model, widget.params, widget.shareType), ); } } @@ -40,18 +40,13 @@ class _GoodsShareMiniprogramContent extends StatefulWidget { final Map params; final String shareType; - const _GoodsShareMiniprogramContent(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const _GoodsShareMiniprogramContent(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override - _GoodsShareMiniprogramContentState createState() => - _GoodsShareMiniprogramContentState(); + _GoodsShareMiniprogramContentState createState() => _GoodsShareMiniprogramContentState(); } -class _GoodsShareMiniprogramContentState - extends State<_GoodsShareMiniprogramContent> - with AutomaticKeepAliveClientMixin { +class _GoodsShareMiniprogramContentState extends State<_GoodsShareMiniprogramContent> with AutomaticKeepAliveClientMixin { GoodsShareImageModel _style; Map _images = Map(); List widgets = List(); @@ -85,11 +80,7 @@ class _GoodsShareMiniprogramContentState child: Container( margin: EdgeInsets.only(bottom: 4), padding: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), - bottomRight: Radius.circular(8))), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -112,22 +103,21 @@ class _GoodsShareMiniprogramContentState ), ), ), - _createBottom(), + _createBottom(data), ], ); }); return Material(); } - Widget _createBottom() { - Map shareImages = _style.cssList.shareImage; + Widget _createBottom(GoodsShareTempDataModel data) { + Map shareImages = _style.cssList.shareMini; if (shareImages == null) { return Container(); } // CustomButtonModel btnCopy = CustomButtonModel.fromJson( // Map.from(shareImages['copy_btn'])); - CustomButtonModel btnShare = CustomButtonModel.fromJson( - Map.from(shareImages['share_btn'])); + CustomButtonModel btnShare = CustomButtonModel.fromJson(Map.from(shareImages['share_btn'])); return SafeArea( child: Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), @@ -145,11 +135,27 @@ class _GoodsShareMiniprogramContentState borderRadius: BorderRadius.circular(18), ), child: CustomButton(btnShare)), - onTap: () {}, + onTap: () { + print(data.toJson()); + _shareMini(data); + }, ), ], ), ), ); } + + void _shareMini(GoodsShareTempDataModel data) { + WeChatShareMiniProgramModel shareMiniProgramModel = WeChatShareMiniProgramModel( + miniProgramType: WXMiniProgramType.RELEASE, + userName: data?.userName, + webPageUrl: data?.page, + path: data?.page, + title: data?.miniAppTitle, + thumbnail: WeChatImage.network(data?.imageUrl)); + + shareToWeChat(shareMiniProgramModel); + + } } diff --git a/lib/pages/goods_share_page/goods_share_page.dart b/lib/pages/goods_share_page/goods_share_page.dart index 04be686..a79b750 100644 --- a/lib/pages/goods_share_page/goods_share_page.dart +++ b/lib/pages/goods_share_page/goods_share_page.dart @@ -49,9 +49,10 @@ class _GoodsShareContainerState extends State<_GoodsShareContainer> // Map data = // Map.from(convert.jsonDecode(d)); Map data = widget.model; - Logger.debug(data['share_url_args'].toString()); + Logger.debug(data.toString()); _bloc = BlocProvider.of(context); _params = data['share_url_args']; + _params['good_id']=data['good_id']; _bloc.loadData('taobao', _params); super.initState(); } diff --git a/lib/pages/goods_share_page/models/goods_share_style_model.dart b/lib/pages/goods_share_page/models/goods_share_style_model.dart index cd3875f..7c44f26 100644 --- a/lib/pages/goods_share_page/models/goods_share_style_model.dart +++ b/lib/pages/goods_share_page/models/goods_share_style_model.dart @@ -11,6 +11,7 @@ class GoodsShareStyleModel { Map shareImage; GoodsShareTempEditorModel editTemplate; Map shareLink; + Map shareMini; GoodsShareStyleModel( {this.unChooseColor, @@ -33,6 +34,7 @@ class GoodsShareStyleModel { rewardText = json['reward_text']; shareImage = json['share_image']; shareLink=json['share_link']; + shareMini=json['share_mini']; if (json['edit_template'] != null) { editTemplate = GoodsShareTempEditorModel.fromJson( Map.from(json['edit_template'])); diff --git a/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart b/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart index 606cfd5..2f6bae7 100644 --- a/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart +++ b/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart @@ -14,12 +14,13 @@ class GoodsShareTempDataModel { String miniAppCode; String miniAppDesc; - GoodsShareTempDataModel( - {this.shareContent, - this.shareTemplate, - this.shareTip, - this.appUrl, - this.miniAppUrl}); + String appId; + String userName; + String miniprogramType; + String page; + String imageUrl; + + GoodsShareTempDataModel({this.shareContent, this.shareTemplate, this.shareTip, this.appUrl, this.miniAppUrl}); GoodsShareTempDataModel.fromJson(Map json) { shareContent = json['template_content']; @@ -41,14 +42,18 @@ class GoodsShareTempDataModel { miniAppCode = json['mini_app_code']; miniAppDesc = json['mini_app_desc']; imgUrl = json['image_url']; + appId = json['app_id']; + userName = json['user_name']; + miniprogramType = json['miniprogram_type']; + page = json['page']; + imageUrl=json['image_url']; } Map toJson() { final Map data = new Map(); data['share_content'] = this.shareContent; if (this.shareTemplate != null) { - data['template_content'] = - this.shareTemplate.map((v) => v.toJson()).toList(); + data['template_content'] = this.shareTemplate.map((v) => v.toJson()).toList(); } data['share_tip'] = this.shareTip; data['app_url'] = this.appUrl; @@ -64,6 +69,10 @@ class GoodsShareTempDataModel { data['mini_app_url'] = this.miniAppUrl; data['mini_app_code'] = this.miniAppCode; data['mini_app_desc'] = this.miniAppDesc; + data['app_id'] = appId; + data['user_name'] = userName; + data['miniprogram_type'] = miniprogramType; + data['page'] = page; return data; } } diff --git a/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart b/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart index 01dc17c..f8b9ec3 100644 --- a/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart +++ b/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart @@ -56,12 +56,12 @@ class GoodsShareMiniprogramWidget extends StatelessWidget { ), Row( children: [ - Container( - margin: EdgeInsets.only(right: 6), - width: 15, - height: 15, - // color: Colors.redAccent, - ), + // Container( + // margin: EdgeInsets.only(right: 6), + // width: 15, + // height: 15, + // // color: Colors.redAccent, + // ), Text( '小程序', style: TextStyle(fontSize: 11, color: Color(0xff333333)), diff --git a/lib/pages/guide_page/guide_page.dart b/lib/pages/guide_page/guide_page.dart index 837e140..7dc71a9 100644 --- a/lib/pages/guide_page/guide_page.dart +++ b/lib/pages/guide_page/guide_page.dart @@ -59,15 +59,21 @@ class _GuidePageState extends State { height: double.infinity, decoration: BoxDecoration( image: DecorationImage( - image: Image.memory( - bgImage, - ).image, + image: bgImage != null + ? Image.memory( + bgImage, + ).image + : CachedNetworkImageProvider(""), fit: BoxFit.fill)), child: Center( - child: Image.memory( - widget.imageDatas[index], - fit: BoxFit.fitWidth, - ))), + child: widget.imageDatas[index] != null + ? Image.memory( + widget.imageDatas[index], + fit: BoxFit.fitWidth, + ) + : Container( + color: Colors.white, + ))), index == widget?.bgImageDatas?.length - 1 ? Positioned( left: 0, diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index 859cfac..a463313 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -22,8 +22,10 @@ import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_di import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart'; import 'package:zhiying_base_widget/models/app_config_model.dart'; +import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart'; import 'package:zhiying_base_widget/utils/contants.dart'; import 'package:zhiying_base_widget/utils/mob_push_util.dart'; +import 'package:zhiying_base_widget/widgets/restart_widget/restart_widget.dart'; import 'package:zhiying_comm/models/base/base_tab_model.dart'; import 'package:zhiying_comm/util/image_util.dart'; import 'package:zhiying_comm/util/mob_util/mob_util.dart'; @@ -39,6 +41,18 @@ import 'package:zhiying_comm/util/event_util/event_util.dart'; import 'package:zhiying_comm/util/event_util/log_out.dart'; import 'package:package_info/package_info.dart'; +class HomeCenterPage extends StatefulWidget { + @override + _HomeCenterPageState createState() => _HomeCenterPageState(); +} + +class _HomeCenterPageState extends State { + @override + Widget build(BuildContext context) { + return RestartWidget(child: HomePage()); + } +} + class HomePage extends StatefulWidget { HomePage({Key key}) : super(key: key); @@ -52,21 +66,33 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); StreamSubscription streamSubscription; + StreamSubscription reloadSubscription; + StreamSubscription aliasSubscription; + StreamSubscription logOutSubscription; + StreamSubscription loginSubscription; + + StreamSubscription eventChannelSubscription; + @override void initState() { ///初始化一些数据 initAsync(); //如果登出则重新打开首页 - streamSubscription = EventUtil.instance.on().listen((event) async{ - UserInfoModel user = - await Provider.of(context, listen: false) - .getUserInfoModel(); - user.token=''; + streamSubscription = EventUtil.instance.on().listen((event) async { + UserInfoModel user = await Provider.of(context, listen: false).getUserInfoModel(); + user.token = ''; Navigator.maybePop(context); + print("重启1"); Navigator.pushReplacementNamed(context, "/homePage"); }); + reloadSubscription = EventUtil.instance.on().listen((event) async { + print("重启2"); + await BaseSettingModel.init(isGetCache: false); + RestartWidget.restartApp(context); + }); + super.initState(); } @@ -82,16 +108,9 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker NativeUtil.notifyInitSuccess(); }); }); - String data = BaseSettingModel.setting.tab['data']; - try { - List list = convert.jsonDecode(data); - _data = list.map((item) { - return Map.from(item); - }).toList(); - Logger.debug(_data); - } catch (error) { - Logger.error(error); - } + + initBaseSet(); + Constants.isShowIntellectDialog = false; TaobaoAuth.initAuth(context); @@ -108,10 +127,10 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker //app后台杀死时候的还原 Moblink.restoreScene(_restore); // 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来) - _eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); + eventChannelSubscription= _eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); MobPushUtil.addPushReceiver(); - EventUtil.instance.on().listen((event) async { + aliasSubscription = EventUtil.instance.on().listen((event) async { UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; var setting = await NativeUtil.getSetting(); String masterId = setting['master_id']; @@ -121,12 +140,12 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker } }); - EventUtil.instance.on().listen((event) { + logOutSubscription = EventUtil.instance.on().listen((event) { MobPushUtil.deleteAlias(); }); - super.initState(); + MobPushUtil.addPushReceiver(); - EventUtil.instance.on().listen((event) async { + loginSubscription = EventUtil.instance.on().listen((event) async { UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo; var setting = await NativeUtil.getSetting(); String masterId = setting['master_id']; @@ -136,19 +155,36 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker } }); - EventUtil.instance.on().listen((event) { - MobPushUtil.deleteAlias(); - }); + } catch (e, s) { print(e); print(s); } + + } + + initBaseSet() { + String data = BaseSettingModel.setting.tab['data']; + try { + List list = convert.jsonDecode(data); + _data = list.map((item) { + return Map.from(item); + }).toList(); + Logger.debug(_data); + } catch (error) { + Logger.error(error); + } } @override void dispose() { WidgetsBinding.instance.removeObserver(this); streamSubscription.cancel(); + reloadSubscription?.cancel(); + aliasSubscription?.cancel(); + logOutSubscription?.cancel(); + loginSubscription?.cancel(); + eventChannelSubscription?.cancel(); super.dispose(); } diff --git a/lib/pages/hot_ranking_page/hot_ranking_page_sk.dart b/lib/pages/hot_ranking_page/hot_ranking_page_sk.dart index caefe4d..905bdc9 100644 --- a/lib/pages/hot_ranking_page/hot_ranking_page_sk.dart +++ b/lib/pages/hot_ranking_page/hot_ranking_page_sk.dart @@ -35,7 +35,7 @@ class HotRankingPageSkeleton extends StatelessWidget { _buildBottomListItem() { List listWidget = List(); - for (var index = 0; index < 3; index++) { + for (var index = 0; index < 10; index++) { listWidget.add(Container( margin: EdgeInsets.only(left: 16, top: 10, bottom: 10), child: Row( diff --git a/lib/pages/launch_page/launch_page.dart b/lib/pages/launch_page/launch_page.dart index 0394013..eb58166 100644 --- a/lib/pages/launch_page/launch_page.dart +++ b/lib/pages/launch_page/launch_page.dart @@ -40,14 +40,12 @@ class LaunchPage extends StatefulWidget { class _LaunchPageState extends State with TickerProviderStateMixin { final GlobalKey navigatorKey = new GlobalKey(); - ///闪屏动画 - AnimationController animationController; int showTime = 0; @override void initState() { - animationController = AnimationController(vsync: this); + validateInit(); super.initState(); } @@ -59,7 +57,6 @@ class _LaunchPageState extends State with TickerProviderStateMixin { Logger.debug('ConnectivityResult.wifi'); print('ConnectivityResult.wifi'); Application.init().then((_) async { - ///引导页 PackageInfo packageInfo = await PackageInfo.fromPlatform(); String versionNumber = await SharedPreferencesUtil.getStringValue(Constants.versionNumber); @@ -76,7 +73,8 @@ class _LaunchPageState extends State with TickerProviderStateMixin { // CupertinoPageRoute(builder: (context) => HomePage())); Navigator.of(context).pushReplacementNamed('/homePage'); } - }).catchError((err) async { + }).catchError((err, s) async { + print(s); // if (err.toString().contains("BaseSettingModel")) { // await showDialog( // context: context, @@ -121,22 +119,30 @@ class _LaunchPageState extends State with TickerProviderStateMixin { Dio dio = Dio(); print("加载图片"); List guideImages = List(); - ListbgImages = List(); + List bgImages = List(); for (int i = 0; i < guide.guideData.guideCss.length; i++) { - Response response = await dio.get(guide.guideData.guideCss[i].contentImage, options: Options(responseType: ResponseType.bytes)); - if (response.statusCode == 200) { - Uint8List data = Uint8List.fromList(response.data); - guideImages.add(data); + try { + Response response = await dio.get(guide.guideData.guideCss[i].contentImage, options: Options(responseType: ResponseType.bytes)); + if (response.statusCode == 200) { + Uint8List data = Uint8List.fromList(response.data); + guideImages.add(data); + } + } catch (e, s) { + guideImages.add(null); } - response = await dio.get(guide.guideData.guideCss[i].bgImage, options: Options(responseType: ResponseType.bytes)); - if (response.statusCode == 200) { - Uint8List data = Uint8List.fromList(response.data); - bgImages.add(data); + + try { + Response response = await dio.get(guide.guideData.guideCss[i].bgImage, options: Options(responseType: ResponseType.bytes)); + if (response.statusCode == 200) { + Uint8List data = Uint8List.fromList(response.data); + bgImages.add(data); + } + } catch (e, s) { + bgImages.add(null); } } - NativeUtil.notifyInitSuccess(); - await Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GuidePage(guide.guideData, guideImages,bgImages))); + await Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GuidePage(guide.guideData, guideImages, bgImages))); } } catch (e) { throw "引导图加载失败"; diff --git a/lib/pages/mine_detail_page/mine_detail_page.dart b/lib/pages/mine_detail_page/mine_detail_page.dart index 7bee974..c5ce758 100644 --- a/lib/pages/mine_detail_page/mine_detail_page.dart +++ b/lib/pages/mine_detail_page/mine_detail_page.dart @@ -316,8 +316,9 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { if (cropperFile == null) { return; } - File resultFile = await EncodeUtil.compressImage(cropperFile, 800); Loading.show(context); + File resultFile = await EncodeUtil.compressImage(context,file:cropperFile,size: 800); + _bloc.uploadAvatar(resultFile); } } diff --git a/lib/pages/search_think_page/bloc/search_think_event.dart b/lib/pages/search_think_page/bloc/search_think_event.dart index f7930f1..b9529b4 100644 --- a/lib/pages/search_think_page/bloc/search_think_event.dart +++ b/lib/pages/search_think_page/bloc/search_think_event.dart @@ -26,6 +26,12 @@ class SearchThinkChangeTypeEvent extends SearchThinkEvent{ /// 显示原本视图 class SearchThinkShowBaseViewEvent extends SearchThinkEvent{ + + ///选中搜索的类型 + final String type; + + SearchThinkShowBaseViewEvent({this.type}); + @override List get props => []; } \ No newline at end of file diff --git a/lib/pages/security_page/security_password/security_password.dart b/lib/pages/security_page/security_password/security_password.dart index 0fee690..d02d79b 100644 --- a/lib/pages/security_page/security_password/security_password.dart +++ b/lib/pages/security_page/security_password/security_password.dart @@ -30,6 +30,8 @@ class _SecurityPasswordState extends State { bool _canConfirm = false; String _phone; + Timer timer; + @override void initState() { Logger.debug(widget.model.toString()); @@ -143,9 +145,7 @@ class _SecurityPasswordState extends State { } void _verifiy() { - bool canConfirm = _passwordController.text.length >= 6 && - _confirmController.text.length >= 6 && - _codeController.text.length == 6; + bool canConfirm = _passwordController.text.length >= 6 && _confirmController.text.length >= 6 && _codeController.text.length == 6; if (canConfirm != _canConfirm) { setState(() { _canConfirm = canConfirm; @@ -153,20 +153,26 @@ class _SecurityPasswordState extends State { } } + @override + void dispose() { + timer?.cancel(); + super.dispose(); + } + /// 获取验证码 void _sendCode() async { - bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.NORMAL); - if(result){ + bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.NORMAL); + if (result) { Fluttertoast.showToast(msg: '发送成功'); _second = 60; - Timer.periodic(Duration(seconds: 1), (timer) { + timer = Timer.periodic(Duration(seconds: 1), (timer) { _second--; if (_second <= 0) { timer.cancel(); } setState(() {}); }); - }else{ + } else { // Fluttertoast.showToast(msg: '获取验证码失败'); } @@ -187,13 +193,8 @@ class _SecurityPasswordState extends State { void _confirm() async { NetUtil.request('/api/v1/settings/account/security/password', - params: Map.from({ - 'new_password': _passwordController.text, - 'new_password_ack': _confirmController.text, - 'valid_code': _codeController.text, - 'phone': _phone, - 'zone': '86' - }), + params: Map.from( + {'new_password': _passwordController.text, 'new_password_ack': _confirmController.text, 'valid_code': _codeController.text, 'phone': _phone, 'zone': '86'}), method: NetMethod.POST, onSuccess: (result) { Logger.debug(result); Fluttertoast.showToast(msg: '设置成功'); diff --git a/lib/pages/webview/base_webview.dart b/lib/pages/webview/base_webview.dart index 92ba57d..c09a01e 100644 --- a/lib/pages/webview/base_webview.dart +++ b/lib/pages/webview/base_webview.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_user_agent/flutter_user_agent.dart'; import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart'; import 'package:zhiying_comm/util/log/let_log.dart'; import 'package:zhiying_comm/util/empty_util.dart'; @@ -45,7 +46,7 @@ class _BaseWebviewState extends State { loadData() { print("加载数据"); progress = 0.0; - if(timer?.isActive??false){ + if (timer?.isActive ?? false) { timer?.cancel(); } timer = Timer.periodic(Duration(milliseconds: 10), (timer) { @@ -77,27 +78,33 @@ class _BaseWebviewState extends State { @override Widget build(BuildContext context) { + print("设备:"+FlutterUserAgent.webViewUserAgent); return Scaffold( appBar: _createNav(), backgroundColor: Colors.white, body: Stack( children: [ WebView( + initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow, initialUrl: _url, + userAgent: FlutterUserAgent.userAgent, javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController) { _webViewController = webViewController; loadData(); }, + navigationDelegate: (NavigationRequest request) async { + + print("重定向" + request.url); // 解决Android的拼多多webview 转发的问题 if (Platform.isAndroid) { String url = request?.url?.toString(); if (!EmptyUtil.isEmpty(url) && !url.startsWith('https://') && !url.startsWith('http://')) { Logger.log('navigation url = $url'); - // if(await canLaunch(url)){ - // await launch(url); - // } + if (await canLaunch(url)) { + await launch(url); + } return NavigationDecision.prevent; } } @@ -107,14 +114,14 @@ class _BaseWebviewState extends State { print('Page started loading: $url'); }, onPageFinished: (String url) { - if(progress<0.8){ + if (progress < 0.8) { progress = 0.8; } - setState(() {}); + //setState(() {}); print('Page finished loading: $url'); _webViewController.getTitle().then((title) { _title = title; - setState(() {}); + // setState(() {}); }); }, gestureNavigationEnabled: true, diff --git a/lib/pages/withdraw_page/withdraw_page.dart b/lib/pages/withdraw_page/withdraw_page.dart index 1feeda6..60b4050 100644 --- a/lib/pages/withdraw_page/withdraw_page.dart +++ b/lib/pages/withdraw_page/withdraw_page.dart @@ -2,6 +2,7 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart'; import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart'; import 'package:zhiying_base_widget/pages/withdraw_page/bloc/withdraw_bloc.dart'; import 'package:zhiying_base_widget/pages/withdraw_page/models/withdraw_model.dart'; @@ -71,8 +72,6 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { super.initState(); } - - reload() { _bloc.loadData(widget.data['skip_identifier']); _bloc.loadWithdrawData(); @@ -117,14 +116,15 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { return AppBar( elevation: 1, brightness: Brightness.light, - backgroundColor: HexColor.fromHex(model?.appBarBgColor??""), + backgroundColor: HexColor.fromHex(model?.appBarBgColor ?? ""), leading: Navigator.canPop(context) ? GestureDetector( child: Container( padding: EdgeInsets.zero, child: Icon( Icons.arrow_back_ios, - size: 20, + size: 18, + color: HexColor.fromHex(model?.appBarNameColor??""), ), ), onTap: () { @@ -137,27 +137,24 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { centerTitle: true, title: Text( model.appBarName, - style: TextStyle( - fontSize: 17, - color: HexColor.fromHex(model.appBarNameColor), - fontWeight: FontWeight.w600 - ), + style: TextStyle(fontSize: 17, color: HexColor.fromHex(model.appBarNameColor), fontWeight: FontWeight.w600), ), - actions:[ GestureDetector( - child: Center( - child: Padding( - padding: EdgeInsets.only(right: 16), - child: Text( - model.appBarRightText, - style: TextStyle(fontSize: 13, color: HexColor.fromHex(model?.appBarNameColor??"")), + actions: [ + GestureDetector( + child: Center( + child: Padding( + padding: EdgeInsets.only(right: 16), + child: Text( + model.appBarRightText, + style: TextStyle(fontSize: 13, color: HexColor.fromHex(model?.appBarNameColor ?? "")), + ), ), ), - ), - onTap: () { - RouterUtil.route( - model.detailSkipModel, model.detailSkipModel.toJson(), context); - }, - )], + onTap: () { + RouterUtil.route(model.detailSkipModel, model.detailSkipModel.toJson(), context); + }, + ) + ], ); } @@ -166,8 +163,7 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { return Container( width: double.infinity, height: 97, - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10)), child: Stack( children: [ Container( @@ -206,24 +202,12 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { Widget _createVerify(WithdrawModel model) { var data = _bloc.withdrawDataModel; - var param = { - 'status': _bloc.aliPayModel, - Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, - 'data': _bloc.aliPayModel - }; + var param = {'status': _bloc.aliPayModel, Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, 'data': _bloc.aliPayModel}; return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Logger.debug('绑定支付宝'); - RouterUtil.route( - model.gotoAliPay, - { - 'status': _bloc.aliPayModel, - Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, - 'data': param - }, - context) - .then((value) { + RouterUtil.route(model.gotoAliPay, {'status': _bloc.aliPayModel, Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, 'data': param}, context).then((value) { reload(); }); }, @@ -232,28 +216,20 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { child: Row( children: [ CachedNetworkImage( - imageUrl: (data?.alipayUserName == null || - data?.alipayUserName.length == 0) - ? model.unbindAlipayImg - : model.bindAlipayImg, + imageUrl: (data?.alipayUserName == null || data?.alipayUserName.length == 0) ? model.unbindAlipayImg : model.bindAlipayImg, height: 23, ), Expanded( child: Padding( padding: const EdgeInsets.only(left: 8, right: 8), child: Text( - (data?.alipayUserName == null || - data?.alipayUserName.length == 0) - ? model.unbindAlipayText - : data.alipayUserName, + (data?.alipayUserName == null || data?.alipayUserName.length == 0) ? model.unbindAlipayText : data.alipayUserName, style: TextStyle(fontSize: 11, color: Color(0xff999999)), ), ), ), Text( - (data?.alipayUserName == null || data?.alipayUserName.length == 0) - ? model.unbindAlipayGotoText - : model.bindAlipayGotoText, + (data?.alipayUserName == null || data?.alipayUserName.length == 0) ? model.unbindAlipayGotoText : model.bindAlipayGotoText, style: TextStyle(fontSize: 11, color: Color(0xff999999)), ), Icon( @@ -268,8 +244,7 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { } Widget _createPrice(WithdrawModel model) { - if (_controller.text.length == 0 && - model.cashOutDashbordItems[_currentIndex].name != "自定义") { + if (_controller.text.length == 0 && model.cashOutDashbordItems[_currentIndex].name != "自定义") { _controller.text = model.cashOutDashbordItems[0].value; } return GridView.builder( @@ -293,17 +268,11 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { }, child: Container( decoration: BoxDecoration( - color: index == _currentIndex - ? HexColor.fromHex( - model.cashOutDashbordItemsSelectedBgColor ?? '') - : HexColor.fromHex( - model.cashOutDashbordItemsUnselectedBgColor ?? ''), + color: + index == _currentIndex ? HexColor.fromHex(model.cashOutDashbordItemsSelectedBgColor ?? '') : HexColor.fromHex(model.cashOutDashbordItemsUnselectedBgColor ?? ''), borderRadius: BorderRadius.circular(5), border: Border.all( - color: index == _currentIndex - ? HexColor.fromHex( - model.cashOutDashbordItemsSelectedColor ?? '') - : HexColor.fromHex('#d2d2d2'), + color: index == _currentIndex ? HexColor.fromHex(model.cashOutDashbordItemsSelectedColor ?? '') : HexColor.fromHex('#d2d2d2'), ), ), child: Center( @@ -311,11 +280,8 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { item.name, style: TextStyle( fontSize: 14, - color: index == _currentIndex - ? HexColor.fromHex( - model.cashOutDashbordItemsSelectedColor ?? '') - : HexColor.fromHex( - model.cashOutDashbordItemsUnselectedColor ?? ''), + color: + index == _currentIndex ? HexColor.fromHex(model.cashOutDashbordItemsSelectedColor ?? '') : HexColor.fromHex(model.cashOutDashbordItemsUnselectedColor ?? ''), ), ), ), @@ -365,8 +331,7 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { onChanged: (value) { _checkSubmit(value); }, - placeholderStyle: - TextStyle(fontSize: 26, color: Colors.grey[400]), + placeholderStyle: TextStyle(fontSize: 26, color: Colors.grey[400]), ), ), Container( @@ -397,12 +362,8 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { // } try { var currentWithdraw = num.tryParse(_controller.text); - var finValue = num.tryParse(_bloc.withdrawDataModel.finValue); - if (currentWithdraw != null && - currentWithdraw != 0 && - finValue != null && - finValue != 0 && - currentWithdraw <= finValue) { + var finValue = num.tryParse(_bloc.withdrawDataModel?.finValue??"0"); + if (currentWithdraw != null && currentWithdraw != 0 && finValue != null && finValue != 0 && currentWithdraw <= finValue) { _submitable = true; } else { _submitable = false; @@ -413,18 +374,32 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { } return GestureDetector( - onTap: () { + onTap: () async { + ///提现 if (_submitable) { + if (_bloc?.withdrawDataModel != null && _bloc?.withdrawDataModel?.isBindAlipay == "0") { + var result = await showDialog( + context: context, + child: TipDialog( + content: "请绑定支付宝", + btnText: "前往绑定支付宝", + )); + if (result != null && result) { + var param = {'status': _bloc.aliPayModel, Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, 'data': _bloc.aliPayModel}; + RouterUtil.route(model.gotoAliPay, {'status': _bloc.aliPayModel, Constants.SkipIdentifierName: model.gotoAliPay.skipIdentifier, 'data': param}, context).then((value) { + reload(); + }); + } + return; + } _bloc.submitApply(context, _controller.text); } }, child: Container( height: 50, decoration: BoxDecoration( - color: _submitable - ? HexColor.fromHex(model.cashOutBtnTextAvailableBgColor ?? '') - : HexColor.fromHex(model.cashOutBtnTextUnavailableBgColor ?? ''), + color: _submitable ? HexColor.fromHex(model.cashOutBtnTextAvailableBgColor ?? '') : HexColor.fromHex(model.cashOutBtnTextUnavailableBgColor ?? ''), borderRadius: BorderRadius.circular(7.5), ), child: Center( @@ -432,10 +407,7 @@ class _WithdrawContainerState extends State<_WithdrawContainer> { model.cashOutBtnText ?? '', style: TextStyle( fontSize: 15, - color: _submitable - ? HexColor.fromHex(model.cashOutBtnTextAvailableColor ?? '') - : HexColor.fromHex( - model.cashOutBtnTextUnavailableColor ?? ''), + color: _submitable ? HexColor.fromHex(model.cashOutBtnTextAvailableColor ?? '') : HexColor.fromHex(model.cashOutBtnTextUnavailableColor ?? ''), ), ), ), diff --git a/lib/register.dart b/lib/register.dart index 80e9ae8..f777e6b 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:flutter_user_agent/flutter_user_agent.dart'; import 'package:jdsdk/jdsdk.dart'; import 'package:sharesdk_plugin/sharesdk_interface.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart'; @@ -69,6 +70,7 @@ import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart' import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income.dart'; import 'package:zhiying_base_widget/widgets/wallet_bil_detail/wallet_bil_detail.dart'; +import 'package:zhiying_base_widget/zhiying_base_widget.dart'; import 'package:zhiying_comm/util/defalut_widget_creater.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -132,6 +134,13 @@ class BaseWidgetRegister { Jdsdk.init(appKey: config.keys?.jdAndroid?.appkey ?? '', appSecret: config.keys?.jdAndroid?.secret ?? ''); } SharesdkPlugin.regist(register); + + ///微信支付初始化 + registerWxApi(appId: config?.keys?.weixin?.appId, universalLink: config?.keys?.weixin?.universalLink); + + ///高德定位注册 + AMapFlutterLocation.setApiKey(config?.keys?.gd?.androidKey ?? "", config?.keys?.gd?.iosKey); + }); // MOB 秒验 @@ -155,6 +164,9 @@ class BaseWidgetRegister { // // 考拉 // NetUtil.post('/api/v1/rec/kaola?page=1', method: NetMethod.GET, cache: true, showToast: false); LoginStyleUtil.fetchNetPageData(); + + FlutterUserAgent.init(force: true); + return null; }); @@ -200,7 +212,6 @@ class BaseWidgetRegister { /// 反馈列表页 PageFactory.regist('pub.flutter.feedback_list', (model) => FeedbackRecordPage(model)); - /// 提现页 PageFactory.regist('pub.flutter.cash_out', (model) => WithdrawPage(model)); diff --git a/lib/widgets/custom/multi_nav/custom_quick_entry.dart b/lib/widgets/custom/multi_nav/custom_quick_entry.dart index 8b7144c..d4560d9 100644 --- a/lib/widgets/custom/multi_nav/custom_quick_entry.dart +++ b/lib/widgets/custom/multi_nav/custom_quick_entry.dart @@ -420,7 +420,9 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: () => _itemIconClick(item), + onTap: () { + _itemIconClick(item); + }, child: Container( height: itemHeight, width: 60, @@ -648,7 +650,7 @@ class _CustomQuickCateEntryState extends State with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController tabController; - PrimaryPageController primaryPageController; + bool isOnTap = false; @@ -660,7 +662,7 @@ class _CustomQuickCateEntryState extends State @override void initState() { - // primaryPageController = PrimaryPageController(keepPage: true); + if (widget?.model != null) { tabController = TabController(length: widget?.model?.typeList?.length ?? 0, vsync: this); @@ -668,25 +670,15 @@ class _CustomQuickCateEntryState extends State } _controller = SwiperController(); - // primaryPageController.addListener(() { - // if (isOnTap) { - // return; - // } - // if ((primaryPageController.page - tabController.index).abs() > 0.9) { - // tabController.animateTo(primaryPageController.page.floor()); - // } - // }); + super.initState(); } @override void dispose() { tabController?.dispose(); - primaryPageController?.dispose(); - for (var item in widget.model?.typeList) { - item.primaryPageController?.dispose(); - item.primaryPageController = null; - } + + _controller?.dispose(); super.dispose(); } @@ -709,9 +701,7 @@ class _CustomQuickCateEntryState extends State if (model.typeList != null) { for (var item in model?.typeList) { item.listStyle = List(); - if (item.primaryPageController == null) { - item.primaryPageController = PrimaryPageController(keepPage: true); - } + for (var listItem in model?.listStyle) { if (listItem?.typeListKey == item.key) { item.listStyle.add(listItem); @@ -1041,7 +1031,7 @@ class _CustomQuickCateEntryState extends State // 当前元素的下表 = 当前的列数 + 当前的行数 * 列数 + 当前的页数 * 当前的行数 + 当前的列数 int currentIndex = currentColum + currentRow * columSize; - print("当前页" + currentPage.toString() + "当前点" + currentIndex.toString()); + //print("当前页" + currentPage.toString() + "当前点" + currentIndex.toString()); // print('current Index sss = $currentIndex'); if (currentIndex >= totalDataSize) { diff --git a/lib/widgets/custom/multi_nav/model/custom_quick_entry_model.dart b/lib/widgets/custom/multi_nav/model/custom_quick_entry_model.dart index 5c453d9..c4cb398 100644 --- a/lib/widgets/custom/multi_nav/model/custom_quick_entry_model.dart +++ b/lib/widgets/custom/multi_nav/model/custom_quick_entry_model.dart @@ -153,6 +153,7 @@ class ListStyle extends SkipModel{ String requiredTaobaoAuth; String skipIdentifier; + ListStyle( {this.img, this.title, @@ -173,6 +174,7 @@ class ListStyle extends SkipModel{ requiredLogin = json['required_login']; requiredTaobaoAuth = json['required_taobao_auth']; skipIdentifier = json['skip_identifier']; + } Map toJson() { @@ -185,6 +187,7 @@ class ListStyle extends SkipModel{ data['required_login'] = this.requiredLogin; data['required_taobao_auth'] = this.requiredTaobaoAuth; data['skip_identifier'] = this.skipIdentifier; + return data; } } diff --git a/lib/widgets/custom/notice/custom_notice_widget.dart b/lib/widgets/custom/notice/custom_notice_widget.dart index 2e2ddd8..140acc1 100644 --- a/lib/widgets/custom/notice/custom_notice_widget.dart +++ b/lib/widgets/custom/notice/custom_notice_widget.dart @@ -18,7 +18,9 @@ class CustomNoticeWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => CustomNoticeBloc(repository: CustomNoticeRepository())..add(CustomNoticeInitEvent(model: model)), + create: (_) => + CustomNoticeBloc(repository: CustomNoticeRepository()) + ..add(CustomNoticeInitEvent(model: model)), child: _CustomNoticeWidgetContainer(), ); } @@ -79,9 +81,9 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain top: ParseUtil.stringParseDouble(model?.topMargin), left: ParseUtil.stringParseDouble(model?.leftRightMargin), right: ParseUtil.stringParseDouble(model?.leftRightMargin)), - padding: EdgeInsets.symmetric(horizontal:7.5, vertical: 7.5), + padding: EdgeInsets.symmetric(horizontal: 7.5, vertical: 7.5), child: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(model?.outsideBgColor??'#F6F6F6')), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(model?.outsideBgColor ?? '#F6F6F6')), padding: const EdgeInsets.only(top: 8, bottom: 8, left: 12, right: 8), width: double.infinity, child: _getChildWidget(model), @@ -97,6 +99,7 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain behavior: HitTestBehavior.opaque, child: Row( children: [ + /// 图片 // Container(width: 52, height: 13, color: Colors.red), CachedNetworkImage( @@ -114,7 +117,7 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain // color: Colors.yellowAccent, child: MarqueeWidget( model?.listStyle?.length ?? 0, - (BuildContext context, int index) { + (BuildContext context, int index) { NoticeListStyle item = model.listStyle[index]; return Align(alignment: Alignment.centerLeft, child: Text('${item?.contentText}', style: TextStyle(color: HexColor.fromHex(model?.textColor), fontSize: 12))); }, @@ -161,10 +164,14 @@ class _MarqueeWidgetState extends State { _controller = PageController(); _timer = Timer.periodic(Duration(seconds: 5), (timer) { // 如果当前位于最后一页,则直接跳转到第一页,两者内容相同,跳转时视觉上无感知 - if (_controller.page.round() >= widget.count) { - _controller.jumpToPage(0); + try { + if (_controller.page.round() >= widget.count) { + _controller.jumpToPage(0); + } + _controller.nextPage(duration: Duration(seconds: 1), curve: Curves.linear); + } catch (e){ + _timer?.cancel(); } - _controller.nextPage(duration: Duration(seconds: 1), curve: Curves.linear); }); } } diff --git a/lib/widgets/custom/slide_banner/custom_slide_banner.dart b/lib/widgets/custom/slide_banner/custom_slide_banner.dart index d66d587..edd097e 100644 --- a/lib/widgets/custom/slide_banner/custom_slide_banner.dart +++ b/lib/widgets/custom/slide_banner/custom_slide_banner.dart @@ -56,6 +56,7 @@ class _CustomSlideBannerContainerState extends State @override void dispose() { + _swiperController.stopAutoplay(); _swiperController?.dispose(); super.dispose(); } diff --git a/lib/widgets/home/home_goods/models/home_goods_list_style_model.dart b/lib/widgets/home/home_goods/models/home_goods_list_style_model.dart index af660f6..b63ded9 100644 --- a/lib/widgets/home/home_goods/models/home_goods_list_style_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_list_style_model.dart @@ -33,7 +33,7 @@ class HomeGoodsListStyleModel { }); HomeGoodsListStyleModel.fromJson(Map json) { - hotRankIconList = json['hot_rank_icon_list'].cast(); + hotRankIconList = json['hot_rank_icon_list']. cast(); topMargin = json['top_margin']; listColumn = json['list_column']; leftRighMargin = json['left_righ_margin']; diff --git a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart index 5eb4ab3..755e9a1 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_bloc.dart @@ -23,6 +23,8 @@ class HotRankingListBloc extends BlocBase { bool isLoading = false; + bool isFirst=true; + @override void dispose() { _dataController.close(); @@ -35,6 +37,11 @@ class HotRankingListBloc extends BlocBase { // return; // } // isLoading = true; + if(isFirst){ + isFirst=false; + await Future.delayed(Duration(milliseconds: 300)); + } + currentTypeId = typeId; NetUtil.request('/api/v1/rec?pvd=taobao&category_id=' + typeId + '&page=' + page.toString(), method: NetMethod.GET, onCache: (data) { complete(); diff --git a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list_sk.dart b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list_sk.dart index fb0b167..2cef462 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list_sk.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list_sk.dart @@ -10,13 +10,13 @@ class HotRankingSkeleton extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container( - width: double.infinity, - margin: EdgeInsets.all(16), - height: 48, - child: Row( - children: _buildTopRow(), - )), + // Container( + // width: double.infinity, + // margin: EdgeInsets.all(16), + // height: 48, + // child: Row( + // children: _buildTopRow(), + // )), Expanded( child: Container( child: Column( @@ -30,7 +30,7 @@ class HotRankingSkeleton extends StatelessWidget { _buildBottomListItem() { List listWidget = List(); - for (var index = 0; index < 3; index++) { + for (var index = 0; index < 10; index++) { listWidget.add(Container( margin: EdgeInsets.only(left: 16,top: 10,bottom: 10), child: Row( diff --git a/lib/widgets/restart_widget/restart_widget.dart b/lib/widgets/restart_widget/restart_widget.dart new file mode 100644 index 0000000..26a6a92 --- /dev/null +++ b/lib/widgets/restart_widget/restart_widget.dart @@ -0,0 +1,91 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class RestartWidget extends StatefulWidget { + RestartWidget({this.child}); + + final Widget child; + + static void restartApp(BuildContext context) { + //查找顶层_RestartWidgetState并重启 + context.findAncestorStateOfType<_RestartWidgetState>().restartApp(); + } + + @override + _RestartWidgetState createState() => _RestartWidgetState(); +} + +class _RestartWidgetState extends State { + bool reStart = false; + + int com = 0; + Timer timer1; + Timer timer2; + + StreamController streamController=StreamController(); + + Stream outData; + + bool isFirst=true; + + void restartApp() async { + + if (reStart) { + return; + } + + com++; + + ///刷新3次后不再刷新 + if (com > 3) { + if (com < 7) { + Fluttertoast.showToast(msg: "网络服务不可用"); + } + return; + } + + Loading.show(context, msg: "更新数据中..."); + + streamController.add(null); + + timer1 = Timer(Duration(milliseconds: 1000), () async { + print("重启"); + streamController.add("restart"); + }); + timer2 = Timer(Duration(milliseconds: 1500), () { + Loading.dismiss(); + }); + } + + @override + void initState() { + outData=streamController.stream; + super.initState(); + } + + @override + Widget build(BuildContext context) { + + return StreamBuilder(stream: outData,builder: (context,asyn){ + if(asyn.data==null&&!isFirst){ + return Scaffold( + body: Container(), + ); + }else{ + isFirst=false; + return widget?.child; + } + }); + + } + + @override + void dispose() { + timer1?.cancel(); + timer2?.cancel(); + super.dispose(); + } +} diff --git a/lib/widgets/search/history_tag/search_history_tag.dart b/lib/widgets/search/history_tag/search_history_tag.dart index 08f7349..41a7204 100644 --- a/lib/widgets/search/history_tag/search_history_tag.dart +++ b/lib/widgets/search/history_tag/search_history_tag.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:flutter/cupertino.dart'; @@ -7,6 +8,7 @@ import 'package:zhiying_base_widget/pages/search_page/notifier/search_tag_notifi import 'package:zhiying_base_widget/pages/search_result_page/search_result_page.dart'; import 'package:zhiying_base_widget/pages/search_think_page/model/search_think_model.dart'; import 'package:zhiying_base_widget/widgets/search/history_tag/model/search_history_model.dart'; +import 'package:zhiying_base_widget/widgets/search/input/model/search_tab_bar_event.dart'; import 'package:zhiying_base_widget/widgets/search/widget/text_tag_widget.dart'; import 'package:zhiying_base_widget/widgets/search/widget/title_widget.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -39,15 +41,18 @@ class _SearchHistoryTagWidgetState extends State { /// 最大存储条数 static final int MAX_COUNT = 10; + String type; + + StreamSubscription subscription; + /// 点击历史标签 void _historyTagClick(String tag) { if (!EmptyUtil.isEmpty(tag)) { SearchThinkModel model = SearchThinkModel(); - model.type = (Provider.of(context, listen: false)?.getType()) ?? GlobalConfig.PROVIDER_TB; + model.type = type ?? GlobalConfig.PROVIDER_TB; model.keywords = tag ?? ''; Provider.of(context, listen: false).addTag(tag); - Navigator.push( - context, CupertinoPageRoute(builder: (_) => SearchResultPage(model.toJson()..['tag'] = 'search_page'))); + Navigator.push(context, CupertinoPageRoute(builder: (_) => SearchResultPage(model.toJson()..['tag'] = 'search_page'))); // Navigator.push( // context, CupertinoPageRoute(builder: (_) => SearchResultPage({'keywords': tag ?? '', 'tag': 'search_page'}))); } @@ -96,6 +101,9 @@ class _SearchHistoryTagWidgetState extends State { @override void initState() { + subscription = EventUtil.instance.on().listen((event) { + type = event.type; + }); _initHistoryTag(); super.initState(); } @@ -111,6 +119,12 @@ class _SearchHistoryTagWidgetState extends State { super.didChangeDependencies(); } + @override + void dispose() { + subscription?.cancel(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Container( diff --git a/lib/widgets/search/hot_tag/search_hot_tag_widget.dart b/lib/widgets/search/hot_tag/search_hot_tag_widget.dart index 5705d39..3c50515 100644 --- a/lib/widgets/search/hot_tag/search_hot_tag_widget.dart +++ b/lib/widgets/search/hot_tag/search_hot_tag_widget.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:flutter/cupertino.dart'; @@ -6,6 +7,7 @@ import 'package:zhiying_base_widget/pages/search_page/notifier/search_tag_notifi import 'package:zhiying_base_widget/pages/search_result_page/search_result_page.dart'; import 'package:zhiying_base_widget/pages/search_think_page/model/search_think_model.dart'; import 'package:zhiying_base_widget/widgets/search/hot_tag/model/search_hot_tag_model.dart'; +import 'package:zhiying_base_widget/widgets/search/input/model/search_tab_bar_event.dart'; import 'package:zhiying_base_widget/widgets/search/widget/text_tag_widget.dart'; import 'package:zhiying_base_widget/widgets/search/widget/title_widget.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -14,7 +16,8 @@ import 'package:provider/provider.dart'; /// /// 搜索页面,热门搜索的标签 /// -class SearchHotTagWidget extends StatelessWidget { + +class SearchHotTagWidget extends StatefulWidget { final Map data; SearchHotTagModel model; @@ -26,18 +29,42 @@ class SearchHotTagWidget extends StatelessWidget { } } + @override + _SearchHotTagWidgetState createState() => _SearchHotTagWidgetState(); +} + +class _SearchHotTagWidgetState extends State { + Map data; + SearchHotTagModel model; + String type; + StreamSubscription subscription; + + @override + void initState() { + data = widget?.data; + model = widget?.model; + subscription = EventUtil.instance.on().listen((event) { + type = event.type; + }); + super.initState(); + } + + @override + void dispose() { + subscription?.cancel(); + super.dispose(); + } + /// 点击事件 void _tagOnClick(BuildContext context, SearchHostTagItemModel model) async { print('${model?.keyword}'); if (!EmptyUtil.isEmpty(model?.keyword)) { - Provider.of(context, listen: false).addTag(model.keyword); SearchThinkModel searchThinkModel = SearchThinkModel(); - searchThinkModel.type = (Provider.of(context, listen: false)?.getType()) ?? GlobalConfig.PROVIDER_TB; + searchThinkModel.type = type ?? GlobalConfig.PROVIDER_TB; searchThinkModel.keywords = model?.keyword ?? ''; - Navigator.push( - context, CupertinoPageRoute(builder: (_) => SearchResultPage(searchThinkModel.toJson()..['tag'] = 'search_page'))); + Navigator.push(context, CupertinoPageRoute(builder: (_) => SearchResultPage(searchThinkModel.toJson()..['tag'] = 'search_page'))); // Navigator.push(context, CupertinoPageRoute(builder: (_) => SearchResultPage({'keywords': model?.keyword ?? '', 'tag': 'search_page'}))); } } diff --git a/lib/widgets/search/input/model/search_tab_bar_event.dart b/lib/widgets/search/input/model/search_tab_bar_event.dart new file mode 100644 index 0000000..f18e22e --- /dev/null +++ b/lib/widgets/search/input/model/search_tab_bar_event.dart @@ -0,0 +1,7 @@ + +///用于搜索第一页的tabbar事件 +class SearchTabBarEvent{ + final String type; + + SearchTabBarEvent(this.type); +} \ No newline at end of file diff --git a/lib/widgets/search/input/search_input_widget.dart b/lib/widgets/search/input/search_input_widget.dart index 606c211..6925384 100644 --- a/lib/widgets/search/input/search_input_widget.dart +++ b/lib/widgets/search/input/search_input_widget.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:ui'; @@ -12,6 +13,7 @@ import 'package:zhiying_base_widget/pages/search_result_page/search_result_page. import 'package:zhiying_base_widget/pages/search_think_page/bloc/search_think_bloc.dart'; import 'package:zhiying_base_widget/pages/search_think_page/model/search_think_model.dart'; import 'package:zhiying_base_widget/pages/search_think_page/search_think_page.dart'; +import 'package:zhiying_base_widget/widgets/search/input/model/search_tab_bar_event.dart'; import 'package:zhiying_base_widget/widgets/search/input/model/search_input_model.dart'; import 'package:zhiying_base_widget/widgets/search/input/search_input_sk.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -38,6 +40,8 @@ class SearchInputWidget extends StatefulWidget { class _SearchInputWidgetState extends State { FocusNode _focusNode; TextEditingController _editingController; + String type; + StreamSubscription subscription; /// 点击搜索按钮 void _onSearchButtomClick() async { @@ -48,10 +52,10 @@ class _SearchInputWidgetState extends State { Provider.of(context, listen: false).addTag(content); RouterUtil.hideKeyboard(context); SearchThinkModel searchThinkModel = SearchThinkModel(); - searchThinkModel.type = (Provider.of(context, listen: false)?.getType()) ?? GlobalConfig.PROVIDER_TB; + + searchThinkModel.type = type ?? GlobalConfig.PROVIDER_TB; searchThinkModel.keywords = content ?? ''; - Navigator.push( - context, CupertinoPageRoute(builder: (_) => SearchResultPage(searchThinkModel.toJson()..['tag'] = 'search_page'))); + Navigator.push(context, CupertinoPageRoute(builder: (_) => SearchResultPage(searchThinkModel.toJson()..['tag'] = 'search_page'))); // Navigator.push(context, CupertinoPageRoute(builder: (_) => SearchResultPage({'keywords': content, 'tag': 'search_page'}))); } else { @@ -89,6 +93,9 @@ class _SearchInputWidgetState extends State { void initState() { _focusNode = FocusNode(); _editingController = TextEditingController(); + subscription = EventUtil.instance.on().listen((event) { + type = event.type; + }); super.initState(); } @@ -97,6 +104,7 @@ class _SearchInputWidgetState extends State { _focusNode?.unfocus(); _focusNode?.dispose(); _editingController?.dispose(); + subscription?.cancel(); super.dispose(); } diff --git a/lib/widgets/search/tabbar/search_tab_widget.dart b/lib/widgets/search/tabbar/search_tab_widget.dart index 4d48a29..3386f46 100644 --- a/lib/widgets/search/tabbar/search_tab_widget.dart +++ b/lib/widgets/search/tabbar/search_tab_widget.dart @@ -10,6 +10,7 @@ import 'package:zhiying_base_widget/pages/search_result_page/search_result_page. import 'package:zhiying_base_widget/pages/search_think_page/bloc/search_think_bloc.dart'; import 'package:zhiying_base_widget/pages/search_think_page/model/search_think_model.dart'; import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:zhiying_base_widget/widgets/search/input/model/search_tab_bar_event.dart'; import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_sk.dart'; import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -63,6 +64,7 @@ class _SearchTabWidgetState extends State { try { _type = widget.model.search_icon_list[_tabController.index].type; Provider.of(context, listen: false).setType(_type); + EventUtil.instance.fire(SearchTabBarEvent(_type)); } catch (e, s) { Logger.error(e, s); } diff --git a/lib/widgets/search_result/search_input/search_result_input.dart b/lib/widgets/search_result/search_input/search_result_input.dart index 3210746..33493df 100644 --- a/lib/widgets/search_result/search_input/search_result_input.dart +++ b/lib/widgets/search_result/search_input/search_result_input.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:flutter/cupertino.dart'; @@ -7,6 +8,7 @@ import 'package:zhiying_base_widget/pages/search_result_page/search_result_page. import 'package:zhiying_base_widget/pages/search_think_page/bloc/search_think_bloc.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/widgets/search_result/search_input/model/search_result_input_model.dart'; +import 'package:zhiying_base_widget/widgets/search_result/tarbar/model/search_btn_event.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'dart:ui'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -35,6 +37,12 @@ class _SearchResultInputWidgetState extends State { FocusNode _focusNode; bool _canSearchTag = true; + StreamSubscription subscription; + + String lastText; + + String _type; + /// 返回事件 void _openPop() { Navigator.maybePop(context); @@ -44,57 +52,68 @@ class _SearchResultInputWidgetState extends State { void _onSearchButtomClick() { print('搜索商品'); RouterUtil.hideKeyboard(context); + /// 搜索 - if(!_canSearchTag){ + if (!_canSearchTag) { BlocProvider.of(context).add(SearchThinkShowBaseViewEvent()); } + if(_canSearchTag){ + _onSearchInputSubmit(); + } } /// 搜索事件 - void _onSearchInputSubmit(){ - + void _onSearchInputSubmit() { String text = _textEditingController?.text?.toString()?.trim(); if(!EmptyUtil.isEmpty(text)) { Provider.of(context, listen: false).addTag(text); RouterUtil.hideKeyboard(context); // TODO ❌ 如果使用咸鱼,则这里需要改成 push Navigator.pushReplacement(context, CupertinoPageRoute( - builder: (_) => SearchResultPage({'keywords':text}), + builder: (_) => SearchResultPage({'keywords':text,'type':_type}), //SearchResultPage(model.toJson()..['tag'] = 'search_page') )); } } /// 输入变化 - void _onChanged(String text){ + void _onChanged(String text) { Logger.log('onChanged input text = $text'); - if(!EmptyUtil.isEmpty(text)){ + if (!EmptyUtil.isEmpty(text)) { BlocProvider.of(context).add(SearchThinkKeyWrodsChangeEvent(text)); - }else{ + } else { BlocProvider.of(context).add(SearchThinkShowBaseViewEvent()); } } - @override void initState() { _textEditingController = TextEditingController(text: widget?.model?.keywords ?? ''); - _focusNode = FocusNode()..addListener(() { - bool hasFocus = _focusNode?.hasFocus ?? false; - Logger.log('onInputClick input onTap = $hasFocus'); - if(hasFocus){ + lastText = _textEditingController.text; + if(widget?.data.containsKey('type')){ + _type=widget?.data['type']; + } + + _focusNode = FocusNode() + ..addListener(() { + bool hasFocus = _focusNode?.hasFocus ?? false; + Logger.log('onInputClick input onTap = $hasFocus'); + if (hasFocus) { String text = _textEditingController?.text?.toString()?.trim(); - if(!EmptyUtil.isEmpty(text)){ + if (!EmptyUtil.isEmpty(text)) { BlocProvider.of(context).add(SearchThinkKeyWrodsChangeEvent(text)); } setState(() { _canSearchTag = false; }); - }else{ + } else { setState(() { - _canSearchTag =true; + _canSearchTag = true; }); - } + } + }); + subscription = EventUtil.instance.on().listen((event) { + _type=event.type; }); super.initState(); } @@ -104,10 +123,10 @@ class _SearchResultInputWidgetState extends State { _focusNode?.unfocus(); _focusNode?.dispose(); _textEditingController?.dispose(); + subscription?.cancel(); super.dispose(); } - @override Widget build(BuildContext context) { return Container( @@ -143,7 +162,6 @@ class _SearchResultInputWidgetState extends State { Icons.arrow_back_ios, size: 22, color: HexColor.fromHex('#000000'), - ), onPressed: () => _openPop(), ); @@ -151,9 +169,10 @@ class _SearchResultInputWidgetState extends State { /// 搜索按钮 Widget _createSubmitButtomWidget(SearchResultInputModel model) { + return GestureDetector( behavior: HitTestBehavior.opaque, - onTap: ()=> _onSearchButtomClick(), + onTap: () => _onSearchButtomClick(), child: Container( alignment: Alignment.center, padding: const EdgeInsets.only( @@ -163,7 +182,8 @@ class _SearchResultInputWidgetState extends State { ), child: Text( _canSearchTag ? model?.search_button ?? '搜索' : '取消', - style: TextStyle(fontSize: 14, color: HexColor.fromHex(_canSearchTag ?model?.search_button_color : '#999999'), fontWeight: _canSearchTag? FontWeight.bold : FontWeight.normal), + style: TextStyle( + fontSize: 14, color: HexColor.fromHex(_canSearchTag ? model?.search_button_color : '#999999'), fontWeight: _canSearchTag ? FontWeight.bold : FontWeight.normal), ), ), ); @@ -196,7 +216,7 @@ class _SearchResultInputWidgetState extends State { contentPadding: EdgeInsets.zero, // contentPadding: const EdgeInsets.only(left: 0, right: 0,top: 0 ,bottom: 12), // focusColor: Colors.transparent, - fillColor: Colors.transparent, + fillColor: Colors.transparent, border: InputBorder.none, focusedBorder: InputBorder.none, focusedErrorBorder: InputBorder.none, @@ -210,5 +230,4 @@ class _SearchResultInputWidgetState extends State { ), ); } - } diff --git a/lib/widgets/search_result/tarbar/model/search_btn_event.dart b/lib/widgets/search_result/tarbar/model/search_btn_event.dart new file mode 100644 index 0000000..c915644 --- /dev/null +++ b/lib/widgets/search_result/tarbar/model/search_btn_event.dart @@ -0,0 +1,8 @@ + + +///点击tabBar时的类型传递 +class SearchBtnEvent{ + final String type; + + SearchBtnEvent(this.type); +} \ No newline at end of file diff --git a/lib/widgets/search_result/tarbar/search_result_tab_widget.dart b/lib/widgets/search_result/tarbar/search_result_tab_widget.dart index 34e1338..1c53749 100644 --- a/lib/widgets/search_result/tarbar/search_result_tab_widget.dart +++ b/lib/widgets/search_result/tarbar/search_result_tab_widget.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:event_bus/event_bus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -14,6 +15,7 @@ import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_sk.dart'; import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart'; import 'package:provider/provider.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:zhiying_base_widget/widgets/search_result/tarbar/model/search_btn_event.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -66,6 +68,9 @@ class _SearchResultTabWidgetState extends State { } } }catch(_){} + Future.delayed(Duration(milliseconds: 10),(){ + EventUtil.instance.fire(SearchBtnEvent(_type)); + }); _tabController = TabController(length: length, vsync: ScrollableState(), initialIndex: initIndex) ..addListener(() { try{ @@ -75,6 +80,7 @@ class _SearchResultTabWidgetState extends State { }catch(e, s){ Logger.error(e, s); } + EventUtil.instance.fire(SearchBtnEvent(_type)); }); diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index 992bc51..18402f7 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -270,9 +270,9 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { } else { var type = SSDKContentTypes.auto; - if (widget?.model?.image?.first != null && widget.model?.url != null) { + if (widget?.model?.image?.length != 0 && widget.model?.url != null) { type = SSDKContentTypes.webpage; - } else if (widget?.model?.image?.first != null) { + } else if (widget?.model?.image?.length != 0) { type = SSDKContentTypes.image; } else if (widget?.model?.title != null || widget.model?.content != null) { type = SSDKContentTypes.text; @@ -282,12 +282,18 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { type = SSDKContentTypes.message; } + var isExistImage = false; + + if (widget?.model?.image != null && widget?.model?.image?.length > 0) { + isExistImage = true; + } + params = SSDKMap() ..setGeneral( widget.model?.title ?? '', widget?.model?.content ?? '', Platform.isIOS ? widget.model.image : null, - Platform.isAndroid ? widget?.model?.image?.first : null, + Platform.isAndroid ? (isExistImage ? widget?.model?.image?.first : null) : null, null, widget.model.url, null, diff --git a/lib/widgets/share/share_alert_select.dart b/lib/widgets/share/share_alert_select.dart index beffe8a..754b42a 100644 --- a/lib/widgets/share/share_alert_select.dart +++ b/lib/widgets/share/share_alert_select.dart @@ -34,9 +34,7 @@ class ShareAlertSelect extends StatefulWidget { final bool isPicShow; final ShareSelectPicModel selectPicModel; - const ShareAlertSelect(this.model, this.skipIdentifier, - {Key key, this.isContentShow = false, this.selectPicModel, this.isPicShow}) - : super(key: key); // 中间视图 + const ShareAlertSelect(this.model, this.skipIdentifier, {Key key, this.isContentShow = false, this.selectPicModel, this.isPicShow}) : super(key: key); // 中间视图 @override _ShareAlertSelectState createState() => _ShareAlertSelectState(); @@ -48,10 +46,11 @@ class _ShareAlertSelectState extends State { ShareSelectPicModel selectPicModel; GlobalKey _globalKey = GlobalKey(); + List tempPoster; + @override void initState() { - NetUtil.request('/api/v1/mod/${widget.skipIdentifier}', method: NetMethod.GET, - onCache: (data) { + NetUtil.request('/api/v1/mod/${widget.skipIdentifier}', method: NetMethod.GET, onCache: (data) { // try{ // _parseData(data); // }catch(e){ @@ -76,8 +75,7 @@ class _ShareAlertSelectState extends State { Map d = modList.first; if (d != null) { String dString = d['data']; - _iconModel = - ShareAlertModel.fromJson(Map.from(jsonDecode(dString))); + _iconModel = ShareAlertModel.fromJson(Map.from(jsonDecode(dString))); setState(() {}); } @@ -89,8 +87,15 @@ class _ShareAlertSelectState extends State { for (int i = 0; i < picList.length; i++) { if (picList[i].select) { if (i == 0) { - ShareDataModel shareDataModel = await _updateModel(_globalKey); - model.poster = shareDataModel.poster; + if (tempPoster == null) { + Loading.show(context); + ShareDataModel shareDataModel = await _updateModel(_globalKey); + tempPoster = shareDataModel.poster; + model.poster = shareDataModel.poster; + Loading.dismiss(); + } else { + model.poster = tempPoster; + } } else { model.image.add(picList[i].pic); } @@ -105,11 +110,13 @@ class _ShareAlertSelectState extends State { BuildContext buildContext = _globalKey.currentContext; if (null != buildContext) { RenderRepaintBoundary boundary = buildContext.findRenderObject(); + ///pixelRatio是放大倍数 - ui.Image image = await boundary.toImage(pixelRatio: 1); + ui.Image image = await boundary.toImage(pixelRatio: 5); // 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); Uint8List pngBytes = byteData.buffer.asUint8List(); + _shareModel.poster = pngBytes; } else { _shareModel.poster = null; @@ -181,8 +188,7 @@ class _ShareAlertSelectState extends State { right: 15, child: GestureDetector( onTap: () { - selectPicModel.picList[index].select = - !selectPicModel.picList[index].select; + selectPicModel.picList[index].select = !selectPicModel.picList[index].select; setState(() {}); _selectPic(selectPicModel.picList, index); }, @@ -190,9 +196,7 @@ class _ShareAlertSelectState extends State { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), - color: selectPicModel.picList[index].select - ? Colors.red - : Colors.grey, + color: selectPicModel.picList[index].select ? Colors.red : Colors.grey, ), child: Icon( CupertinoIcons.check_mark, @@ -211,8 +215,7 @@ class _ShareAlertSelectState extends State { ), ) : Container(), - _ShareAlertContent( - widget.model, widget.skipIdentifier, _iconModel, isPicShow), + _ShareAlertContent(widget.model, widget.skipIdentifier, _iconModel, isPicShow), ], ), ), // 模糊化 @@ -232,10 +235,7 @@ class _ShareAlertContent extends StatefulWidget { final ShareAlertModel iconModel; final bool isSelectPic; - const _ShareAlertContent( - this.model, this.skipIdentifier, this.iconModel, this.isSelectPic, - {Key key}) - : super(key: key); + const _ShareAlertContent(this.model, this.skipIdentifier, this.iconModel, this.isSelectPic, {Key key}) : super(key: key); @override _ShareAlertContentState createState() => _ShareAlertContentState(); @@ -294,13 +294,11 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { margin: EdgeInsets.only(top: 8, bottom: 8), width: 62, height: 4, - decoration: BoxDecoration( - color: Color(0xffd8d8d8), borderRadius: BorderRadius.circular(2)), + decoration: BoxDecoration(color: Color(0xffd8d8d8), borderRadius: BorderRadius.circular(2)), ), Text( '分享至', - style: TextStyle( - fontSize: 15, color: Color(0xff333333), fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 15, color: Color(0xff333333), fontWeight: FontWeight.bold), ), Container( margin: EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), @@ -310,15 +308,11 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { child: Container( margin: EdgeInsets.only(left: 12, right: 12, bottom: 10), padding: EdgeInsets.all(12), - decoration: BoxDecoration( - color: Color(0xfff3f3f3), borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration(color: Color(0xfff3f3f3), borderRadius: BorderRadius.circular(8)), child: Center( child: Text( '取消', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Color(0xff999999)), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: Color(0xff999999)), ), ), ), @@ -346,85 +340,91 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { Widget _createIcon(ShareIconModel item) { return GestureDetector( - child: Container( - width: 60, - child: Column( - children: [ - Container( - width: 40, - height: 40, - child: CachedNetworkImage( - imageUrl: item.icon, - fit: BoxFit.contain, + child: Container( + width: 60, + child: Column( + children: [ + Container( + width: 40, + height: 40, + child: CachedNetworkImage( + imageUrl: item.icon, + fit: BoxFit.contain, + ), ), - ), - Padding( - padding: const EdgeInsets.only(top: 2, bottom: 2), - child: Text( - item.name, - style: TextStyle( - fontSize: 12, color: Color(0xff333333), fontWeight: FontWeight.bold), + Padding( + padding: const EdgeInsets.only(top: 2, bottom: 2), + child: Text( + item.name, + style: TextStyle(fontSize: 12, color: Color(0xff333333), fontWeight: FontWeight.bold), + ), ), - ), - ], + ], + ), ), - ), - onTap: () async { - //检查是否有存储权限 - var status = await Permission.storage.status; - if (!status.isGranted) { - status = await Permission.storage.request(); - print(status); - return; - } - - int count = 0; - if (_shareDataModel.poster != null) { - count++; - } - count += (_shareDataModel?.image?.length ?? 0); - // 多图分享 - if (count > 1) { - _shareMultipleImages(item.type); - return; - } - - - if (item.type == 'wx') { - _shareByMob(ShareSDKPlatforms.wechatSession); - } else if (item.type == 'pyq') { - _shareByMob(ShareSDKPlatforms.wechatTimeline); - } else if (item.type == 'qq') { - _shareByMob(ShareSDKPlatforms.qq); - } else if (item.type == 'qq_space') { - _shareByMob(ShareSDKPlatforms.qZone); - } else if (item.type == 'weibo') { - _shareByMob(ShareSDKPlatforms.sina); - } else if (item.type == 'more_setting') { - _shareBySystem(item.type); - } - }, - ); + onTap: () async { + //检查是否有存储权限 + var status = await Permission.storage.status; + if (!status.isGranted) { + status = await Permission.storage.request(); + print(status); + return; + } + + Loading.show(context); + + ///检查是否选中图片 + if (_shareDataModel?.poster == null && (_shareDataModel?.image == null || _shareDataModel?.image?.length == 0)) { + Fluttertoast.showToast(msg: "请选择需要分享的图片"); + Loading.dismiss(); + return; + } + + if (_shareDataModel?.poster != null) { + File file = await EncodeUtil.compressImage(context, images: _shareDataModel?.poster, size: 400); + _shareDataModel.poster = file.readAsBytesSync(); + Loading.dismiss(); + } + + int count = 0; + if (_shareDataModel.poster != null) { + count++; + } + count += (_shareDataModel?.image?.length ?? 0); + // 多图分享 + if (count > 1) { + _shareMultipleImages(item.type); + return; + } + + if (item.type == 'wx') { + _shareByMob(ShareSDKPlatforms.wechatSession); + } else if (item.type == 'pyq') { + _shareByMob(ShareSDKPlatforms.wechatTimeline); + } else if (item.type == 'qq') { + _shareByMob(ShareSDKPlatforms.qq); + } else if (item.type == 'qq_space') { + _shareByMob(ShareSDKPlatforms.qZone); + } else if (item.type == 'weibo') { + _shareByMob(ShareSDKPlatforms.sina); + } else if (item.type == 'more_setting') { + _shareBySystem(item.type); + } + }); } - // mob分享,只能单图分享,多图分享调用系统分享 +// mob分享,只能单图分享,多图分享调用系统分享 void _shareByMob(ShareSDKPlatform plateform) async { - if (isSelectPic && - EmptyUtil.isEmpty(_shareDataModel) && - EmptyUtil.isEmpty(_shareDataModel?.poster) && - EmptyUtil.isEmpty(_shareDataModel?.image)) { + if (isSelectPic && EmptyUtil.isEmpty(_shareDataModel) && EmptyUtil.isEmpty(_shareDataModel?.poster) && EmptyUtil.isEmpty(_shareDataModel?.image)) { Fluttertoast.showToast(msg: '请选择分享图片'); return; } - Loading.show(context); Timer(Duration(milliseconds: 2000), () { Loading.dismiss(); }); - - SSDKMap params; if (_shareDataModel.poster != null) { String path = await _savePoster(); @@ -488,12 +488,9 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { }); } - // 系统分享,只能分享图片或者文字,不能组合分享 +// 系统分享,只能分享图片或者文字,不能组合分享 void _shareBySystem(String type) async { - if (isSelectPic && - EmptyUtil.isEmpty(_shareDataModel) && - EmptyUtil.isEmpty(_shareDataModel?.poster) && - EmptyUtil.isEmpty(_shareDataModel?.image)) { + if (isSelectPic && EmptyUtil.isEmpty(_shareDataModel) && EmptyUtil.isEmpty(_shareDataModel?.poster) && EmptyUtil.isEmpty(_shareDataModel?.image)) { Fluttertoast.showToast(msg: '请选择分享图片'); return; } @@ -517,7 +514,6 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { } else { ShareExtend.share(_shareDataModel.content, 'text'); } - } Future _savePoster() async { @@ -550,7 +546,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { return path; } - // 多图分享,调用系统分享 +// 多图分享,调用系统分享 void _shareMultipleImages(String type) async { List paths = List(); String path = await _savePoster(); diff --git a/lib/zhiying_base_widget.dart b/lib/zhiying_base_widget.dart index 3dfc1e8..cb7fe3b 100644 --- a/lib/zhiying_base_widget.dart +++ b/lib/zhiying_base_widget.dart @@ -4,4 +4,8 @@ export 'dialog/loading/loading.dart'; export 'package:flutter_swiper/flutter_swiper.dart'; export 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart'; -export 'package:pull_to_refresh/pull_to_refresh.dart'; \ No newline at end of file +export 'package:pull_to_refresh/pull_to_refresh.dart'; +export 'package:flutter_user_agent/flutter_user_agent.dart'; +export 'package:zhiying_base_widget/widgets/restart_widget/restart_widget.dart'; +export 'package:amap_flutter_location/amap_flutter_location.dart'; +export 'package:amap_flutter_location/amap_location_option.dart'; \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 0a40247..a427a60 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,6 @@ dependencies: # 列表滑动删除 flutter_slidable: 0.5.7 # image_gallery_saver: ^1.6.0 - permission_handler: git: ref: 0.0.1 @@ -52,10 +51,16 @@ dependencies: loading_indicator: ^1.2.0 + #高德定位 + amap_flutter_location: ^1.0.1 + + mobpush_plugin: plugin_platform_interface: ^1.0.1 permission_handler_platform_interface: ^2.0.1 + flutter_user_agent: ^1.2.2 + dev_dependencies: @@ -65,7 +70,6 @@ dev_dependencies: zhiying_comm: path: ../zhiying_comm - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec