Skip to content

Commit

Permalink
⭐️ Impl: PresentationControllerMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 27, 2024
1 parent e17c2ea commit 0cb73f7
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions ios/Temp/PresentationControllerMetrics.swift
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;
};
};

0 comments on commit 0cb73f7

Please sign in to comment.