Adds inline tooltip to IT bar

This commit is contained in:
Kelrap 2024-08-15 16:55:53 -04:00 committed by ggurdin
parent 41ce213553
commit 8a947e83d9
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
5 changed files with 39 additions and 2 deletions

View file

@ -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."
}

View file

@ -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<void> initializeIT(ITStartData itStartData) async {
_willOpen = true;
Future.delayed(const Duration(microseconds: 100), () {

View file

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

View file

@ -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;
}
}
}

View file

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