mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
adding actions to contacts
This commit is contained in:
parent
49c2aafaf4
commit
fce0f4e630
@ -85,6 +85,14 @@ const Strings = [
|
|||||||
// contacts page
|
// contacts page
|
||||||
add: 'Add',
|
add: 'Add',
|
||||||
back: 'Back',
|
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',
|
confirmed: 'Saved',
|
||||||
pending: 'Unknown',
|
pending: 'Unknown',
|
||||||
@ -186,6 +194,14 @@ const Strings = [
|
|||||||
//constacts page
|
//constacts page
|
||||||
add: 'Ajouter',
|
add: 'Ajouter',
|
||||||
back: 'Arrière',
|
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é',
|
confirmed: 'Enregistré',
|
||||||
pending: 'Inconnu',
|
pending: 'Inconnu',
|
||||||
@ -196,7 +212,7 @@ const Strings = [
|
|||||||
offsync: 'Hors Sync',
|
offsync: 'Hors Sync',
|
||||||
|
|
||||||
actionResync: 'Resync',
|
actionResync: 'Resync',
|
||||||
actionConnect: 'Connexion',
|
actionConnect: 'Connecter',
|
||||||
actionAccept: 'Accepter',
|
actionAccept: 'Accepter',
|
||||||
actionSave: 'Enregistrer',
|
actionSave: 'Enregistrer',
|
||||||
actionCancel: 'Annuler',
|
actionCancel: 'Annuler',
|
||||||
@ -287,7 +303,15 @@ const Strings = [
|
|||||||
// contacts page
|
// contacts page
|
||||||
add: 'Agregar',
|
add: 'Agregar',
|
||||||
back: 'Atrás',
|
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',
|
confirmed: 'Guardado',
|
||||||
pending: 'Desconocido',
|
pending: 'Desconocido',
|
||||||
connecting: 'Conectando',
|
connecting: 'Conectando',
|
||||||
@ -305,7 +329,7 @@ const Strings = [
|
|||||||
actionIgnore: 'Ignorar',
|
actionIgnore: 'Ignorar',
|
||||||
actionDelete: 'Borrar',
|
actionDelete: 'Borrar',
|
||||||
actionBlock: 'Bloquear',
|
actionBlock: 'Bloquear',
|
||||||
actionReport: 'Informe',
|
actionReport: 'Reportar',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
visibleRegistry: 'Sichtbar in der Registrierung',
|
visibleRegistry: 'Sichtbar in der Registrierung',
|
||||||
@ -388,6 +412,14 @@ const Strings = [
|
|||||||
//contacts page
|
//contacts page
|
||||||
add: 'Hinzufügen',
|
add: 'Hinzufügen',
|
||||||
back: 'Rückwärts',
|
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',
|
confirmed: 'Gerettet',
|
||||||
pending: 'Unbekannt',
|
pending: 'Unbekannt',
|
||||||
|
@ -311,8 +311,8 @@ export function Contact({ contact, drawer, back }) {
|
|||||||
const OVERLAP = 32;
|
const OVERLAP = 32;
|
||||||
|
|
||||||
|
|
||||||
const promptDelete = (action) => {
|
const promptAction = (prompt, action) => {
|
||||||
actions.deletePrompt(async () => {
|
prompt(async () => {
|
||||||
if (!busy) {
|
if (!busy) {
|
||||||
try {
|
try {
|
||||||
setBusy(true);
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{ drawer && (
|
{ drawer && (
|
||||||
@ -462,7 +445,7 @@ export function Contact({ contact, drawer, back }) {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{ state.status === 'connected' && (
|
{ 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} />
|
<MatIcons name="account-cancel-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={42} color={Colors.linkText} />
|
||||||
<Text style={styles.actionLabel}>{ state.strings.actionDisconnect }</Text>
|
<Text style={styles.actionLabel}>{ state.strings.actionDisconnect }</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@ -480,25 +463,25 @@ export function Contact({ contact, drawer, back }) {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{ (state.status === 'connected' || state.status === 'connecting' || state.status === 'received') && (
|
{ (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} />
|
<MatIcons name="trash-can-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||||
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{ state.status === 'confirmed' && (
|
{ 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} />
|
<MatIcons name="trash-can-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||||
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
<Text style={styles.actionLabel}>{ state.strings.actionDelete }</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{ state.status !== 'unsaved' && state.status !== 'pending' && (
|
{ 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} />
|
<MatIcons name="block-helper" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={34} color={Colors.linkText} />
|
||||||
<Text style={styles.actionLabel}>{ state.strings.actionBlock }</Text>
|
<Text style={styles.actionLabel}>{ state.strings.actionBlock }</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{ true && (
|
{ 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} />
|
<MatIcons name="account-alert-outline" style={{ ...styles.actionIcon, paddingBottom: 4 }} size={40} color={Colors.linkText} />
|
||||||
<Text style={styles.actionLabel}>{ state.strings.actionReport }</Text>
|
<Text style={styles.actionLabel}>{ state.strings.actionReport }</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect, useRef, useContext } from 'react';
|
import { useState, useEffect, useRef, useContext } from 'react';
|
||||||
import { useWindowDimensions } from 'react-native';
|
import { Alert, useWindowDimensions } from 'react-native';
|
||||||
import { CardContext } from 'context/CardContext';
|
import { CardContext } from 'context/CardContext';
|
||||||
import { ProfileContext } from 'context/ProfileContext';
|
import { ProfileContext } from 'context/ProfileContext';
|
||||||
import { DisplayContext } from 'context/DisplayContext';
|
import { DisplayContext } from 'context/DisplayContext';
|
||||||
@ -147,9 +147,48 @@ export function useContact(contact) {
|
|||||||
},
|
},
|
||||||
deletePrompt: (action) => {
|
deletePrompt: (action) => {
|
||||||
display.actions.showPrompt({
|
display.actions.showPrompt({
|
||||||
title: state.strings.loggingOut,
|
title: state.strings.deleteContact,
|
||||||
centerButtons: true,
|
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(
|
Alert.alert(
|
||||||
state.strings.error,
|
state.strings.error,
|
||||||
state.strings.tryAgain,
|
state.strings.tryAgain,
|
||||||
|
Loading…
Reference in New Issue
Block a user