diff --git a/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart b/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart index 2e9b299..033fc45 100755 --- a/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart +++ b/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart @@ -794,7 +794,7 @@ class _ChatKFPageState extends State } }); }, - decoration: InputDecoration.collapsed(hintText: "输入内容..."), + decoration: InputDecoration.collapsed(hintText: "输入内容...",hintStyle:TextStyle(color:Colors.grey.shade500) ), controller: _textController, onSubmitted: _handleSubmitted, ), @@ -1289,7 +1289,7 @@ class _ChatKFPageState extends State //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,), Text( '允许访问相册图片上传图片', - style: TextStyle(color: Color(0xFF666666), fontSize: 14.rsp), + style: TextStyle(color: Color(0xFF666666), fontSize: 14), ), ], ), @@ -1441,6 +1441,67 @@ class _ChatKFPageState extends State // 拍照 Future _takeImage() async { try { + bool permission = await Permission.camera.isGranted; + if (!permission) { + + Alert.show( + context, + NormalContentDialog( + title: '需要获取相机访问权限', + content: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,), + Text( + '允许访问相机上传图片', + style: TextStyle(color: Color(0xFF666666), fontSize: 14), + ), + ], + ), + items: ["残忍拒绝"], + listener: (index) { + Alert.dismiss(context); + }, + deleteItem: "立即授权", + deleteListener: () async { + Alert.dismiss(context); + + bool canUseCamera = await PermissionTool.haveCameraPermission(); + if (!canUseCamera) { + PermissionTool.showOpenPermissionDialog( + context, "没有相机使用权限,授予相机使用权限后才能上传素材"); + + } else{ + XFile? pickedFile = await _picker.pickImage( + source: ImageSource.camera, maxWidth: 800, imageQuality: 95); + // + if (pickedFile != null) { + BytedeskUtils.printLog('take image path: ${pickedFile.path}'); + // TODO: 将图片显示到对话消息中 + // TODO: 显示处理中loading + // 压缩 + // final dir = await path_provider.getTemporaryDirectory(); + // final targetPath = dir.absolute.path + + // "/" + + // BytedeskUtils.currentTimeMillis().toString() + + // ".jpg"; + // BytedeskUtils.printLog('targetPath: $targetPath'); + // await BytedeskUtils.compressImage(File(pickedFile.path), targetPath); + // // 上传压缩后图片 + // BlocProvider.of(context) + // ..add(UploadImageEvent(filePath: targetPath)); + // + BlocProvider.of(context) + ..add(UploadImageEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未拍照'); + } + } + }, + type: NormalTextDialogType.delete, + ), + ); + } else { XFile? pickedFile = await _picker.pickImage( source: ImageSource.camera, maxWidth: 800, imageQuality: 95); // @@ -1465,6 +1526,9 @@ class _ChatKFPageState extends State } else { Fluttertoast.showToast(msg: '未拍照'); } + } + + } catch (e) { BytedeskUtils.printLog('take image error ${e.toString()}'); Fluttertoast.showToast(msg: "未选取图片"); @@ -1476,18 +1540,73 @@ class _ChatKFPageState extends State // 手机可以播放,但chrome无法播放 Future _pickVideo() async { try { - XFile? pickedFile = await _picker.pickVideo( - source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); - - if (pickedFile != null) { - BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); - // - BlocProvider.of(context) - ..add(UploadVideoEvent(filePath: pickedFile.path)); + bool permission = await Permission.camera.isGranted; + if (!permission) { + Alert.show( + context, + NormalContentDialog( + title: '需要获取相机访问权限', + content: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,), + Text( + '允许访问相机上传图片', + style: TextStyle(color: Color(0xFF666666), fontSize: 14), + ), + ], + ), + items: ["残忍拒绝"], + listener: (index) { + Alert.dismiss(context); + }, + deleteItem: "立即授权", + deleteListener: () async { + Alert.dismiss(context); + + bool canUseCamera = await PermissionTool.haveCameraPermission(); + if (!canUseCamera) { + PermissionTool.showOpenPermissionDialog( + context, "没有相机使用权限,授予相机使用权限后才能上传素材"); + + } else{ + XFile? pickedFile = await _picker.pickVideo( + source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); + + if (pickedFile != null) { + BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); + // + BlocProvider.of(context) + ..add(UploadVideoEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未选取视频'); + } + } + }, + type: NormalTextDialogType.delete, + ), + ); } else { - Fluttertoast.showToast(msg: '未选取视频'); + XFile? pickedFile = await _picker.pickVideo( + source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); + + if (pickedFile != null) { + BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); + // + BlocProvider.of(context) + ..add(UploadVideoEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未选取视频'); + } } + + + + + + + } catch (e) { BytedeskUtils.printLog('pick video error ${e.toString()}'); Fluttertoast.showToast(msg: "未选取视频"); diff --git a/bytedesk_kefu/lib/ui/widget/image_choose_widget.dart b/bytedesk_kefu/lib/ui/widget/image_choose_widget.dart index 7c20af6..830b70e 100755 --- a/bytedesk_kefu/lib/ui/widget/image_choose_widget.dart +++ b/bytedesk_kefu/lib/ui/widget/image_choose_widget.dart @@ -1,5 +1,6 @@ // import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_chat_ui/flutter_chat_ui.dart'; //选择头像底部弹出框 class ImageChooseWidget extends StatelessWidget { @@ -40,6 +41,7 @@ class ImageChooseWidget extends StatelessWidget { child: Text('立即拍照', style: TextStyle( fontSize: 16, + color: Colors.black )), ), )), @@ -63,7 +65,7 @@ class ImageChooseWidget extends StatelessWidget { vertical: 15.0, ), child: Center( - child: Text('从相册选择', style: TextStyle(fontSize: 16)), + child: Text('从相册选择', style: TextStyle(fontSize: 16, color: Colors.black)), ), )), ), @@ -85,7 +87,7 @@ class ImageChooseWidget extends StatelessWidget { vertical: 15.0, ), child: Center( - child: Text('上传视频', style: TextStyle(fontSize: 16)), + child: Text('上传视频', style: TextStyle(fontSize: 16, color: Colors.black)), ), )), ), @@ -107,7 +109,7 @@ class ImageChooseWidget extends StatelessWidget { vertical: 15.0, ), child: Center( - child: Text('录制视频', style: TextStyle(fontSize: 16)), + child: Text('录制视频', style: TextStyle(fontSize: 16, color: Colors.black)), ), )), ), @@ -127,7 +129,7 @@ class ImageChooseWidget extends StatelessWidget { vertical: 15.0, ), child: Center( - child: Text('取消', style: TextStyle(fontSize: 16)), + child: Text('取消', style: TextStyle(fontSize: 16, color: Colors.black)), ), )), ), diff --git a/bytedesk_kefu/lib/vendors/emoji_picker_flutter/emoji_picker_flutter.dart b/bytedesk_kefu/lib/vendors/emoji_picker_flutter/emoji_picker_flutter.dart index 5fba8eb..ba34376 100644 --- a/bytedesk_kefu/lib/vendors/emoji_picker_flutter/emoji_picker_flutter.dart +++ b/bytedesk_kefu/lib/vendors/emoji_picker_flutter/emoji_picker_flutter.dart @@ -1,6 +1,7 @@ library emoji_picker_flutter; export './src/category_icons.dart'; +// lib/vendors/emoji_picker_flutter/src/config.dart export './src/config.dart'; export './src/emoji.dart'; export './src/emoji_picker.dart';