Skip to content

Commit

Permalink
🛠 Refactor: Update Access - Make Types Public
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Apr 7, 2023
1 parent bd8fa0d commit ecf960a
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension UIModalTransitionStyle: CaseIterable {
];
};

func stringDescription() -> String {
public func stringDescription() -> String {
switch self {
case .coverVertical : return "coverVertical";
case .flipHorizontal: return "flipHorizontal";
Expand All @@ -28,7 +28,7 @@ extension UIModalTransitionStyle: CaseIterable {
};
};

static func fromString(_ string: String) -> UIModalTransitionStyle? {
public static func fromString(_ string: String) -> UIModalTransitionStyle? {
return self.allCases.first{ $0.stringDescription() == string };
};
};
4 changes: 2 additions & 2 deletions ios/src_library/Extensions/UIView+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// `react-native-utilities`
///
extension UIView {
var parentViewController: UIViewController? {
public var parentViewController: UIViewController? {
var parentResponder: UIResponder? = self;

while parentResponder != nil {
Expand All @@ -13,7 +13,7 @@ extension UIView {
};
};

return nil
return nil;
};

/// Remove all ancestor constraints that are affecting this view instance
Expand Down
8 changes: 4 additions & 4 deletions ios/src_library/Helpers+Utilities/MulticastDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import Foundation


class MulticastDelegate<T: AnyObject> {
public class MulticastDelegate<T: AnyObject> {
private let delegates: NSHashTable<T> = NSHashTable.weakObjects();

func add(_ delegate: T) {
public func add(_ delegate: T) {
delegates.add(delegate);
};

func remove(_ delegate: T) {
public func remove(_ delegate: T) {
self.delegates.remove(delegate);
};

func invoke (_ invocation: @escaping (T) -> Void) {
public func invoke (_ invocation: @escaping (T) -> Void) {
for delegate in delegates.allObjects {
invocation(delegate)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension RNIDictionarySynthesizable {
if let synthesizableDict = value as? (any RNIDictionarySynthesizable) {
return(propertyKey, synthesizableDict.synthesizedDictionary);
};

return (propertyKey, value)
};

Expand Down
6 changes: 3 additions & 3 deletions ios/src_library/Helpers+Utilities/RNIIdentifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ fileprivate class Counter {
};

public final class RNIObjectIdentifier {
let id: Int;
let uuid = UUID();
public let id: Int;
public let uuid = UUID();

init(type: Any) {
public init(type: Any) {
self.id = Counter.getAndIncrement(forType: type);
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

protocol RNIViewControllerLifeCycleNotifiable: AnyObject {
public protocol RNIViewControllerLifeCycleNotifiable: AnyObject {

func viewDidLoad(sender: UIViewController);

Expand All @@ -34,35 +34,35 @@ protocol RNIViewControllerLifeCycleNotifiable: AnyObject {
};

extension RNIViewControllerLifeCycleNotifiable {
func viewDidLoad(sender: UIViewController) {
public func viewDidLoad(sender: UIViewController) {
// no-op
};

func viewDidLayoutSubviews(sender: UIViewController) {
public func viewDidLayoutSubviews(sender: UIViewController) {
// no-op
};

func viewWillAppear(sender: UIViewController, animated: Bool) {
public func viewWillAppear(sender: UIViewController, animated: Bool) {
// no-op
};

func viewDidAppear(sender: UIViewController, animated: Bool) {
public func viewDidAppear(sender: UIViewController, animated: Bool) {
// no-op
};

func viewWillDisappear(sender: UIViewController, animated: Bool) {
public func viewWillDisappear(sender: UIViewController, animated: Bool) {
// no-op
};

func viewDidDisappear(sender: UIViewController, animated: Bool) {
public func viewDidDisappear(sender: UIViewController, animated: Bool) {
// no-op
};

func willMove(sender: UIViewController, toParent parent: UIViewController?) {
public func willMove(sender: UIViewController, toParent parent: UIViewController?) {
// no-op
};

func didMove(sender: UIViewController, toParent parent: UIViewController?) {
public func didMove(sender: UIViewController, toParent parent: UIViewController?) {
// no-op
};
};
2 changes: 1 addition & 1 deletion ios/src_library/Helpers+Utilities/WeakElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
import Foundation


class WeakElement<Element: AnyObject> {
public class WeakElement<Element: AnyObject> {
private(set) weak var value: Element?;
};
16 changes: 8 additions & 8 deletions ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import Foundation

extension RNIModalState where Self: RNIIdentifiable {
var modalNativeID: String {
public var modalNativeID: String {
self.synthesizedStringID
};
};

extension RNIModalState where Self: RNIModalPresentation {

/// Programmatically check if this instance is presented
var synthesizedIsModalPresented: Bool {
public var synthesizedIsModalPresented: Bool {
let listPresentedVC =
RNIModalManager.getPresentedViewControllers(for: self.window);

Expand All @@ -26,7 +26,7 @@ extension RNIModalState where Self: RNIModalPresentation {
};

/// Programmatically check if this instance is in focus
var synthesizedIsModalInFocus: Bool {
public var synthesizedIsModalInFocus: Bool {
let listPresentedVC =
RNIModalManager.getPresentedViewControllers(for: self.window);

Expand All @@ -41,7 +41,7 @@ extension RNIModalState where Self: RNIModalPresentation {
/// * This is based on the view controller hierarchy
/// * So parent/child view controller that aren't modals are also counted
///
var synthesizedViewControllerIndex: Int {
public var synthesizedViewControllerIndex: Int {
let listPresentedVC =
RNIModalManager.getPresentedViewControllers(for: self.window);

Expand All @@ -54,7 +54,7 @@ extension RNIModalState where Self: RNIModalPresentation {
};

/// Programmatically get the "modal index"
var synthesizedModalIndex: Int {
public var synthesizedModalIndex: Int {
let listPresentedVC =
RNIModalManager.getPresentedViewControllers(for: self.window);

Expand All @@ -72,15 +72,15 @@ extension RNIModalState where Self: RNIModalPresentation {
return -1;
};

var synthesizedCurrentModalIndex: Int {
public var synthesizedCurrentModalIndex: Int {
guard let window = self.window else { return -1 };
return RNIModalManagerShared.getCurrentModalIndex(for: window);
};
};

extension RNIModalState where Self: RNIModal {

var synthesizedModalData: RNIModalData {
public var synthesizedModalData: RNIModalData {
return RNIModalData(
modalNativeID: self.modalNativeID,
modalIndex: self.modalIndex,
Expand All @@ -95,7 +95,7 @@ extension RNIModalState where Self: RNIModal {
);
};

var synthesizedModalDataDict: Dictionary<String, Any> {
public var synthesizedModalDataDict: Dictionary<String, Any> {
self.synthesizedModalData.synthesizedDictionary;
};
};
20 changes: 10 additions & 10 deletions ios/src_library/React Native/RNIModal/RNIModalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
import Foundation

public struct RNIModalData: RNIDictionarySynthesizable {
let modalNativeID: String;
public let modalNativeID: String;

let modalIndex: Int;
let currentModalIndex: Int;
public let modalIndex: Int;
public let currentModalIndex: Int;

let isModalPresented: Bool;
let isModalInFocus: Bool;
public let isModalPresented: Bool;
public let isModalInFocus: Bool;

let synthesizedIsModalInFocus: Bool;
let synthesizedIsModalPresented: Bool;
public let synthesizedIsModalInFocus: Bool;
public let synthesizedIsModalPresented: Bool;

let synthesizedModalIndex: Int;
let synthesizedViewControllerIndex: Int;
public let synthesizedModalIndex: Int;
public let synthesizedViewControllerIndex: Int;

let synthesizedWindowID: String?;
public let synthesizedWindowID: String?;
};
12 changes: 6 additions & 6 deletions ios/src_library/React Native/RNIModal/RNIModalEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public struct RNIModalBaseEventData: RNIDictionarySynthesizable {
[\.modalData];
};

let reactTag: Int;
let modalID: String?;
public let reactTag: Int;
public let modalID: String?;

let modalData: RNIModalData;
public let modalData: RNIModalData;
};

public struct RNIOnModalFocusEventData: RNIDictionarySynthesizable {
Expand All @@ -37,8 +37,8 @@ public struct RNIOnModalFocusEventData: RNIDictionarySynthesizable {
[\.modalData];
};

let modalData: RNIModalBaseEventData;
let senderInfo: RNIModalData;
public let modalData: RNIModalBaseEventData;
public let senderInfo: RNIModalData;

let isInitial: Bool;
public let isInitial: Bool;
};
4 changes: 2 additions & 2 deletions ios/src_library/React Native/RNIModal/RNIModalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class RNIModalManager {
// ------------------------

/// TODO:2023-03-20-21-29-36 - Move to `RNIUtilities`
static func getWindows() -> [UIWindow] {
public static func getWindows() -> [UIWindow] {
var windows: [UIWindow] = [];

#if swift(>=5.5)
Expand Down Expand Up @@ -118,7 +118,7 @@ public class RNIModalManager {
};

/// TODO:2023-03-20-21-29-36 - Move to `RNIUtilities`
static func getRootViewController(
public static func getRootViewController(
for window: UIWindow? = nil
) -> UIViewController? {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum RNIModalPresentationState: String {
// MARK: - Computed Properties
// ---------------------------

var isDismissing: Bool {
public var isDismissing: Bool {
switch self {
case .DISMISSING_UNKNOWN,
.DISMISSING_GESTURE,
Expand All @@ -40,11 +40,11 @@ public enum RNIModalPresentationState: String {
};
};

var isDismissingKnown: Bool {
public var isDismissingKnown: Bool {
self.isDismissing && self != .DISMISSING_UNKNOWN;
};

var isPresenting: Bool {
public var isPresenting: Bool {
switch self {
case .PRESENTING_PROGRAMMATIC,
.PRESENTING_UNKNOWN,
Expand All @@ -56,7 +56,7 @@ public enum RNIModalPresentationState: String {
};
};

var isNotSpecific: Bool {
public var isNotSpecific: Bool {
switch self {
case .PRESENTING_UNKNOWN,
.DISMISSING_UNKNOWN:
Expand All @@ -70,19 +70,19 @@ public enum RNIModalPresentationState: String {
// MARK: - Computed Properties - Alias
// -----------------------------------

var isDismissViaGestureCancelling: Bool {
public var isDismissViaGestureCancelling: Bool {
self == .DISMISS_GESTURE_CANCELLING;
};

var isDismissingViaGesture: Bool {
public var isDismissingViaGesture: Bool {
self == .DISMISSING_GESTURE
};

var isPresented: Bool {
public var isPresented: Bool {
self == .PRESENTED;
};

var isDismissed: Bool {
public var isDismissed: Bool {
self == .DISMISSED;
};
};
Expand All @@ -92,30 +92,30 @@ public struct RNIModalPresentationStateMachine {
// MARK: - Properties
// ------------------

var state: RNIModalPresentationState = .INITIAL;
var statePrev: RNIModalPresentationState = .INITIAL;
private(set) public var state: RNIModalPresentationState = .INITIAL;
private(set) public var statePrev: RNIModalPresentationState = .INITIAL;

// MARK: - Properties - Completion Handlers
// ----------------------------------------

var onDismissWillCancel: (() -> Void)?;
var onDismissDidCancel: (() -> Void)?;
public var onDismissWillCancel: (() -> Void)?;
public var onDismissDidCancel: (() -> Void)?;

// MARK: - Computed Properties
// ---------------------------

var isPresented: Bool {
public var isPresented: Bool {
self.state == .PRESENTED;
};

var wasDismissViaGestureCancelled: Bool {
public var wasDismissViaGestureCancelled: Bool {
self.statePrev.isDismissViaGestureCancelling
};

// MARK: - Functions
// -----------------

mutating func set(state nextState: RNIModalPresentationState){
public mutating func set(state nextState: RNIModalPresentationState){
let prevState = self.state;
self.statePrev = prevState;

Expand All @@ -131,7 +131,7 @@ public struct RNIModalPresentationStateMachine {
/// Do not over-write specific/"known state", with non-specific/"unknown
/// state", e.g.
///
/// * ✅: `PRESENTING_PROGRAMMATIC` -> `PRESENTING_UNKNOWN`
/// * ✅: `PRESENTING_UNKNOWN` -> `PRESENTING_PROGRAMMATIC`
/// * ❌: `DISMISSING_GESTURE` -> `DISMISSING_UNKNOWN`
return;

Expand Down
Loading

0 comments on commit ecf960a

Please sign in to comment.