Merge pull request #81 from pangeachat/testing-updates
Toolbar Tooltips + Free Trial Buttons
This commit is contained in:
commit
582def150b
5 changed files with 95 additions and 60 deletions
|
|
@ -3934,8 +3934,11 @@
|
|||
"continuedWithoutSubscription": "Continue without subscribing",
|
||||
"trialPeriodExpired": "Your trial period has expired",
|
||||
"selectToDefine": "To define a word in this message, just select it!",
|
||||
"translation": "translation",
|
||||
"audio": "message audio",
|
||||
"translations": "translations",
|
||||
"messageAudio": "message audio",
|
||||
"definitions": "definitions",
|
||||
"subscribedToUnlockTools": "Subscribe to unlock language tools, including"
|
||||
"subscribedToUnlockTools": "Subscribe to unlock language tools, including",
|
||||
"more": "More",
|
||||
"translationTooltip": "Translate",
|
||||
"audioTooltip": "Play Audio"
|
||||
}
|
||||
|
|
@ -4550,54 +4550,33 @@
|
|||
"showDefinition": "Mostrar definición",
|
||||
"acceptedKeyVerification": "{sender} verificación de clave aceptada",
|
||||
"@acceptedKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"canceledKeyVerification": "{sender} canceló la verificación de claves",
|
||||
"@canceledKeyVerification": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"sender": {}
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"translations": "traducciónes",
|
||||
"messageAudio": "mensaje de audio",
|
||||
"definitions": "definiciones",
|
||||
"subscribedToUnlockTools": "Suscríbase para desbloquear herramientas lingüísticas, como"
|
||||
"subscribedToUnlockTools": "Suscríbase para desbloquear herramientas lingüísticas, como",
|
||||
"more": "Más",
|
||||
"translationTooltip": "Traducir",
|
||||
"audioTooltip": "Reproducir audio"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
String getModeTitle(MessageMode mode) {
|
||||
switch (mode) {
|
||||
case MessageMode.translation:
|
||||
return L10n.of(context)!.translation;
|
||||
return L10n.of(context)!.translations;
|
||||
case MessageMode.play:
|
||||
return L10n.of(context)!.audio;
|
||||
return L10n.of(context)!.messageAudio;
|
||||
case MessageMode.definition:
|
||||
return L10n.of(context)!.definitions;
|
||||
default:
|
||||
|
|
@ -178,6 +178,20 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
}
|
||||
}
|
||||
|
||||
String getModeTooltip(MessageMode mode) {
|
||||
switch (mode) {
|
||||
case MessageMode.translation:
|
||||
return L10n.of(context)!.translationTooltip;
|
||||
case MessageMode.play:
|
||||
return L10n.of(context)!.audioTooltip;
|
||||
case MessageMode.definition:
|
||||
return L10n.of(context)!.define;
|
||||
default:
|
||||
return L10n.of(context)!
|
||||
.oopsSomethingWentWrong; // Title to indicate an error or unsupported mode
|
||||
}
|
||||
}
|
||||
|
||||
void updateMode(MessageMode newMode) {
|
||||
debugPrint("updating toolbar mode");
|
||||
final bool subscribed =
|
||||
|
|
@ -186,6 +200,8 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
if (!subscribed) {
|
||||
child = MessageUnsubscribedCard(
|
||||
languageTool: getModeTitle(newMode),
|
||||
mode: newMode,
|
||||
toolbarModeStream: widget.toolbarModeStream,
|
||||
);
|
||||
} else {
|
||||
switch (currentMode) {
|
||||
|
|
@ -318,18 +334,24 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: MessageMode.values.map((mode) {
|
||||
return IconButton(
|
||||
icon: Icon(getIconData(mode)),
|
||||
color: currentMode == mode
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
onPressed: () => updateMode(mode),
|
||||
return Tooltip(
|
||||
message: getModeTooltip(mode),
|
||||
child: IconButton(
|
||||
icon: Icon(getIconData(mode)),
|
||||
color: currentMode == mode
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
onPressed: () => updateMode(mode),
|
||||
),
|
||||
);
|
||||
}).toList() +
|
||||
[
|
||||
IconButton(
|
||||
icon: Icon(Icons.adaptive.more_outlined),
|
||||
onPressed: showMore,
|
||||
Tooltip(
|
||||
message: L10n.of(context)!.more,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.adaptive.more_outlined),
|
||||
onPressed: showMore,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,19 +1,40 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_style.dart';
|
||||
import 'package:fluffychat/pangea/widgets/chat/message_toolbar.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;
|
||||
final MessageMode mode;
|
||||
final StreamController<MessageMode> toolbarModeStream;
|
||||
|
||||
const MessageUnsubscribedCard({
|
||||
super.key,
|
||||
required this.languageTool,
|
||||
required this.mode,
|
||||
required this.toolbarModeStream,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool inTrialWindow =
|
||||
MatrixState.pangeaController.userController.inTrialWindow;
|
||||
|
||||
void onButtonPress() {
|
||||
if (inTrialWindow) {
|
||||
MatrixState.pangeaController.subscriptionController
|
||||
.activateNewUserTrial();
|
||||
toolbarModeStream.add(mode);
|
||||
} else {
|
||||
MatrixState.pangeaController.subscriptionController
|
||||
.showPaywall(context);
|
||||
}
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
||||
child: Column(
|
||||
|
|
@ -27,17 +48,17 @@ class MessageUnsubscribedCard extends StatelessWidget {
|
|||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
MatrixState.pangeaController.subscriptionController
|
||||
.showPaywall(context);
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
},
|
||||
onPressed: onButtonPress,
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all<Color>(
|
||||
(AppConfig.primaryColor).withOpacity(0.1),
|
||||
),
|
||||
),
|
||||
child: Text(L10n.of(context)!.getAccess),
|
||||
child: Text(
|
||||
inTrialWindow
|
||||
? L10n.of(context)!.activateTrial
|
||||
: L10n.of(context)!.getAccess,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ class PaywallCard extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool inTrialWindow =
|
||||
MatrixState.pangeaController.userController.inTrialWindow;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
|
@ -40,8 +43,11 @@ class PaywallCard extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
MatrixState.pangeaController.subscriptionController
|
||||
.showPaywall(context);
|
||||
inTrialWindow
|
||||
? MatrixState.pangeaController.subscriptionController
|
||||
.activateNewUserTrial()
|
||||
: MatrixState.pangeaController.subscriptionController
|
||||
.showPaywall(context);
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
},
|
||||
style: ButtonStyle(
|
||||
|
|
@ -49,7 +55,11 @@ class PaywallCard extends StatelessWidget {
|
|||
(AppConfig.primaryColor).withOpacity(0.1),
|
||||
),
|
||||
),
|
||||
child: Text(L10n.of(context)!.seeOptions),
|
||||
child: Text(
|
||||
inTrialWindow
|
||||
? L10n.of(context)!.activateTrial
|
||||
: L10n.of(context)!.seeOptions,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5.0),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue