Skip to content

Commit b2f51ac

Browse files
committed
Fix circular
1 parent c7053d7 commit b2f51ac

File tree

5 files changed

+7805
-22
lines changed

5 files changed

+7805
-22
lines changed

src/components/common/BottomSheet.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import Reanimated, {
99
import { Dimensions, View } from 'react-native';
1010
import { toJS } from 'mobx';
1111

12-
import { useUiStore } from '../../stores/ui';
1312
import colors from '../../constants/colors';
14-
15-
export const BOTTOM_SHEET_POPUP_ANIMATION_TIME = 250;
13+
import { useUiStore } from '../../stores';
1614

1715
// Centralized props used to style the top section of the BottomSheetGorhom.
1816
export const greenBottomSheetGorhomProps = {

src/stores/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import UiClass from './ui';
23

34
/**
@@ -8,3 +9,15 @@ export class RootStore {
89
}
910

1011
export const rootStore = new RootStore();
12+
13+
export const StoreContext = React.createContext<typeof rootStore>(rootStore);
14+
15+
// This store needs to be separated in his own file in order to avoid init error.
16+
// Leave this hook here as the single element of the file.
17+
export function useStores() {
18+
return React.useContext(StoreContext);
19+
}
20+
21+
export function useUiStore() {
22+
return useStores().ui;
23+
}

src/stores/ui.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { action, makeAutoObservable } from 'mobx';
22
import { Keyboard, ViewStyle } from 'react-native';
33
import { AnimatedStyle, SharedValue } from 'react-native-reanimated';
44
import metrics from '../constants/metrics';
5-
import { useStores } from './useStores';
6-
import { BOTTOM_SHEET_POPUP_ANIMATION_TIME } from '../components/common/BottomSheet';
5+
6+
export const BOTTOM_SHEET_POPUP_ANIMATION_TIME = 250;
77

88
const DEFAULT_BOTTOM_SHEET_SNAP_POINTS = [1, 300 + metrics.safeBottomDistance];
99
interface OpenBottomSheetOps {
@@ -39,8 +39,7 @@ class UiClass {
3939

4040
bottomSheetSharedValue: UiStore['bottomSheetSharedValue'] = undefined;
4141

42-
bottomSheetSnapPoints: UiStore['bottomSheetSnapPoints'] =
43-
DEFAULT_BOTTOM_SHEET_SNAP_POINTS;
42+
bottomSheetSnapPoints: UiStore['bottomSheetSnapPoints'] = DEFAULT_BOTTOM_SHEET_SNAP_POINTS;
4443
containerStyle: UiStore['containerStyle'] = {};
4544
bottomSheetGorhomProps: UiStore['bottomSheetGorhomProps'] = {};
4645
bottomSheetStyle: OpenBottomSheetOps['bottomSheetStyle'] = undefined;
@@ -53,10 +52,11 @@ class UiClass {
5352

5453
bottomSheetTargetSharedValue: UiStore['bottomSheetTargetSharedValue'] = 0;
5554

56-
setBottomSheetTargetSharedValue: UiStore['setBottomSheetTargetSharedValue'] =
57-
action((targetSharedValue) => {
55+
setBottomSheetTargetSharedValue: UiStore['setBottomSheetTargetSharedValue'] = action(
56+
(targetSharedValue) => {
5857
this.bottomSheetTargetSharedValue = targetSharedValue;
59-
});
58+
},
59+
);
6060

6161
openBottomSheet: UiStore['openBottomSheet'] = action((options) => {
6262
if (!this.isBottomSheetOpen && !this.bottomSheetDebouncedDelay) {
@@ -108,8 +108,4 @@ class UiClass {
108108
}
109109
}
110110

111-
export function useUiStore() {
112-
return useStores().ui;
113-
}
114-
115111
export default UiClass;

src/stores/useStores.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)