From cc936648dc53f9e5b2e814b3eb8fe1814b71dd13 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 09:24:40 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8F=91=E9=80=81?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Flutter/flutter_export_environment.sh | 4 +-- ios/Podfile.lock | 6 ++++ ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/chat/ChatPageItem.dart | 33 +++++++++++++-------- lib/chat/company_server_view.dart | 2 +- lib/chat/download_item.dart | 6 ++-- lib/chat/full_img_view.dart | 7 +++-- lib/chat/group_chat_item.dart | 36 +++++++++++++---------- lib/chat/input_bar.dart | 4 +-- lib/chat/util_keyboard.dart | 2 +- 10 files changed, 63 insertions(+), 39 deletions(-) diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index 4496333..ff59f0b 100755 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -1,8 +1,8 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. export "FLUTTER_ROOT=/Users/random/sdk/flutter_sdk" -export "FLUTTER_APPLICATION_PATH=/Users/random/code/flutter/project/qunliao" -export "FLUTTER_TARGET=/Users/random/code/flutter/project/qunliao/lib/main.dart" +export "FLUTTER_APPLICATION_PATH=/Users/random/code/flutter/project/Hibok" +export "FLUTTER_TARGET=/Users/random/code/flutter/project/Hibok/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios" diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7e8bdbd..ebd70eb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -127,6 +127,8 @@ PODS: - Flutter - share (0.5.2): - Flutter + - share_extend (0.0.1): + - Flutter - shared_preferences (0.0.1): - Flutter - shared_preferences_macos (0.0.1): @@ -189,6 +191,7 @@ DEPENDENCIES: - photo_manager (from `.symlinks/plugins/photo_manager/ios`) - receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`) - share (from `.symlinks/plugins/share/ios`) + - share_extend (from `.symlinks/plugins/share_extend/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) @@ -298,6 +301,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/receive_sharing_intent/ios" share: :path: ".symlinks/plugins/share/ios" + share_extend: + :path: ".symlinks/plugins/share_extend/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" shared_preferences_macos: @@ -370,6 +375,7 @@ SPEC CHECKSUMS: Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1 share: bae0a282aab4483288913fc4dc0b935d4b491f2e + share_extend: b6748dc53695587891126a89533b862b92548c7b shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01 shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6a452f2..6ce8972 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -778,7 +778,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 12; - DEVELOPMENT_TEAM = QJ9M3998Q6; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index 4f06c4a..6e75478 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -1019,19 +1019,26 @@ class _ChatPageItemState extends State ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); var imgSize = _getImgSize(); - return GestureDetector( - child: Container( - width: imgSize.width, - height: imgSize.height, - child: ClipRRect( - child: Image( - image: provider ?? AssetImage(R.assetsImagesIcAlbum), - ), - borderRadius: BorderRadius.circular(5), - )), - onTap: () async { - showFullImg(context, widget.msg); - }); + + return DownloadItem( + isAutoDown: false, + msg: widget.msg, + onFinishTap: (){ + widget.hideKeyboard(); + showFullImg(context, widget.msg); + }, + child: Container( + width: imgSize.width, + height: imgSize.height, + child: ClipRRect( + child: Image( + image: provider ?? AssetImage(R.assetsImagesIcAlbum), + ), + borderRadius: BorderRadius.circular(5), + ), + ), + ); + } _receiveVideo(BuildContext context, List imgData, diff --git a/lib/chat/company_server_view.dart b/lib/chat/company_server_view.dart index 7a59cec..1915b01 100644 --- a/lib/chat/company_server_view.dart +++ b/lib/chat/company_server_view.dart @@ -178,7 +178,7 @@ class _CompanyServerPageState extends State { if (imgSize > ImgSizeLimit) { print('图片大于 $ImgSizeLimit,压缩'); //发送压缩图 - sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path); + sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path ); isNeedUpload = true; } else { sendImg = imgFile.readAsBytesSync(); diff --git a/lib/chat/download_item.dart b/lib/chat/download_item.dart index f05a832..44297da 100644 --- a/lib/chat/download_item.dart +++ b/lib/chat/download_item.dart @@ -12,12 +12,14 @@ class DownloadItem extends StatefulWidget { final bool isShowProgress; final bool isAutoDown; final Function onComplete; + final Function onFinishTap; DownloadItem( {this.msg, this.child, this.isShowProgress = true, this.isAutoDown = true, - this.onComplete}); + this.onComplete, + this.onFinishTap}); @override _DownloadItemState createState() => _DownloadItemState(); } @@ -129,7 +131,7 @@ class _DownloadItemState extends State { (widget.msg.state != MsgState.Downloading && widget.msg.state != MsgState.DownloadSuccess); return InkWell( - onTap: isNeedDown ? downloadRes : null, + onTap: isNeedDown ? downloadRes : widget.onFinishTap, child: Stack( alignment: Alignment.center, children: [widget.child, _downloadWidget()], diff --git a/lib/chat/full_img_view.dart b/lib/chat/full_img_view.dart index ed6e04a..d4cd273 100644 --- a/lib/chat/full_img_view.dart +++ b/lib/chat/full_img_view.dart @@ -56,6 +56,7 @@ class _PhotoPageState extends State Widget build(BuildContext context) { Uint8List fileData; if (widget.msg.localFile != null) { + print('本地了'); fileData = File(widget.msg.localFile).readAsBytesSync(); } else { fileData = Uint8List.fromList(widget.msg.msgContent); @@ -99,15 +100,17 @@ class _PhotoPageState extends State Positioned( right: 10, bottom: 10, - child: InkWell( + child: Material(child: InkWell( onTap: saveToGallery, child: Container( + width: 50, + height: 50, padding: EdgeInsets.all(5), decoration: BoxDecoration( color: Colors.grey.withAlpha(150), borderRadius: BorderRadius.circular(8)), child: Icon(Icons.save_alt, color: Colors.white70), - ))) + )),)) ], ))); } diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 5f3eda9..01f630d 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -1036,21 +1036,27 @@ class _GroupChatPageItemState extends State ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); var imgSize = _getImgSize(); - return GestureDetector( - child: Container( - alignment: Alignment.centerLeft, - width: imgSize.width, - height: imgSize.height, - child: ClipRRect( - child: Image( - image: provider ?? AssetImage(R.assetsImagesIcAlbum), - ), - borderRadius: BorderRadius.circular(5), - )), - onTap: () async { - widget.hideKeyboard(); - showFullImg(context, widget.msg); - }); + + return DownloadItem( + isAutoDown: false, + msg: widget.msg, + onFinishTap: (){ + widget.hideKeyboard(); + showFullImg(context, widget.msg); + }, + child: Container( + alignment: Alignment.centerLeft, + width: imgSize.width, + height: imgSize.height, + child: ClipRRect( + child: Image( + image: provider ?? AssetImage(R.assetsImagesIcAlbum), + ), + borderRadius: BorderRadius.circular(5), + ), + ), + ); + } _receiveVideo(BuildContext context, List imgData, diff --git a/lib/chat/input_bar.dart b/lib/chat/input_bar.dart index a222ba9..5904532 100644 --- a/lib/chat/input_bar.dart +++ b/lib/chat/input_bar.dart @@ -732,8 +732,8 @@ class InputBarState extends State bool isNeedUpload = false; if (imgSize > ImgSizeLimit) { print('图片大于 $ImgSizeLimit,压缩'); - //发送压缩图 - sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path); + //发送压缩图 WidgetUtil.getCompressImg(path,quality: 80,percentage: 80); + sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path ); isNeedUpload = true; } else { sendImg = imgFile.readAsBytesSync(); diff --git a/lib/chat/util_keyboard.dart b/lib/chat/util_keyboard.dart index 94b843f..698ecdc 100644 --- a/lib/chat/util_keyboard.dart +++ b/lib/chat/util_keyboard.dart @@ -392,7 +392,7 @@ class _UtilKeyboardState extends State { File file =await FileCacheMgr().writeFile(DateTime.now().millisecondsSinceEpoch.toString(),thumbnail); File compressedFile = await FlutterNativeImage.compressImage(file.path, - quality: 20, percentage: 10); + quality: 30, percentage: 40); thumbnail =compressedFile.readAsBytesSync().toList(); From 56446a560a1a05bffa7bbd796eb6ee407d644a24 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 14:44:34 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flutter-plugins-dependencies | 2 +- android/app/build.gradle | 12 ++-- android/build.gradle | 3 + ios/Flutter/flutter_export_environment.sh | 4 +- ios/Podfile.lock | 18 +++++ ios/Runner.xcodeproj/project.pbxproj | 4 +- lib/chat/company_server_view.dart | 57 ++++++++++++--- lib/chat/input_bar.dart | 55 ++++++++++++--- lib/home/AddProgram.dart | 86 +++++++++++++++++------ lib/home/InformUser.dart | 62 +++++++++++++--- lib/utils/file_cache_mgr.dart | 4 +- lib/utils/image_util.dart | 5 ++ pubspec.lock | 7 ++ pubspec.yaml | 5 +- 14 files changed, 257 insertions(+), 67 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 51117eb..0eafb9d 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"agora_rtc_engine","dependencies":[]},{"name":"amap_location","dependencies":[]},{"name":"android_intent","dependencies":[]},{"name":"app_installer","dependencies":[]},{"name":"apple_sign_in","dependencies":[]},{"name":"audioplayer","dependencies":[]},{"name":"auto_orientation","dependencies":[]},{"name":"city_pickers","dependencies":[]},{"name":"connectivity","dependencies":[]},{"name":"easy_contact_picker","dependencies":[]},{"name":"file_picker","dependencies":[]},{"name":"flutter_app_badger","dependencies":[]},{"name":"flutter_audio_recorder","dependencies":[]},{"name":"flutter_bugly","dependencies":[]},{"name":"flutter_facebook_login","dependencies":[]},{"name":"flutter_ijkplayer","dependencies":[]},{"name":"flutter_inapp_purchase","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_native_image","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_qr_reader","dependencies":["image_picker"]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"fluwx_no_pay","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"google_maps_flutter","dependencies":[]},{"name":"image_cropper","dependencies":[]},{"name":"image_gallery_saver","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"jpush_flutter","dependencies":[]},{"name":"keyboard_utils","dependencies":[]},{"name":"location","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"open_file","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"receive_sharing_intent","dependencies":[]},{"name":"share","dependencies":[]},{"name":"share_extend","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"video_thumbnail","dependencies":[]},{"name":"wifi_info_plugin","dependencies":[]}]} \ No newline at end of file +{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"agora_rtc_engine","dependencies":[]},{"name":"amap_location","dependencies":[]},{"name":"android_intent","dependencies":[]},{"name":"app_installer","dependencies":[]},{"name":"apple_sign_in","dependencies":[]},{"name":"audioplayer","dependencies":[]},{"name":"auto_orientation","dependencies":[]},{"name":"city_pickers","dependencies":[]},{"name":"connectivity","dependencies":[]},{"name":"easy_contact_picker","dependencies":[]},{"name":"file_picker","dependencies":[]},{"name":"flutter_app_badger","dependencies":[]},{"name":"flutter_audio_recorder","dependencies":[]},{"name":"flutter_bugly","dependencies":[]},{"name":"flutter_facebook_login","dependencies":[]},{"name":"flutter_ijkplayer","dependencies":[]},{"name":"flutter_inapp_purchase","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_native_image","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_qr_reader","dependencies":["image_picker"]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"fluwx_no_pay","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"google_maps_flutter","dependencies":[]},{"name":"image_cropper","dependencies":[]},{"name":"image_gallery_saver","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"jpush_flutter","dependencies":[]},{"name":"keyboard_utils","dependencies":[]},{"name":"location","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"multi_image_picker","dependencies":[]},{"name":"open_file","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"receive_sharing_intent","dependencies":[]},{"name":"share","dependencies":[]},{"name":"share_extend","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"video_thumbnail","dependencies":[]},{"name":"wifi_info_plugin","dependencies":[]}]} \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index d004d6d..0bfc4ad 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -56,9 +56,9 @@ android { // manifestPlaceholders = [ // AMAP_KEY : "1fd4e93e3b4b13747da41f484c955fe2", /// 高德地图key // ] - // ndk { - // abiFilters 'armeabi-v7a' - // } +// ndk { +// abiFilters 'armeabi-v7a' +// } multiDexEnabled true manifestPlaceholders = [ JPUSH_PKGNAME : 'com.cyhd.henhoandroid', @@ -108,6 +108,11 @@ flutter { } subprojects { + if (project.hasProperty("android")) { + android { + compileSdkVersion 28 + } + } project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' @@ -125,7 +130,6 @@ subprojects { dependencies { - testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/android/build.gradle b/android/build.gradle index eb74505..460483d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -68,6 +68,9 @@ subprojects { if (details.requested.group == 'androidx.annotation') { details.useVersion "1.1.0" } + if (details.requested.group == 'androidx.cardview') { + details.useVersion "1.0.0" + } } diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index ff59f0b..a011c3d 100755 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -1,8 +1,8 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. export "FLUTTER_ROOT=/Users/random/sdk/flutter_sdk" -export "FLUTTER_APPLICATION_PATH=/Users/random/code/flutter/project/Hibok" -export "FLUTTER_TARGET=/Users/random/code/flutter/project/Hibok/lib/main.dart" +export "FLUTTER_APPLICATION_PATH=/Users/random/code/flutter/project/hibok" +export "FLUTTER_TARGET=/Users/random/code/flutter/project/hibok/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios" diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ebd70eb..37831be 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -19,6 +19,11 @@ PODS: - Flutter - auto_orientation (0.0.1): - Flutter + - BSGridCollectionViewLayout (1.2.5) + - BSImagePicker (2.10.3): + - BSGridCollectionViewLayout (= 1.2.5) + - BSImageView (= 1.0.3) + - BSImageView (1.0.3) - Bugly (2.5.2) - city_pickers (0.0.1): - Flutter @@ -112,6 +117,9 @@ PODS: - Flutter - location_permissions (2.0.3): - Flutter + - multi_image_picker (4.6.4): + - BSImagePicker (~> 2.10.3) + - Flutter - open_file (0.0.1): - Flutter - package_info (0.0.1): @@ -184,6 +192,7 @@ DEPENDENCIES: - keyboard_utils (from `.symlinks/plugins/keyboard_utils/ios`) - location (from `.symlinks/plugins/location/ios`) - location_permissions (from `.symlinks/plugins/location_permissions/ios`) + - multi_image_picker (from `.symlinks/plugins/multi_image_picker/ios`) - open_file (from `.symlinks/plugins/open_file/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) @@ -206,6 +215,9 @@ SPEC REPOS: - AgoraRtcEngine_iOS - AMapFoundation - AMapLocation + - BSGridCollectionViewLayout + - BSImagePicker + - BSImageView - Bugly - FBSDKCoreKit - FBSDKLoginKit @@ -287,6 +299,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/location/ios" location_permissions: :path: ".symlinks/plugins/location_permissions/ios" + multi_image_picker: + :path: ".symlinks/plugins/multi_image_picker/ios" open_file: :path: ".symlinks/plugins/open_file/ios" package_info: @@ -331,6 +345,9 @@ SPEC CHECKSUMS: apple_sign_in: 7716c7ddfa195aeab7dec0dc374ef4ff45d1adb4 audioplayer: f4462b84216b9c55f02bbbdc7ab60eec7427b2d4 auto_orientation: 2941c44ebe5c3d41016001597ab03e81a92a26ce + BSGridCollectionViewLayout: 333dcb457a5a3bdd9212607ab5756553dcfe06cb + BSImagePicker: 07404254f2fcdaf5a2eb403c0f8c337267ce8738 + BSImageView: a149459433a2687157d034c78e059d30ac7f2544 Bugly: dbac48b55ad469a97cc4321045cd50df8f63d44f city_pickers: b0370f4c35c201723b5b7fcce10ec29b59d5bc35 connectivity: 6e94255659cc86dcbef1d452ad3e0491bb1b3e75 @@ -367,6 +384,7 @@ SPEC CHECKSUMS: libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740 location_permissions: 195ff2a1182fa9029ef3f2653156961ee5a1e40b + multi_image_picker: 1651732277b2db3b09e83f3be8eb7ea65cf2a933 open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d package_info: 48b108e75b8802c2d5e126f208ef540561c98aef path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6ce8972..f018f05 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -244,8 +244,8 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 74E44EF25DBCD813164B0D15 /* [CP] Embed Pods Frameworks */, - 72C47CA77DA3D0C2C0859F91 /* [CP] Copy Pods Resources */, 5C95C0992406514F00CEBCE3 /* Embed App Extensions */, + 3DE22D2D9939DF611C2BA757 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -366,7 +366,7 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; - 72C47CA77DA3D0C2C0859F91 /* [CP] Copy Pods Resources */ = { + 3DE22D2D9939DF611C2BA757 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( diff --git a/lib/chat/company_server_view.dart b/lib/chat/company_server_view.dart index 1915b01..e9b176a 100644 --- a/lib/chat/company_server_view.dart +++ b/lib/chat/company_server_view.dart @@ -13,6 +13,7 @@ import 'package:chat/proto/chat.pb.dart'; import 'package:chat/r.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/image_util.dart'; import 'package:chat/utils/keyboard_utils.dart'; import 'package:chat/utils/msgHandler.dart'; @@ -20,6 +21,7 @@ import 'package:chat/utils/screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:photo_manager/photo_manager.dart'; import 'package:chat/utils/MessageMgr.dart'; @@ -149,19 +151,52 @@ class _CompanyServerPageState extends State { } void _openPhotoView() async { - var photos = await PhotoPicker.pickAsset( - context: context, - themeColor: Color(0xFFF0F0F0), - textColor: Color(0xFF3F3F3F), - pickType: PickType.onlyImage); - - if (photos != null && photos.length > 0) { - for (var i = 0; i < photos.length; i++) { - AssetEntity photoEntity = photos[i]; - var file = await photoEntity.file; - _sendPhotoFile(file); + + List resultList = List(); + try { + resultList = await MultiImagePicker.pickImages( + maxImages: 9, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: false, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + _sendPhotoFile(file); + } } + + + } on Exception catch (e) { + print(e.toString()); } + + + +// var photos = await PhotoPicker.pickAsset( +// context: context, +// themeColor: Color(0xFFF0F0F0), +// textColor: Color(0xFF3F3F3F), +// pickType: PickType.onlyImage); +// +// if (photos != null && photos.length > 0) { +// for (var i = 0; i < photos.length; i++) { +// AssetEntity photoEntity = photos[i]; +// var file = await photoEntity.file; +// _sendPhotoFile(file); +// } +// } } void _sendPhotoFile(File imgFile) async { diff --git a/lib/chat/input_bar.dart b/lib/chat/input_bar.dart index 5904532..6b4205f 100644 --- a/lib/chat/input_bar.dart +++ b/lib/chat/input_bar.dart @@ -18,6 +18,7 @@ import 'package:chat/photo/photo.dart'; import 'package:chat/proto/all.pbserver.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/MessageMgr.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/group_member_model.dart'; import 'package:chat/utils/image_util.dart'; import 'package:chat/utils/keyboard_utils.dart'; @@ -28,6 +29,7 @@ import 'package:extended_text_field/extended_text_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:photo_manager/photo_manager.dart'; import 'package:provider/provider.dart'; @@ -685,20 +687,51 @@ class InputBarState extends State // Provider.of(context, listen: false) // .changeSelectIndex(4); - var photos = await PhotoPicker.pickAsset( - context: context, - themeColor: Color(0xFFF0F0F0), - textColor: Color(0xFF3F3F3F), - pickType: PickType.onlyImage); - - if (photos != null && photos.length > 0) { - for (var i = 0; i < photos.length; i++) { - AssetEntity photoEntity = photos[i]; - var file = await photoEntity.file; - _sendPhotoFile(file); + List resultList = List(); + try { + resultList = await MultiImagePicker.pickImages( + maxImages: 9, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: false, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + _sendPhotoFile(file); + } } + + + } on Exception catch (e) { + print(e.toString()); } + +// var photos = await PhotoPicker.pickAsset( +// context: context, +// themeColor: Color(0xFFF0F0F0), +// textColor: Color(0xFF3F3F3F), +// pickType: PickType.onlyImage); +// +// if (photos != null && photos.length > 0) { +// for (var i = 0; i < photos.length; i++) { +// AssetEntity photoEntity = photos[i]; +// var file = await photoEntity.file; +// _sendPhotoFile(file); +// } +// } + ///防止再点键盘不谈 } diff --git a/lib/home/AddProgram.dart b/lib/home/AddProgram.dart index c443c36..eb860d7 100644 --- a/lib/home/AddProgram.dart +++ b/lib/home/AddProgram.dart @@ -19,6 +19,7 @@ import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/PicSwiper.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/keyboard/bottom_area_avoider.dart'; import 'package:chat/utils/keyboard_utils.dart'; import 'package:chat/utils/screen.dart'; @@ -27,6 +28,7 @@ import 'package:extended_text_field/extended_text_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:photo_manager/photo_manager.dart'; @@ -710,30 +712,68 @@ class _AddProgramState extends State { void _sendPicture() async { closeEmojiAction(); - var photos = await PhotoPicker.pickAsset( - context: context, - themeColor: Color(0xFFF0F0F0), - maxSelected: Max_Img_Num - imgUrlList.length, - textColor: Color(0xFF3F3F3F), - pickType: PickType.onlyImage); - - if (photos != null && photos.length > 0) { - List fileList = []; - for (var i = 0; i < photos.length; i++) { - AssetEntity photoEntity = photos[i]; - fileList.add(await photoEntity.file); - } - Map data = {"type": 3, "userId": UserData().basicInfo.userId}; - data['sign'] = TokenMgr().getSign(data); - Response res = await HttpUtil().uploadFiles( - fileList, data, 'upload/post/postfiles', 'image', - isShowLoading: true); - var resData = res.data; - if (resData['code'] == 0 && resData['msg'] != null) { - imgUrlList.addAll(resData['msg'].split("|")); - setState(() {}); + + List resultList = List(); + + resultList = await MultiImagePicker.pickImages( + maxImages: Max_Img_Num - imgUrlList.length, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: false, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { + List fileList = []; + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + fileList.add(file); + } + Map data = {"type": 3, "userId": UserData().basicInfo.userId}; + data['sign'] = TokenMgr().getSign(data); + Response res = await HttpUtil().uploadFiles( + fileList, data, 'upload/post/postfiles', 'image', + isShowLoading: true); + var resData = res.data; + if (resData['code'] == 0 && resData['msg'] != null) { + imgUrlList.addAll(resData['msg'].split("|")); + setState(() {}); + } } - } + + +// var photos = await PhotoPicker.pickAsset( +// context: context, +// themeColor: Color(0xFFF0F0F0), +// maxSelected: Max_Img_Num - imgUrlList.length, +// textColor: Color(0xFF3F3F3F), +// pickType: PickType.onlyImage); +// +// if (photos != null && photos.length > 0) { +// List fileList = []; +// for (var i = 0; i < photos.length; i++) { +// AssetEntity photoEntity = photos[i]; +// fileList.add(await photoEntity.file); +// } +// Map data = {"type": 3, "userId": UserData().basicInfo.userId}; +// data['sign'] = TokenMgr().getSign(data); +// Response res = await HttpUtil().uploadFiles( +// fileList, data, 'upload/post/postfiles', 'image', +// isShowLoading: true); +// var resData = res.data; +// if (resData['code'] == 0 && resData['msg'] != null) { +// imgUrlList.addAll(resData['msg'].split("|")); +// setState(() {}); +// } +// } } Widget _buildDynicContent() { diff --git a/lib/home/InformUser.dart b/lib/home/InformUser.dart index 10d8487..2d3e746 100644 --- a/lib/home/InformUser.dart +++ b/lib/home/InformUser.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:typed_data'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:chat/data/UserData.dart'; @@ -10,9 +11,11 @@ import 'package:chat/photo/photo.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/PicSwiper.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/screen.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:photo_manager/photo_manager.dart'; @@ -179,18 +182,30 @@ class _InformUserPageState extends State { } void _sendPicture() async { - var photos = await PhotoPicker.pickAsset( - context: context, - themeColor: Color(0xFFF0F0F0), - maxSelected: MaxImgNum - imgUrlList.length, - textColor: Color(0xFF3F3F3F), - pickType: PickType.onlyImage); - if (photos != null && photos.length > 0) { + List resultList = List(); + + resultList = await MultiImagePicker.pickImages( + maxImages: MaxImgNum - imgUrlList.length, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: false, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { List fileList = []; - for (var i = 0; i < photos.length; i++) { - AssetEntity photoEntity = photos[i]; - fileList.add(await photoEntity.file); + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + fileList.add(file); } Map data = {"type": 3, "userId": UserData().basicInfo.userId}; data['sign'] = TokenMgr().getSign(data); @@ -203,6 +218,33 @@ class _InformUserPageState extends State { setState(() {}); } } + + + +// var photos = await PhotoPicker.pickAsset( +// context: context, +// themeColor: Color(0xFFF0F0F0), +// maxSelected: MaxImgNum - imgUrlList.length, +// textColor: Color(0xFF3F3F3F), +// pickType: PickType.onlyImage); +// +// if (photos != null && photos.length > 0) { +// List fileList = []; +// for (var i = 0; i < photos.length; i++) { +// AssetEntity photoEntity = photos[i]; +// fileList.add(await photoEntity.file); +// } +// Map data = {"type": 3, "userId": UserData().basicInfo.userId}; +// data['sign'] = TokenMgr().getSign(data); +// Response res = await HttpUtil().uploadFiles( +// fileList, data, 'upload/post/postfiles', 'image', +// isShowLoading: true); +// var resData = res.data; +// if (resData['code'] == 0 && resData['msg'] != null) { +// imgUrlList.addAll(resData['msg'].split("|")); +// setState(() {}); +// } +// } } Widget _buildRadioButtom(str, radio, callback) { diff --git a/lib/utils/file_cache_mgr.dart b/lib/utils/file_cache_mgr.dart index 43ae94c..cad71a7 100644 --- a/lib/utils/file_cache_mgr.dart +++ b/lib/utils/file_cache_mgr.dart @@ -35,7 +35,7 @@ class FileCacheMgr { return filePath; } - Future writeFile(String fileId, Uint8List fileBytes) async { + Future writeFile(String fileId, fileBytes) async { var path = p.join(await getFilePath(), fileId); print('receive path : $path'); var folder = new File(path).parent; @@ -47,6 +47,8 @@ class FileCacheMgr { return file; } + + Future getFile(String fileId) async { var filePath = p.join(await getFilePath(), fileId); var file = File(filePath); diff --git a/lib/utils/image_util.dart b/lib/utils/image_util.dart index 2f70fac..01fd748 100644 --- a/lib/utils/image_util.dart +++ b/lib/utils/image_util.dart @@ -85,6 +85,11 @@ class WidgetUtil { return k; } + + + + + ///Get the coordinates of the widget on the screen.Widgets must be rendered completely. ///获取widget在屏幕上的坐标,widget必须渲染完成 static Offset getWidgetLocalToGlobal(BuildContext context) { diff --git a/pubspec.lock b/pubspec.lock index 7091cf6..c099b2b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -718,6 +718,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.9.6+3" + multi_image_picker: + dependency: "direct main" + description: + name: multi_image_picker + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.6.4" node_interop: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3b03a7b..bd5e123 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -173,9 +173,10 @@ dependencies: file_picker: ^1.4.3+2 #文件打开 open_file: ^3.0.1 - + #文件分享 share_extend: ^1.1.1 - + #多图片选择 + multi_image_picker: ^4.6.4 dev_dependencies: flutter_test: From e5a9153f745dae2f72c19705808b6db1256c4d59 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 16:02:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=BD=AC=E5=8F=91=E9=94=99=E8=AF=AF/=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=B6=88=E6=81=AF=E8=BD=AC=E5=8F=91/?= =?UTF-8?q?=E6=8F=90=E6=AC=BE=E8=A7=84=E5=88=99=E5=9F=9F=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/chat/ChatPage.dart | 8 +++++++- lib/chat/ChatPageItem.dart | 25 ++++++++++++++++++++----- lib/chat/group_chat_item.dart | 20 ++++++++++++++------ lib/chat/group_chat_view.dart | 8 +++++++- lib/home/MoneyPage.dart | 3 ++- lib/home/service_view.dart | 2 +- lib/utils/HttpUtil.dart | 4 ++-- lib/utils/upload_util.dart | 5 +++++ 8 files changed, 58 insertions(+), 17 deletions(-) diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index 4b442c8..1a33fd9 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'package:chat/utils/upload_util.dart'; import 'package:fixnum/fixnum.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:chat/chat/translate_state.dart'; @@ -215,7 +216,12 @@ class _ChatPageState extends State { MsgModel msg = MsgHandler.createSendMsg( ChatType.valueOf(originMsg.msgType), originMsg.msgContent); msg.extraInfo = originMsg.extraInfo; - msg.extraFile = originMsg.extraFile; + if(originMsg.extraFile.contains('http')){ + msg.extraFile = originMsg.extraFile; + }else{ + msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType); + } + msg.localFile = originMsg.localFile; msg.friendId = widget.friendId; if (msg.localFile != null) { diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index 6e75478..b909cde 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -629,7 +629,7 @@ class _ChatPageItemState extends State List actions = [ I18n.of(context).delete, I18n.of(context).reply, - I18n.of(context).forward + ]; actionsFunc.add(() { @@ -639,10 +639,25 @@ class _ChatPageItemState extends State print('发送引用的消息'); MessageMgr().emit('Reply Select Message', widget.msg); }); - actionsFunc.add(() { - print('转发消息'); - AppNavigator.pushForwardPage(context, widget.msg); - }); + + + ///转发 + if (widget.msg.msgType == ChatType.TextChatType.value|| + widget.msg.msgType == ChatType.ImageChatType.value|| + widget.msg.msgType == ChatType.ShortVideoChatType.value|| + widget.msg.msgType == ChatType.PlaceChatType.value|| + widget.msg.msgType == ChatType.EmoticonType.value|| + widget.msg.msgType == ChatType.FileChatType.value + ){ + actions.add( I18n.of(context).forward); + actionsFunc.add(() { + print('转发消息'); + AppNavigator.pushForwardPage(context, widget.msg); + }); + } + + + if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) { diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 01f630d..72980ee 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -574,7 +574,6 @@ class _GroupChatPageItemState extends State List actionsFunc = []; List actions = [ I18n.of(context).reply, - I18n.of(context).forward, I18n.of(context).delete, ]; @@ -582,16 +581,25 @@ class _GroupChatPageItemState extends State print('发送引用的消息'); MessageMgr().emit('Reply Select Message', widget.msg); }); - actionsFunc.add(() { - print('转发消息'); - AppNavigator.pushForwardPage(context, widget.msg); - }); actionsFunc.add(() { MessageMgr().emit('Delete Select Message', widget.msg); }); - + ///转发 + if (widget.msg.msgType == ChatType.TextChatType.value|| + widget.msg.msgType == ChatType.ImageChatType.value|| + widget.msg.msgType == ChatType.ShortVideoChatType.value|| + widget.msg.msgType == ChatType.PlaceChatType.value|| + widget.msg.msgType == ChatType.EmoticonType.value|| + widget.msg.msgType == ChatType.FileChatType.value + ){ + actions.add( I18n.of(context).forward); + actionsFunc.add(() { + print('转发消息'); + AppNavigator.pushForwardPage(context, widget.msg); + }); + } if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) { diff --git a/lib/chat/group_chat_view.dart b/lib/chat/group_chat_view.dart index bb42964..631d9c7 100644 --- a/lib/chat/group_chat_view.dart +++ b/lib/chat/group_chat_view.dart @@ -23,6 +23,7 @@ import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sound_util.dart'; import 'package:chat/utils/sp_utils.dart'; import 'package:chat/utils/sql_util.dart'; +import 'package:chat/utils/upload_util.dart'; import 'package:extended_text/extended_text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -111,7 +112,12 @@ class _GroupChatPageState extends State { ChatType.valueOf(originMsg.msgType), originMsg.msgContent, channelType: ChatChannelType.Group); msg.extraInfo = originMsg.extraInfo; - msg.extraFile = originMsg.extraFile; +// msg.extraFile = originMsg.extraFile; + if(originMsg.extraFile.contains('http')){ + msg.extraFile = originMsg.extraFile; + }else{ + msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType); + } msg.localFile = originMsg.localFile; if (msg.localFile != null) { msg.state = MsgState.Uploaded; diff --git a/lib/home/MoneyPage.dart b/lib/home/MoneyPage.dart index 3d8500c..ab8f7e8 100644 --- a/lib/home/MoneyPage.dart +++ b/lib/home/MoneyPage.dart @@ -684,9 +684,10 @@ class MoneyPageState extends State ], ), InkWell( + onTap: () { launch( - "https://datasm.chengyouhd.com/zh-CN/Home/WithdrawalRole?language=${UserData().language}"); + "http://datechatagent.chengyouhd.com/zh-CN/Home/WithdrawalRole?language=${UserData().language}"); }, child: Container( margin: EdgeInsets.only(top: 25, bottom: 10, left: 13.5), diff --git a/lib/home/service_view.dart b/lib/home/service_view.dart index 71a54c7..6437f9a 100644 --- a/lib/home/service_view.dart +++ b/lib/home/service_view.dart @@ -31,7 +31,7 @@ class ServiceMsgModel { ServiceMsgModel({this.isMe, this.msg}); } -class ServiceCenterPage extends StatefulWidget { +class ServiceCenterPage extends StatefulWidget { final int questionIndex; ServiceCenterPage({this.questionIndex = -1}); diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index 7661a77..86d44dd 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -44,9 +44,9 @@ class HttpUtil { //static const String BaseUrl = 'http://192.168.0.223:7001/'; //static const String BaseUrl = 'http://192.168.0.207:9080/'; -// static const String BaseUrl = 'http://120.79.107.63:9080/'; + static const String BaseUrl = 'http://120.79.107.63:9080/'; //static const String BaseUrl = 'http://192.168.0.177:9016/'; - static const String BaseUrl = 'https://datasm.chengyouhd.com/'; +// static const String BaseUrl = 'https://datasm.chengyouhd.com/'; static HttpUtil _getInstance() { if (_instance == null) { diff --git a/lib/utils/upload_util.dart b/lib/utils/upload_util.dart index 3580f9c..f6e2a7f 100644 --- a/lib/utils/upload_util.dart +++ b/lib/utils/upload_util.dart @@ -199,7 +199,12 @@ class UploadUtil { Future downloadFile(MsgModel msg, {CancelToken cancelToken}) async { Response response; + + var fullUrl = getFullUrl(msg.extraFile, msg.sessionId, msg.channelType); + if(msg.extraFile.contains('http://')){ + fullUrl = msg.extraFile; + } print('下载文件$fullUrl'); From 3da8a63df260adefdfacade28c96a0ce52be1dca Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 16:07:22 +0800 Subject: [PATCH 4/5] 1 --- lib/chat/ChatPage.dart | 2 +- lib/chat/group_chat_view.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index 1a33fd9..0da9f09 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -216,7 +216,7 @@ class _ChatPageState extends State { MsgModel msg = MsgHandler.createSendMsg( ChatType.valueOf(originMsg.msgType), originMsg.msgContent); msg.extraInfo = originMsg.extraInfo; - if(originMsg.extraFile.contains('http')){ + if(originMsg.extraFile==null ||originMsg.extraFile.contains('http')){ msg.extraFile = originMsg.extraFile; }else{ msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType); diff --git a/lib/chat/group_chat_view.dart b/lib/chat/group_chat_view.dart index 631d9c7..ef5d1cc 100644 --- a/lib/chat/group_chat_view.dart +++ b/lib/chat/group_chat_view.dart @@ -113,7 +113,7 @@ class _GroupChatPageState extends State { channelType: ChatChannelType.Group); msg.extraInfo = originMsg.extraInfo; // msg.extraFile = originMsg.extraFile; - if(originMsg.extraFile.contains('http')){ + if(originMsg.extraFile==null ||originMsg.extraFile.contains('http')){ msg.extraFile = originMsg.extraFile; }else{ msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType); From 0f936a46bf5d5cc932150274ddca7a029f807722 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 16:49:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=9C=89=E5=8E=9F=E5=9B=BE=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=B8=85=E6=99=B0=E5=8E=9F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/chat/ChatPageItem.dart | 7 +++++-- lib/chat/full_img_view.dart | 3 ++- lib/chat/group_chat_item.dart | 6 ++++-- lib/utils/HttpUtil.dart | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index b909cde..40237c0 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; @@ -483,6 +484,7 @@ class _ChatPageItemState extends State _imgMsg(List imgData) { var imgSize = _getImgSize(); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); return GestureDetector( child: ClipRRect( @@ -494,7 +496,7 @@ class _ChatPageItemState extends State width: imgSize.width, child: Image( fit: BoxFit.contain, - image: MemoryImage(Uint8List.fromList(imgData)), + image: provider, ), )), borderRadius: BorderRadius.circular(5), @@ -1031,7 +1033,8 @@ class _ChatPageItemState extends State } _receiveImg(BuildContext context, List imgData, {String downloadData}) { - ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); + + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); var imgSize = _getImgSize(); diff --git a/lib/chat/full_img_view.dart b/lib/chat/full_img_view.dart index d4cd273..cdcface 100644 --- a/lib/chat/full_img_view.dart +++ b/lib/chat/full_img_view.dart @@ -56,8 +56,9 @@ class _PhotoPageState extends State Widget build(BuildContext context) { Uint8List fileData; if (widget.msg.localFile != null) { - print('本地了'); + fileData = File(widget.msg.localFile).readAsBytesSync(); +// print('本地了${fileData.lengthInBytes}'); } else { fileData = Uint8List.fromList(widget.msg.msgContent); } diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 72980ee..42799d8 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -472,6 +472,7 @@ class _GroupChatPageItemState extends State _imgMsg(List imgData) { var imgSize = _getImgSize(); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); return GestureDetector( child: ClipRRect( @@ -483,7 +484,7 @@ class _GroupChatPageItemState extends State width: imgSize.width, child: Image( fit: BoxFit.contain, - image: MemoryImage(Uint8List.fromList(imgData)), + image:provider, ), )), borderRadius: BorderRadius.circular(5), @@ -1041,7 +1042,8 @@ class _GroupChatPageItemState extends State } _receiveImg(BuildContext context, List imgData, {String downloadData}) { - ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); +// ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); var imgSize = _getImgSize(); diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index 86d44dd..7661a77 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -44,9 +44,9 @@ class HttpUtil { //static const String BaseUrl = 'http://192.168.0.223:7001/'; //static const String BaseUrl = 'http://192.168.0.207:9080/'; - static const String BaseUrl = 'http://120.79.107.63:9080/'; +// static const String BaseUrl = 'http://120.79.107.63:9080/'; //static const String BaseUrl = 'http://192.168.0.177:9016/'; -// static const String BaseUrl = 'https://datasm.chengyouhd.com/'; + static const String BaseUrl = 'https://datasm.chengyouhd.com/'; static HttpUtil _getInstance() { if (_instance == null) { diff --git a/pubspec.yaml b/pubspec.yaml index bd5e123..a421854 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: chat description: A new Flutter project. #修改版本号后get-clean -version: 1.0.5+6 +version: 1.0.9+13 environment: sdk: ">=2.1.0 <3.0.0"