Skip to content

Commit

Permalink
💫 Update: Exp - AdaptiveModal
Browse files Browse the repository at this point in the history
Summary: Update experiment/test - `swift-programmatic-modal/AdaptiveModal`.
  • Loading branch information
dominicstop committed Jun 16, 2023
1 parent 317e20d commit f194b5b
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class AdaptiveModalManager: NSObject {
// MARK: - Properties
// -------------------

private var didTriggerSetup = false;

weak var eventDelegate: AdaptiveModalEventNotifiable?;

// MARK: - Computed Properties
Expand Down Expand Up @@ -900,6 +902,8 @@ class AdaptiveModalManager: NSObject {
self.modalBackgroundVisualEffectView = nil;
self.backgroundDimmingView = nil;
self.backgroundVisualEffectView = nil;

self.didTriggerSetup = false;
};

private func cleanup() {
Expand Down Expand Up @@ -1254,6 +1258,7 @@ class AdaptiveModalManager: NSObject {

private func notifyOnModalDidHide(){
self.cleanup();
self.modalViewController?.dismiss(animated: false);
};

// MARK: - User-Invoked Functions
Expand All @@ -1266,22 +1271,32 @@ class AdaptiveModalManager: NSObject {
guard let modalView = modalView ?? self.modalView,
let targetView = targetView ?? self.targetView
else { return };

self.cleanup();

let didViewsChange =
modalView !== self.modalView || targetView !== self.targetView;

let shouldReset = !self.didTriggerSetup || didViewsChange;

if shouldReset {
self.cleanup();
};

self.modalView = modalView;
self.targetView = targetView;

self.computeSnapPoints();

self.setupInitViews();
self.setupDummyModalView();
self.setupGestureHandler();

self.setupAddViews();
self.setupViewConstraints();
if shouldReset {
self.setupInitViews();
self.setupDummyModalView();
self.setupGestureHandler();

self.setupAddViews();
self.setupViewConstraints();
};

self.updateModal();
self.didTriggerSetup = true;
};

func prepareForPresentation(
Expand Down

0 comments on commit f194b5b

Please sign in to comment.