diff --git a/lib/controllers/attachment.dart b/lib/controllers/attachment.dart index c976684..118f02c 100644 --- a/lib/controllers/attachment.dart +++ b/lib/controllers/attachment.dart @@ -5,7 +5,6 @@ import "package:nexus/controllers/rooms.dart"; import "package:nexus/models/content/content.dart"; import "package:nexus/models/content/message.dart"; import "package:nexus/models/composer_params.dart"; -import "package:path/path.dart"; typedef AttachmentParams = ({ComposerParams composer, int? editingRowId}); @@ -15,8 +14,7 @@ class AttachmentController(final AttachmentParams params) Null build() => null; Future add(XFile file) async { - final filename = basename(file.path); - state = (filename, null); + state = (file.name, null); final isEncrypted = ref.read( RoomsController.provider.select( @@ -30,9 +28,11 @@ class AttachmentController(final AttachmentParams params) final content = await ref .read(ClientController.provider.notifier) - .uploadMedia(.new(path: file.path, encrypt: isEncrypted)); + .uploadMedia( + .new(path: file.path, encrypt: isEncrypted, filename: file.name), + ); - state = (filename, content); + state = (file.name, content); } void set((String, MessageContent?)? attachment) => state = attachment; diff --git a/lib/helpers/file_dialog_helper.dart b/lib/helpers/file_dialog_helper.dart index de93d12..77b506d 100644 --- a/lib/helpers/file_dialog_helper.dart +++ b/lib/helpers/file_dialog_helper.dart @@ -18,7 +18,9 @@ class FileDialogHelper(final Ref ref) { .toList(), ); - final filenameWithExtension = mimeType == null + // Only add an extension if the filename doesn't already have a known one + final filenameWithExtension = + mimeType == null || lookupMimeType(filename) != null ? filename : "$filename.${extensionFromMime(mimeType)}"; diff --git a/lib/widgets/emoji/emoji_picker.dart b/lib/widgets/emoji/emoji_picker.dart index 086bd1a..c46e217 100644 --- a/lib/widgets/emoji/emoji_picker.dart +++ b/lib/widgets/emoji/emoji_picker.dart @@ -45,7 +45,9 @@ class const EmojiPicker({ const .empty(); return upstream.EmojiPicker( - searchHint: "Search or send emoji...", + searchHint: allowFreeText + ? "Search emoji or react with text..." + : "Search emoji...", onSelection: (emoji) async { final image = switch (emoji.data) { final PackImage image => image, diff --git a/lib/widgets/players/video.dart b/lib/widgets/players/video.dart index 76c8641..007f9f4 100644 --- a/lib/widgets/players/video.dart +++ b/lib/widgets/players/video.dart @@ -35,7 +35,11 @@ class const VideoPlayer( PlayerConfiguration( aspectRatio: aspectRatio, fit: .contain, - autoDetectFullscreenDeviceOrientation: true, + // Follow the system's rotation setting rather than locking to the + // video's orientation, so users can rotate freely while watching + autoDetectFullscreenAspectRatio: true, + deviceOrientationsOnFullScreen: const [], + deviceOrientationsAfterFullScreen: const [], routePageBuilder: (context, animation, secondaryAnimation, provider) => HookBuilder( builder: (context) { diff --git a/lib/widgets/renderers/event.dart b/lib/widgets/renderers/event.dart index a9f2f92..9037df9 100644 --- a/lib/widgets/renderers/event.dart +++ b/lib/widgets/renderers/event.dart @@ -135,7 +135,10 @@ class const EventRenderer( (threadRoot == null || previousEvent?.eventId != threadRoot) && (previousEvent?.isShownAsMessage ?? false) && event.sender == previousEvent?.sender && - event.pmp?.id == previousEvent?.pmp?.id; + event.pmp?.id == previousEvent?.pmp?.id && + // Start a new group after a pause, so it's clear when messages were sent + event.timestamp.difference(previousEvent!.timestamp).abs() < + const .new(minutes: 5); // For what a state event changed, from and to final removedColor = colorScheme.error; diff --git a/lib/widgets/renderers/message.dart b/lib/widgets/renderers/message.dart index 655fc0d..86956c2 100644 --- a/lib/widgets/renderers/message.dart +++ b/lib/widgets/renderers/message.dart @@ -1,6 +1,7 @@ import "package:collection/collection.dart"; import "package:material_ui/material_ui.dart"; -import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:flutter_hooks/flutter_hooks.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:linkify/linkify.dart"; import "package:nexus/controllers/client_state.dart"; import "package:nexus/controllers/event.dart"; @@ -39,7 +40,7 @@ class const MessageRenderer( final bool isGrouped = false, final int? maxLines, super.key, -}) extends ConsumerWidget { +}) extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final theme = Theme.of(context); @@ -53,6 +54,8 @@ class const MessageRenderer( fontStyle: event.content is EmoteMessageContent ? .italic : null, ); + final hovered = useState(false); + final rendered = switch (event.content) { _ when event.redactedBy != null => Text( "Redacted event", @@ -160,14 +163,37 @@ class const MessageRenderer( _ => throw Exception("This is impossible"), }; - return Row( + final row = Row( crossAxisAlignment: .start, mainAxisSize: .min, spacing: 6, children: [ if (!textOnly) if (isGrouped) - SizedBox(width: 40) + // Shows when the message was sent on hover, as grouped messages + // have no header + SizedBox( + width: 40, + child: Visibility.maintain( + visible: hovered.value, + child: Padding( + padding: .only(top: 14), + child: Tooltip( + message: event.timestamp.toString(), + child: FittedBox( + fit: .scaleDown, + child: Text( + TimeOfDay.fromDateTime(event.timestamp).format(context), + maxLines: 1, + style: theme.textTheme.labelSmall?.copyWith( + color: Colors.grey, + ), + ), + ), + ), + ), + ), + ) else MessageAvatar(event, height: 40), Flexible( @@ -253,5 +279,13 @@ class const MessageRenderer( ), ], ); + + return isGrouped && !textOnly + ? MouseRegion( + onEnter: (_) => hovered.value = true, + onExit: (_) => hovered.value = false, + child: row, + ) + : row; } }