Skip to content

Commit

Permalink
🛠 Refactor: Extract RNIModalViewControllerRegistry
Browse files Browse the repository at this point in the history
Summary: Extract type `RNIModalViewControllerRegistry` from `ios/src_library/Extensions/UIViewController+Swizzling`, into its own file `ios/src_library/React Native/RNIModalViewControllerWrapper/RNIModalViewControllerRegistry`.
  • Loading branch information
dominicstop committed Apr 27, 2023
1 parent 62ce749 commit 1cb9fe5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
30 changes: 0 additions & 30 deletions ios/src_library/Extensions/UIViewController+Swizzling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,6 @@
import Foundation


class RNIModalViewControllerRegistry {
static let instanceMap = NSMapTable<
UIViewController,
RNIModalViewControllerWrapper
>(
keyOptions: .weakMemory,
valueOptions: .weakMemory
);

static func get(
forViewController viewController: UIViewController
) -> RNIModalViewControllerWrapper? {

Self.instanceMap.object(forKey: viewController);
};

static func set(
forViewController viewController: UIViewController,
_ modalWrapper: RNIModalViewControllerWrapper
){

Self.instanceMap.setObject(modalWrapper, forKey: viewController);
};

static func isRegistered(
forViewController viewController: UIViewController
) -> Bool {
Self.get(forViewController: viewController) != nil;
};
};


extension UIViewController {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// RNIModalViewControllerRegistry.swift
// react-native-ios-modal
//
// Created by Dominic Go on 4/27/23.
//

import Foundation

class RNIModalViewControllerRegistry {
static let instanceMap = NSMapTable<
UIViewController,
RNIModalViewControllerWrapper
>(
keyOptions: .weakMemory,
valueOptions: .weakMemory
);

static func get(
forViewController viewController: UIViewController
) -> RNIModalViewControllerWrapper? {

Self.instanceMap.object(forKey: viewController);
};

static func set(
forViewController viewController: UIViewController,
_ modalWrapper: RNIModalViewControllerWrapper
){

Self.instanceMap.setObject(modalWrapper, forKey: viewController);
};

static func isRegistered(
forViewController viewController: UIViewController
) -> Bool {
Self.get(forViewController: viewController) != nil;
};
};

0 comments on commit 1cb9fe5

Please sign in to comment.