From 8a947e83d97f1a316ca24307196bf5817223c396 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Thu, 15 Aug 2024 16:55:53 -0400 Subject: [PATCH] Adds inline tooltip to IT bar --- assets/l10n/intl_en.arb | 3 ++- .../controllers/it_controller.dart | 13 ++++++++++++ lib/pangea/choreographer/widgets/it_bar.dart | 20 +++++++++++++++++++ lib/pangea/enum/instructions_enum.dart | 3 +++ lib/pangea/utils/inline_tooltip.dart | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 490f6c91d..9921f8c28 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4127,5 +4127,6 @@ "createSpace": "Create space", "createChat": "Create chat", "error520Title": "Please try again.", - "error520Desc": "Sorry, we could not understand your message..." + "error520Desc": "Sorry, we could not understand your message...", + "translationChoicesBody": "Click and hold an option for a hint." } \ No newline at end of file diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 3187d4a6a..6739db2d9 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -3,7 +3,9 @@ import 'dart:developer'; import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart'; import 'package:fluffychat/pangea/constants/choreo_constants.dart'; +import 'package:fluffychat/pangea/enum/instructions_enum.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; @@ -54,6 +56,17 @@ class ITController { choreographer.setState(); } + void closeHint() { + MatrixState.pangeaController.instructions.turnOffInstruction( + InlineInstructions.translationChoices.toString(), + ); + MatrixState.pangeaController.instructions.updateEnableInstructions( + InlineInstructions.translationChoices.toString(), + true, + ); + choreographer.setState(); + } + Future initializeIT(ITStartData itStartData) async { _willOpen = true; Future.delayed(const Duration(microseconds: 100), () { diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index fc398cf03..793519e23 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -7,7 +7,9 @@ import 'package:fluffychat/pangea/choreographer/widgets/it_bar_buttons.dart'; import 'package:fluffychat/pangea/choreographer/widgets/it_feedback_card.dart'; import 'package:fluffychat/pangea/choreographer/widgets/translation_finished_flow.dart'; import 'package:fluffychat/pangea/constants/choreo_constants.dart'; +import 'package:fluffychat/pangea/enum/instructions_enum.dart'; import 'package:fluffychat/pangea/utils/error_handler.dart'; +import 'package:fluffychat/pangea/utils/inline_tooltip.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -138,6 +140,24 @@ class ITBarState extends State { ), ), ), + if (!widget + .choreographer.pangeaController.instructions + .wereInstructionsTurnedOff( + InlineInstructions.translationChoices.toString(), + )) + Container( + constraints: const BoxConstraints( + maxWidth: 180, + ), + child: InlineTooltip( + body: InlineInstructions.translationChoices + .body(context), + onClose: itController.closeHint, + ), + ), + const SizedBox( + height: 10, + ), ], ), ), diff --git a/lib/pangea/enum/instructions_enum.dart b/lib/pangea/enum/instructions_enum.dart index 4e12c12b8..007f60f37 100644 --- a/lib/pangea/enum/instructions_enum.dart +++ b/lib/pangea/enum/instructions_enum.dart @@ -58,6 +58,7 @@ extension InstructionsEnumExtension on InstructionsEnum { enum InlineInstructions { speechToText, l1Translation, + translationChoices, } extension InlineInstructionsExtension on InlineInstructions { @@ -67,6 +68,8 @@ extension InlineInstructionsExtension on InlineInstructions { return L10n.of(context)!.speechToTextBody; case InlineInstructions.l1Translation: return L10n.of(context)!.l1TranslationBody; + case InlineInstructions.translationChoices: + return L10n.of(context)!.translationChoicesBody; } } } diff --git a/lib/pangea/utils/inline_tooltip.dart b/lib/pangea/utils/inline_tooltip.dart index 21fc7321a..2dc1bfddb 100644 --- a/lib/pangea/utils/inline_tooltip.dart +++ b/lib/pangea/utils/inline_tooltip.dart @@ -29,7 +29,7 @@ class InlineTooltip extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Theme.of(context).colorScheme.primary.withAlpha(20), + color: Theme.of(context).colorScheme.primary.withAlpha(40), ), child: Padding( padding: const EdgeInsets.all(10),