Skip to content

Commit

Permalink
add contacts options in setings
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Nov 21, 2023
1 parent 2b9e864 commit 6f2426f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 29 deletions.
2 changes: 1 addition & 1 deletion assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"meltNostrProfileHint": "Senden Sie Ihr Guthaben zu der LN-Adresse, die mit Ihrem Nostr-Profil verknüpft ist.",
"nostrDmHint": "eNuts kann nicht auf Ihre Nostr-Nachrichten zugreifen, da es keinen Zugriff auf Ihren privaten Schlüssel hat. Stattdessen generiert es einen neuen Schlüssel zum Senden von Ecash. Wenn Sie Ecash über Nostr senden, erhält der Empfänger es mit Ihrem neuen öffentlichen eNuts-Schlüssel. Wenn der Empfänger auf die Nachricht mit einem Ecash-Token antwortet, wird es hier angezeigt. Wir arbeiten aktiv an einer sicheren Lösung für private Schlüssel.",
"nostrIssueHeader": "Nostr-Kontaktproblem",
"nostrIssueHint": "Wenn Sie Schwierigkeiten haben, Ihre Nostr-Kontakte zu öffnen, klicken Sie auf die Schaltfläche unten oder setzen Sie die Nostr-Daten in den Einstellungen zurück, um das Problem zu lösen.",
"nostrIssueHint": "Wenn Sie Schwierigkeiten haben, Ihre Nostr-Kontakte zu öffnen, klicken Sie auf die Schaltfläche unten oder setzen Sie die Nostr-Daten in \"Optionen > Kontakte > Daten zurücksetzen\" zurück, um das Problem zu lösen.",
"submitNostrIssue": "Daten zurücksetzen",
"nostrIssueSuccess": "Nostr-Daten erfolgreich zurückgesetzt!"
},
Expand Down
2 changes: 1 addition & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"meltNostrProfileHint": "Transfer funds to the LN address associated with your Nostr profile.",
"nostrDmHint": "eNuts can't access your Nostr account DMs due to its lack of access to your private key. Instead, it generates a new key for sending Ecash. When you send Ecash via Nostr, the recipient gets it using your new eNuts public key. If the recipient replies to the DM with an Ecash token, you can view it here. We're actively working on a secure private key solution.",
"nostrIssueHeader": "Nostr contacts issue",
"nostrIssueHint": "If you're having trouble opening your Nostr contacts, click the button below or reset the Nostr data in settings to resolve the issue.",
"nostrIssueHint": "If you're having trouble opening your Nostr contacts, click the button below or reset the Nostr data in \"options > contacts > reset data now\" data to resolve the issue.",
"submitNostrIssue": "Reset data now",
"nostrIssueSuccess": "Nostr data reset successfully!"
},
Expand Down
6 changes: 3 additions & 3 deletions assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@
"disclaimerHint": "Cette clause de non-responsabilité doit être prise au sérieux et ne doit pas être ignorée ni sous-estimée. Nous apprécions votre intérêt pour ce projet et continuerons à travailler à son amélioration.",
"searchContacts": "Recherchez ou saisissez NPUB",
"submit": "Soumettre",
"clearMetadataCache": "Vider le cache",
"clearMetadataCache": "Vider le cache métadonnées",
"clearMetadataCacheHint": "Vider le cache des métadonnées?",
"clearImageCache": "Vider le cache",
"clearImageCache": "Vider le cache des images",
"clearImageCacheHint": "Vider le cache des images?",
"pullRefresh": "Tirer pour rafraîchir",
"processTestPay": "Traitement du paiement de test...",
Expand All @@ -213,7 +213,7 @@
"meltNostrProfileHint": "Transférez des fonds vers l'adresse du LN associée à votre profil Nostr.",
"nostrDmHint": "eNuts ne peut pas accéder aux DM de votre compte Nostr en raison de son manque d'accès à votre clé privée. À la place, il génère une nouvelle clé pour l'envoi d'Ecash. Lorsque vous envoyez de l'Ecash via Nostr, le destinataire le reçoit en utilisant votre nouvelle clé publique eNuts. Si le destinataire répond au DM avec un jeton Ecash, vous pouvez le voir ici. Nous travaillons activement sur une solution sécurisée pour les clés privées.",
"nostrIssueHeader": "Problème de contacts Nostr",
"nostrIssueHint": "Si vous rencontrez des problèmes pour ouvrir vos contacts Nostr, cliquez sur le bouton ci-dessous ou réinitialisez les données Nostr dans les paramètres pour résoudre le problème.",
"nostrIssueHint": "Si vous rencontrez des problèmes pour ouvrir vos contacts Nostr, cliquez sur le bouton ci-dessous ou réinitialisez les données Nostr dans \"options > contacts > Réinitialiser maintenant\" pour résoudre le problème.",
"submitNostrIssue": "Réinitialiser maintenant",
"nostrIssueSuccess": "Réinitialisation des données Nostr réussie!"
},
Expand Down
2 changes: 1 addition & 1 deletion assets/translations/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"meltNostrProfileHint": "Hamishia fedha kwa anwani ya Mtandao wa Lightning (LN) inayohusishwa na wasifu wako wa Nostr.",
"nostrDmHint": "eNuts hawezi kupata ujumbe wako wa Nostr kutokana na kutokuwa na ufikiaji wa ufunguo wako wa faragha. Badala yake, inazalisha ufunguo mpya kwa ajili ya kutuma Ecash. Ukipeleka Ecash kupitia Nostr, mpokeaji atapokea kwa kutumia ufunguo wa umma mpya wa eNuts. Ikiwa mpokeaji atajibu ujumbe huo na alama ya Ecash, unaweza kuiona hapa. Tunafanya kazi kwa bidii kwenye suluhisho salama la ufunguo wa faragha.",
"nostrIssueHeader": "Tatizo la Mawasiliano ya Nostr",
"nostrIssueHint": "Kama una matatizo kufungua mawasiliano yako ya Nostr, bonyeza kitufe hapa chini au rudisha data ya Nostr kwenye mipangilio kusuluhisha tatizo.",
"nostrIssueHint": "Kama unakumbana na shida kufungua mawasiliano yako ya Nostr, bonyeza kitufe hapa chini au rudisha data ya Nostr katika \"chaguo > mawasiliano > rudisha data sasa\" ili kutatua tatizo.",
"submitNostrIssue": "Rudisha data sasa",
"nostrIssueSuccess": "Urejeshaji wa data ya Nostr umefanikiwa!"
},
Expand Down
15 changes: 14 additions & 1 deletion src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,20 @@ export function SendMsgIcon({ width, height, color }: TIconProps) {
</Svg>
)
}

