Paywall on IGC click (#1310)
* Shows paywall when user clicks IGC button * Always show paywall card on press IGC button --------- Co-authored-by: ggurdin <ggurdin@gmail.com>
This commit is contained in:
parent
e7dcd893fc
commit
0d477ad5b4
3 changed files with 22 additions and 0 deletions
|
|
@ -631,6 +631,10 @@ class Choreographer {
|
|||
);
|
||||
|
||||
AssistanceState get assistanceState {
|
||||
if (!pangeaController.subscriptionController.isSubscribed) {
|
||||
return AssistanceState.noSub;
|
||||
}
|
||||
|
||||
if (currentText.isEmpty && itController.sourceText == null) {
|
||||
return AssistanceState.noMessage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import 'dart:math' as math;
|
|||
|
||||
import 'package:fluffychat/pangea/enum/assistance_state_enum.dart';
|
||||
import 'package:fluffychat/pangea/pages/settings_learning/settings_learning.dart';
|
||||
import 'package:fluffychat/pangea/utils/overlay.dart';
|
||||
import 'package:fluffychat/pangea/widgets/igc/paywall_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../pages/chat/chat.dart';
|
||||
|
|
@ -67,6 +69,18 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
|
||||
Future<void> _onTap() async {
|
||||
switch (assistanceState) {
|
||||
case AssistanceState.noSub:
|
||||
OverlayUtil.showPositionedCard(
|
||||
context: context,
|
||||
cardToShow: PaywallCard(
|
||||
chatController: widget.controller,
|
||||
),
|
||||
maxHeight: 325,
|
||||
maxWidth: 325,
|
||||
transformTargetId:
|
||||
widget.controller.choreographer.inputTransformTargetKey,
|
||||
);
|
||||
return;
|
||||
case AssistanceState.noMessage:
|
||||
showDialog(
|
||||
context: context,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
// assistance state is, user has not typed a message, user has typed a message and IGC has not run,
|
||||
// IGC is running, IGC has run and there are remaining steps (either IT or IGC), or all steps are done
|
||||
// Or user does not have a subscription
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/constants/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
enum AssistanceState {
|
||||
noSub,
|
||||
noMessage,
|
||||
notFetched,
|
||||
fetching,
|
||||
|
|
@ -16,6 +18,7 @@ enum AssistanceState {
|
|||
extension AssistanceStateExtension on AssistanceState {
|
||||
Color stateColor(context) {
|
||||
switch (this) {
|
||||
case AssistanceState.noSub:
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.notFetched:
|
||||
case AssistanceState.fetching:
|
||||
|
|
@ -32,6 +35,7 @@ extension AssistanceStateExtension on AssistanceState {
|
|||
case AssistanceState.noMessage:
|
||||
case AssistanceState.notFetched:
|
||||
return l10n.runGrammarCorrection;
|
||||
case AssistanceState.noSub:
|
||||
case AssistanceState.fetching:
|
||||
return "";
|
||||
case AssistanceState.fetched:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue