From 0cb73f7eedb88f2895e511ca46458d1e82deee98 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Fri, 27 Sep 2024 11:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`PresentationContr?= =?UTF-8?q?ollerMetrics`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Temp/PresentationControllerMetrics.swift | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 ios/Temp/PresentationControllerMetrics.swift diff --git a/ios/Temp/PresentationControllerMetrics.swift b/ios/Temp/PresentationControllerMetrics.swift new file mode 100644 index 00000000..d6b4cdfb --- /dev/null +++ b/ios/Temp/PresentationControllerMetrics.swift @@ -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; + }; +}; +