Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetBottomAttachedOverlayLayoutConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Oct 5, 2024
1 parent b37f584 commit 25bd33b
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions ios/ModalSheet/ModalSheetBottomAttachedOverlayLayoutConfig.swift
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
);
};
};

0 comments on commit 25bd33b

Please sign in to comment.