made inline tooltip take up only one line, sped up animation when closing inline tooltip

This commit is contained in:
ggurdin 2024-08-20 14:36:01 -04:00
parent 8a947e83d9
commit 104750732b
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
3 changed files with 30 additions and 34 deletions

View file

@ -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<void> initializeIT(ITStartData itStartData) async {

View file

@ -47,12 +47,16 @@ class ITBarState extends State<ITBar> {
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<ITBar> {
: 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<ITBar> {
// 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<ITBar> {
),
),
),
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<ITBar> {
),
),
),
// ),
),
);
}

View file

@ -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),