Skip to content

Dev 2.1.0+1 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev_2.1.0+1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sdk_service/wrappers/group_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mixin GroupWrapper on ChatUIKitServiceBase {
onAllGroupMemberMuteStateChanged: onAllGroupMemberMuteStateChanged,
onAllowListAddedFromGroup: onAllowListAddedFromGroup,
onAllowListRemovedFromGroup: onAllowListRemovedFromGroup,
onAnnouncementChangedFromGroup: onAnnouncementChangedFromGroup,
// onAnnouncementChangedFromGroup: onAnnouncementChangedFromGroup,
onAutoAcceptInvitationFromGroup: onAutoAcceptInvitationFromGroup,
onInvitationAcceptedFromGroup: onInvitationAcceptedFromGroup,
onInvitationDeclinedFromGroup: onInvitationDeclinedFromGroup,
Expand Down
4 changes: 2 additions & 2 deletions lib/sdk_service/wrappers/room_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mixin RoomWrapper on ChatUIKitServiceBase {
onAllChatRoomMemberMuteStateChanged,
onAllowListAddedFromChatRoom: onAllowListAddedFromChatRoom,
onAllowListRemovedFromChatRoom: onAllowListRemovedFromChatRoom,
onAnnouncementChangedFromChatRoom: onAnnouncementChangedFromChatRoom,
// onAnnouncementChangedFromChatRoom: onAnnouncementChangedFromChatRoom,
onChatRoomDestroyed: onChatRoomDestroyed,
onMemberExitedFromChatRoom: onMemberExitedFromChatRoom,
onMemberJoinedFromChatRoom: onMemberJoinedFromChatRoom,
onMuteListAddedFromChatRoom: onMuteListAddedFromChatRoom,
// onMuteListAddedFromChatRoom: onMuteListAddedFromChatRoom,
onMuteListRemovedFromChatRoom: onMuteListRemovedFromChatRoom,
onOwnerChangedFromChatRoom: onOwnerChangedFromChatRoom,
onRemovedFromChatRoom: onRemovedFromChatRoom,
Expand Down
18 changes: 12 additions & 6 deletions lib/ui/controllers/messages_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,24 @@ class MessagesViewController extends ChangeNotifier
if (path.isEmpty) {
return;
}
final imageData = await VideoThumbnail.thumbnailData(
video: path,
imageFormat: ImageFormat.JPEG,
maxWidth: 200,
quality: 80,
// 获取视频缩略图
File? imageData = await VideoCompress.getFileThumbnail(
path, // 视频文件路径
quality: 50, // 质量 (1-100)
position: -1 // 获取哪一帧 (-1 表示中间帧)
);
// final imageData = await VideoThumbnail.thumbnailData(
// video: path,
// imageFormat: ImageFormat.JPEG,
// maxWidth: 200,
// quality: 80,
// );
if (imageData != null) {
final directory = await getApplicationCacheDirectory();
String thumbnailPath =
'${directory.path}/thumbnail_${Random().nextInt(999999999)}.jpeg';
final file = File(thumbnailPath);
file.writeAsBytesSync(imageData);
file.writeAsBytesSync(imageData.readAsBytesSync());

final videoFile = File(path);

Expand Down
18 changes: 12 additions & 6 deletions lib/ui/controllers/thread_messages_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,24 @@ class ThreadMessagesViewController
if (path.isEmpty) {
return;
}
final imageData = await VideoThumbnail.thumbnailData(
video: path,
imageFormat: ImageFormat.JPEG,
maxWidth: 200,
quality: 80,
// 获取视频缩略图
File? imageData = await VideoCompress.getFileThumbnail(
path, // 视频文件路径
quality: 50, // 质量 (1-100)
position: -1 // 获取哪一帧 (-1 表示中间帧)
);
// final imageData = await VideoThumbnail.thumbnailData(
// video: path,
// imageFormat: ImageFormat.JPEG,
// maxWidth: 200,
// quality: 80,
// );
if (imageData != null) {
final directory = await getApplicationCacheDirectory();
String thumbnailPath =
'${directory.path}/thumbnail_${Random().nextInt(999999999)}.jpeg';
final file = File(thumbnailPath);
file.writeAsBytesSync(imageData);
file.writeAsBytesSync(imageData.readAsBytesSync());

final videoFile = File(path);

Expand Down
30 changes: 19 additions & 11 deletions lib/ui/views/messages_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1576,17 +1576,25 @@ class _MessagesViewState extends State<MessagesView>
}

Future<bool> selectFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
PlatformFile file = result.files.single;
if (file.path?.isNotEmpty == true) {
controller.sendFileMessage(
file.path!,
name: file.name,
fileSize: file.size,
);
return true;
}
final XFile? file = await openFile(
acceptedTypeGroups: [
XTypeGroup(
label: '所有类型文件',
extensions: [],
mimeTypes: [],
),
],
);
if (file != null) {
// 获取文件大小(字节)
final fileData = await file.readAsBytes();
final sizeInBytes = fileData.lengthInBytes;
controller.sendFileMessage(
file.path,
name: file.name,
fileSize: sizeInBytes,
);
return true;
}
return false;
}
Expand Down
43 changes: 32 additions & 11 deletions lib/ui/views/thread_messages_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -992,19 +992,40 @@ class _ThreadMessagesViewState extends State<ThreadMessagesView>
}

Future<bool> selectFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
PlatformFile file = result.files.single;
if (file.path?.isNotEmpty == true) {
controller.sendFileMessage(
file.path!,
name: file.name,
fileSize: file.size,
);
return true;
}
final XFile? file = await openFile(
acceptedTypeGroups: [
XTypeGroup(
label: '所有类型文件',
extensions: [],
mimeTypes: [],
),
],
);
if (file != null) {
// 获取文件大小(字节)
final fileData = await file.readAsBytes();
final sizeInBytes = fileData.lengthInBytes;
controller.sendFileMessage(
file.path,
name: file.name,
fileSize: sizeInBytes,
);
return true;
}
return false;
// FilePickerResult? result = await FilePicker.platform.pickFiles();
// if (result != null) {
// PlatformFile file = result.files.single;
// if (file.path?.isNotEmpty == true) {
// controller.sendFileMessage(
// file.path!,
// name: file.name,
// fileSize: file.size,
// );
// return true;
// }
// }
// return false;
}

void selectCard() async {
Expand Down
7 changes: 4 additions & 3 deletions lib/ui/widgets/chat_uikit_avatar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
// import 'package:cached_network_image/cached_network_image.dart';
import '../../../chat_uikit.dart';
import '../../../universal/chat_uikit_log.dart';

Expand Down Expand Up @@ -92,7 +92,8 @@ class _ChatUIKitAvatarState extends State<ChatUIKitAvatar>
),
),
child: avatarUrl?.isNotEmpty == true
? CachedNetworkImage(
? Text('CachedNetworkImage无')
/*CachedNetworkImage(
imageUrl: avatarUrl!,
errorListener: (value) {
chatPrint('avatarUrl: $avatarUrl, error: $value');
Expand All @@ -112,7 +113,7 @@ class _ChatUIKitAvatarState extends State<ChatUIKitAvatar>
width: widget.size,
);
},
)
)*/
: ChatUIKitImageLoader.defaultAvatar(
height: widget.size,
width: widget.size,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:math';

import 'package:cached_network_image/cached_network_image.dart';
// import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

import '../../../../../chat_uikit.dart';
Expand Down Expand Up @@ -108,34 +108,35 @@ class ChatUIKitTextBubbleWidget extends StatelessWidget {
}
return FittedBox(
fit: BoxFit.none,
child: CachedNetworkImage(
height: 118,
width: constraints.maxWidth + 24,
imageUrl: imgUrl,
fit: BoxFit.cover,
placeholder: (context, url) {
return Container(
height: 118,
width: 300,
color: theme.color.isDark
? theme.color.neutralColor3
: theme.color.neutralColor95,
);
},
errorWidget: (context, url, error) {
debugPrint('urlPreview errorWidget: $url');
return Container(
height: 118,
width: 300,
color: theme.color.isDark
? theme.color.neutralColor3
: theme.color.neutralColor95,
);
},
errorListener: (value) {
debugPrint('urlPreview errorListener: $value');
},
),
child: Text('CachedNetworkImage无'),
// child: CachedNetworkImage(
// height: 118,
// width: constraints.maxWidth + 24,
// imageUrl: imgUrl,
// fit: BoxFit.cover,
// placeholder: (context, url) {
// return Container(
// height: 118,
// width: 300,
// color: theme.color.isDark
// ? theme.color.neutralColor3
// : theme.color.neutralColor95,
// );
// },
// errorWidget: (context, url, error) {
// debugPrint('urlPreview errorWidget: $url');
// return Container(
// height: 118,
// width: 300,
// color: theme.color.isDark
// ? theme.color.neutralColor3
// : theme.color.neutralColor95,
// );
// },
// errorListener: (value) {
// debugPrint('urlPreview errorListener: $value');
// },
// ),
);
},
),
Expand Down
Loading