Compare commits

...

4 Commits

7 changed files with 86 additions and 40 deletions

View File

@ -46,7 +46,7 @@ class MoxxyReconnectionPolicy extends ReconnectionPolicy {
// Cancel the timer if it was running
await _stopTimer();
await setIsReconnecting(false);
triggerConnectionLost!();
await triggerConnectionLost!();
} else if (regained && shouldReconnect) {
// We should reconnect
_log.finest('Network regained. Attempting reconnection...');

View File

@ -254,17 +254,16 @@ class AudioChatState extends State<AudioChatWidget> {
}
Widget _buildDownloadable() {
// TODO(Unknown): Implement
return FileChatBaseWidget(
widget.message,
Icons.image,
widget.message.isFileUploadNotification ?
(widget.message.filename ?? '') :
filenameFromUrl(widget.message.srcUrl!),
widget.radius,
widget.maxWidth,
widget.sent,
extra: DownloadButton(
mimeType: widget.message.mediaType,
downloadButton: DownloadButton(
onPressed: () {
MoxplatformPlugin.handler.getDataSender().sendData(
RequestDownloadCommand(message: widget.message),

View File

@ -14,25 +14,39 @@ import 'package:moxxyv2/ui/widgets/chat/progress.dart';
class FileChatBaseWidget extends StatelessWidget {
const FileChatBaseWidget(
this.message,
this.icon,
this.filename,
this.radius,
this.maxWidth,
this.sent,
{
this.extra,
this.downloadButton,
this.onTap,
this.mimeType,
super.key,
}
);
final Message message;
final IconData icon;
final String filename;
final BorderRadius radius;
final double maxWidth;
final Widget? extra;
final Widget? downloadButton;
final bool sent;
final void Function()? onTap;
final String? mimeType;
IconData _mimeTypeToIcon() {
if (mimeType == null) return Icons.file_present;
if (mimeType!.startsWith('image/')) {
return Icons.image;
} else if (mimeType!.startsWith('video/')) {
return Icons.video_file_outlined;
} else if (mimeType!.startsWith('audio/')) {
return Icons.music_note;
}
return Icons.file_present;
}
@override
Widget build(BuildContext context) {
@ -40,20 +54,43 @@ class FileChatBaseWidget extends StatelessWidget {
width: maxWidth,
child: MediaBaseChatWidget(
Padding(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(8),
child: Row(
children: [
Icon(
icon,
size: 48,
),
if (downloadButton != null)
downloadButton!,
Padding(
padding: const EdgeInsets.only(left: 6),
child: Text(
filename,
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
filename,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
_mimeTypeToIcon(),
size: 48,
),
Text(
mimeTypeToName(mimeType),
style: const TextStyle(
fontSize: 24,
),
),
],
),
),
],
),
),
],
@ -62,7 +99,7 @@ class FileChatBaseWidget extends StatelessWidget {
MessageBubbleBottom(message, sent),
radius,
gradient: false,
extra: extra,
//extra: extra,
onTap: onTap,
),
);
@ -91,14 +128,14 @@ class FileChatWidget extends StatelessWidget {
Widget _buildNonDownloaded() {
return FileChatBaseWidget(
message,
Icons.file_present,
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
extra: DownloadButton(
mimeType: message.mediaType,
downloadButton: DownloadButton(
onPressed: () {
MoxplatformPlugin.handler.getDataSender().sendData(
RequestDownloadCommand(message: message),
@ -112,25 +149,27 @@ class FileChatWidget extends StatelessWidget {
Widget _buildDownloading() {
return FileChatBaseWidget(
message,
Icons.file_present,
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl ?? ''),
radius,
maxWidth,
sent,
extra: ProgressWidget(id: message.id),
mimeType: message.mediaType,
downloadButton: ProgressWidget(id: message.id),
);
}
Widget _buildInner() {
return FileChatBaseWidget(
message,
Icons.file_present,
message.isFileUploadNotification ? (message.filename ?? '') : filenameFromUrl(message.srcUrl!),
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
mimeType: message.mediaType,
onTap: () {
openFile(message.mediaUrl!);
},

View File

@ -58,12 +58,14 @@ class ImageChatWidget extends StatelessWidget {
} else {
return FileChatBaseWidget(
message,
Icons.image,
message.isFileUploadNotification ? (message.filename ?? '') : filenameFromUrl(message.srcUrl!),
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
extra: ProgressWidget(id: message.id),
mimeType: message.mediaType,
downloadButton: ProgressWidget(id: message.id),
);
}
}
@ -114,12 +116,14 @@ class ImageChatWidget extends StatelessWidget {
} else {
return FileChatBaseWidget(
message,
Icons.image,
message.isFileUploadNotification ? (message.filename ?? '') : filenameFromUrl(message.srcUrl!),
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
extra: DownloadButton(
mimeType: message.mediaType,
downloadButton: DownloadButton(
onPressed: () {
MoxplatformPlugin.handler.getDataSender().sendData(
RequestDownloadCommand(message: message),

View File

@ -69,12 +69,14 @@ class VideoChatWidget extends StatelessWidget {
} else {
return FileChatBaseWidget(
message,
Icons.video_file_outlined,
message.isFileUploadNotification ? (message.filename ?? '') : filenameFromUrl(message.srcUrl!),
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
extra: ProgressWidget(id: message.id),
mimeType: message.mediaType,
downloadButton: ProgressWidget(id: message.id),
);
}
}
@ -122,12 +124,14 @@ class VideoChatWidget extends StatelessWidget {
} else {
return FileChatBaseWidget(
message,
Icons.video_file_outlined,
message.isFileUploadNotification ? (message.filename ?? '') : filenameFromUrl(message.srcUrl!),
message.isFileUploadNotification ?
(message.filename ?? '') :
filenameFromUrl(message.srcUrl!),
radius,
maxWidth,
sent,
extra: DownloadButton(
mimeType: message.mediaType,
downloadButton: DownloadButton(
onPressed: () {
MoxplatformPlugin.handler.getDataSender().sendData(
RequestDownloadCommand(message: message),

View File

@ -829,7 +829,7 @@ packages:
description:
path: "packages/moxxmpp"
ref: HEAD
resolved-ref: d7723615fe311a2fc8028946fd27c091848d788d
resolved-ref: ed49212f5a527b2b0084faf97cb5c383221772e2
url: "https://git.polynom.me/Moxxy/moxxmpp.git"
source: git
version: "0.1.6+1"

View File

@ -139,7 +139,7 @@ dependency_overrides:
moxxmpp:
git:
url: https://git.polynom.me/Moxxy/moxxmpp.git
rev: d7723615fe311a2fc8028946fd27c091848d788d
rev: ed49212f5a527b2b0084faf97cb5c383221772e2
path: packages/moxxmpp
extra_licenses: