toolbar updates
This commit is contained in:
parent
4a2e60d48c
commit
abbcd41064
5 changed files with 158 additions and 23 deletions
|
|
@ -3932,5 +3932,10 @@
|
|||
"subscriptionPopupDesc": "Subscribe today to unlock translation and grammar correction!",
|
||||
"seeOptions": "See options",
|
||||
"continuedWithoutSubscription": "Continue without subscribing",
|
||||
"trialPeriodExpired": "Your trial period has expired"
|
||||
"trialPeriodExpired": "Your trial period has expired",
|
||||
"selectToDefine": "To define a word in this message, just select it!",
|
||||
"translation": "translation",
|
||||
"audio": "message audio",
|
||||
"definitions": "definitions",
|
||||
"subscribedToUnlockTools": "Subscribe to unlock language tools, including"
|
||||
}
|
||||
|
|
@ -4543,5 +4543,61 @@
|
|||
"conversationTopic": "Tema de conversación",
|
||||
"enableModeration": "Activar la moderación",
|
||||
"enableModerationDesc": "Activar la moderación automática para revisar los mensajes antes de enviarlos",
|
||||
"conversationLanguageLevel": "¿Cuál es el nivel lingüístico de esta conversación?"
|
||||
}
|
||||
"conversationLanguageLevel": "¿Cuál es el nivel lingüístico de esta conversación?",
|
||||
"errorGettingAudio": "Error al recibir audio. Por favor, actualice e inténtelo de nuevo.",
|
||||
"define": "Defina",
|
||||
"listen": "Listas",
|
||||
"showDefinition": "Mostrar definición",
|
||||
"acceptedKeyVerification": "{sender} verificación de clave aceptada",
|
||||
"@acceptedKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"canceledKeyVerification": "{sender} canceló la verificación de claves",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"completedKeyVerification": "{sender} verificación de claves completada",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"isReadyForKeyVerification": "{sender} está listo para la verificación de claves",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"requestedKeyVerification": "{sender} solicitó verificación de claves",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"startedKeyVerification": "{sender} ha iniciado la verificación de claves",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"subscriptionPopupTitle": "Esta frase podría tener un error gramatical...",
|
||||
"subscriptionPopupDesc": "Suscríbase hoy mismo para desbloquear la traducción y la corrección gramatical.",
|
||||
"seeOptions": "Ver opciones",
|
||||
"continuedWithoutSubscription": "Continuar sin suscribirse",
|
||||
"trialPeriodExpired": "Su periodo de prueba ha expirado",
|
||||
"selectToDefine": "Para definir una palabra en este mensaje, ¡sólo tiene que seleccionarla!",
|
||||
"translation": "traducción",
|
||||
"audio": "mensaje de audio",
|
||||
"definitions": "definiciones",
|
||||
"subscribedToUnlockTools": "Suscríbase para desbloquear herramientas lingüísticas, como"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ import 'package:fluffychat/pangea/utils/overlay.dart';
|
|||
import 'package:fluffychat/pangea/widgets/chat/message_audio_card.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_text_selection.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_translation_card.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_unsubscribed_card.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/overlay_message.dart';
|
||||
import 'package:fluffychat/pangea/widgets/igc/word_data_card.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
enum MessageMode { translation, play, definition }
|
||||
|
|
@ -162,35 +164,43 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
}
|
||||
}
|
||||
|
||||
bool enabledButton(MessageMode mode) {
|
||||
String getModeTitle(MessageMode mode) {
|
||||
switch (mode) {
|
||||
case MessageMode.translation:
|
||||
return true;
|
||||
return L10n.of(context)!.translation;
|
||||
case MessageMode.play:
|
||||
return true;
|
||||
return L10n.of(context)!.audio;
|
||||
case MessageMode.definition:
|
||||
return widget.textSelection.selectedText != null;
|
||||
// return true;
|
||||
return L10n.of(context)!.definitions;
|
||||
default:
|
||||
return false;
|
||||
return L10n.of(context)!
|
||||
.oopsSomethingWentWrong; // Title to indicate an error or unsupported mode
|
||||
}
|
||||
}
|
||||
|
||||
void updateMode(MessageMode newMode) {
|
||||
debugPrint("updating toolbar mode");
|
||||
final bool subscribed =
|
||||
MatrixState.pangeaController.subscriptionController.isSubscribed;
|
||||
setState(() => currentMode = newMode);
|
||||
switch (currentMode) {
|
||||
case MessageMode.translation:
|
||||
showTranslation();
|
||||
break;
|
||||
case MessageMode.play:
|
||||
playAudio();
|
||||
break;
|
||||
case MessageMode.definition:
|
||||
showDefinition();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (!subscribed) {
|
||||
child = MessageUnsubscribedCard(
|
||||
languageTool: getModeTitle(newMode),
|
||||
);
|
||||
} else {
|
||||
switch (currentMode) {
|
||||
case MessageMode.translation:
|
||||
showTranslation();
|
||||
break;
|
||||
case MessageMode.play:
|
||||
playAudio();
|
||||
break;
|
||||
case MessageMode.definition:
|
||||
showDefinition();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
|
@ -214,6 +224,7 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
void showDefinition() {
|
||||
if (widget.textSelection.selectedText == null ||
|
||||
widget.textSelection.selectedText!.isEmpty) {
|
||||
child = const SelectToDefine();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +323,7 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
color: currentMode == mode
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
onPressed:
|
||||
enabledButton(mode) ? () => updateMode(mode) : null,
|
||||
onPressed: () => updateMode(mode),
|
||||
);
|
||||
}).toList() +
|
||||
[
|
||||
|
|
|
|||
47
lib/pangea/widgets/chat/message_unsubscribed_card.dart
Normal file
47
lib/pangea/widgets/chat/message_unsubscribed_card.dart
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_style.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class MessageUnsubscribedCard extends StatelessWidget {
|
||||
final String languageTool;
|
||||
|
||||
const MessageUnsubscribedCard({
|
||||
super.key,
|
||||
required this.languageTool,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
style: BotStyle.text(context),
|
||||
"${L10n.of(context)!.subscribedToUnlockTools} $languageTool",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
MatrixState.pangeaController.subscriptionController
|
||||
.showPaywall(context);
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
},
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all<Color>(
|
||||
(AppConfig.primaryColor).withOpacity(0.1),
|
||||
),
|
||||
),
|
||||
child: Text(L10n.of(context)!.getAccess),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -381,3 +381,20 @@ class PartOfSpeechBlock extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SelectToDefine extends StatelessWidget {
|
||||
const SelectToDefine({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
L10n.of(context)!.selectToDefine,
|
||||
style: BotStyle.text(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue