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 May 27, 2023
1 parent 9f44dd6 commit 3992014
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class AdaptiveModalManager {
// MARK: - Computed Properties
// ---------------------------

var isSwiping: Bool {
self.gestureInitialPoint != nil
};

/// Defines which axis of the gesture point to use to drive the interpolation
/// of the modal snap points
///
Expand Down Expand Up @@ -186,12 +190,22 @@ class AdaptiveModalManager {
func setFrameForModal(){
guard let modalView = self.modalView else { return };

let currentSnapPoint = self.currentSnapPointConfig.snapPoint;
let computedRect: CGRect = {
if let gesturePoint = self.gesturePoint {
return self.interpolateModalRect(
forGesturePoint: gesturePoint
);
};

let currentSnapPoint = self.currentSnapPointConfig.snapPoint;

return currentSnapPoint.computeRect(
withTargetRect: self.targetRectProvider(),
currentSize: self.currentSizeProvider()
);
}();

modalView.frame = currentSnapPoint.computeRect(
withTargetRect: self.targetRectProvider(),
currentSize: self.currentSizeProvider()
);
modalView.frame = computedRect;
};

func animateModal(toRect nextRect: CGRect) {
Expand Down Expand Up @@ -378,6 +392,7 @@ class AdaptiveModalManager {
self.gestureOffset = nil;
self.gestureInitialPoint = nil;
self.gestureVelocity = nil;
self.gesturePoint = nil;
break;

case .changed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class RNIDraggableTestViewController : UIViewController {
self.modalManager.setFrameForModal();
};

override func viewDidLayoutSubviews() {
self.modalManager.setFrameForModal();
};

@objc func onPressFloatingViewLabel(_ sender: UITapGestureRecognizer){
// self.layoutConfigCount += 1;
// self.updateFloatingView(isAnimated: true);
Expand Down

0 comments on commit 3992014

Please sign in to comment.