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 4496333..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/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..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): @@ -127,6 +135,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): @@ -182,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`) @@ -189,6 +200,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`) @@ -203,6 +215,9 @@ SPEC REPOS: - AgoraRtcEngine_iOS - AMapFoundation - AMapLocation + - BSGridCollectionViewLayout + - BSImagePicker + - BSImageView - Bugly - FBSDKCoreKit - FBSDKLoginKit @@ -284,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: @@ -298,6 +315,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: @@ -326,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 @@ -362,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 @@ -370,6 +393,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..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 = ( @@ -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/ChatPage.dart b/lib/chat/ChatPage.dart index 4b442c8..0da9f09 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==null ||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 4f06c4a..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), @@ -629,7 +631,7 @@ class _ChatPageItemState extends State List actions = [ I18n.of(context).delete, I18n.of(context).reply, - I18n.of(context).forward + ]; actionsFunc.add(() { @@ -639,10 +641,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) { @@ -1016,22 +1033,30 @@ 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(); - 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..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 { @@ -178,7 +213,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..cdcface 100644 --- a/lib/chat/full_img_view.dart +++ b/lib/chat/full_img_view.dart @@ -56,7 +56,9 @@ class _PhotoPageState extends State Widget build(BuildContext context) { Uint8List fileData; if (widget.msg.localFile != null) { + fileData = File(widget.msg.localFile).readAsBytesSync(); +// print('本地了${fileData.lengthInBytes}'); } else { fileData = Uint8List.fromList(widget.msg.msgContent); } @@ -99,15 +101,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..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), @@ -574,7 +575,6 @@ class _GroupChatPageItemState extends State List actionsFunc = []; List actions = [ I18n.of(context).reply, - I18n.of(context).forward, I18n.of(context).delete, ]; @@ -582,16 +582,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) { @@ -1033,24 +1042,31 @@ 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(); - 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/group_chat_view.dart b/lib/chat/group_chat_view.dart index bb42964..ef5d1cc 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==null ||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/chat/input_bar.dart b/lib/chat/input_bar.dart index a222ba9..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); +// } +// } + ///防止再点键盘不谈 } @@ -732,8 +765,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(); diff --git a/lib/home/AddProgram.dart b/lib/home/AddProgram.dart index cc618f7..ec6a174 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": 7, "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": 7, "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/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/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/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'); 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..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" @@ -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: