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 2, 2023
1 parent d124753 commit 7799c6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ struct AdaptiveModalConfig {
};
};

var shouldInvertPercent: Bool {
switch self.snapDirection {
case .bottomToTop, .rightToLeft: return true;
default: return false;
};
};

// MARK: - Init
// ------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ struct AdaptiveModalInterpolationPoint: Equatable {
self.percent = percent ?? {
switch modalConfig.snapPercentStrategy {
case .position:
let shouldInvertPercent: Bool = {
switch modalConfig.snapDirection {
case .bottomToTop, .rightToLeft: return true;
default: return false;
};
}();

let maxRangeInput =
targetRect[keyPath: modalConfig.maxInputRangeKeyForRect];

Expand All @@ -56,7 +49,7 @@ struct AdaptiveModalInterpolationPoint: Equatable {

let percent = inputValue / maxRangeInput;

return shouldInvertPercent
return modalConfig.shouldInvertPercent
? AdaptiveModalManager.invertPercent(percent)
: percent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,9 @@ class AdaptiveModalManager {
let inputCoord =
modalView.frame.origin[keyPath: self.modalConfig.inputValueKeyForPoint];

let shouldInvertPercent: Bool = {
switch self.modalConfig.snapDirection {
case .bottomToTop, .rightToLeft: return true;
default: return false;
};
}();

let percent = inputCoord / interpolationRangeMaxInput;

return shouldInvertPercent
return self.modalConfig.shouldInvertPercent
? Self.invertPercent(percent)
: percent;
};
Expand Down Expand Up @@ -647,7 +640,7 @@ class AdaptiveModalManager {
let prevModalFrame = self.prevModalFrame;
let nextModalFrame = modalViewPresentationLayer.frame;

// guard inputValueNext != inputValuePrev else { return };
guard prevModalFrame != nextModalFrame else { return };

self.applyInterpolationToBackgroundVisualEffect(
forInputPercentValue: currentPercent
Expand Down Expand Up @@ -679,8 +672,6 @@ class AdaptiveModalManager {
withTargetRect: targetView.frame,
currentSize: currentSize
);

print(self.interpolationSteps);
};

func notifyOnDragPanGesture(_ gesture: UIPanGestureRecognizer){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ struct AdaptiveModalPropertyAnimator {
let inputPercentAdj = inputPercentValue - self.inputRangeStart;

let percent = inputPercentAdj / inputRangeEndAdj;

print(
"component: \(self.component)"
+ "\n - percent: \(percent)"
);
self.setFractionComplete(forPercent: percent);
};

Expand Down

0 comments on commit 7799c6e

Please sign in to comment.