From a92dade08c5dc9829be7e9f240f0bea8d26961f7 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Fri, 2 May 2025 12:01:01 -0400 Subject: [PATCH] chore: some updates to copy in user sheet, account for transcription height in message overlay positioner (#2622) --- assets/l10n/intl_en.arb | 5 ++- lib/config/app_config.dart | 1 + .../user_bottom_sheet_view.dart | 15 +++++++-- .../widgets/message_selection_positioner.dart | 17 ++++++++-- .../toolbar/widgets/overlay_message.dart | 33 +++++++++++-------- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 1985e3d48..0e621dd6c 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4886,5 +4886,8 @@ "type": "String" } } - } + }, + "ban": "Ban", + "unban": "Unban", + "kick": "Kick" } \ No newline at end of file diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 7456c3ef2..139398a7c 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -40,6 +40,7 @@ abstract class AppConfig { toolbarButtonsHeight + (chatInputRowOverlayPadding * 2) + toolbarSpacing; + static const double audioTranscriptionMaxHeight = 150.0; static TextStyle messageTextStyle( Event? event, diff --git a/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart b/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart index 9727f8096..22c922cf5 100644 --- a/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart +++ b/lib/pages/user_bottom_sheet/user_bottom_sheet_view.dart @@ -325,7 +325,10 @@ class UserBottomSheetView extends StatelessWidget { ListTile( textColor: theme.colorScheme.error, iconColor: theme.colorScheme.error, - title: Text(L10n.of(context).kickFromChat), + // #Pangea + // title: Text(L10n.of(context).kickFromChat), + title: Text(L10n.of(context).kick), + // Pangea# leading: const Icon(Icons.exit_to_app_outlined), onTap: () => controller.participantAction(UserBottomSheetAction.kick), @@ -336,7 +339,10 @@ class UserBottomSheetView extends StatelessWidget { ListTile( textColor: theme.colorScheme.onErrorContainer, iconColor: theme.colorScheme.onErrorContainer, - title: Text(L10n.of(context).banFromChat), + // #Pangea + // title: Text(L10n.of(context).banFromChat), + title: Text(L10n.of(context).ban), + // Pangea# leading: const Icon(Icons.warning_sharp), onTap: () => controller.participantAction(UserBottomSheetAction.ban), @@ -345,7 +351,10 @@ class UserBottomSheetView extends StatelessWidget { user.canBan && user.membership == Membership.ban) ListTile( - title: Text(L10n.of(context).unbanFromChat), + // #Pangea + // title: Text(L10n.of(context).unbanFromChat), + title: Text(L10n.of(context).unban), + // Pangea# leading: const Icon(Icons.warning_outlined), onTap: () => controller.participantAction(UserBottomSheetAction.unban), diff --git a/lib/pangea/toolbar/widgets/message_selection_positioner.dart b/lib/pangea/toolbar/widgets/message_selection_positioner.dart index effa7e740..80fe813aa 100644 --- a/lib/pangea/toolbar/widgets/message_selection_positioner.dart +++ b/lib/pangea/toolbar/widgets/message_selection_positioner.dart @@ -401,8 +401,8 @@ class MessageSelectionPositionerState extends State _reactionsHeight - _selectionButtonsHeight; - final hasHeaderOverflow = - topOffset < (_headerHeight + AppConfig.toolbarSpacing); + final hasHeaderOverflow = topOffset < + (_headerHeight + AppConfig.toolbarSpacing + _audioTranscriptionHeight); final hasFooterOverflow = bottomOffset < (_footerHeight + AppConfig.toolbarSpacing); @@ -414,11 +414,16 @@ class MessageSelectionPositionerState extends State } if (hasHeaderOverflow) { - final difference = topOffset - (_headerHeight + AppConfig.toolbarSpacing); + final difference = topOffset - + (_headerHeight + + AppConfig.toolbarSpacing + + _audioTranscriptionHeight); + double newBottomOffset = _mediaQuery!.size.height - _originalMessageOffset.dy + difference - _originalMessageSize.height; + if (newBottomOffset < _footerHeight + AppConfig.toolbarSpacing) { newBottomOffset = _footerHeight + AppConfig.toolbarSpacing; } @@ -504,6 +509,12 @@ class MessageSelectionPositionerState extends State return showSelectionButtons ? AppConfig.toolbarButtonsHeight : 0; } + double get _audioTranscriptionHeight { + return widget.pangeaMessageEvent?.isAudioMessage ?? false + ? AppConfig.audioTranscriptionMaxHeight + : 0; + } + bool get _hasReactions { final reactionsEvents = widget.event.aggregatedEvents( widget.chatController.timeline!, diff --git a/lib/pangea/toolbar/widgets/overlay_message.dart b/lib/pangea/toolbar/widgets/overlay_message.dart index e1f61ebfc..846225a03 100644 --- a/lib/pangea/toolbar/widgets/overlay_message.dart +++ b/lib/pangea/toolbar/widgets/overlay_message.dart @@ -280,8 +280,11 @@ class OverlayMessage extends StatelessWidget { ) : content, if (showTranscription || showTranslation) - SizedBox( + Container( width: messageWidth, + constraints: const BoxConstraints( + maxHeight: AppConfig.audioTranscriptionMaxHeight, + ), child: Padding( padding: const EdgeInsets.fromLTRB( 12.0, @@ -289,20 +292,22 @@ class OverlayMessage extends StatelessWidget { 12.0, 12.0, ), - child: showTranscription - ? MessageSpeechToTextCard( - messageEvent: pangeaMessageEvent!, - textColor: textColor, - ) - : Text( - overlayController.translationText!, - style: AppConfig.messageTextStyle( - event, - textColor, - ).copyWith( - fontStyle: FontStyle.italic, + child: SingleChildScrollView( + child: showTranscription + ? MessageSpeechToTextCard( + messageEvent: pangeaMessageEvent!, + textColor: textColor, + ) + : Text( + overlayController.translationText!, + style: AppConfig.messageTextStyle( + event, + textColor, + ).copyWith( + fontStyle: FontStyle.italic, + ), ), - ), + ), ), ), ],