Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetState
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 26, 2024
1 parent 298dff2 commit 717ff68
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
65 changes: 65 additions & 0 deletions ios/Temp/ModalSheetState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// ModalSheetState.swift
// react-native-ios-modal
//
// Created by Dominic Go on 9/27/24.
//

import Foundation


public enum ModalSheetState: String {

case presenting;
case dismissViaGestureCancelling;

case presented;
case dismissViaGestureCancelled;

case dismissing;
case dismissingViaGesture;
case presentingViaGestureCanceling;

case dismissed;
case dismissedViaGesture;
case presentingViaGestureCancelled;

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

public var modalState: ModalState {
switch self {
case .presenting, .dismissViaGestureCancelling:
return .presenting;

case .presented, .dismissViaGestureCancelled:
return .presented;

case .dismissing, .dismissingViaGesture, .presentingViaGestureCanceling:
return .dismissing;

case .dismissed, .dismissedViaGesture, .presentingViaGestureCancelled:
return .dismissed;
};
};

public var isPresenting: Bool {
self.modalState.isPresenting;
};

public var isPresented: Bool {
self.modalState.isPresented;
};

public var isDismissing: Bool {
self.modalState.isDismissing;
};

public var isDismissed: Bool {
self.modalState.isDismissed;
};

public var simplified: Self {
self.modalState.modalSheetState;
};
};
52 changes: 52 additions & 0 deletions ios/Temp/ModalState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// ModalState.swift
// react-native-ios-modal
//
// Created by Dominic Go on 9/27/24.
//

import Foundation


public enum ModalState: String {

case presenting;
case presented;
case dismissing;
case dismissed;

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

public var isPresenting: Bool {
self == .presenting;
};

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

public var isDismissing: Bool {
self == .dismissing;
};

public var isDismissed: Bool {
self == .dismissed;
};

public var modalSheetState: ModalSheetState {
switch self {
case .presenting:
return .presenting;

case .presented:
return .presented;

case .dismissing:
return .dismissing;

case .dismissed:
return .dismissed;
};
};
};

0 comments on commit 717ff68

Please sign in to comment.