Skip to content

Commit

Permalink
⭐️ Impl: RNIModalSheetStateMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 29, 2024
1 parent 5322de9 commit ce1abce
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
24 changes: 24 additions & 0 deletions ios/Common/ModalSheetState+Helpers.swift
Original file line number Diff line number Diff line change
@@ -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;
};
};
45 changes: 45 additions & 0 deletions ios/RNIModalSheetView/RNIModalSheetStateMetrics.swift
Original file line number Diff line number Diff line change
@@ -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;
};
};
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
export type * from './types/CommonModalEvents';
export type * from './types/ModalSheetState';
export type * from './types/RNIModalSheetStateMetrics';
13 changes: 13 additions & 0 deletions src/types/ModalSheetState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


export type ModalSheetState =
| 'presenting'
| 'dismissViaGestureCancelling'
| 'presented'
| 'dismissViaGestureCancelled'
| 'dismissing'
| 'dismissingViaGesture'
| 'presentingViaGestureCanceling'
| 'dismissed'
| 'dismissedViaGesture'
| 'presentingViaGestureCancelled';
12 changes: 12 additions & 0 deletions src/types/RNIModalSheetStateMetrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { ModalSheetState } from "./ModalSheetState";


export type RNIModalSheetStateMetrics = {
state: ModalSheetState;
simplified: ModalSheetState;

isPresenting: boolean;
isPresented: boolean;
isDismissing: boolean;
isDismissed: boolean;
};

0 comments on commit ce1abce

Please sign in to comment.