Skip to content

Commit

Permalink
⭐️ Impl: RNIModalSheetStateMetrics.isIdle
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 29, 2024
1 parent 8636385 commit cc4ca4b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ios/RNIModalSheetView/RNIModalSheetStateMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ public struct RNIModalSheetStateMetrics: DictionaryRepresentationSynthesizing {
public var isPresented: Bool;
public var isDismissing: Bool;
public var isDismissed: Bool;
public var isIdle: Bool;

public init(
state: ModalSheetState,
simplified: ModalSheetState,
isPresenting: Bool,
isPresented: Bool,
isDismissing: Bool,
isDismissed: Bool
isDismissed: Bool,
isIdle: Bool
) {
self.state = state;
self.simplified = simplified;
self.isPresenting = isPresenting;
self.isPresented = isPresented;
self.isDismissing = isDismissing;
self.isDismissed = isDismissed;
self.isIdle = isIdle;
};

public init(fromModalSheetState state: ModalSheetState){
Expand All @@ -41,5 +44,6 @@ public struct RNIModalSheetStateMetrics: DictionaryRepresentationSynthesizing {
self.isPresented = state.isPresented;
self.isDismissing = state.isDismissing;
self.isDismissed = state.isDismissed;
self.isIdle = state.isIdle;
};
};
14 changes: 13 additions & 1 deletion ios/Temp/ModalSheetState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public enum ModalSheetState: String {
case presented;
case dismissViaGestureCancelled;

case draggingViaGesture;

case dismissing;
case dismissingViaGesture;
case presentingViaGestureCanceling;
Expand All @@ -35,7 +37,7 @@ public enum ModalSheetState: String {
case .presented, .dismissViaGestureCancelled:
return .presented;

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

case .dismissed, .dismissedViaGesture, .presentingViaGestureCancelled:
Expand All @@ -59,6 +61,16 @@ public enum ModalSheetState: String {
self.modalState.isDismissed;
};

public var isIdle: Bool {
switch self {
case .draggingViaGesture:
return false;

default:
return self.modalState.isIdle;
};
};

public var simplified: Self {
self.modalState.modalSheetState;
};
Expand Down
10 changes: 10 additions & 0 deletions ios/Temp/ModalState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public enum ModalState: String {
self == .dismissed;
};

public var isIdle: Bool {
switch self {
case .presenting, .dismissing:
return false;

default:
return true;
};
};

public var modalSheetState: ModalSheetState {
switch self {
case .presenting:
Expand Down
1 change: 1 addition & 0 deletions src/types/RNIModalSheetStateMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export type RNIModalSheetStateMetrics = {
isPresented: boolean;
isDismissing: boolean;
isDismissed: boolean;
isIdle: boolean;
};

0 comments on commit cc4ca4b

Please sign in to comment.