From 4effe97333f5061c44644deef5101ceade4e6df9 Mon Sep 17 00:00:00 2001 From: Dominic Go <18517029+dominicstop@users.noreply.github.com> Date: Fri, 2 Jun 2023 22:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20Exp=20-=20`AdaptiveMod?= =?UTF-8?q?al`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Update experiment/test - `swift-programmatic-modal/AdaptiveModal`. --- .../AdaptiveModalSnapPointPreset.swift | 8 ++--- .../AdaptiveModal/RNILayoutPreset.swift | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalSnapPointPreset.swift b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalSnapPointPreset.swift index d81dac93..0c2b5e11 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalSnapPointPreset.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalSnapPointPreset.swift @@ -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; }; }; diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/RNILayoutPreset.swift b/experiments/swift-programmatic-modal/AdaptiveModal/RNILayoutPreset.swift index 532bd96e..d8f4f551 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/RNILayoutPreset.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/RNILayoutPreset.swift @@ -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; @@ -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(