activate trial from toolbar
This commit is contained in:
parent
713bac400e
commit
b382f93abb
3 changed files with 42 additions and 9 deletions
|
|
@ -186,6 +186,8 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
if (!subscribed) {
|
||||
child = MessageUnsubscribedCard(
|
||||
languageTool: getModeTitle(newMode),
|
||||
mode: newMode,
|
||||
toolbarModeStream: widget.toolbarModeStream,
|
||||
);
|
||||
} else {
|
||||
switch (currentMode) {
|
||||
|
|
|
|||
|
|
@ -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