-
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:
ModalSheetBottomAttachedOverlayLayoutConfig
- Loading branch information
1 parent
b37f584
commit 25bd33b
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
ios/ModalSheet/ModalSheetBottomAttachedOverlayLayoutConfig.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,77 @@ | ||
// | ||
// ModalSheetBottomAttachedOverlayLayoutConfig.swift | ||
// react-native-ios-modal | ||
// | ||
// Created by Dominic Go on 10/6/24. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct ModalSheetBottomAttachedOverlayLayoutConfig { | ||
|
||
public var horizontalPositionMode: ViewPositionHorizontal; | ||
|
||
public var marginLeft: CGFloat; | ||
public var marginRight: CGFloat; | ||
|
||
public var marginBottom: ModalSheetBottomDistance; | ||
public var paddingBottom: ModalSheetBottomDistance; | ||
|
||
init( | ||
horizontalPositionMode: ViewPositionHorizontal, | ||
marginLeft: CGFloat = 0, | ||
marginRight: CGFloat = 0, | ||
marginBottom: ModalSheetBottomDistance = .zero, | ||
paddingBottom: ModalSheetBottomDistance = .zero | ||
) { | ||
self.horizontalPositionMode = horizontalPositionMode; | ||
self.marginLeft = marginLeft; | ||
self.marginRight = marginRight; | ||
self.marginBottom = marginBottom; | ||
self.paddingBottom = paddingBottom; | ||
}; | ||
|
||
public func createExternalHorizontalConstraints( | ||
forView childView: UIView, | ||
attachingTo parentView: UIView, | ||
preferToUseWidthConstraint: Bool = false | ||
) -> [NSLayoutConstraint] { | ||
|
||
let window = | ||
childView.window | ||
?? parentView.window | ||
?? UIApplication.shared.activeWindow; | ||
|
||
return self.horizontalPositionMode.createHorizontalConstraints( | ||
forView: childView, | ||
attachingTo: parentView, | ||
withWindow: window, | ||
marginLeading: self.marginLeft, | ||
marginTrailing: self.marginRight, | ||
preferToUseWidthConstraint: preferToUseWidthConstraint | ||
); | ||
}; | ||
|
||
public func createExternalBottomConstraints( | ||
forView childView: UIView, | ||
attachingTo parentView: UIView | ||
) -> [NSLayoutConstraint] { | ||
|
||
self.marginBottom.createBottomConstraint( | ||
forView: childView, | ||
attachingTo: parentView | ||
); | ||
}; | ||
|
||
public func createInternalBottomConstraint( | ||
forView childView: UIView, | ||
attachingTo parentView: UIView | ||
) -> [NSLayoutConstraint] { | ||
|
||
self.paddingBottom.createBottomConstraint( | ||
forView: childView, | ||
attachingTo: parentView | ||
); | ||
}; | ||
}; |