Merge pull request #824 from pangeachat/819-cant-type-with-it-bar
some name cleanup, error handling and dont open overlay if click outs…
This commit is contained in:
commit
b055dcb580
5 changed files with 51 additions and 30 deletions
|
|
@ -70,8 +70,8 @@ class Choreographer {
|
|||
void send(BuildContext context) {
|
||||
if (isFetching) return;
|
||||
|
||||
if (pangeaController.subscriptionController.canSendStatus ==
|
||||
CanSendStatus.showPaywall) {
|
||||
if (pangeaController.subscriptionController.subscriptionStatus ==
|
||||
SubscriptionStatus.showPaywall) {
|
||||
OverlayUtil.showPositionedCard(
|
||||
context: context,
|
||||
cardToShow: PaywallCard(
|
||||
|
|
@ -245,10 +245,10 @@ class Choreographer {
|
|||
}) async {
|
||||
try {
|
||||
if (errorService.isError) return;
|
||||
final CanSendStatus canSendStatus =
|
||||
pangeaController.subscriptionController.canSendStatus;
|
||||
final SubscriptionStatus canSendStatus =
|
||||
pangeaController.subscriptionController.subscriptionStatus;
|
||||
|
||||
if (canSendStatus != CanSendStatus.subscribed ||
|
||||
if (canSendStatus != SubscriptionStatus.subscribed ||
|
||||
(!igcEnabled && !itEnabled) ||
|
||||
(!isAutoIGCEnabled && !manual && choreoMode != ChoreoMode.it)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -63,10 +63,13 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
|
||||
bool get itEnabled => widget.controller.choreographer.itEnabled;
|
||||
bool get igcEnabled => widget.controller.choreographer.igcEnabled;
|
||||
CanSendStatus get canSendStatus =>
|
||||
widget.controller.pangeaController.subscriptionController.canSendStatus;
|
||||
|
||||
SubscriptionStatus get subscriptionStatus => widget
|
||||
.controller.pangeaController.subscriptionController.subscriptionStatus;
|
||||
|
||||
bool get grammarCorrectionEnabled =>
|
||||
(itEnabled || igcEnabled) && canSendStatus == CanSendStatus.subscribed;
|
||||
(itEnabled || igcEnabled) &&
|
||||
subscriptionStatus == SubscriptionStatus.subscribed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import 'package:http/http.dart';
|
|||
import 'package:purchases_flutter/purchases_flutter.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
enum CanSendStatus {
|
||||
enum SubscriptionStatus {
|
||||
subscribed,
|
||||
dimissedPaywall,
|
||||
showPaywall,
|
||||
|
|
@ -227,11 +227,13 @@ class SubscriptionController extends BaseController {
|
|||
setState(null);
|
||||
}
|
||||
|
||||
CanSendStatus get canSendStatus => isSubscribed
|
||||
? CanSendStatus.subscribed
|
||||
/// if the user is subscribed, returns subscribed
|
||||
/// if the user has dismissed the paywall, returns dismissed
|
||||
SubscriptionStatus get subscriptionStatus => isSubscribed
|
||||
? SubscriptionStatus.subscribed
|
||||
: _shouldShowPaywall
|
||||
? CanSendStatus.showPaywall
|
||||
: CanSendStatus.dimissedPaywall;
|
||||
? SubscriptionStatus.showPaywall
|
||||
: SubscriptionStatus.dimissedPaywall;
|
||||
|
||||
DateTime? get _lastDismissedPaywall {
|
||||
final lastDismissed = _pangeaController.pStoreService.read(
|
||||
|
|
@ -249,6 +251,7 @@ class SubscriptionController extends BaseController {
|
|||
return backoff;
|
||||
}
|
||||
|
||||
/// whether or not the paywall should be shown
|
||||
bool get _shouldShowPaywall {
|
||||
return initialized.isCompleted &&
|
||||
!isSubscribed &&
|
||||
|
|
|
|||
|
|
@ -47,9 +47,11 @@ class PangeaTextController extends TextEditingController {
|
|||
debugger(when: kDebugMode);
|
||||
return;
|
||||
}
|
||||
final CanSendStatus canSendStatus =
|
||||
choreographer.pangeaController.subscriptionController.canSendStatus;
|
||||
if (canSendStatus == CanSendStatus.showPaywall &&
|
||||
|
||||
// show the paywall if appropriate
|
||||
if (choreographer
|
||||
.pangeaController.subscriptionController.subscriptionStatus ==
|
||||
SubscriptionStatus.showPaywall &&
|
||||
!choreographer.isFetching &&
|
||||
text.isNotEmpty) {
|
||||
OverlayUtil.showPositionedCard(
|
||||
|
|
@ -63,11 +65,18 @@ class PangeaTextController extends TextEditingController {
|
|||
);
|
||||
}
|
||||
|
||||
// if there is no igc text data, then don't do anything
|
||||
if (choreographer.igc.igcTextData == null) return;
|
||||
|
||||
// debugPrint(
|
||||
// "onInputTap matches are ${choreographer.igc.igcTextData?.matches.map((e) => e.match.rule.id).toList().toString()}");
|
||||
|
||||
// if user is just trying to get their cursor into the text input field to add soemthing,
|
||||
// then don't interrupt them
|
||||
if (selection.baseOffset >= text.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int tokenIndex = choreographer.igc.igcTextData!.tokenIndexByOffset(
|
||||
selection.baseOffset,
|
||||
);
|
||||
|
|
@ -147,9 +156,9 @@ class PangeaTextController extends TextEditingController {
|
|||
// debugPrint("composing after ${value.composing.textAfter(value.text)}");
|
||||
// }
|
||||
|
||||
final CanSendStatus canSendStatus =
|
||||
choreographer.pangeaController.subscriptionController.canSendStatus;
|
||||
if (canSendStatus == CanSendStatus.showPaywall &&
|
||||
final SubscriptionStatus canSendStatus = choreographer
|
||||
.pangeaController.subscriptionController.subscriptionStatus;
|
||||
if (canSendStatus == SubscriptionStatus.showPaywall &&
|
||||
!choreographer.isFetching &&
|
||||
text.isNotEmpty) {
|
||||
return TextSpan(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -11,18 +12,17 @@ class ErrorReporter {
|
|||
void onErrorCallback(Object error, [StackTrace? stackTrace]) async {
|
||||
Logs().e(message ?? 'Error caught', error, stackTrace);
|
||||
// #Pangea
|
||||
// Attempt to retrieve the L10n instance using the current context
|
||||
final L10n? l10n = L10n.of(context);
|
||||
|
||||
// Check if the L10n instance is null
|
||||
if (l10n == null) {
|
||||
// Log an error message saying that the localization object is null
|
||||
Logs().e('Localization object is null, cannot show error message.');
|
||||
// Exits early to prevent further execution
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Attempt to retrieve the L10n instance using the current context
|
||||
final L10n? l10n = L10n.of(context);
|
||||
|
||||
// Check if the L10n instance is null
|
||||
if (l10n == null) {
|
||||
// Log an error message saying that the localization object is null
|
||||
Logs().e('Localization object is null, cannot show error message.');
|
||||
// Exits early to prevent further execution
|
||||
return;
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
|
|
@ -32,6 +32,12 @@ class ErrorReporter {
|
|||
);
|
||||
} catch (err) {
|
||||
debugPrint("Failed to show error snackbar.");
|
||||
} finally {
|
||||
ErrorHandler.logError(
|
||||
e: error,
|
||||
s: stackTrace,
|
||||
m: message ?? 'Error caught',
|
||||
);
|
||||
}
|
||||
}
|
||||
// final text = '$error\n${stackTrace ?? ''}';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue