From ddeb55a33733c6de28a5a9ce7ff42a4f4eacb89d Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:47:16 -0500 Subject: [PATCH] fix speech-to-text inline tooltip overflow (#1100) --- lib/pangea/choreographer/widgets/it_bar.dart | 24 ++++--- lib/pangea/utils/inline_tooltip.dart | 2 +- .../chat/message_speech_to_text_card.dart | 65 ++++++++++--------- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index e39b34615..30cc7c007 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -118,21 +118,9 @@ class ITBarState extends State with SingleTickerProviderStateMixin { child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if (!itController.isEditingSourceText && - itController.sourceText != null) - SizedBox(width: iconDimension * 3), - if (!itController.isEditingSourceText) - Expanded( - child: itController.sourceText != null - ? Text( - itController.sourceText!, - textAlign: TextAlign.center, - ) - : const LinearProgressIndicator(), - ), if (itController.isEditingSourceText) Expanded( child: Padding( @@ -205,6 +193,16 @@ class ITBarState extends State with SingleTickerProviderStateMixin { ), ], ), + if (!itController.isEditingSourceText) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: itController.sourceText != null + ? Text( + itController.sourceText!, + textAlign: TextAlign.center, + ) + : const LinearProgressIndicator(), + ), const SizedBox(height: 8.0), if (showITInstructionsTooltip) const InlineTooltip( diff --git a/lib/pangea/utils/inline_tooltip.dart b/lib/pangea/utils/inline_tooltip.dart index 88681a00d..19913432a 100644 --- a/lib/pangea/utils/inline_tooltip.dart +++ b/lib/pangea/utils/inline_tooltip.dart @@ -92,7 +92,7 @@ class InlineTooltipState extends State color: Theme.of(context).colorScheme.onSurface, height: 1.5, ), - textAlign: TextAlign.left, + textAlign: TextAlign.center, ), ), ), diff --git a/lib/pangea/widgets/chat/message_speech_to_text_card.dart b/lib/pangea/widgets/chat/message_speech_to_text_card.dart index ae05cbca9..98996ba3a 100644 --- a/lib/pangea/widgets/chat/message_speech_to_text_card.dart +++ b/lib/pangea/widgets/chat/message_speech_to_text_card.dart @@ -170,7 +170,7 @@ class MessageSpeechToTextCardState extends State { //TODO: find better icons return Padding( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.all(16), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -178,34 +178,41 @@ class MessageSpeechToTextCardState extends State { RichText( text: _buildTranscriptText(context), ), - const SizedBox(height: 16), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconNumberWidget( - icon: Symbols.target, - number: - "${selectedToken?.confidence ?? speechToTextResponse!.transcript.confidence}%", - toolTip: L10n.of(context)!.accuracy, - ), - const SizedBox(width: 16), - IconNumberWidget( - icon: Icons.speed, - number: wordsPerMinuteString != null - ? "$wordsPerMinuteString" - : "??", - toolTip: L10n.of(context)!.wordsPerMinute, - ), - ], - ), - const Row( - mainAxisSize: MainAxisSize.min, - children: [ - InlineTooltip( - instructionsEnum: InstructionsEnum.speechToText, - ), - ], - ), + if (widget.messageEvent.senderId == Matrix.of(context).client.userID) + Column( + children: [ + const SizedBox(height: 16), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconNumberWidget( + icon: Symbols.target, + number: + "${selectedToken?.confidence ?? speechToTextResponse!.transcript.confidence}%", + toolTip: L10n.of(context)!.accuracy, + ), + const SizedBox(width: 16), + IconNumberWidget( + icon: Icons.speed, + number: wordsPerMinuteString != null + ? "$wordsPerMinuteString" + : "??", + toolTip: L10n.of(context)!.wordsPerMinute, + ), + ], + ), + const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: InlineTooltip( + instructionsEnum: InstructionsEnum.speechToText, + ), + ), + ], + ), + ], + ), ], ), );