diff --git a/ios/Common/ModalSheetState+Helpers.swift b/ios/Common/ModalSheetState+Helpers.swift new file mode 100644 index 00000000..3c9bf9e2 --- /dev/null +++ b/ios/Common/ModalSheetState+Helpers.swift @@ -0,0 +1,24 @@ +// +// ModalSheetState+Helpers.swift +// react-native-ios-modal +// +// Created by Dominic Go on 9/29/24. +// + +import Foundation +import DGSwiftUtilities + + +// MARK: - DictionaryRepresentable+Helpers +// --------------------------------------- + +public extension ModalSheetState { + + var asMetrics: RNIModalSheetStateMetrics { + .init(fromModalSheetState: self); + }; + + var asDictionary: [String : Any] { + self.asMetrics.synthesizedDictionary; + }; +}; diff --git a/ios/RNIModalSheetView/RNIModalSheetStateMetrics.swift b/ios/RNIModalSheetView/RNIModalSheetStateMetrics.swift new file mode 100644 index 00000000..48a62842 --- /dev/null +++ b/ios/RNIModalSheetView/RNIModalSheetStateMetrics.swift @@ -0,0 +1,45 @@ +// +// RNIModalSheetStateMetrics.swift +// react-native-ios-modal +// +// Created by Dominic Go on 9/29/24. +// + +import Foundation + + +public struct RNIModalSheetStateMetrics: DictionaryRepresentationSynthesizing { + + public var state: ModalSheetState; + public var simplified: ModalSheetState; + + public var isPresenting: Bool; + public var isPresented: Bool; + public var isDismissing: Bool; + public var isDismissed: Bool; + + public init( + state: ModalSheetState, + simplified: ModalSheetState, + isPresenting: Bool, + isPresented: Bool, + isDismissing: Bool, + isDismissed: Bool + ) { + self.state = state; + self.simplified = simplified; + self.isPresenting = isPresenting; + self.isPresented = isPresented; + self.isDismissing = isDismissing; + self.isDismissed = isDismissed; + }; + + public init(fromModalSheetState state: ModalSheetState){ + self.state = state; + self.simplified = state.simplified; + self.isPresenting = state.isPresenting; + self.isPresented = state.isPresented; + self.isDismissing = state.isDismissing; + self.isDismissed = state.isDismissed; + }; +}; diff --git a/src/index.ts b/src/index.ts index 8e07b688..9ee95e59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,4 +5,6 @@ export * from './context/ModalSheetViewContext'; export type * from './types/ModalViewControllerMetrics'; export type * from './types/PresentationControllerMetrics'; export type * from './types/ModalMetrics'; -export type * from './types/CommonModalEvents'; \ No newline at end of file +export type * from './types/CommonModalEvents'; +export type * from './types/ModalSheetState'; +export type * from './types/RNIModalSheetStateMetrics'; \ No newline at end of file diff --git a/src/types/ModalSheetState.ts b/src/types/ModalSheetState.ts new file mode 100644 index 00000000..875e6fe8 --- /dev/null +++ b/src/types/ModalSheetState.ts @@ -0,0 +1,13 @@ + + +export type ModalSheetState = + | 'presenting' + | 'dismissViaGestureCancelling' + | 'presented' + | 'dismissViaGestureCancelled' + | 'dismissing' + | 'dismissingViaGesture' + | 'presentingViaGestureCanceling' + | 'dismissed' + | 'dismissedViaGesture' + | 'presentingViaGestureCancelled'; \ No newline at end of file diff --git a/src/types/RNIModalSheetStateMetrics.ts b/src/types/RNIModalSheetStateMetrics.ts new file mode 100644 index 00000000..8bc7f6fb --- /dev/null +++ b/src/types/RNIModalSheetStateMetrics.ts @@ -0,0 +1,12 @@ +import type { ModalSheetState } from "./ModalSheetState"; + + +export type RNIModalSheetStateMetrics = { + state: ModalSheetState; + simplified: ModalSheetState; + + isPresenting: boolean; + isPresented: boolean; + isDismissing: boolean; + isDismissed: boolean; +}; \ No newline at end of file