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 b66705d commit 4effe97
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ extension AdaptiveModalSnapPointPreset {
forDirection direction: AdaptiveModalConfig.Direction
) -> RNILayoutPreset {
switch direction {
case .bottomToTop: return .offscreenTop;
case .topToBottom: return .offscreenBottom;
case .leftToRight: return .offscreenLeft;
case .rightToLeft: return .offscreenRight;
case .bottomToTop: return .edgeTop;
case .topToBottom: return .edgeBottom;
case .leftToRight: return .edgeLeft;
case .rightToLeft: return .edgeRight;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit

enum RNILayoutPreset {
case offscreenBottom, offscreenTop, offscreenLeft, offscreenRight;
case halfOffscreenBottom, halfOffscreenTop, halfOffscreenLeft, halfOffscreenRight;
case edgeBottom, edgeTop, edgeLeft, edgeRight;
case center;

Expand Down Expand Up @@ -57,6 +58,34 @@ enum RNILayoutPreset {
derivedFrom: baseLayoutConfig,
verticalAlignment: .bottom
);

case .halfOffscreenBottom:
return .init(
derivedFrom: baseLayoutConfig,
verticalAlignment: .top,
marginTop: baseRect.height / 2
);

case .halfOffscreenTop:
return .init(
derivedFrom: baseLayoutConfig,
verticalAlignment: .top,
marginTop: -(baseRect.height / 2)
);

case .halfOffscreenLeft:
return .init(
derivedFrom: baseLayoutConfig,
horizontalAlignment: .left,
marginLeft: -(baseRect.width / 2)
);

case .halfOffscreenRight:
return .init(
derivedFrom: baseLayoutConfig,
horizontalAlignment: .right,
marginRight: baseRect.width / 2
);

case .edgeTop:
return .init(
Expand Down

0 comments on commit 4effe97

Please sign in to comment.