integrated terms acceptance with redux

This commit is contained in:
Nouman Tahir 2022-07-05 21:04:09 +05:00
parent c28c909dfa
commit 35f1f84567
4 changed files with 22 additions and 4 deletions

View File

@ -30,7 +30,8 @@ import {
SET_LAST_APP_VERSION, SET_LAST_APP_VERSION,
SET_COLOR_THEME, SET_COLOR_THEME,
SET_SETTINGS_MIGRATED, SET_SETTINGS_MIGRATED,
HIDE_POSTS_THUMBNAILS HIDE_POSTS_THUMBNAILS,
SET_TERMS_ACCEPTED
} from '../constants/constants'; } from '../constants/constants';
export const login = (payload) => ({ export const login = (payload) => ({
@ -203,4 +204,9 @@ export const setHidePostsThumbnails = (shouldHide:boolean) => ({
type: HIDE_POSTS_THUMBNAILS, type: HIDE_POSTS_THUMBNAILS,
}); });
export const setIsTermsAccepted = (isTermsAccepted:boolean) => ({
payload:isTermsAccepted,
type: SET_TERMS_ACCEPTED
})

View File

@ -35,6 +35,7 @@ export const CHANGE_ALL_NOTIFICATION_SETTINGS = 'CHANGE_ALL_NOTIFICATION_SETTING
export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION';
export const SET_COLOR_THEME = 'SET_COLOR_THEME'; export const SET_COLOR_THEME = 'SET_COLOR_THEME';
export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED'; export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED';
export const SET_TERMS_ACCEPTED = 'SET_TERMS_ACCEPTED';
// Accounts // Accounts
export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT';

View File

@ -29,6 +29,7 @@ import {
SET_COLOR_THEME, SET_COLOR_THEME,
SET_SETTINGS_MIGRATED, SET_SETTINGS_MIGRATED,
HIDE_POSTS_THUMBNAILS, HIDE_POSTS_THUMBNAILS,
SET_TERMS_ACCEPTED,
} from '../constants/constants'; } from '../constants/constants';
interface State { interface State {
@ -67,6 +68,7 @@ interface State {
lastAppVersion:string; lastAppVersion:string;
settingsMigrated: boolean; settingsMigrated: boolean;
hidePostsThumbnails: boolean; hidePostsThumbnails: boolean;
isTermsAccepted: boolean;
} }
const initialState:State = { const initialState:State = {
@ -105,6 +107,7 @@ const initialState:State = {
lastAppVersion:'', lastAppVersion:'',
settingsMigrated: false, settingsMigrated: false,
hidePostsThumbnails: false, hidePostsThumbnails: false,
isTermsAccepted: false,
}; };
export default function (state = initialState, action) { export default function (state = initialState, action) {
@ -274,6 +277,12 @@ export default function (state = initialState, action) {
hidePostsThumbnails:action.payload hidePostsThumbnails:action.payload
} }
case SET_TERMS_ACCEPTED:
return {
...state,
isTermsAccepted:action.payload
}
default: default:
return state; return state;
} }

View File

@ -8,7 +8,7 @@ import VersionNumber from 'react-native-version-number';
import { CheckBox, Icon, MainButton, Modal } from '../../../components'; import { CheckBox, Icon, MainButton, Modal } from '../../../components';
import { useAppDispatch, useAppSelector } from '../../../hooks'; import { useAppDispatch, useAppSelector } from '../../../hooks';
import { setLastAppVersion } from '../../../redux/actions/applicationActions'; import { setLastAppVersion, setIsTermsAccepted } from '../../../redux/actions/applicationActions';
import parseVersionNumber from '../../../utils/parseVersionNumber'; import parseVersionNumber from '../../../utils/parseVersionNumber';
import LaunchScreen from '../../launch'; import LaunchScreen from '../../launch';
@ -19,10 +19,11 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const lastAppVersion = useAppSelector(state => state.application.lastAppVersion) const lastAppVersion = useAppSelector(state => state.application.lastAppVersion)
const isTermsAccepted = useAppSelector(state => state.application.isTermsAccepted);
const [showAnimation, setShowAnimation] = useState(true); const [showAnimation, setShowAnimation] = useState(true);
const [showWelcomeModal, setShowWelcomeModal] = useState(false); const [showWelcomeModal, setShowWelcomeModal] = useState(false);
const [isConsentChecked, setIsConsentChecked] = useState(false); const [isConsentChecked, setIsConsentChecked] = useState(isTermsAccepted);
const [appVersion] = useState(VersionNumber.appVersion); const [appVersion] = useState(VersionNumber.appVersion);
@ -52,6 +53,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
const _handleButtonPress = () => { const _handleButtonPress = () => {
dispatch(setLastAppVersion(appVersion)) dispatch(setLastAppVersion(appVersion))
dispatch(setIsTermsAccepted(isConsentChecked));
setShowWelcomeModal(false); setShowWelcomeModal(false);
onModalVisibilityChange(false); onModalVisibilityChange(false);
} }
@ -78,7 +80,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
const _renderConsent = () => ( const _renderConsent = () => (
<View style={styles.consentContainer}> <View style={styles.consentContainer}>
<CheckBox value={isConsentChecked} clicked={_onCheckPress} style={styles.checkStyle} /> <CheckBox isChecked={isConsentChecked} clicked={_onCheckPress} style={styles.checkStyle} />
<TouchableOpacity onPress={() => Linking.openURL('https://ecency.com/terms-of-service')}> <TouchableOpacity onPress={() => Linking.openURL('https://ecency.com/terms-of-service')}>
<View style={styles.consentTextContainer}> <View style={styles.consentTextContainer}>
<Text style={styles.termsDescText}> <Text style={styles.termsDescText}>