adding tos to all access screens

This commit is contained in:
balzack 2023-03-07 15:19:29 -08:00
parent 5a0a2a8af2
commit 5e181d090f
10 changed files with 334 additions and 27 deletions

View File

@ -1,8 +1,10 @@
import { KeyboardAvoidingView, ActivityIndicator, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native'; import { KeyboardAvoidingView, Modal, ScrollView, ActivityIndicator, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native';
import { styles } from './Admin.styled'; import { styles } from './Admin.styled';
import Ionicons from 'react-native-vector-icons/AntDesign'; import Ionicons from 'react-native-vector-icons/AntDesign';
import { useAdmin } from './useAdmin.hook'; import { useAdmin } from './useAdmin.hook';
import Colors from 'constants/Colors'; import Colors from 'constants/Colors';
import MatIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { tos } from 'constants/TermsOfService';
export function Admin() { export function Admin() {
@ -53,7 +55,23 @@ export function Admin() {
)} )}
</TouchableOpacity> </TouchableOpacity>
</View> </View>
{ state.enabled && (
<View style={styles.tos}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<Text style={styles.viewtermstext}>View Terms of Service</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
{ state.agree && (
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
)}
{ !state.agree && (
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
)}
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
</TouchableOpacity>
</View>
{ state.enabled && state.agree && (
<TouchableOpacity style={styles.reset} onPress={admin}> <TouchableOpacity style={styles.reset} onPress={admin}>
{ state.busy && ( { state.busy && (
<ActivityIndicator size="small" color="#ffffff" /> <ActivityIndicator size="small" color="#ffffff" />
@ -63,7 +81,7 @@ export function Admin() {
)} )}
</TouchableOpacity> </TouchableOpacity>
)} )}
{ !state.enabled && ( { (!state.enabled || !state.agree) && (
<View style={styles.noreset}> <View style={styles.noreset}>
<Text style={styles.noresettext}>Access</Text> <Text style={styles.noresettext}>Access</Text>
</View> </View>
@ -73,6 +91,23 @@ export function Admin() {
<Text style={styles.versiontext}>v{ state.version }</Text> <Text style={styles.versiontext}>v{ state.version }</Text>
</View> </View>
</View> </View>
<Modal
animationType="fade"
transparent={true}
visible={state.showTerms}
supportedOrientations={['portrait', 'landscape']}
onRequestClose={actions.hideTerms}
>
<View style={styles.modalContainer}>
<ScrollView style={styles.terms} persistentScrollbar={true}>
<Text style={styles.termsheader}>Terms of Use and User Policy</Text>
<Text numberOfLines={0}>{ tos.message }</Text>
</ScrollView>
<TouchableOpacity style={styles.done} onPress={actions.hideTerms}>
<Text style={styles.donetext}>Done</Text>
</TouchableOpacity>
</View>
</Modal>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
} }

View File

@ -15,6 +15,63 @@ export const styles = StyleSheet.create({
space: { space: {
width: 32, width: 32,
}, },
modalContainer: {
width: '100%',
height: '100%',
backgroundColor: Colors.grey,
alignItems: 'center',
justifyContent: 'center',
},
tos: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
agreeterms: {
display: 'flex',
flexDirection: 'row',
padding: 8,
},
agreetermstext: {
color: Colors.primary,
paddingLeft: 8,
fontSize: 14,
},
viewterms: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
padding: 8,
},
viewtermstext: {
color: Colors.primary,
fontSize: 14,
},
terms: {
borderRadius: 4,
maxHeight: '80%',
padding: 8,
margin: 16,
backgroundColor: Colors.formBackground,
},
done: {
paddingTop: 8,
paddingBottom: 8,
paddingLeft: 16,
paddingRight: 16,
borderRadius: 4,
backgroundColor: Colors.white,
marginTop: 8,
},
donetext: {
color: Colors.text,
fontSize: 16,
},
termsheader: {
fontWeight: 'bold',
textAlign: 'center',
},
container: { container: {
flexDirection: 'column', flexDirection: 'column',
backgroundColor: Colors.formBackground, backgroundColor: Colors.formBackground,

View File

@ -18,6 +18,8 @@ export function useAdmin() {
token: null, token: null,
plainText: false, plainText: false,
version: null, version: null,
agree: false,
showTerms: false,
}); });
const updateState = (value) => { const updateState = (value) => {
@ -62,6 +64,15 @@ export function useAdmin() {
hidePass: () => { hidePass: () => {
updateState({ plainText: false }); updateState({ plainText: false });
}, },
showTerms: () => {
updateState({ showTerms: true });
},
hideTerms: () => {
updateState({ showTerms: false });
},
agree: (agree) => {
updateState({ agree });
},
access: async () => { access: async () => {
if (!state.busy) { if (!state.busy) {
try { try {

View File

@ -138,25 +138,23 @@ export function Create() {
</View> </View>
)} )}
{ Platform.OS !== 'ios' && ( <View style={styles.tos}>
<View style={styles.tos}> <TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}> <Text style={styles.viewtermstext}>View Terms of Service</Text>
<Text style={styles.viewtermstext}>View Terms of Service</Text> </TouchableOpacity>
</TouchableOpacity> <TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}> { state.agree && (
{ state.agree && ( <MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} /> )}
)} { !state.agree && (
{ !state.agree && ( <MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} /> )}
)} <Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text> </TouchableOpacity>
</TouchableOpacity> </View>
</View>
)}
<View style={styles.buttons}> <View style={styles.buttons}>
{ state.enabled && (state.agree || Platform.OS === 'ios') && ( { state.enabled && state.agree && (
<TouchableOpacity style={styles.create} onPress={create}> <TouchableOpacity style={styles.create} onPress={create}>
{ state.busy && ( { state.busy && (
<ActivityIndicator size="small" color="#ffffff" /> <ActivityIndicator size="small" color="#ffffff" />
@ -166,7 +164,7 @@ export function Create() {
)} )}
</TouchableOpacity> </TouchableOpacity>
)} )}
{ (!state.enabled || (!state.agree && Platform.OS !== 'ios')) && ( { (!state.enabled || !state.agree) && (
<View style={styles.nocreate}> <View style={styles.nocreate}>
<Text style={styles.nocreatetext}>Create Account</Text> <Text style={styles.nocreatetext}>Create Account</Text>
</View> </View>

View File

@ -1,8 +1,10 @@
import { KeyboardAvoidingView, ActivityIndicator, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native'; import { KeyboardAvoidingView, ActivityIndicator, Modal, ScrollView, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native';
import { styles } from './Login.styled'; import { styles } from './Login.styled';
import Ionicons from 'react-native-vector-icons/AntDesign'; import Ionicons from 'react-native-vector-icons/AntDesign';
import { useLogin } from './useLogin.hook'; import { useLogin } from './useLogin.hook';
import { Colors } from 'constants/Colors'; import { Colors } from 'constants/Colors';
import MatIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { tos } from 'constants/TermsOfService';
export function Login() { export function Login() {
@ -60,7 +62,23 @@ export function Login() {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
)} )}
{ state.enabled && (
<View style={styles.tos}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<Text style={styles.viewtermstext}>View Terms of Service</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
{ state.agree && (
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
)}
{ !state.agree && (
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
)}
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
</TouchableOpacity>
</View>
{ state.enabled && state.agree && (
<TouchableOpacity style={styles.login} onPress={login}> <TouchableOpacity style={styles.login} onPress={login}>
{ state.busy && ( { state.busy && (
<ActivityIndicator size="small" color="#ffffff" /> <ActivityIndicator size="small" color="#ffffff" />
@ -70,7 +88,7 @@ export function Login() {
)} )}
</TouchableOpacity> </TouchableOpacity>
)} )}
{ !state.enabled && ( { (!state.enabled || !state.agree) && (
<View style={styles.nologin}> <View style={styles.nologin}>
<Text style={styles.nologintext}>Login</Text> <Text style={styles.nologintext}>Login</Text>
</View> </View>
@ -85,6 +103,23 @@ export function Login() {
</View> </View>
</View> </View>
</View> </View>
<Modal
animationType="fade"
transparent={true}
visible={state.showTerms}
supportedOrientations={['portrait', 'landscape']}
onRequestClose={actions.hideTerms}
>
<View style={styles.modalContainer}>
<ScrollView style={styles.terms} persistentScrollbar={true}>
<Text style={styles.termsheader}>Terms of Use and User Policy</Text>
<Text numberOfLines={0}>{ tos.message }</Text>
</ScrollView>
<TouchableOpacity style={styles.done} onPress={actions.hideTerms}>
<Text style={styles.donetext}>Done</Text>
</TouchableOpacity>
</View>
</Modal>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
} }

View File

@ -15,6 +15,63 @@ export const styles = StyleSheet.create({
space: { space: {
width: 32, width: 32,
}, },
modalContainer: {
width: '100%',
height: '100%',
backgroundColor: Colors.grey,
alignItems: 'center',
justifyContent: 'center',
},
tos: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
agreeterms: {
display: 'flex',
flexDirection: 'row',
padding: 8,
},
agreetermstext: {
color: Colors.primary,
paddingLeft: 8,
fontSize: 14,
},
viewterms: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
padding: 8,
},
viewtermstext: {
color: Colors.primary,
fontSize: 14,
},
terms: {
borderRadius: 4,
maxHeight: '80%',
padding: 8,
margin: 16,
backgroundColor: Colors.formBackground,
},
done: {
paddingTop: 8,
paddingBottom: 8,
paddingLeft: 16,
paddingRight: 16,
borderRadius: 4,
backgroundColor: Colors.white,
marginTop: 8,
},
donetext: {
color: Colors.text,
fontSize: 16,
},
termsheader: {
fontWeight: 'bold',
textAlign: 'center',
},
container: { container: {
flexDirection: 'column', flexDirection: 'column',
backgroundColor: Colors.formBackground, backgroundColor: Colors.formBackground,

View File

@ -14,6 +14,8 @@ export function useLogin() {
login: null, login: null,
password: null, password: null,
showPassword: false, showPassword: false,
agree: false,
showTerms: false,
}); });
const updateState = (value) => { const updateState = (value) => {
@ -57,6 +59,15 @@ export function useLogin() {
hidePassword: () => { hidePassword: () => {
updateState({ showPassword: false }); updateState({ showPassword: false });
}, },
showTerms: () => {
updateState({ showTerms: true });
},
hideTerms: () => {
updateState({ showTerms: false });
},
agree: (agree) => {
updateState({ agree });
},
login: async () => { login: async () => {
if (!state.busy) { if (!state.busy) {
updateState({ busy: true }); updateState({ busy: true });

View File

@ -1,8 +1,10 @@
import { KeyboardAvoidingView, ActivityIndicator, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native'; import { KeyboardAvoidingView, ActivityIndicator, Modal, ScrollView, Alert, Text, TextInput, View, TouchableOpacity } from 'react-native';
import { styles } from './Reset.styled'; import { styles } from './Reset.styled';
import Ionicons from 'react-native-vector-icons/AntDesign'; import Ionicons from 'react-native-vector-icons/AntDesign';
import { useReset } from './useReset.hook'; import { useReset } from './useReset.hook';
import Colors from 'constants/Colors'; import Colors from 'constants/Colors';
import MatIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { tos } from 'constants/TermsOfService';
export function Reset() { export function Reset() {
@ -45,7 +47,23 @@ export function Reset() {
autoCapitalize="none" placeholder="token" placeholderTextColor={Colors.grey} /> autoCapitalize="none" placeholder="token" placeholderTextColor={Colors.grey} />
<View style={styles.space} /> <View style={styles.space} />
</View> </View>
{ state.enabled && (
<View style={styles.tos}>
<TouchableOpacity style={styles.viewterms} onPress={actions.showTerms}>
<Text style={styles.viewtermstext}>View Terms of Service</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.agreeterms} onPress={() => actions.agree(!state.agree)}>
{ state.agree && (
<MatIcons name={'checkbox-outline'} size={20} color={Colors.primary} />
)}
{ !state.agree && (
<MatIcons name={'checkbox-blank-outline'} size={20} color={Colors.primary} />
)}
<Text style={styles.agreetermstext}>I agree to Terms of Service</Text>
</TouchableOpacity>
</View>
{ state.enabled && state.agree && (
<TouchableOpacity style={styles.reset} onPress={reset}> <TouchableOpacity style={styles.reset} onPress={reset}>
{ state.busy && ( { state.busy && (
<ActivityIndicator size="small" color="#ffffff" /> <ActivityIndicator size="small" color="#ffffff" />
@ -55,7 +73,7 @@ export function Reset() {
)} )}
</TouchableOpacity> </TouchableOpacity>
)} )}
{ !state.enabled && ( { (!state.enabled || !state.agree) && (
<View style={styles.noreset}> <View style={styles.noreset}>
<Text style={styles.noresettext}>Access</Text> <Text style={styles.noresettext}>Access</Text>
</View> </View>
@ -65,6 +83,23 @@ export function Reset() {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
<Modal
animationType="fade"
transparent={true}
visible={state.showTerms}
supportedOrientations={['portrait', 'landscape']}
onRequestClose={actions.hideTerms}
>
<View style={styles.modalContainer}>
<ScrollView style={styles.terms} persistentScrollbar={true}>
<Text style={styles.termsheader}>Terms of Use and User Policy</Text>
<Text numberOfLines={0}>{ tos.message }</Text>
</ScrollView>
<TouchableOpacity style={styles.done} onPress={actions.hideTerms}>
<Text style={styles.donetext}>Done</Text>
</TouchableOpacity>
</View>
</Modal>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
} }

View File

@ -15,6 +15,63 @@ export const styles = StyleSheet.create({
space: { space: {
width: 32, width: 32,
}, },
modalContainer: {
width: '100%',
height: '100%',
backgroundColor: Colors.grey,
alignItems: 'center',
justifyContent: 'center',
},
tos: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
agreeterms: {
display: 'flex',
flexDirection: 'row',
padding: 8,
},
agreetermstext: {
color: Colors.primary,
paddingLeft: 8,
fontSize: 14,
},
viewterms: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
padding: 8,
},
viewtermstext: {
color: Colors.primary,
fontSize: 14,
},
terms: {
borderRadius: 4,
maxHeight: '80%',
padding: 8,
margin: 16,
backgroundColor: Colors.formBackground,
},
done: {
paddingTop: 8,
paddingBottom: 8,
paddingLeft: 16,
paddingRight: 16,
borderRadius: 4,
backgroundColor: Colors.white,
marginTop: 8,
},
donetext: {
color: Colors.text,
fontSize: 16,
},
termsheader: {
fontWeight: 'bold',
textAlign: 'center',
},
container: { container: {
flexDirection: 'column', flexDirection: 'column',
backgroundColor: Colors.formBackground, backgroundColor: Colors.formBackground,

View File

@ -13,6 +13,8 @@ export function useReset() {
enabled: false, enabled: false,
server: null, server: null,
token: null, token: null,
agree: false,
showTerms: false,
}); });
const updateState = (value) => { const updateState = (value) => {
@ -47,6 +49,15 @@ export function useReset() {
login: () => { login: () => {
navigate('/login'); navigate('/login');
}, },
showTerms: () => {
updateState({ showTerms: true });
},
hideTerms: () => {
updateState({ showTerms: false });
},
agree: (agree) => {
updateState({ agree });
},
access: async () => { access: async () => {
if (!state.busy) { if (!state.busy) {
try { try {