various fixes

This commit is contained in:
Henry Hiles 2026-05-18 14:30:44 -04:00
commit c9b5b3dda8
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 194 additions and 162 deletions

View file

@ -21,8 +21,8 @@ class UserController extends AsyncNotifier<MembershipContent> {
), ),
); );
if (member?.content is MembershipContent) { if (member?.content case final MembershipContent content) {
return member!.content as MembershipContent; return content;
} }
final profile = await ref.watch(ProfileController.provider(userId).future); final profile = await ref.watch(ProfileController.provider(userId).future);

View file

@ -2,6 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/material.dart"; import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/client_state_controller.dart"; import "package:nexus/controllers/client_state_controller.dart";
import "package:nexus/helpers/extensions/show_context_menu.dart";
import "package:nexus/helpers/launch_helper.dart"; import "package:nexus/helpers/launch_helper.dart";
import "package:nexus/models/content/avatar.dart"; import "package:nexus/models/content/avatar.dart";
import "package:nexus/models/content/content.dart"; import "package:nexus/models/content/content.dart";
@ -35,6 +36,7 @@ class EventText extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context); final theme = Theme.of(context);
final colorScheme = theme.colorScheme; final colorScheme = theme.colorScheme;
final errorStyle = TextStyle(color: colorScheme.error);
final timestamp = Tooltip( final timestamp = Tooltip(
message: event.timestamp.toString(), message: event.timestamp.toString(),
@ -43,8 +45,17 @@ class EventText extends ConsumerWidget {
style: theme.textTheme.labelSmall?.copyWith(color: Colors.grey), style: theme.textTheme.labelSmall?.copyWith(color: Colors.grey),
), ),
); );
final contextMenuCallback = getEventOptions == null
? null
: (details) => context.showContextMenu(
globalPosition: details.globalPosition,
children: getEventOptions!(event).toList(),
);
return switch (event.content) { return GestureDetector(
onSecondaryTapUp: contextMenuCallback,
onLongPressStart: contextMenuCallback,
child: switch (event.content) {
MessageContent() => Row( MessageContent() => Row(
spacing: 8, spacing: 8,
children: [ children: [
@ -67,7 +78,10 @@ class EventText extends ConsumerWidget {
ClipRRect( ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8)), borderRadius: BorderRadius.all(Radius.circular(8)),
child: Container( child: Container(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12), padding: EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color:
ref.watch( ref.watch(
@ -90,7 +104,7 @@ class EventText extends ConsumerWidget {
switch (event.content) { switch (event.content) {
Content(:final parseError?) => SelectableText( Content(:final parseError?) => SelectableText(
"An error occurred while parsing this message:\n$parseError", "An error occurred while parsing this message:\n$parseError",
style: TextStyle(color: colorScheme.error), style: errorStyle,
), ),
TextMessageContent( TextMessageContent(
:final body, :final body,
@ -99,10 +113,12 @@ class EventText extends ConsumerWidget {
) => ) =>
Column( Column(
children: [ children: [
format == "org.matrix.custom.html" format == "org.matrix.custom.html" &&
!textOnly
? Html( ? Html(
textStyle: textStyle:
event.localContent?.bigEmoji == true event.localContent?.bigEmoji ==
true
? TextStyle(fontSize: 32) ? TextStyle(fontSize: 32)
: null, : null,
formattedBody!.replaceAllMapped( formattedBody!.replaceAllMapped(
@ -125,6 +141,7 @@ class EventText extends ConsumerWidget {
) )
: Linkify( : Linkify(
text: body, text: body,
maxLines: maxLines,
options: LinkifyOptions( options: LinkifyOptions(
humanize: false, humanize: false,
), ),
@ -149,7 +166,13 @@ class EventText extends ConsumerWidget {
LinkPreview(link), LinkPreview(link),
], ],
), ),
_ => SizedBox.shrink(), _ =>
textOnly
? Text(
"Unknown message type",
style: errorStyle,
)
: SizedBox.shrink(),
}, },
], ],
), ),
@ -175,8 +198,12 @@ class EventText extends ConsumerWidget {
Text("changed the room avatar"), Text("changed the room avatar"),
], ],
), ),
_ => Text("AAAAA"), _ =>
}; textOnly
? Text("Unknown event type", style: errorStyle)
: SizedBox.shrink(),
},
);
} }
} }

View file

@ -99,13 +99,17 @@ class RoomChat extends HookConsumerWidget {
), ),
)) ))
PopupMenuItem( PopupMenuItem(
enabled: false,
child: IconTheme(
data: theme.iconTheme,
child: Row( child: Row(
children: [ children: [
...{ ...{
...ref.watch( ...ref.watch(
AccountDataController.provider.select( AccountDataController.provider.select(
(value) => IList( (value) => IList(
value["m.recent_emoji"]?.content["recent_emoji"] ?? value["m.recent_emoji"]
?.content["recent_emoji"] ??
[], [],
).map((entry) => entry["emoji"]), ).map((entry) => entry["emoji"]),
), ),
@ -137,6 +141,7 @@ class RoomChat extends HookConsumerWidget {
], ],
), ),
), ),
),
if (ref.watch( if (ref.watch(
PowerLevelController.provider( PowerLevelController.provider(
PowerLevelConfig(eventType: EventType.message), PowerLevelConfig(eventType: EventType.message),