|
|
|
|
@ -10,7 +10,6 @@ import 'package:fluffychat/pangea/widgets/chat/toolbar_content_loading_indicator
|
|
|
|
|
import 'package:fluffychat/pangea/widgets/igc/card_error_widget.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
|
|
class MessageTranslationCard extends StatefulWidget {
|
|
|
|
|
final PangeaMessageEvent messageEvent;
|
|
|
|
|
@ -133,6 +132,22 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Show warning if message's language code is user's L1
|
|
|
|
|
/// or if translated text is same as original text.
|
|
|
|
|
/// Warning does not show if was previously closed
|
|
|
|
|
bool get showWarning {
|
|
|
|
|
if (MatrixState.pangeaController.instructions.wereInstructionsTurnedOff(
|
|
|
|
|
InlineInstructions.l1Translation.toString(),
|
|
|
|
|
)) return false;
|
|
|
|
|
|
|
|
|
|
final bool isWrittenInL1 =
|
|
|
|
|
l1Code != null && widget.messageEvent.originalSent?.langCode == l1Code;
|
|
|
|
|
final bool isTextIdentical = selectionTranslation != null &&
|
|
|
|
|
widget.messageEvent.originalSent?.text == selectionTranslation;
|
|
|
|
|
|
|
|
|
|
return isWrittenInL1 || isTextIdentical;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
if (!_fetchingRepresentation &&
|
|
|
|
|
@ -141,19 +156,6 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
|
|
|
|
|
return const CardErrorWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show warning if message's language code is user's L1
|
|
|
|
|
// or if translated text is same as original text
|
|
|
|
|
// Warning does not show if was previously closed
|
|
|
|
|
final bool showWarning = widget.messageEvent.originalSent != null &&
|
|
|
|
|
((!widget.immersionMode &&
|
|
|
|
|
widget.messageEvent.originalSent!.langCode.equals(l1Code)) ||
|
|
|
|
|
(selectionTranslation == null ||
|
|
|
|
|
widget.messageEvent.originalSent!.text
|
|
|
|
|
.equals(selectionTranslation))) &&
|
|
|
|
|
!MatrixState.pangeaController.instructions.wereInstructionsTurnedOff(
|
|
|
|
|
InlineInstructions.l1Translation.toString(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
child: _fetchingRepresentation
|
|
|
|
|
? const ToolbarContentLoadingIndicator()
|
|
|
|
|
|