Skip to content

Commit

Permalink
⭐️ Impl: RNIModalIdentifiable Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed May 13, 2023
1 parent 77c3a73 commit 7d3531e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 7 additions & 1 deletion ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@

import Foundation

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

extension RNIModalIdentifiable {
public var modalUserID: String? {
nil
};
};

extension RNIModalState where Self: RNIModalPresentation {

internal var synthesizedWindowMapData: RNIWindowMapData? {
Expand Down
15 changes: 15 additions & 0 deletions ios/src_library/React Native/RNIModal/RNIModal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ import Foundation
///
public typealias RNIModal =
RNIIdentifiable
& RNIModalIdentifiable
& RNIModalState
& RNIModalRequestable
& RNIModalFocusNotifiable
& RNIModalPresentationNotifying
& RNIModalPresentation;


/// Contains modal-related properties for identifying a specific modal instance
///
/// Specifies that the "adoptee/delegate" that conforms to this protocol must
/// have the specified modal-related properties so that it can be uniquely
/// identified amongst different modal instances.
///
public protocol RNIModalIdentifiable: AnyObject {

var modalNativeID: String { get };

var modalUserID: String? { get };
};

/// Contains modal-related properties for keeping track of the state of the
/// modal.
Expand Down
11 changes: 9 additions & 2 deletions ios/src_library/React Native/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import Foundation

public class RNIModalView:
UIView, RNIIdentifiable, RNIModalPresentationNotifying, RNIModalState,
RNIModalPresentation {
UIView, RNIIdentifiable, RNIModalIdentifiable, RNIModalPresentationNotifying,
RNIModalState, RNIModalPresentation {

public typealias CompletionHandler = () -> Void;

Expand Down Expand Up @@ -39,6 +39,13 @@ public class RNIModalView:

public weak var modalPresentationNotificationDelegate:
RNIModalPresentationNotifiable!;

// MARK: - Properties - RNIModalIdentifiable
// -----------------------------------------

public var modalUserID: String? {
self.modalID as? String
};

// MARK: - Properties - RNIModalState
// ----------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Foundation
/// Wraps a `UIViewController` so it can be used w/ `RNIModalManager`
///
public class RNIModalViewControllerWrapper:
RNIIdentifiable, RNIModalPresentationNotifying, RNIModalState,
RNIModalPresentation {
RNIIdentifiable, RNIModalIdentifiable, RNIModalPresentationNotifying,
RNIModalState, RNIModalPresentation {

// MARK: - Properties - RNIIdentifiable
// ------------------------------------
Expand Down

0 comments on commit 7d3531e

Please sign in to comment.