From e17c2ea7dcaafe68a229623320d2a5cea64a1fff Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Fri, 27 Sep 2024 11:47:55 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`ModalViewControll?= =?UTF-8?q?erMetrics`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Temp/ModalViewControllerMetrics.swift | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 ios/Temp/ModalViewControllerMetrics.swift diff --git a/ios/Temp/ModalViewControllerMetrics.swift b/ios/Temp/ModalViewControllerMetrics.swift new file mode 100644 index 00000000..d13cddca --- /dev/null +++ b/ios/Temp/ModalViewControllerMetrics.swift @@ -0,0 +1,47 @@ +// +// ModalViewControllerMetrics.swift +// react-native-ios-modal +// +// Created by Dominic Go on 9/27/24. +// + +import Foundation +import DGSwiftUtilities + + +public struct ModalViewControllerMetrics: Encodable { + + public var isBeingDismissed: Bool; + public var isBeingPresented: Bool; + public var isPresentedAsModal: Bool; + + public var modalLevel: Int; + public var topmostModalLevel: Int; + public var isTopMostModal: Bool; + + public var hasPanGesture: Bool; + public var isPanGestureEnabled: Bool; + + public var modalPresentationStyle: String; + public var isUsingSheetPresentationController: Bool; + + public init(viewController modalVC: UIViewController){ + + self.isBeingDismissed = modalVC.isBeingDismissed + self.isBeingPresented = modalVC.isBeingPresented + self.isPresentedAsModal = modalVC.isPresentedAsModal; + + self.modalLevel = modalVC.modalLevel ?? -1; + self.topmostModalLevel = modalVC.topmostModalLevel ?? -1; + self.isTopMostModal = modalVC.isTopMostModal; + + let modalGesture = modalVC.closestSheetPanGesture; + self.hasPanGesture = modalGesture != nil; + self.isPanGestureEnabled = modalGesture?.isEnabled ?? false; + + self.modalPresentationStyle = modalVC.modalPresentationStyle.caseString; + + self.isUsingSheetPresentationController = + modalVC.isUsingSheetPresentationController; + }; +};