diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index 2db0663e8..3e362a697 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -14,6 +14,7 @@ import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart'; import 'package:fluffychat/pangea/choreographer/repo/igc_repo.dart'; import 'package:fluffychat/pangea/choreographer/widgets/igc/span_card.dart'; import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import '../../common/utils/error_handler.dart'; import '../../common/utils/overlay.dart'; import '../models/span_card_model.dart'; @@ -243,6 +244,7 @@ class IgcController { } choreographer.chatController.inputFocus.unfocus(); + MatrixState.pAnyState.closeAllOverlays(RegExp(r'span_card_overlay_\d+')); OverlayUtil.showPositionedCard( overlayKey: "span_card_overlay_$firstMatchIndex", context: context, @@ -267,6 +269,7 @@ class IgcController { maxWidth: 350, transformTargetId: choreographer.inputTransformTargetKey, onDismiss: () => choreographer.setState(), + ignorePointer: true, ); } diff --git a/lib/pangea/choreographer/controllers/it_controller.dart b/lib/pangea/choreographer/controllers/it_controller.dart index 216bbeca4..77eae649e 100644 --- a/lib/pangea/choreographer/controllers/it_controller.dart +++ b/lib/pangea/choreographer/controllers/it_controller.dart @@ -13,6 +13,7 @@ import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart'; import 'package:fluffychat/pangea/choreographer/enums/edit_type.dart'; import 'package:fluffychat/pangea/common/utils/error_handler.dart'; import 'package:fluffychat/pangea/events/models/pangea_token_model.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import '../models/custom_input_translation_model.dart'; import '../models/it_response_model.dart'; import '../models/it_step.dart'; @@ -41,6 +42,8 @@ class ITController { void clear() { _isOpen = false; _willOpen = false; + MatrixState.pAnyState.closeOverlay("it_feedback_card"); + showChoiceFeedback = false; _isEditingSourceText = false; dismissed = false; diff --git a/lib/pangea/choreographer/widgets/igc/pangea_text_controller.dart b/lib/pangea/choreographer/widgets/igc/pangea_text_controller.dart index 386e4c42c..054d83913 100644 --- a/lib/pangea/choreographer/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/choreographer/widgets/igc/pangea_text_controller.dart @@ -7,6 +7,7 @@ import 'package:fluffychat/pangea/choreographer/models/igc_text_data_model.dart' import 'package:fluffychat/pangea/choreographer/widgets/igc/paywall_card.dart'; import 'package:fluffychat/pangea/choreographer/widgets/igc/span_card.dart'; import 'package:fluffychat/pangea/subscription/controllers/subscription_controller.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import '../../../common/utils/overlay.dart'; import '../../controllers/choreographer.dart'; import '../../enums/edit_type.dart'; @@ -119,6 +120,7 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { + MatrixState.pAnyState.closeAllOverlays(RegExp(r'span_card_overlay_\d+')); OverlayUtil.showPositionedCard( overlayKey: matchIndex != -1 ? "span_card_overlay_$matchIndex" : null, context: context, @@ -130,6 +132,7 @@ class PangeaTextController extends TextEditingController { cardToShow: cardToShow, transformTargetId: choreographer.inputTransformTargetKey, onDismiss: () => choreographer.setState(), + ignorePointer: true, ); } } diff --git a/lib/pangea/choreographer/widgets/it_bar.dart b/lib/pangea/choreographer/widgets/it_bar.dart index 62da52de0..328888cc3 100644 --- a/lib/pangea/choreographer/widgets/it_bar.dart +++ b/lib/pangea/choreographer/widgets/it_bar.dart @@ -16,6 +16,7 @@ import 'package:fluffychat/pangea/common/utils/error_handler.dart'; import 'package:fluffychat/pangea/instructions/instructions_enum.dart'; import 'package:fluffychat/pangea/instructions/instructions_inline_tooltip.dart'; import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import '../../common/utils/overlay.dart'; import '../controllers/it_feedback_controller.dart'; import '../models/it_response_model.dart'; @@ -334,6 +335,7 @@ class ITChoices extends StatelessWidget { } controller.choreographer.chatController.inputFocus.unfocus(); + MatrixState.pAnyState.closeOverlay("it_feedback_card"); OverlayUtil.showPositionedCard( context: context, cardToShow: choiceFeedback == null @@ -370,10 +372,13 @@ class ITChoices extends StatelessWidget { borderColor: borderColor, transformTargetId: controller.choreographer.itBarTransformTargetKey, isScrollable: choiceFeedback == null, + overlayKey: "it_feedback_card", + ignorePointer: true, ); } void selectContinuance(int index, BuildContext context) { + MatrixState.pAnyState.closeOverlay("it_feedback_card"); final Continuance continuance = controller.currentITStep!.continuances[index]; if (continuance.level == 1) { diff --git a/lib/pangea/common/utils/any_state_holder.dart b/lib/pangea/common/utils/any_state_holder.dart index d7b563900..e759159fa 100644 --- a/lib/pangea/common/utils/any_state_holder.dart +++ b/lib/pangea/common/utils/any_state_holder.dart @@ -82,8 +82,15 @@ class PangeaAnyState { } } - void closeAllOverlays() { - final shouldRemove = entries.where((element) => element.canPop).toList(); + void closeAllOverlays([RegExp? regex]) { + List shouldRemove = + entries.where((element) => element.canPop).toList(); + if (regex != null) { + shouldRemove = shouldRemove + .where((element) => element.key != null) + .where((element) => regex.hasMatch(element.key!)) + .toList(); + } if (shouldRemove.isEmpty) return; for (int i = 0; i < shouldRemove.length; i++) { try { diff --git a/lib/pangea/common/utils/overlay.dart b/lib/pangea/common/utils/overlay.dart index a08efdf8d..633fe82c0 100644 --- a/lib/pangea/common/utils/overlay.dart +++ b/lib/pangea/common/utils/overlay.dart @@ -45,46 +45,46 @@ class OverlayUtil { builder: (context) => AnimatedContainer( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, - child: IgnorePointer( - ignoring: ignorePointer, - child: Stack( - children: [ - if (backDropToDismiss) - TransparentBackdrop( + child: Stack( + children: [ + if (backDropToDismiss) + IgnorePointer( + ignoring: ignorePointer, + child: TransparentBackdrop( backgroundColor: backgroundColor, onDismiss: onDismiss, blurBackground: blurBackground, ), - Positioned( - top: (position == OverlayPositionEnum.centered || - position == OverlayPositionEnum.top) - ? 0 - : null, - right: (position == OverlayPositionEnum.centered || - position == OverlayPositionEnum.top) - ? 0 - : null, - left: (position == OverlayPositionEnum.centered || - position == OverlayPositionEnum.top) - ? 0 - : null, - bottom: (position == OverlayPositionEnum.centered) ? 0 : null, - child: (position != OverlayPositionEnum.transform) - ? child - : CompositedTransformFollower( - targetAnchor: targetAnchor ?? Alignment.topCenter, - followerAnchor: - followerAnchor ?? Alignment.bottomCenter, - link: MatrixState.pAnyState - .layerLinkAndKey(transformTargetId) - .link, - showWhenUnlinked: false, - offset: offset ?? Offset.zero, - child: child, - ), ), - ], - ), + Positioned( + top: (position == OverlayPositionEnum.centered || + position == OverlayPositionEnum.top) + ? 0 + : null, + right: (position == OverlayPositionEnum.centered || + position == OverlayPositionEnum.top) + ? 0 + : null, + left: (position == OverlayPositionEnum.centered || + position == OverlayPositionEnum.top) + ? 0 + : null, + bottom: (position == OverlayPositionEnum.centered) ? 0 : null, + child: (position != OverlayPositionEnum.transform) + ? child + : CompositedTransformFollower( + targetAnchor: targetAnchor ?? Alignment.topCenter, + followerAnchor: + followerAnchor ?? Alignment.bottomCenter, + link: MatrixState.pAnyState + .layerLinkAndKey(transformTargetId) + .link, + showWhenUnlinked: false, + offset: offset ?? Offset.zero, + child: child, + ), + ), + ], ), ), ); @@ -118,6 +118,7 @@ class OverlayUtil { bool isScrollable = true, bool addBorder = true, VoidCallback? onDismiss, + bool ignorePointer = false, }) { try { final LayerLinkAndKey layerLinkAndKey = @@ -194,6 +195,7 @@ class OverlayUtil { followerAnchor: hasTopOverflow ? Alignment.topCenter : Alignment.bottomCenter, onDismiss: onDismiss, + ignorePointer: ignorePointer, ); } catch (err, stack) { debugger(when: kDebugMode);