export function DatabaseIcon({ width, height, color }: TIconProps) {
return (
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
<Path d="M3 7.39095V10C3 10.3436 3.85363 10.8747 5.40973 11.2842C7.13505 11.7383 9.48657 12 12 12C14.5134 12 16.8649 11.7383 18.5903 11.2842C20.1464 10.8747 21 10.3436 21 10V7.39095C19.3864 8.40254 15.9832 9 12 9C8.01684 9 4.61364 8.40254 3 7.39095ZM2 6C2 4.16677 6.43371 3 12 3C17.5663 3 22 4.16677 22 6V18C22 19.8332 17.5663 21 12 21C6.43371 21 2 19.8332 2 18V6ZM21 11.3909C19.3864 12.4025 15.9832 13 12 13C8.01684 13 4.61364 12.4025 3 11.3909V14C3 14.3436 3.85363 14.8747 5.40973 15.2842C7.13505 15.7383 9.48657 16 12 16C14.5134 16 16.8649 15.7383 18.5903 15.2842C20.1464 14.8747 21 14.3436 21 14V11.3909ZM21 15.3909C19.3864 16.4025 15.9832 17 12 17C8.01684 17 4.61364 16.4025 3 15.3909V18C3 18.3436 3.85363 18.8747 5.40973 19.2842C7.13505 19.7383 9.48657 20 12 20C14.5134 20 16.8649 19.7383 18.5903 19.2842C20.1464 18.8747 21 18.3436 21 18V15.3909ZM12 8C14.5134 8 16.8649 7.73826 18.5903 7.28423C20.1464 6.87473 21 6.34362 21 6C21 5.65638 20.1464 5.12527 18.5903 4.71577C16.8649 4.26174 14.5134 4 12 4C9.48657 4 7.13505 4.26174 5.40973 4.71577C3.85363 5.12527 3 5.65638 3 6C3 6.34362 3.85363 6.87473 5.40973 7.28423C7.13505 7.73826 9.48657 8 12 8Z" fill={color} />
</Svg>
)
}
export function ImageIcon({ width, height, color }: TIconProps) {
return (
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
<Path d="M20 15.2929V5.5C20 4.67157 19.3284 4 18.5 4H5.5C4.67157 4 4 4.67157 4 5.5V12.2929L7.14645 9.14645C7.34171 8.95118 7.65829 8.95118 7.85355 9.14645L13.5 14.7929L16.1464 12.1464C16.3417 11.9512 16.6583 11.9512 16.8536 12.1464L20 15.2929ZM20 16.7071L16.5 13.2071L13.8536 15.8536C13.6583 16.0488 13.3417 16.0488 13.1464 15.8536L7.5 10.2071L4 13.7071V18.5C4 19.3284 4.67157 20 5.5 20H18.5C19.3284 20 20 19.3284 20 18.5V16.7071ZM3 5.5C3 4.11929 4.11929 3 5.5 3H18.5C19.8807 3 21 4.11929 21 5.5V18.5C21 19.8807 19.8807 21 18.5 21H5.5C4.11929 21 3 19.8807 3 18.5V5.5ZM15 6H17C17.5523 6 18 6.44772 18 7V9C18 9.55228 17.5523 10 17 10H15C14.4477 10 14 9.55228 14 9V7C14 6.44772 14.4477 6 15 6ZM15 7V9H17V7H15Z" fill={color} />
</Svg>
)
}
const styles = StyleSheet.create({
nostrIcon: {
marginLeft: -5
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav/BottomNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function BottomNav({ navigation, route }: TBottomNavProps) {
route.name === 'Security settings' ||
route.name === 'BackupPage' ||
route.name === 'Privacy settings' ||
route.name === 'Nostr settings'
route.name === 'Contacts settings'

return (
<View style={[styles.bottomNav, { backgroundColor: color.BACKGROUND, paddingBottom: isIOS ? 40 : 10 }]}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/nav/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import ScanSuccessScreen from '@screens/QRScan/ScanSuccess'
import Settings from '@screens/Settings'
import AboutSettings from '@screens/Settings/About'
import BackupPage from '@screens/Settings/Backup'
import ContactsSettings from '@screens/Settings/Contacts'
import GeneralSettings from '@screens/Settings/General'
import AdvancedFunctionScreen from '@screens/Settings/General/Advanced'
import DisplaySettings from '@screens/Settings/General/Display'
import LanguageSettings from '@screens/Settings/General/Language'
import NostrSettings from '@screens/Settings/Nostr'
import PrivacySettings from '@screens/Settings/Privacy'
import SecuritySettings from '@screens/Settings/Security'
import { useThemeContext } from '@src/context/Theme'
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function Navigator({
<Stack.Screen name='Display settings' component={DisplaySettings} />
<Stack.Screen name='Security settings' component={SecuritySettings} />
<Stack.Screen name='Privacy settings' component={PrivacySettings} />
<Stack.Screen name='Nostr settings' component={NostrSettings} />
<Stack.Screen name='Contacts settings' component={ContactsSettings} />
<Stack.Screen name='Language settings' component={LanguageSettings} />
<Stack.Screen name='Advanced settings' component={AdvancedFunctionScreen} />
<Stack.Screen name='About settings' component={AboutSettings} />
Expand Down
4 changes: 2 additions & 2 deletions src/model/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type RootStackParamList = {
'Display settings': undefined
'Language settings': undefined
'Advanced settings': undefined
'Nostr settings': undefined
'Contacts settings': undefined
'About settings': undefined
auth: {
pinHash: string
Expand Down Expand Up @@ -243,7 +243,7 @@ export type TGeneralSettingsPageProps = NativeStackScreenProps<RootStackParamLis
export type TDisplaySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Display settings'>
export type TSecuritySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Security settings'>
export type TPrivacySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Privacy settings'>
export type TNostrSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Nostr settings'>
export type TNostrSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Contacts settings'>
export type TLanguageSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Language settings'>
export type TAdvancedSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Advanced settings'>
export type TAboutSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'About settings'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import Button, { TxtButton } from '@comps/Button'
import { TrashbinIcon } from '@comps/Icons'
import { DatabaseIcon, ImageIcon, TrashbinIcon } from '@comps/Icons'
import MyModal from '@comps/modal'
import Screen from '@comps/Screen'
import Separator from '@comps/Separator'
import Txt from '@comps/Txt'
import type { TNostrSettingsPageProps } from '@model/nav'
import BottomNav from '@nav/BottomNav'
import { Nostr } from '@nostr/class/Nostr'
import { useNostrContext } from '@src/context/Nostr'
import { usePromptContext } from '@src/context/Prompt'
import { useThemeContext } from '@src/context/Theme'
import { NS } from '@src/i18n'
import { Nostr } from '@src/nostr/class/Nostr'
import { globals } from '@styles'
import { globals, mainColors } from '@styles'
import { Image } from 'expo-image'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'

export default function NostrSettings({ navigation, route }: TNostrSettingsPageProps) {
export default function ContactsSettings({ navigation, route }: TNostrSettingsPageProps) {
const { t } = useTranslation([NS.common])
const { color, highlight } = useThemeContext()
const { openPromptAutoClose } = usePromptContext()
const { resetNostrData } = useNostrContext()
const [visible, setVisible] = useState({
metadata: false,
image: false,
reset: false
})

const handleNostrCache = async () => {
Expand All @@ -37,31 +40,44 @@ export default function NostrSettings({ navigation, route }: TNostrSettingsPageP
openPromptAutoClose({ msg: success ? 'Image cache cleared' : 'Everything is clear!', success })
}

const handleResetData = async () => {
await resetNostrData()
onCancel()
openPromptAutoClose({ msg: t('nostrIssueSuccess'), success: true })
}

const onCancel = () => {
setVisible({ metadata: false, image: false })
setVisible({ metadata: false, image: false, reset: false })
}

return (
<Screen
screenName='Nostr'
screenName={t('contacts', { ns: NS.bottomNav })}
withBackBtn
handlePress={() => navigation.goBack()}
>
<ScrollView>
<View style={globals(color).wrapContainer}>
<TouchableOpacity style={globals().wrapRow} onPress={() => setVisible(prev => ({ ...prev, metadata: true }))}>
<View style={styles.iconWrap}>
<TrashbinIcon color={color.TEXT} />
<DatabaseIcon color={color.TEXT} />
<Txt txt={t('clearMetadataCache')} styles={[styles.optTxt]} />
</View>
</TouchableOpacity>
<Separator />
<TouchableOpacity style={globals().wrapRow} onPress={() => setVisible(prev => ({ ...prev, image: true }))}>
<View style={styles.iconWrap}>
<TrashbinIcon color={color.TEXT} />
<ImageIcon color={color.TEXT} />
<Txt txt={t('clearImageCache')} styles={[styles.optTxt]} />
</View>
</TouchableOpacity>
<Separator />
<TouchableOpacity style={globals().wrapRow} onPress={() => setVisible(prev => ({ ...prev, reset: true }))}>
<View style={styles.iconWrap}>
<TrashbinIcon color={mainColors.ERROR} />
<Txt txt={t('submitNostrIssue')} styles={[styles.optTxt, { color: mainColors.ERROR }]} />
</View>
</TouchableOpacity>
</View>
</ScrollView>
<BottomNav navigation={navigation} route={route} />
Expand Down Expand Up @@ -95,6 +111,21 @@ export default function NostrSettings({ navigation, route }: TNostrSettingsPageP
style={[styles.cancelBtn]}
/>
</MyModal>
{/* reset data */}
<MyModal type='bottom' animation='slide' visible={visible.reset} close={onCancel}>
<Text style={globals(color, highlight).modalHeader}>
{t('submitNostrIssue')}
</Text>
<Text style={globals(color, highlight).modalTxt}>
{t('delNpubHint')}
</Text>
<Button txt={t('yes')} onPress={() => void handleResetData()} />
<TxtButton
txt={t('no')}
onPress={onCancel}
style={[styles.cancelBtn]}
/>
</MyModal>
</Screen >
)
}
Expand Down
22 changes: 13 additions & 9 deletions src/screens/Settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { AboutIcon, EyeClosedIcon, HeartIcon, LockIcon, MintBoardIcon, OptionsIcon } from '@comps/Icons'
import { AboutIcon, BookIcon, EyeClosedIcon, HeartIcon, LockIcon, MintBoardIcon, OptionsIcon } from '@comps/Icons'
import { ZapModal } from '@comps/modal/Zap'
import Screen from '@comps/Screen'
import Txt from '@comps/Txt'
import { appVersion } from '@consts/env'
import { BottomModal } from '@modal/Question'
import type { TSettingsPageProps } from '@model/nav'
import BottomNav from '@nav/BottomNav'
import { useNostrContext } from '@src/context/Nostr'
import { useThemeContext } from '@src/context/Theme'
import { NS } from '@src/i18n'
import { dropAllData } from '@src/storage/dev'
Expand All @@ -22,11 +23,12 @@ export default function Settings({ navigation, route }: TSettingsPageProps) {
const { color } = useThemeContext()
const [confirmReset, setConfirmReset] = useState(false)
const [zapModal, setZapModal] = useState(false)
const { nostr } = useNostrContext()

const handleReset = async () => {
try {
await dropAllData()
} catch (e) {/* ignore */}
} catch (e) {/* ignore */ }
setConfirmReset(false)
void Updates.reloadAsync()
}
Expand Down Expand Up @@ -66,13 +68,15 @@ export default function Settings({ navigation, route }: TSettingsPageProps) {
hasSeparator
hasChevron
/>
{/* <MenuItem
txt='Nostr'
icon={<NostrIcon width={25} height={25} />}
onPress={() => navigation.navigate('Nostr settings')}
hasSeparator
hasChevron
/> */}
{nostr.nutPub.length > 0 &&
<MenuItem
txt={t('contacts', { ns: NS.bottomNav })}
icon={<BookIcon color={color.TEXT} />}
onPress={() => navigation.navigate('Contacts settings')}
hasSeparator
hasChevron
/>
}
<MenuItem
txt={t('about', { ns: NS.topNav })}
icon={<AboutIcon color={color.TEXT} />}
Expand Down

0 comments on commit 6f2426f

Please sign in to comment.