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 6, 2023
1 parent 108c27a commit 71e9bc5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct AdaptiveModalInterpolationPoint: Equatable {
let percent = inputValue / maxRangeInput;

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

case .index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ class AdaptiveModalManager {
y: (gestureVelocity.y / 2).clamped(minMax: maxVelocity)
);

let nextX = Self.computeFinalPosition(
let nextX = AdaptiveModalUtilities.computeFinalPosition(
position: gesturePoint.x,
initialVelocity: gestureVelocityClamped.x
);

let nextY = Self.computeFinalPosition(
let nextY = AdaptiveModalUtilities.computeFinalPosition(
position: gesturePoint.y,
initialVelocity: gestureVelocityClamped.y
);
Expand Down Expand Up @@ -351,7 +351,7 @@ class AdaptiveModalManager {
let interpolationRangeInput = rangeInput ?? self.interpolationRangeInput
else { return nil };

return Self.interpolate(
return AdaptiveModalUtilities.interpolate(
inputValue: inputValue,
rangeInput: interpolationRangeInput,
rangeOutput: interpolationSteps.map {
Expand All @@ -375,7 +375,7 @@ class AdaptiveModalManager {
let interpolationRangeInput = rangeInput ?? self.interpolationRangeInput
else { return nil };

return Self.interpolateColor(
return AdaptiveModalUtilities.interpolateColor(
inputValue: inputValue,
rangeInput: interpolationRangeInput,
rangeOutput: interpolationSteps.map {
Expand Down Expand Up @@ -676,15 +676,15 @@ class AdaptiveModalManager {
forInputPercentValue: inputPercentValue
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: modalView,
forPropertyKey: \.transform,
withValue: self.interpolateModalTransform(
forInputPercentValue: inputPercentValue
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: modalView,
forPropertyKey: \.alpha,
withValue: self.interpolate(
Expand All @@ -693,15 +693,15 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: modalView,
forPropertyKey: \.layer.cornerRadius,
withValue: self.interpolateModalBorderRadius(
forInputPercentValue: inputPercentValue
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.modalBackgroundView,
forPropertyKey: \.backgroundColor,
withValue: self.interpolateColor(
Expand All @@ -710,7 +710,7 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.modalBackgroundView,
forPropertyKey: \.alpha,
withValue: self.interpolate(
Expand All @@ -719,7 +719,7 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.modalBackgroundVisualEffectView,
forPropertyKey: \.alpha,
withValue: self.interpolate(
Expand All @@ -728,7 +728,7 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.backgroundDimmingView,
forPropertyKey: \.backgroundColor,
withValue: self.interpolateColor(
Expand All @@ -737,7 +737,7 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.backgroundDimmingView,
forPropertyKey: \.alpha,
withValue: self.interpolate(
Expand All @@ -746,7 +746,7 @@ class AdaptiveModalManager {
)
);

Self.setProperty(
AdaptiveModalUtilities.unwrapAndSetProperty(
forObject: self.backgroundVisualEffectView,
forPropertyKey: \.alpha,
withValue: self.interpolate(
Expand Down Expand Up @@ -780,7 +780,7 @@ class AdaptiveModalManager {
let percent = inputValue / interpolationRangeMaxInput;

let percentAdj = shouldInvertPercent
? Self.invertPercent(percent)
? AdaptiveModalUtilities.invertPercent(percent)
: percent;

self.applyInterpolationToModal(forInputPercentValue: percentAdj);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ class AdaptiveModalManager {
let percent = inputCoord / interpolationRangeMaxInput;

let percentAdj = self.modalConfig.shouldInvertPercent
? Self.invertPercent(percent)
? AdaptiveModalUtilities.invertPercent(percent)
: percent;


Expand Down Expand Up @@ -1125,7 +1125,7 @@ class AdaptiveModalManager {
self.getClosestSnapPoint(forRect: self.modalFrame)
else { return };

let interpolatedDuration = Self.interpolate(
let interpolatedDuration = AdaptiveModalUtilities.interpolate(
inputValue: closestSnapPoint.snapDistance,
rangeInput: [0, targetView.frame.height],
rangeOutput: [0.2, 0.7]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct AdaptiveModalRangePropertyAnimator {
return [0, 1];
}();

let percent = AdaptiveModalManager.interpolate(
let percent = AdaptiveModalUtilities.interpolate(
inputValue: inputPercentValue,
rangeInput: range.map {
$0.percent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

extension AdaptiveModalManager {
class AdaptiveModalUtilities {

static func interpolate(
inputValue : CGFloat,
Expand Down Expand Up @@ -180,7 +180,7 @@ extension AdaptiveModalManager {
return 1 - percent + offset;
};

static func setProperty<O: AnyObject, T>(
static func unwrapAndSetProperty<O: AnyObject, T>(
forObject object: O?,
forPropertyKey propertyKey: WritableKeyPath<O, T>,
withValue value: T?
Expand All @@ -192,7 +192,7 @@ extension AdaptiveModalManager {
object[keyPath: propertyKey] = value;
};

static func setProperty<O, T>(
static func unwrapAndSetProperty<O, T>(
for valueType: inout O?,
forPropertyKey propertyKey: WritableKeyPath<O, T>,
withValue newValue: T?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
880492582A23F89000D74E9F /* AdaptiveModalInterpolationPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 880492572A23F89000D74E9F /* AdaptiveModalInterpolationPoint.swift */; };
88075E272A2121FE00B78388 /* AdaptiveModalManager+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88075E262A2121FE00B78388 /* AdaptiveModalManager+Helpers.swift */; };
88075E272A2121FE00B78388 /* AdaptiveModalUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88075E262A2121FE00B78388 /* AdaptiveModalUtilities.swift */; };
88203DC12A122AC20088C8E2 /* RNIDynamicModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88203DC02A122AC20088C8E2 /* RNIDynamicModal.swift */; };
88B7D0EF29C593F400490628 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B7D0EE29C593F400490628 /* AppDelegate.swift */; };
88B7D0F129C593F400490628 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B7D0F029C593F400490628 /* SceneDelegate.swift */; };
Expand Down Expand Up @@ -96,7 +96,7 @@

/* Begin PBXFileReference section */
880492572A23F89000D74E9F /* AdaptiveModalInterpolationPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptiveModalInterpolationPoint.swift; sourceTree = "<group>"; };
88075E262A2121FE00B78388 /* AdaptiveModalManager+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AdaptiveModalManager+Helpers.swift"; sourceTree = "<group>"; };
88075E262A2121FE00B78388 /* AdaptiveModalUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptiveModalUtilities.swift; sourceTree = "<group>"; };
88203DC02A122AC20088C8E2 /* RNIDynamicModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNIDynamicModal.swift; sourceTree = "<group>"; };
88B7D0EB29C593F400490628 /* swift-programmatic-modal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift-programmatic-modal.app"; sourceTree = BUILT_PRODUCTS_DIR; };
88B7D0EE29C593F400490628 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -526,7 +526,7 @@
880492572A23F89000D74E9F /* AdaptiveModalInterpolationPoint.swift */,
88C2F45D2A278A9200DA7450 /* AdaptiveModalRangePropertyAnimator.swift */,
88D0188D2A1DCA61004664D2 /* AdaptiveModalManager.swift */,
88075E262A2121FE00B78388 /* AdaptiveModalManager+Helpers.swift */,
88075E262A2121FE00B78388 /* AdaptiveModalUtilities.swift */,
88C2F4612A2CD81F00DA7450 /* AdaptiveModalEventNotifiable.swift */,
88C2F4632A2D8D3400DA7450 /* AdaptiveModalKeyframePropertyAnimator.swift */,
);
Expand Down Expand Up @@ -660,7 +660,7 @@
88D018272A1B3030004664D2 /* RNIInternalCleanupMode.swift in Sources */,
88D018782A1B3030004664D2 /* RNIComputableSize.swift in Sources */,
88D018732A1B3030004664D2 /* RNIModalCustomSheetDetent.swift in Sources */,
88075E272A2121FE00B78388 /* AdaptiveModalManager+Helpers.swift in Sources */,
88075E272A2121FE00B78388 /* AdaptiveModalUtilities.swift in Sources */,
88D018252A1B3030004664D2 /* UIViewController+Helpers.swift in Sources */,
88D018882A1D0A36004664D2 /* AdaptiveModalConfig.swift in Sources */,
88D018432A1B3030004664D2 /* UIGestureRecognizer+Helpers.swift in Sources */,
Expand Down

0 comments on commit 71e9bc5

Please sign in to comment.