mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 05:42:33 +03:00
integrated terms acceptance with redux
This commit is contained in:
parent
c28c909dfa
commit
35f1f84567
@ -30,7 +30,8 @@ import {
|
||||
SET_LAST_APP_VERSION,
|
||||
SET_COLOR_THEME,
|
||||
SET_SETTINGS_MIGRATED,
|
||||
HIDE_POSTS_THUMBNAILS
|
||||
HIDE_POSTS_THUMBNAILS,
|
||||
SET_TERMS_ACCEPTED
|
||||
} from '../constants/constants';
|
||||
|
||||
export const login = (payload) => ({
|
||||
@ -203,4 +204,9 @@ export const setHidePostsThumbnails = (shouldHide:boolean) => ({
|
||||
type: HIDE_POSTS_THUMBNAILS,
|
||||
});
|
||||
|
||||
export const setIsTermsAccepted = (isTermsAccepted:boolean) => ({
|
||||
payload:isTermsAccepted,
|
||||
type: SET_TERMS_ACCEPTED
|
||||
})
|
||||
|
||||
|
||||
|
@ -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_COLOR_THEME = 'SET_COLOR_THEME';
|
||||
export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED';
|
||||
export const SET_TERMS_ACCEPTED = 'SET_TERMS_ACCEPTED';
|
||||
|
||||
// Accounts
|
||||
export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT';
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
SET_COLOR_THEME,
|
||||
SET_SETTINGS_MIGRATED,
|
||||
HIDE_POSTS_THUMBNAILS,
|
||||
SET_TERMS_ACCEPTED,
|
||||
} from '../constants/constants';
|
||||
|
||||
interface State {
|
||||
@ -67,6 +68,7 @@ interface State {
|
||||
lastAppVersion:string;
|
||||
settingsMigrated: boolean;
|
||||
hidePostsThumbnails: boolean;
|
||||
isTermsAccepted: boolean;
|
||||
}
|
||||
|
||||
const initialState:State = {
|
||||
@ -105,6 +107,7 @@ const initialState:State = {
|
||||
lastAppVersion:'',
|
||||
settingsMigrated: false,
|
||||
hidePostsThumbnails: false,
|
||||
isTermsAccepted: false,
|
||||
};
|
||||
|
||||
export default function (state = initialState, action) {
|
||||
@ -274,6 +277,12 @@ export default function (state = initialState, action) {
|
||||
hidePostsThumbnails:action.payload
|
||||
}
|
||||
|
||||
case SET_TERMS_ACCEPTED:
|
||||
return {
|
||||
...state,
|
||||
isTermsAccepted:action.payload
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import VersionNumber from 'react-native-version-number';
|
||||
|
||||
import { CheckBox, Icon, MainButton, Modal } from '../../../components';
|
||||
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
||||
import { setLastAppVersion } from '../../../redux/actions/applicationActions';
|
||||
import { setLastAppVersion, setIsTermsAccepted } from '../../../redux/actions/applicationActions';
|
||||
import parseVersionNumber from '../../../utils/parseVersionNumber';
|
||||
import LaunchScreen from '../../launch';
|
||||
|
||||
@ -19,10 +19,11 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const lastAppVersion = useAppSelector(state => state.application.lastAppVersion)
|
||||
const isTermsAccepted = useAppSelector(state => state.application.isTermsAccepted);
|
||||
|
||||
const [showAnimation, setShowAnimation] = useState(true);
|
||||
const [showWelcomeModal, setShowWelcomeModal] = useState(false);
|
||||
const [isConsentChecked, setIsConsentChecked] = useState(false);
|
||||
const [isConsentChecked, setIsConsentChecked] = useState(isTermsAccepted);
|
||||
|
||||
const [appVersion] = useState(VersionNumber.appVersion);
|
||||
|
||||
@ -52,6 +53,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
|
||||
|
||||
const _handleButtonPress = () => {
|
||||
dispatch(setLastAppVersion(appVersion))
|
||||
dispatch(setIsTermsAccepted(isConsentChecked));
|
||||
setShowWelcomeModal(false);
|
||||
onModalVisibilityChange(false);
|
||||
}
|
||||
@ -78,7 +80,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => {
|
||||
|
||||
const _renderConsent = () => (
|
||||
<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')}>
|
||||
<View style={styles.consentTextContainer}>
|
||||
<Text style={styles.termsDescText}>
|
||||
|
Loading…
Reference in New Issue
Block a user