-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
298dff2
commit 717ff68
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
}; | ||
}; |