mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
adding delete account modal to new settings screen
This commit is contained in:
parent
e87a5b86fb
commit
bcbdfeb963
@ -189,7 +189,7 @@ export function Settings() {
|
||||
<View style={styles.control} />
|
||||
</TouchableOpacity>
|
||||
<View style={styles.divider} />
|
||||
<TouchableOpacity style={styles.entry} activeOpacity={1}>
|
||||
<TouchableOpacity style={styles.entry} activeOpacity={1} onPress={actions.showDelete}>
|
||||
<View style={styles.icon}>
|
||||
<MatIcons name="trash-can-outline" size={20} color={Colors.dangerText} />
|
||||
</View>
|
||||
@ -543,6 +543,42 @@ export function Settings() {
|
||||
</View>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
animationType="fade"
|
||||
transparent={true}
|
||||
visible={state.delete}
|
||||
supportedOrientations={['portrait', 'landscape']}
|
||||
onRequestClose={actions.hideDelete}
|
||||
>
|
||||
<View style={styles.modalOverlay}>
|
||||
<View style={styles.modalContainer}>
|
||||
<View style={styles.modalClose}>
|
||||
<TouchableOpacity style={styles.closeButton} activeOpacity={1} onPress={actions.hideDelete}>
|
||||
<MatIcons name="close" size={20} color={Colors.descriptionText} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<Text style={styles.modalHeader}>{ state.strings.deleteAccount }</Text>
|
||||
<ActivityIndicator style={styles.modalBusy} animating={busy} color={Colors.primary} />
|
||||
|
||||
<View style={styles.modalInput}>
|
||||
<TextInput style={styles.inputText} value={state.sealDelete} onChangeText={actions.setSealDelete}
|
||||
autoCapitalize={'none'} placeholder={state.strings.typeDelete}
|
||||
placeholderTextColor={Colors.inputPlaceholder} />
|
||||
</View>
|
||||
{ state.sealDelete === state.strings.deleteKey && (
|
||||
<TouchableOpacity style={styles.dangerButton} activeOpacity={1} onPress={() => sealAction(actions.removeKey, 'Remove')}>
|
||||
<Text style={styles.dangerButtonText}>{ state.strings.delete }</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ state.sealDelete !== state.strings.deleteKey && (
|
||||
<View style={styles.disabledButton}>
|
||||
<Text style={styles.disabledButtonText}>{ state.strings.delete }</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</Modal>
|
||||
|
||||
</SafeAreaView>
|
||||
</ScrollView>
|
||||
);
|
||||
|
@ -26,6 +26,7 @@ export function useSettings() {
|
||||
available: true,
|
||||
password: null,
|
||||
confirm: null,
|
||||
delete: null,
|
||||
|
||||
logout: false,
|
||||
editSeal: false,
|
||||
@ -106,13 +107,18 @@ export function useSettings() {
|
||||
clearTimeout(debounce.current);
|
||||
checking.current = username;
|
||||
updateState({ username, validated: false });
|
||||
debounce.current = setTimeout(async () => {
|
||||
const cur = JSON.parse(JSON.stringify(username));
|
||||
const available = await profile.actions.getHandleStatus(cur);
|
||||
if (checking.current === cur) {
|
||||
updateState({ available, validated: true });
|
||||
}
|
||||
}, 1000);
|
||||
if (state.handle === username) {
|
||||
updateState({ available: true, validated: true });
|
||||
}
|
||||
else {
|
||||
debounce.current = setTimeout(async () => {
|
||||
const cur = JSON.parse(JSON.stringify(username));
|
||||
const available = await profile.actions.getHandleStatus(cur);
|
||||
if (checking.current === cur) {
|
||||
updateState({ available, validated: true });
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
setPassword: (password) => {
|
||||
updateState({ password });
|
||||
@ -123,6 +129,12 @@ export function useSettings() {
|
||||
logout: async () => {
|
||||
await app.actions.logout();
|
||||
},
|
||||
showDelete: () => {
|
||||
updateState({ delete: true });
|
||||
},
|
||||
hideDelete: () => {
|
||||
updateState({ delete: false });
|
||||
},
|
||||
showLogout: () => {
|
||||
updateState({ logout: true });
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user