diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 6739db2d9..74bce2f92 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -5,7 +5,6 @@ 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; @@ -56,15 +55,21 @@ class ITController { choreographer.setState(); } + bool _closingHint = false; + Duration get animationSpeed => (_closingHint || !_willOpen) + ? const Duration(milliseconds: 500) + : const Duration(milliseconds: 2000); + void closeHint() { - MatrixState.pangeaController.instructions.turnOffInstruction( - InlineInstructions.translationChoices.toString(), - ); - MatrixState.pangeaController.instructions.updateEnableInstructions( - InlineInstructions.translationChoices.toString(), - true, - ); + _closingHint = true; + final String hintKey = InlineInstructions.translationChoices.toString(); + final instructionsController = choreographer.pangeaController.instructions; + instructionsController.turnOffInstruction(hintKey); + instructionsController.updateEnableInstructions(hintKey, true); choreographer.setState(); + Future.delayed(const Duration(milliseconds: 500), () { + _closingHint = false; + }); } Future initializeIT(ITStartData itStartData) async { diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index 793519e23..f7d928f0c 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -47,12 +47,16 @@ class ITBarState extends State { super.dispose(); } + bool get instructionsTurnedOff => + widget.choreographer.pangeaController.instructions + .wereInstructionsTurnedOff( + InlineInstructions.translationChoices.toString(), + ); + @override Widget build(BuildContext context) { return AnimatedSize( - duration: itController.willOpen - ? const Duration(milliseconds: 2000) - : const Duration(milliseconds: 500), + duration: itController.animationSpeed, curve: Curves.fastOutSlowIn, clipBehavior: Clip.none, child: !itController.willOpen @@ -60,9 +64,7 @@ class ITBarState extends State { : CompositedTransformTarget( link: widget.choreographer.itBarLinkAndKey.link, child: AnimatedOpacity( - duration: itController.willOpen - ? const Duration(milliseconds: 2000) - : const Duration(milliseconds: 500), + duration: itController.animationSpeed, opacity: itController.willOpen ? 1.0 : 0.0, child: Container( key: widget.choreographer.itBarLinkAndKey.key, @@ -111,6 +113,12 @@ class ITBarState extends State { // const SizedBox(height: 40.0), OriginalText(controller: itController), const SizedBox(height: 7.0), + if (!instructionsTurnedOff) + InlineTooltip( + body: InlineInstructions.translationChoices + .body(context), + onClose: itController.closeHint, + ), IntrinsicHeight( child: Container( constraints: @@ -140,24 +148,6 @@ 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, - ), ], ), ), @@ -171,6 +161,7 @@ class ITBarState extends State { ), ), ), + // ), ), ); } diff --git a/lib/pangea/utils/inline_tooltip.dart b/lib/pangea/utils/inline_tooltip.dart index 2dc1bfddb..f82a11682 100644 --- a/lib/pangea/utils/inline_tooltip.dart +++ b/lib/pangea/utils/inline_tooltip.dart @@ -26,10 +26,10 @@ class InlineTooltip extends StatelessWidget { onPressed: onClose, ), ), - child: Container( + child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Theme.of(context).colorScheme.primary.withAlpha(40), + color: Theme.of(context).colorScheme.primary.withAlpha(20), ), child: Padding( padding: const EdgeInsets.all(10),