-
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:
PresentationControllerMetrics
- Loading branch information
1 parent
e17c2ea
commit 0cb73f7
Showing
1 changed file
with
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// PresentationControllerMetrics.swift | ||
// react-native-ios-modal | ||
// | ||
// Created by Dominic Go on 9/27/24. | ||
// | ||
|
||
import UIKit | ||
import DGSwiftUtilities | ||
|
||
|
||
public struct PresentationControllerMetrics: Encodable { | ||
|
||
public var frameOfPresentedViewInContainerView: CGRect; | ||
public var preferredContentSize: CGSize; | ||
|
||
public var presentedViewFrame: CGRect?; | ||
public var containerViewFrame: CGRect?; | ||
|
||
public var adaptivePresentationStyle: String; | ||
|
||
public var shouldPresentInFullscreen: Bool; | ||
public var shouldRemovePresentersView: Bool; | ||
|
||
public init(from presentationController: UIPresentationController) { | ||
self.frameOfPresentedViewInContainerView = | ||
presentationController.frameOfPresentedViewInContainerView; | ||
|
||
self.preferredContentSize = | ||
presentationController.preferredContentSize; | ||
|
||
self.presentedViewFrame = { | ||
guard let presentedView = presentationController.presentedView else { | ||
return nil; | ||
}; | ||
|
||
return presentedView.globalFrame ?? presentedView.frame; | ||
}(); | ||
|
||
self.containerViewFrame = { | ||
guard let containerView = presentationController.containerView else { | ||
return nil; | ||
}; | ||
|
||
return containerView.globalFrame ?? containerView.frame; | ||
}(); | ||
|
||
self.adaptivePresentationStyle = | ||
presentationController.adaptivePresentationStyle.caseString; | ||
|
||
self.shouldPresentInFullscreen = | ||
presentationController.shouldPresentInFullscreen; | ||
|
||
self.shouldRemovePresentersView = | ||
presentationController.shouldRemovePresentersView; | ||
}; | ||
}; | ||
|