UNPKG

react-native-unit-components

Version:

Unit React Native components

59 lines 2.08 kB
import { createSlice } from '@reduxjs/toolkit'; import { BottomSheetNativePlaceType } from '../types/internal/bottomSheet.types'; const initialState = { isBottomSheetActive: false, isComponentLoading: false, shouldShowBottomSheet: false, shouldEnableBottomSheetScroll: true, nativePlace: BottomSheetNativePlaceType.overFullScreen, componentHeight: 0 }; const BottomSheetSlice = createSlice({ name: 'BottomSheet', initialState: initialState, reducers: { setIsBottomSheetActive(state, action) { state.isBottomSheetActive = action.payload; }, setIsComponentLoading(state, action) { state.isComponentLoading = action.payload; }, setShouldShowBottomSheet(state, action) { state.shouldShowBottomSheet = action.payload; }, setNativePlace(state, action) { state.nativePlace = action.payload; }, setComponentHeight(state, action) { state.componentHeight = action.payload; }, setShouldEnableBottomSheetScroll(state, action) { state.shouldEnableBottomSheetScroll = action.payload; }, setScrollState(state, action) { state.scrollState = action.payload; }, resetBottomSheetSlice(state) { //resets all besides is active to avoid loops in useEffects invoked by closing the flow state.isComponentLoading = initialState.isComponentLoading; state.shouldShowBottomSheet = initialState.shouldShowBottomSheet; state.nativePlace = initialState.nativePlace; state.componentHeight = initialState.componentHeight; state.shouldEnableBottomSheetScroll = initialState.shouldEnableBottomSheetScroll; state.scrollState = initialState.scrollState; } } }); export const { setIsBottomSheetActive, setIsComponentLoading, setShouldShowBottomSheet, setNativePlace, setComponentHeight, setShouldEnableBottomSheetScroll, setScrollState, resetBottomSheetSlice } = BottomSheetSlice.actions; export const selectConfiguration = state => state.bottomSheet; export default BottomSheetSlice.reducer; //# sourceMappingURL=BottomSheetSlice.js.map