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 5, 2023
1 parent c579ae1 commit 61b4ed4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,31 +186,42 @@ struct AdaptiveModalInterpolationPoint: Equatable {

var transforms: [CGAffineTransform] = [];

if shouldApplyRotation {
if shouldApplyRotation,
self.modalRotation != 0 {

transforms.append(
.init(rotationAngle: self.modalRotation)
);
};

if shouldApplyScale {
if shouldApplyScale,
self.modalScaleX != 1 && self.modalScaleY != 1 {

transforms.append(
.init(scaleX: self.modalScaleX, y: self.modalScaleY)
);
};

if shouldApplyTranslate {
if shouldApplyTranslate,
self.modalTranslateX != 0 && self.modalTranslateY != 0 {

transforms.append(
.init(translationX: self.modalTranslateX, y: self.modalTranslateY)
);
};

if transforms.isEmpty {
return .identity;
};

return transforms.reduce(.identity){
$0.concatenating($1);
};
};

func apply(toModalView modalView: UIView){
modalView.frame = self.computedRect;
modalView.transform = self.getModalTransform(shouldApplyTranslate: false);

modalView.layer.cornerRadius = self.modalCornerRadius;
modalView.layer.maskedCorners = self.modalMaskedCorners;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class AdaptiveModalManager {
if let nextModalTransform = self.interpolateModalTransform(
forInputPercentValue: inputPercentValue
) {
modalView.transform = nextModalTransform;
//modalView.transform = nextModalTransform;
};

if let nextModalRadius = self.interpolateModalBorderRadius(
Expand Down Expand Up @@ -934,10 +934,8 @@ class AdaptiveModalManager {
};

@objc func onDisplayLinkTick(displayLink: CADisplayLink) {
guard let modalView = self.modalView,
let dummyModalViewPresentationLayer =
guard let dummyModalViewPresentationLayer =
self.dummyModalView.layer.presentation(),

let interpolationRangeMaxInput = self.interpolationRangeMaxInput
else { return };

Expand All @@ -963,6 +961,7 @@ class AdaptiveModalManager {
? Self.invertPercent(percent)
: percent;


self.applyInterpolationToBackgroundVisualEffect(
forInputPercentValue: percentAdj
);
Expand All @@ -971,12 +970,6 @@ class AdaptiveModalManager {
forInputPercentValue: percentAdj
);

if let modalTranslate = self.interpolateModalTransform(
forInputPercentValue: percentAdj
) {
modalView.transform = modalTranslate.concatenating(.identity);
};

self.prevModalFrame = nextModalFrame;
};

Expand Down

0 comments on commit 61b4ed4

Please sign in to comment.