feat(chat): fix chat first message, add pick images from gallery

This commit is contained in:
mso7nueh
2025-06-23 19:46:23 +03:00
parent 85d67ba9c4
commit 75fa9ebc5c
10 changed files with 347 additions and 34 deletions

View File

@@ -387,7 +387,6 @@ class _ChatScreenState extends State<ChatScreen> {
onTap: () {
if (textEditingController.text.isNotEmpty) {
chatRoomCubit.sendMessage(
chatId: widget.chatId,
data: textEditingController.text.trim(),
userSlug: state.chatRoom.users.receiver.slug,
);
@@ -411,14 +410,15 @@ class _ChatScreenState extends State<ChatScreen> {
),
if (showAboutOrderButton)
Positioned(
top: 8,
right: 15,
left: 16,
child: AboutOrderButton(
onTap: () async {
GoRouter.of(context).push(InfoByOrderScreen.path, extra: {'planId': state.chatRoom.chosenPlan?.id});
},
)),
top: 8,
right: 15,
left: 16,
child: AboutOrderButton(
onTap: () async {
GoRouter.of(context).push(InfoByOrderScreen.path, extra: {'planId': state.chatRoom.chosenPlan?.id});
},
),
),
],
),
),
@@ -436,7 +436,7 @@ class _ChatScreenState extends State<ChatScreen> {
final picker = ImagePicker();
XFile? image = await picker.pickImage(source: ImageSource.camera);
if (image != null) {
await chatRoomCubit.sendMessage(chatId: widget.chatId, files: [File(image.path)], userSlug: slug);
await chatRoomCubit.sendMessage(files: [File(image.path)], userSlug: slug);
}
},
child: const Row(
@@ -447,6 +447,24 @@ class _ChatScreenState extends State<ChatScreen> {
],
),
),
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
final picker = ImagePicker();
List<XFile> images = await picker.pickMultiImage();
if (images != []) {
List<File> files = images.map((image) => File(image.path)).toList();
await chatRoomCubit.sendMessage(files: files, userSlug: slug);
}
},
child: const Row(
children: [
Icon(Icons.photo_library_rounded),
SizedBox(width: 8),
Text('Галерея'),
],
),
),
CupertinoActionSheetAction(
onPressed: () async {
Navigator.of(context).pop();
@@ -476,7 +494,7 @@ class _ChatScreenState extends State<ChatScreen> {
);
if (result != null) {
List<File> files = result.paths.map((path) => File(path!)).toList();
await chatRoomCubit.sendMessage(chatId: widget.chatId, files: files, userSlug: slug);
await chatRoomCubit.sendMessage(files: files, userSlug: slug);
}
},
child: const Row(