mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
adding actions to contacts
This commit is contained in:
parent
49c2aafaf4
commit
fce0f4e630
@ -85,6 +85,14 @@ const Strings = [
|
||||
// contacts page
|
||||
add: 'Add',
|
||||
back: 'Back',
|
||||
deleteContact: 'Deleting Contact',
|
||||
confirmDelete: 'Delete',
|
||||
disconnectContact: 'Disconnect from Contact',
|
||||
confirmDisconnect: 'Disconnect',
|
||||
blockContact: 'Block Contact',
|
||||
confirmBlock: 'Block',
|
||||
reportContact: 'Report Contact',
|
||||
confirmReport: 'Report',
|
||||
|
||||
confirmed: 'Saved',
|
||||
pending: 'Unknown',
|
||||
@ -186,6 +194,14 @@ const Strings = [
|
||||
//constacts page
|
||||
add: 'Ajouter',
|
||||
back: 'Arrière',
|
||||
deleteContact: 'Supprimer le Contact',
|
||||
confirmDelete: 'Supprimer',
|
||||
disconnectContact: 'Déconnecter le Contact',
|
||||
confirmDisconnect: 'Déconnecter',
|
||||
blockContact: 'Bloquer le Contact',
|
||||
confirmBlock: 'Bloquer',
|
||||
reportContact: 'Signaler le Contact',
|
||||
confirmReport: 'Signaler',
|
||||
|
||||
confirmed: 'Enregistré',
|
||||
pending: 'Inconnu',
|
||||
@ -196,7 +212,7 @@ const Strings = [
|
||||
offsync: 'Hors Sync',
|
||||
|
||||
actionResync: 'Resync',
|
||||
actionConnect: 'Connexion',
|
||||
actionConnect: 'Connecter',
|
||||
actionAccept: 'Accepter',
|
||||
actionSave: 'Enregistrer',
|
||||
actionCancel: 'Annuler',
|
||||
@ -287,7 +303,15 @@ const Strings = [
|
||||
// contacts page
|
||||
add: 'Agregar',
|
||||
back: 'Atrás',
|
||||
|
||||
deleteContact: 'Borrar Contacto',
|
||||
confirmDelete: 'Borrar',
|
||||
disconnectContact: 'Desconectar Contacto',
|
||||
confirmDisconnect: 'Desconectar',
|
||||
blockContact: 'Bloquear el Contacto',
|
||||
confirmBlock: 'Bloquear',
|
||||
reportContact: 'Reportar el Contacto',
|
||||
confirmReport: 'Reportar',
|
||||
|
||||
confirmed: 'Guardado',
|
||||
pending: 'Desconocido',
|
||||
connecting: 'Conectando',
|
||||
@ -305,7 +329,7 @@ const Strings = [
|
||||
actionIgnore: 'Ignorar',
|
||||
actionDelete: 'Borrar',
|
||||
actionBlock: 'Bloquear',
|
||||
actionReport: 'Informe',
|
||||
actionReport: 'Reportar',
|
||||
},
|
||||
{
|
||||
visibleRegistry: 'Sichtbar in der Registrierung',
|
||||
@ -388,6 +412,14 @@ const Strings = [
|
||||
//contacts page
|
||||
add: 'Hinzufügen',
|
||||
back: 'Rückwärts',
|
||||
deleteContact: 'Kontakt Löschen',
|
||||
confirmDelete: 'Löschen',
|
||||
disconnectContact: 'Kontakt Trennen',
|
||||
confirmDisconnect: 'Trennen',
|
||||
blockContact: 'Kontakt Ausblenden',
|
||||
confirmBlock: 'Verstecken',
|
||||
reportContact: 'Kontakt Melden',
|
||||
confirmReport: 'Bericht',
|
||||
|
||||
confirmed: 'Gerettet',
|
||||
pending: 'Unbekannt',
|
||||
|
@ -311,8 +311,8 @@ export function Contact({ contact, drawer, back }) {
|
||||
const OVERLAP = 32;
|
||||
|
||||
|
||||
const promptDelete = (action) => {
|
||||
actions.deletePrompt(async () => {
|
||||
const promptAction = (prompt, action) => {
|
||||
prompt(async () => {
|
||||
if (!busy) {
|
||||
try {
|
||||
setBusy(true);
|
||||
@ -328,23 +328,6 @@ export function Contact({ contact, drawer, back }) {
|
||||
});
|
||||
}
|
||||
|
||||
const action = async (method) => {
|
||||
if (!busy) {
|
||||
try {
|
||||
setBusy(true);
|
||||
await method();
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
Alert.alert(
|
||||
state.strings.error,
|
||||
state.strings.tryAgain,
|
||||
);
|
||||
}
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{ drawer && (
|
||||
@ -462,7 +445,7 @@ export function Contact({ contact, drawer, back }) {
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ state.status === 'connected' && (
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1}>
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptAction(actions.disconnectPrompt, actions.disconnectContact)}>
|
||||
<MatIcons name="account-cancel-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={42} color={Colors.linkText} />
|
||||
<Text style={styles.actionLabel}>{ state.strings.actionDisconnect }</Text>
|
||||
</TouchableOpacity>
|
||||
@ -480,25 +463,25 @@ export function Contact({ contact, drawer, back }) {
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ (state.status === 'connected' || state.status === 'connecting' || state.status === 'received') && (
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptDelete(actions.closeDelete)}>
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptAction(actions.deletePrompt, actions.closeDelete)}>
|
||||
<MatIcons name="trash-can-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ state.status === 'confirmed' && (
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptDelete(actions.deleteContact)}>
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptAction(actions.deletePrompt, actions.deleteContact)}>
|
||||
<MatIcons name="trash-can-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ state.status !== 'unsaved' && state.status !== 'pending' && (
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1}>
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptAction(actions.blockPrompt, actions.blockContact)}>
|
||||
<MatIcons name="block-helper" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={34} color={Colors.linkText} />
|
||||
<Text style={styles.actionLabel}>{ state.strings.actionBlock }</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{ true && (
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1}>
|
||||
<TouchableOpacity style={styles.action} activeOpacity={1} onPress={() => promptAction(actions.reportPrompt, actions.reportContact)}>
|
||||
<MatIcons name="account-alert-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||
<Text style={styles.actionLabel}>{ state.strings.actionReport }</Text>
|
||||
</TouchableOpacity>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef, useContext } from 'react';
|
||||
import { useWindowDimensions } from 'react-native';
|
||||
import { Alert, useWindowDimensions } from 'react-native';
|
||||
import { CardContext } from 'context/CardContext';
|
||||
import { ProfileContext } from 'context/ProfileContext';
|
||||
import { DisplayContext } from 'context/DisplayContext';
|
||||
@ -147,9 +147,48 @@ export function useContact(contact) {
|
||||
},
|
||||
deletePrompt: (action) => {
|
||||
display.actions.showPrompt({
|
||||
title: state.strings.loggingOut,
|
||||
title: state.strings.deleteContact,
|
||||
centerButtons: true,
|
||||
ok: { label: state.strings.confirmLogout, action, failed: () => {
|
||||
ok: { label: state.strings.confirmDelete, action, failed: () => {
|
||||
Alert.alert(
|
||||
state.strings.error,
|
||||
state.strings.tryAgain,
|
||||
);
|
||||
}},
|
||||
cancel: { label: state.strings.cancel },
|
||||
});
|
||||
},
|
||||
disconnectPrompt: (action) => {
|
||||
display.actions.showPrompt({
|
||||
title: state.strings.disconnectContact,
|
||||
centerButtons: true,
|
||||
ok: { label: state.strings.confirmDisconnect, action, failed: () => {
|
||||
Alert.alert(
|
||||
state.strings.error,
|
||||
state.strings.tryAgain,
|
||||
);
|
||||
}},
|
||||
cancel: { label: state.strings.cancel },
|
||||
});
|
||||
},
|
||||
blockPrompt: (action) => {
|
||||
display.actions.showPrompt({
|
||||
title: state.strings.blockContact,
|
||||
centerButtons: true,
|
||||
ok: { label: state.strings.confirmBlock, action, failed: () => {
|
||||
Alert.alert(
|
||||
state.strings.error,
|
||||
state.strings.tryAgain,
|
||||
);
|
||||
}},
|
||||
cancel: { label: state.strings.cancel },
|
||||
});
|
||||
},
|
||||
reportPrompt: (action) => {
|
||||
display.actions.showPrompt({
|
||||
title: state.strings.reportContact,
|
||||
centerButtons: true,
|
||||
ok: { label: state.strings.confirmReport, action, failed: () => {
|
||||
Alert.alert(
|
||||
state.strings.error,
|
||||
state.strings.tryAgain,
|
||||
|
Loading…
Reference in New Issue
Block a user