added redux entries for open closing reply modal

This commit is contained in:
Nouman Tahir 2022-07-18 17:21:55 +05:00
parent 61aa6d5daa
commit b638f01d3c
3 changed files with 33 additions and 3 deletions

View File

@ -10,7 +10,9 @@ import {
SHOW_PROFILE_MODAL,
HIDE_PROFILE_MODAL,
TOGGLE_QR_MODAL,
SET_DEVICE_ORIENTATION
SET_DEVICE_ORIENTATION,
SHOW_REPLY_MODAL,
HIDE_REPLY_MODAL
} from '../constants/constants';
export const updateActiveBottomTab = (payload:string) => ({
@ -77,3 +79,11 @@ export const setDeviceOrientation = (payload:string) => ({
type: SET_DEVICE_ORIENTATION,
});
export const showReplyModal = (selectionPost:any) => ({
payload:selectionPost,
type: SHOW_REPLY_MODAL
})
export const hideReplyModal = () => ({
type: HIDE_REPLY_MODAL
})

View File

@ -62,6 +62,8 @@ export const SET_AVATAR_CACHE_STAMP = 'SET_AVATAR_CACHE_STAMP';
export const SHOW_PROFILE_MODAL = 'SHOW_PROFILE_MODAL';
export const HIDE_PROFILE_MODAL = 'HIDE_PROFILE_MODAL';
export const SET_DEVICE_ORIENTATION = 'SET_DEVICE_ORIENTATION';
export const SHOW_REPLY_MODAL = 'SHOW_REPLY_MODAL';
export const HIDE_REPLY_MODAL = 'HIDE_REPLY_MODAL';
// POSTS
export const SET_FEED_POSTS = 'SET_FEED_POSTS';

View File

@ -1,3 +1,4 @@
import { State } from 'react-native-gesture-handler';
import {
UPDATE_ACTIVE_BOTTOM_TAB,
TOAST_NOTIFICATION,
@ -10,6 +11,7 @@ import {
HIDE_PROFILE_MODAL,
TOGGLE_QR_MODAL,
SET_DEVICE_ORIENTATION,
SHOW_REPLY_MODAL,
} from '../constants/constants';
import { orientations } from '../constants/orientationsConstants';
@ -24,6 +26,8 @@ interface UiState {
profileModalUsername:string;
isVisibleQRModal:boolean;
deviceOrientation: string;
replyModalVisible:boolean;
replyModalPost:any
}
const initialState:UiState = {
@ -36,10 +40,12 @@ const initialState:UiState = {
avatarCacheStamp: 0,
profileModalUsername: '',
isVisibleQRModal: false,
deviceOrientation: orientations.PORTRAIT
deviceOrientation: orientations.PORTRAIT,
replyModalPost: null,
replyModalVisible: false,
};
export default function (state = initialState, action) {
export default function (state = initialState, action) : UiState {
switch (action.type) {
case UPDATE_ACTIVE_BOTTOM_TAB:
return {
@ -109,6 +115,18 @@ export default function (state = initialState, action) {
...state,
deviceOrientation: action.payload,
};
case SHOW_REPLY_MODAL:
return {
...state,
replyModalVisible:true,
replyModalPost:action.payload
}
case HIDE_ACTION_MODAL:
return {
...state,
replyModalVisible:false,
replyModalPost:null
}
default:
return state;
}