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 31, 2023
1 parent 8e31c61 commit dda1dd9
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ class AdaptiveModalManager {
// MARK: - Computed Properties
// ---------------------------

var modalFrame: CGRect? {
var modalRect: CGRect? {
set {
guard let modalView = self.modalView,
let newValue = newValue
else { return };

self.prevModalFrame = modalView.frame;
modalView.frame = newValue;
if let modalPresentationLayer = modalView.layer.presentation() {
self.prevModalFrame = modalPresentationLayer.frame;
};

modalView.bounds.size = newValue.size;

modalView.transform = CGAffineTransform(
translationX: newValue.midX,
y: newValue.midY
);
}
get {
self.modalView?.frame;
Expand Down Expand Up @@ -320,7 +328,7 @@ class AdaptiveModalManager {
if let nextModalRect = self.interpolateModalRect(
forInputValue: gestureInput
) {
self.modalFrame = nextModalRect;
self.modalRect = nextModalRect;
};

if let modalBorderRadiusMask = self.interpolateModalBorderRadius(
Expand Down Expand Up @@ -382,7 +390,8 @@ class AdaptiveModalManager {
self.animator = animator;

animator.addAnimations {
modalView.frame = interpolationPoint.computedRect;
self.modalRect = interpolationPoint.computedRect;
modalView.layer.mask = interpolationPoint.modalRadiusMask
};

if let completion = completion {
Expand Down Expand Up @@ -493,6 +502,7 @@ class AdaptiveModalManager {
};

@objc func onDisplayLinkTick(displayLink: CADisplayLink){
return;
/// `Note:2023-05-30-16-13-29`
///
/// The interpolation can be driven by either via **Method-A** or
Expand Down Expand Up @@ -543,7 +553,8 @@ class AdaptiveModalManager {
print(
"onDisplayLinkTick"
+ "\n - displayLink.timestamp: \(displayLink.timestamp)"
+ "\n - presentation frame: \(modalView.layer.presentation()?.frame)"
+ "\n - inputValueNext: \(inputValueNext)"
+ "\n - inputValuePrev: \(inputValuePrev)"
);
};

Expand Down Expand Up @@ -622,7 +633,7 @@ class AdaptiveModalManager {
currentSize: self.currentSizeProvider()
);

self.modalFrame = computedRect;
self.modalRect = computedRect;
};
};

Expand Down

0 comments on commit dda1dd9

Please sign in to comment.