use a text span with a recognizer instead of a WidgetSpan

Fixes displaynames not ellipsising properly
This commit is contained in:
Henry Hiles 2026-10-26 12:45:54 -04:00
commit f971c50df0
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 139 additions and 67 deletions

View file

@ -12,4 +12,12 @@ extension GlobalRect on BuildContext {
_ => Rect.zero,
};
}
/// [position] on screen as an empty rect, like where text was tapped, to
/// open a popover there.
Rect globalRectAt(Offset position) {
final overlay = Overlay.of(this).context.findRenderObject() as RenderBox;
return overlay.globalToLocal(position) & .zero;
}
}

View file

@ -5,20 +5,20 @@ import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
import "package:nexus/widgets/popover_layout.dart";
extension ShowAdaptivePopover on BuildContext {
/// Shows the widget from [builder] in a popover next to the widget this
/// context belongs to on desktop, or a bottom sheet on mobile. Use the
/// context passed to [builder] to close it.
Future<void> showAdaptivePopover(WidgetBuilder builder) {
/// Shows the widget from [builder] in a popover next to [anchor], or the
/// widget this context belongs to, on desktop, or a bottom sheet on mobile.
/// Use the context passed to [builder] to close it.
Future<void> showAdaptivePopover(WidgetBuilder builder, {Rect? anchor}) {
if (!isDesktop) return showAdaptiveSheet(builder);
final anchor = globalRect;
final rect = anchor ?? globalRect;
return showDialog(
context: this,
barrierColor: Colors.transparent,
useSafeArea: false,
builder: (context) => CustomSingleChildLayout(
delegate: PopoverLayout(anchor),
delegate: PopoverLayout(rect),
child: ConstrainedBox(
constraints: const .new(maxWidth: 420, maxHeight: 600),
child: Material(

View file

@ -3,6 +3,9 @@ import "package:nexus/helpers/extensions/show_adaptive_popover.dart";
import "package:nexus/widgets/user_bottom_sheet.dart";
extension ShowUserPopover on BuildContext {
void showUserPopover(String userId, {String? roomId}) =>
showAdaptivePopover((context) => UserBottomSheet(userId, roomId: roomId));
void showUserPopover(String userId, {String? roomId, Rect? anchor}) =>
showAdaptivePopover(
(context) => UserBottomSheet(userId, roomId: roomId),
anchor: anchor,
);
}