Skip to content

Commit

Permalink
🛠 Refactor: Update Usage for AdaptiveModal
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Jan 25, 2024
1 parent 041bf46 commit ebea86b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ extension AdaptiveModalSnapPointConfig: InitializableFromDictionary {
type: Mode.self
);

let layoutConfig = try dict.getValueFromDictionary(
let key = try? dict.getValueFromDictionary(
forKey: "key",
type: String.self
);

let layoutConfig = try? dict.getValueFromDictionary(
forKey: "layoutConfig",
type: ComputableLayout.self
);
Expand All @@ -35,14 +40,27 @@ extension AdaptiveModalSnapPointConfig: InitializableFromDictionary {

switch mode {
case .standard:
self = .snapPoint(
layoutConfig: layoutConfig,
guard let layoutConfig = layoutConfig else {
throw RNIAdaptiveModalError(
errorCode: .unexpectedNilValue,
description: "layoutConfig is nil"
);
};

self = .init(
key: key,
type: .standard(
layoutConfig: layoutConfig
),
keyframeConfig: keyframeConfig
);

case .inBetween:
self = .inBetweenSnapPoint(
layoutConfig: layoutConfig,
self = .init(
key: key,
type: .inBetween(
layoutConfig: layoutConfig
),
keyframeConfig: keyframeConfig
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ extension RNIAdaptiveModalController: AdaptiveModalPresentationEventsNotifiable

func notifyOnModalWillSnap(
sender: AdaptiveModalManager,
prevSnapPointIndex: Int?,
nextSnapPointIndex: Int,
prevSnapPointConfig: AdaptiveModalSnapPointConfig?,
nextSnapPointConfig: AdaptiveModalSnapPointConfig,
prevInterpolationPoint: AdaptiveModalInterpolationPoint?,
nextInterpolationPoint: AdaptiveModalInterpolationPoint
) {
Expand All @@ -30,10 +26,6 @@ extension RNIAdaptiveModalController: AdaptiveModalPresentationEventsNotifiable

func notifyOnModalDidSnap(
sender: AdaptiveModalManager,
prevSnapPointIndex: Int?,
currentSnapPointIndex: Int,
prevSnapPointConfig: AdaptiveModalSnapPointConfig?,
currentSnapPointConfig: AdaptiveModalSnapPointConfig,
prevInterpolationPoint: AdaptiveModalInterpolationPoint?,
currentInterpolationPoint: AdaptiveModalInterpolationPoint
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import ComputableLayout
extension RNIAdaptiveModalView: AdaptiveModalPresentationEventsNotifiable {

public func notifyOnModalWillSnap(
sender: AdaptiveModalManager, prevSnapPointIndex: Int?,
nextSnapPointIndex: Int,
prevSnapPointConfig: AdaptiveModalSnapPointConfig?,
nextSnapPointConfig: AdaptiveModalSnapPointConfig,
sender: AdaptiveModalManager,
prevInterpolationPoint: AdaptiveModalInterpolationPoint?,
nextInterpolationPoint: AdaptiveModalInterpolationPoint
) {
Expand All @@ -28,10 +25,6 @@ extension RNIAdaptiveModalView: AdaptiveModalPresentationEventsNotifiable {

public func notifyOnModalDidSnap(
sender: AdaptiveModal.AdaptiveModalManager,
prevSnapPointIndex: Int?,
currentSnapPointIndex: Int,
prevSnapPointConfig: AdaptiveModalSnapPointConfig?,
currentSnapPointConfig: AdaptiveModalSnapPointConfig,
prevInterpolationPoint: AdaptiveModalInterpolationPoint?,
currentInterpolationPoint: AdaptiveModalInterpolationPoint
) {
Expand Down
20 changes: 11 additions & 9 deletions src/types/AdaptiveModalConfig/AdaptiveModalSnapPointConfig.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { ComputableLayout } from "react-native-ios-utilities";
import { AdaptiveModalKeyframeConfig } from "./AdaptiveModalKeyframeConfig";

export type AdaptiveModalSnapPointConfigMode =
| 'standard'
| 'inBetween';

export type AdaptiveModalSnapPointConfig = {
mode: AdaptiveModalSnapPointConfigMode;
// TODO: WIP
// key: SnapPointKey;

export type AdaptiveModalSnapPointConfig = ({
mode: 'standard';
layoutConfig: ComputableLayout;
} | {
mode: 'inBetween';
layoutConfig?: ComputableLayout;
}) & {
key?: string;
keyframeConfig?: AdaptiveModalKeyframeConfig;
};
};

export type AdaptiveModalSnapPointConfigMode =
AdaptiveModalSnapPointConfig['mode'];

0 comments on commit ebea86b

Please sign in to comment.