main
王亚玲 11 months ago
parent 0118b90b5e
commit 1f008cfaec

@ -794,7 +794,7 @@ class _ChatKFPageState extends State<ChatKFPage>
} }
}); });
}, },
decoration: InputDecoration.collapsed(hintText: "输入内容..."), decoration: InputDecoration.collapsed(hintText: "输入内容...",hintStyle:TextStyle(color:Colors.grey.shade500) ),
controller: _textController, controller: _textController,
onSubmitted: _handleSubmitted, onSubmitted: _handleSubmitted,
), ),
@ -1289,7 +1289,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,), //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,),
Text( Text(
'允许访问相册图片上传图片', '允许访问相册图片上传图片',
style: TextStyle(color: Color(0xFF666666), fontSize: 14.rsp), style: TextStyle(color: Color(0xFF666666), fontSize: 14),
), ),
], ],
), ),
@ -1441,6 +1441,37 @@ class _ChatKFPageState extends State<ChatKFPage>
// //
Future<void> _takeImage() async { Future<void> _takeImage() async {
try { 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( XFile? pickedFile = await _picker.pickImage(
source: ImageSource.camera, maxWidth: 800, imageQuality: 95); source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
// //
@ -1465,6 +1496,39 @@ class _ChatKFPageState extends State<ChatKFPage>
} else { } else {
Fluttertoast.showToast(msg: '未拍照'); Fluttertoast.showToast(msg: '未拍照');
} }
}
},
type: NormalTextDialogType.delete,
),
);
} 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<MessageBloc>(context)
// ..add(UploadImageEvent(filePath: targetPath));
//
BlocProvider.of<MessageBloc>(context)
..add(UploadImageEvent(filePath: pickedFile.path));
} else {
Fluttertoast.showToast(msg: '未拍照');
}
}
} catch (e) { } catch (e) {
BytedeskUtils.printLog('take image error ${e.toString()}'); BytedeskUtils.printLog('take image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片"); Fluttertoast.showToast(msg: "未选取图片");
@ -1476,6 +1540,36 @@ class _ChatKFPageState extends State<ChatKFPage>
// chrome // chrome
Future<void> _pickVideo() async { Future<void> _pickVideo() async {
try { 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.pickVideo( XFile? pickedFile = await _picker.pickVideo(
source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); source: ImageSource.gallery, maxDuration: const Duration(seconds: 10));
@ -1487,6 +1581,31 @@ class _ChatKFPageState extends State<ChatKFPage>
} else { } else {
Fluttertoast.showToast(msg: '未选取视频'); Fluttertoast.showToast(msg: '未选取视频');
} }
}
},
type: NormalTextDialogType.delete,
),
);
} 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<MessageBloc>(context)
..add(UploadVideoEvent(filePath: pickedFile.path));
} else {
Fluttertoast.showToast(msg: '未选取视频');
}
}
} catch (e) { } catch (e) {
BytedeskUtils.printLog('pick video error ${e.toString()}'); BytedeskUtils.printLog('pick video error ${e.toString()}');

@ -1,5 +1,6 @@
// import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; // import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
// //
class ImageChooseWidget extends StatelessWidget { class ImageChooseWidget extends StatelessWidget {
@ -40,6 +41,7 @@ class ImageChooseWidget extends StatelessWidget {
child: Text('立即拍照', child: Text('立即拍照',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: Colors.black
)), )),
), ),
)), )),
@ -63,7 +65,7 @@ class ImageChooseWidget extends StatelessWidget {
vertical: 15.0, vertical: 15.0,
), ),
child: Center( 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, vertical: 15.0,
), ),
child: Center( 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, vertical: 15.0,
), ),
child: Center( 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, vertical: 15.0,
), ),
child: Center( child: Center(
child: Text('取消', style: TextStyle(fontSize: 16)), child: Text('取消', style: TextStyle(fontSize: 16, color: Colors.black)),
), ),
)), )),
), ),

@ -1,6 +1,7 @@
library emoji_picker_flutter; library emoji_picker_flutter;
export './src/category_icons.dart'; export './src/category_icons.dart';
// lib/vendors/emoji_picker_flutter/src/config.dart
export './src/config.dart'; export './src/config.dart';
export './src/emoji.dart'; export './src/emoji.dart';
export './src/emoji_picker.dart'; export './src/emoji_picker.dart';

Loading…
Cancel
Save