-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ Impl:
ModalSheetBottomAttachedOverlayLayoutConfigPreset
- Loading branch information
1 parent
25bd33b
commit aca4b64
Showing
2 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
ios/ModalSheet/ModalSheetBottomAttachedOverlayLayoutConfigPreset.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// | ||
// ModalSheetBottomAttachedOverlayLayoutConfigPreset.swift | ||
// react-native-ios-modal | ||
// | ||
// Created by Dominic Go on 10/6/24. | ||
// | ||
|
||
import Foundation | ||
|
||
/// These are mainly used for testing | ||
/// | ||
public enum ModalSheetBottomAttachedOverlayLayoutConfigPreset: String, CaseIterable { | ||
|
||
case stretchWithSafeAreaPadding; | ||
|
||
case centerFloatStretch80Percent; | ||
case centerAttachedStretch90Percent; | ||
|
||
case leadingFloatStretchQuarter; | ||
case leadingFloatStretchHalf; | ||
case leadingFloatStretchThreeQuarters; | ||
|
||
case trailingFloatStretchQuarter; | ||
case trailingFloatStretchHalf; | ||
case trailingFloatStretchThreeQuarters; | ||
|
||
case leadingAttachedStretchQuarter; | ||
case leadingAttachedStretchHalf; | ||
case leadingAttachedStretchThreeQuarters; | ||
|
||
case trailingAttachedStretchQuarter; | ||
case trailingAttachedStretchHalf; | ||
case trailingAttachedStretchThreeQuarters; | ||
|
||
// MARK: - Computed Properties | ||
// --------------------------- | ||
|
||
public var config: ModalSheetBottomAttachedOverlayLayoutConfig { | ||
switch self { | ||
case .stretchWithSafeAreaPadding: | ||
return .init( | ||
horizontalPositionMode: .stretch, | ||
paddingBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 0 | ||
) | ||
); | ||
|
||
case .centerFloatStretch80Percent: | ||
return .init( | ||
horizontalPositionMode: .centerStretch(percent: 0.8), | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .centerAttachedStretch90Percent: | ||
return .init( | ||
horizontalPositionMode: .centerStretch(percent: 0.9), | ||
paddingBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .leadingFloatStretchQuarter: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.25), | ||
marginLeft: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .leadingFloatStretchHalf: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.5), | ||
marginLeft: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .leadingFloatStretchThreeQuarters: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.75), | ||
marginLeft: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .trailingFloatStretchQuarter: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.25), | ||
marginRight: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .trailingFloatStretchHalf: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.5), | ||
marginRight: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .trailingFloatStretchThreeQuarters: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.75), | ||
marginRight: 12, | ||
marginBottom: .safeArea( | ||
additionalValue: 0, | ||
minValue: 12 | ||
) | ||
); | ||
|
||
case .leadingAttachedStretchQuarter: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.25), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
|
||
case .leadingAttachedStretchHalf: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.5), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
|
||
case .leadingAttachedStretchThreeQuarters: | ||
return .init( | ||
horizontalPositionMode: .leadingStretch(percent: 0.75), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
|
||
case .trailingAttachedStretchQuarter: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.25), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
|
||
case .trailingAttachedStretchHalf: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.5), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
|
||
case .trailingAttachedStretchThreeQuarters: | ||
return .init( | ||
horizontalPositionMode: .trailingStretch(percent: 0.5), | ||
paddingBottom: .safeArea(minValue: 12) | ||
); | ||
}; | ||
}; | ||
}; |