Add searchbar to home screen

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-12 16:55:48 +03:00
parent ce8ef46c20
commit 5bf066ac98
13 changed files with 358 additions and 1560 deletions

View File

@@ -1,11 +1,13 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { SORT, SORT_DIRECTION, VIEW } from '../types';
import { MEME_TYPE } from '../database';
interface HomeState {
sort: SORT;
sortDirection: SORT_DIRECTION;
view: VIEW;
favoritesOnly: boolean;
filter: MEME_TYPE | undefined;
}
const initialState: HomeState = {
@@ -13,6 +15,7 @@ const initialState: HomeState = {
sortDirection: SORT_DIRECTION.ASCENDING,
view: VIEW.MASONRY,
favoritesOnly: false,
filter: undefined,
};
const homeSlice = createSlice({
@@ -53,6 +56,9 @@ const homeSlice = createSlice({
toggleFavoritesOnly: state => {
state.favoritesOnly = !state.favoritesOnly;
},
setFilter: (state, action: PayloadAction<MEME_TYPE | undefined>) => {
state.filter = action.payload;
},
},
});
@@ -64,6 +70,7 @@ const {
cycleView,
setFavoritesOnly,
toggleFavoritesOnly,
setFilter,
} = homeSlice.actions;
export {
@@ -75,5 +82,6 @@ export {
cycleView,
setFavoritesOnly,
toggleFavoritesOnly,
setFilter,
};
export default homeSlice.reducer;

View File

@@ -58,4 +58,5 @@ export {
cycleView,
setFavoritesOnly,
toggleFavoritesOnly,
setFilter,
} from './home';