diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalConfig.swift b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalConfig.swift index e5b7585e..cb44f9f1 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalConfig.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalConfig.swift @@ -33,8 +33,7 @@ struct AdaptiveModalConfig { let snapAnimationConfig: AdaptiveModalSnapAnimationConfig; let interpolationClampingConfig: AdaptiveModalClampingConfig; - // rename to undershootSnapPoint - let initialSnapPoint: AdaptiveModalSnapPointPreset; + let undershootSnapPoint: AdaptiveModalSnapPointPreset; let overshootSnapPoint: AdaptiveModalSnapPointPreset; let initialSnapPointIndex: Int; @@ -47,7 +46,7 @@ struct AdaptiveModalConfig { if let snapPointFirst = self.baseSnapPoints.first { let initialSnapPointConfig = AdaptiveModalSnapPointConfig( - fromSnapPointPreset: self.initialSnapPoint, + fromSnapPointPreset: self.undershootSnapPoint, fromBaseLayoutConfig: snapPointFirst.snapPoint ); @@ -106,7 +105,7 @@ struct AdaptiveModalConfig { snapAnimationConfig: AdaptiveModalSnapAnimationConfig = .default, interpolationClampingConfig: AdaptiveModalClampingConfig = .default, initialSnapPointIndex: Int = 1, - initialSnapPoint: AdaptiveModalSnapPointPreset? = nil, + undershootSnapPoint: AdaptiveModalSnapPointPreset? = nil, overshootSnapPoint: AdaptiveModalSnapPointPreset? = nil ) { self.baseSnapPoints = snapPoints; @@ -119,7 +118,7 @@ struct AdaptiveModalConfig { self.initialSnapPointIndex = initialSnapPointIndex; - self.initialSnapPoint = initialSnapPoint + self.undershootSnapPoint = undershootSnapPoint ?? .getDefaultInitialSnapPoint(forDirection: snapDirection); self.overshootSnapPoint = overshootSnapPoint diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift index 44434b7d..f0870b56 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift @@ -39,7 +39,7 @@ class AdaptiveModalManager: NSObject { var backgroundDimmingView: UIView?; var backgroundVisualEffectView: UIVisualEffectView?; - var modalFrame: CGRect! { + private var modalFrame: CGRect! { set { guard let newValue = newValue else { return }; self.prevModalFrame = dummyModalView.frame; @@ -52,7 +52,7 @@ class AdaptiveModalManager: NSObject { } }; - var layoutValueContext: RNILayoutValueContext { + private var layoutValueContext: RNILayoutValueContext { if let targetVC = self.targetViewController { return .init(fromTargetViewController: targetVC) ?? .default; }; @@ -189,6 +189,9 @@ class AdaptiveModalManager: NSObject { return CGPoint(x: nextX, y: nextY); }; + // MARK: - Properties - Flags + // --------------------------- + // MARK: - Properties // ------------------- @@ -1004,7 +1007,6 @@ class AdaptiveModalManager: NSObject { animator.startAnimation(); }; - @objc private func onDragPanGesture(_ sender: UIPanGestureRecognizer) { let gesturePoint = sender.location(in: self.targetView); self.gesturePoint = gesturePoint; @@ -1020,7 +1022,7 @@ class AdaptiveModalManager: NSObject { self.modalAnimator?.stopAnimation(true); self.applyInterpolationToModal(forGesturePoint: gesturePoint); - self.onModalWillSnap(); + self.notifyOnModalWillSnap(); case .cancelled, .ended: guard self.enableSnapping else { @@ -1032,7 +1034,7 @@ class AdaptiveModalManager: NSObject { self.snapToClosestSnapPoint(forPoint: gestureFinalPoint) { self.endDisplayLink(); - self.onModalDidSnap(); + self.notifyOnModalDidSnap(); }; self.clearGestureValues(); @@ -1158,13 +1160,13 @@ class AdaptiveModalManager: NSObject { let nextInterpolationPoint = self.interpolationSteps[nextIndex]; - self.onModalWillSnap(); + self.notifyOnModalWillSnap(); self.animateModal(to: nextInterpolationPoint) { _ in self.currentInterpolationIndex = nextIndex; self.nextInterpolationIndex = nil; - self.onModalDidSnap(); + self.notifyOnModalDidSnap(); completion?(); }; }; @@ -1221,9 +1223,7 @@ class AdaptiveModalManager: NSObject { ); }; - func showModal( - completion: (() -> Void)? = nil - ) { + func showModal(completion: (() -> Void)? = nil) { let nextIndex = self.modalConfig.initialSnapPointIndex; self.snapTo(interpolationIndex: nextIndex, completion: completion); }; @@ -1231,7 +1231,7 @@ class AdaptiveModalManager: NSObject { // MARK: - Event Functions // ----------------------- - func onModalWillSnap(){ + private func notifyOnModalWillSnap(){ let interpolationSteps = self.interpolationSteps!; let prevIndex = self.currentInterpolationIndex; @@ -1256,7 +1256,7 @@ class AdaptiveModalManager: NSObject { ); }; - func onModalDidSnap(){ + private func notifyOnModalDidSnap(){ self.eventDelegate?.notifyOnModalDidSnap( prevSnapPointIndex: interpolationSteps[self.prevInterpolationIndex].snapPointIndex,