|
|
@ -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()}');
|
|
|
|