Skip to content

Commit

Permalink
added about screen. Fixes #98 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Jul 2, 2023
1 parent e5b4ed1 commit 5283c1a
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 13 deletions.
13 changes: 10 additions & 3 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
"backToDashboard": "Zurück zu wallet",
"default": "Standard",
"accept": "Annehmen",
"today": "Heute"
"continue": "Fortfahren",
"today": "Heute",
"readme": "Lies mich",
"githubIssues": "GitHub Probleme und Fragen",
"cashuRandD": "Cashu Telegram",
"enutsRandD": "eNuts Telegram"
},
"wallet": {
"disclaimer": "Bitte beachten Sie, dass es sich hierbei um eine Alpha-Version in einem frühen Stadium handelt und diese noch vor der offiziellen Veröffentlichung getestet wird. Die Software und alle darauf enthaltenen Inhalte werden als „wie besehen“ und „wie verfügbar“ bereitgestellt. Wir geben keine Garantien, ob ausdrücklich oder stillschweigend, hinsichtlich der Eignung oder Verwendbarkeit der Software oder deren Inhalte.",
Expand All @@ -119,7 +124,8 @@
"settings": "Einstellungen",
"language": "Sprache",
"security": "Sicherheit",
"backup": "Sicherung"
"backup": "Sicherung",
"about": "Über uns"
},
"bottomNav": {
"contacts": "Kontakte"
Expand Down Expand Up @@ -214,5 +220,6 @@
"getStarted": "Loslegen",
"startHint": "Sie sollten eine Mint hinzufügen, der Sie vertrauen, bevor Sie Token senden oder empfangen.",
"addMintNow": "Füge eine mint hinzu",
"willDoLater": "Mache ich später"
"willDoLater": "Mache ich später",
"aboutToLeaveTo": "Sie sind im Begriff die App zu verlassen"
}
13 changes: 10 additions & 3 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
"backToDashboard": "Back to dashboard",
"default": "Default",
"accept": "Accept",
"today": "Today"
"continue": "Continue",
"today": "Today",
"readme": "Read me",
"githubIssues": "GitHub issues and questions",
"cashuRandD": "Cashu Telegram",
"enutsRandD": "eNuts Telegram"
},
"wallet": {
"disclaimer": "Please note that this is an alpha version in its early stage and is still undergoing testing before its official release. The software and all content found on it are provided on an “as is” and “as available” basis. We do not give any warranties, whether express or implied, as to the suitability or usability of the software or any of its content.",
Expand All @@ -119,7 +124,8 @@
"settings": "Settings",
"language": "Language",
"security": "Security",
"backup": "Backup"
"backup": "Backup",
"about": "About us"
},
"bottomNav": {
"contacts": "Contacts"
Expand Down Expand Up @@ -214,5 +220,6 @@
"getStarted": "Get started",
"startHint": "You should add a mint that you trust before sending or receiving token.",
"addMintNow": "Add a mint now",
"willDoLater": "Will do later"
"willDoLater": "Will do later",
"aboutToLeaveTo": "You are about to leave"
}
13 changes: 10 additions & 3 deletions assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
"backToDashboard": "Retour au tableau de bord",
"default": "Par défaut",
"accept": "Accepter",
"today": "Aujourd'hui"
"continue": "Continuer",
"today": "Aujourd'hui",
"readme": "Lisez-moi",
"githubIssues": "GitHub problèmes et questions",
"cashuRandD": "Cashu Telegram",
"enutsRandD": "eNuts Telegram"
},
"wallet": {
"disclaimer": "Veuillez noter qu'il s'agit d'une version alpha à un stade précoce et qu'elle est encore en cours de test avant sa sortie officielle. Le logiciel et tous les contenus qui s'y trouvent sont fournis « tels quels » et « tels que disponibles ». Nous n'offrons aucune garantie, expresse ou implicite, quant à l'adéquation ou à l'utilisabilité du logiciel ou de l'un de ses contenus.",
Expand All @@ -119,7 +124,8 @@
"settings": "Paramètres",
"language": "Langue",
"security": "Sécurité",
"backup": "Sauvegarde"
"backup": "Sauvegarde",
"about": "À propos de nous"
},
"bottomNav": {
"contacts": "Contacts"
Expand Down Expand Up @@ -214,5 +220,6 @@
"getStarted": "Commencer",
"startHint": "Vous devriez ajouter une mint à laquelle vous faites confiance avant d'envoyer ou de recevoir des token.",
"addMintNow": "Ajoutez une mint",
"willDoLater": "Je ferai plus tard"
"willDoLater": "Je ferai plus tard",
"aboutToLeaveTo": "Vous êtes sur le point de quitter"
}
7 changes: 7 additions & 0 deletions src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,11 @@ export function LanguageIcon({ width, height, color }: TIconProps) {
<Path fillRule="evenodd" clipRule="evenodd" d="M12 2.5C6.7533 2.5 2.5 6.7533 2.5 12C2.5 17.2461 6.75237 21.4991 11.9983 21.5H12.0017C17.2476 21.4991 21.5 17.2461 21.5 12C21.5 6.7533 17.2467 2.5 12 2.5ZM3.775 9.84717C3.59553 10.5347 3.5 11.2562 3.5 12C3.5 12.7438 3.59553 13.4653 3.775 14.1528V14H7.65292C7.55505 13.3561 7.5 12.6869 7.5 12C7.5 11.3131 7.55505 10.6439 7.65292 10H3.775V9.84717ZM4.04455 9H7.84245C8.1542 7.62781 8.64679 6.40035 9.18454 5.3994C9.55305 4.71349 9.94735 4.12531 10.3272 3.66455C7.43138 4.24248 5.06634 6.29177 4.04455 9ZM8.66535 10C8.5599 10.6425 8.5 11.3122 8.5 12C8.5 12.6878 8.5599 13.3575 8.66535 14H15.3347C15.4401 13.3575 15.5 12.6878 15.5 12C15.5 11.3122 15.4401 10.6425 15.3347 10H8.66535ZM15.1301 9H8.86995C9.16061 7.81473 9.59403 6.75016 10.0655 5.87267C10.4873 5.08752 10.9326 4.4652 11.3199 4.04705C11.5143 3.83725 11.6845 3.68915 11.8206 3.59736C11.9245 3.52729 11.9825 3.50758 12 3.50208C12.0175 3.50758 12.0755 3.52729 12.1794 3.59736C12.3155 3.68915 12.4857 3.83725 12.6801 4.04705C13.0674 4.4652 13.5127 5.08752 13.9345 5.87267C14.406 6.75016 14.8394 7.81473 15.1301 9ZM16.3471 10C16.445 10.6439 16.5 11.3131 16.5 12C16.5 12.6869 16.445 13.3561 16.3471 14H20.225V14.1528C20.4045 13.4653 20.5 12.7438 20.5 12C20.5 11.2562 20.4045 10.5347 20.225 9.84717V10H16.3471ZM19.9554 9H16.1575C15.8458 7.62781 15.3532 6.40035 14.8155 5.3994C14.447 4.71349 14.0526 4.12531 13.6728 3.66455C16.5686 4.24248 18.9337 6.29177 19.9554 9ZM10.3272 20.3355C7.43138 19.7575 5.06634 17.7082 4.04455 15H7.84245C8.1542 16.3722 8.64679 17.5997 9.18454 18.6006C9.55305 19.2865 9.94735 19.8747 10.3272 20.3355ZM10.0655 18.1273C9.59403 17.2498 9.16061 16.1853 8.86995 15H15.1301C14.8394 16.1853 14.406 17.2498 13.9345 18.1273C13.5127 18.9125 13.0674 19.5348 12.6801 19.953C12.4857 20.1627 12.3155 20.3108 12.1794 20.4026C12.0755 20.4727 12.0175 20.4924 12 20.4979C11.9825 20.4924 11.9245 20.4727 11.8206 20.4026C11.6845 20.3108 11.5143 20.1627 11.3199 19.953C10.9326 19.5348 10.4873 18.9125 10.0655 18.1273ZM14.8155 18.6006C15.3532 17.5997 15.8458 16.3722 16.1575 15H19.9554C18.9337 17.7082 16.5686 19.7575 13.6728 20.3355C14.0526 19.8747 14.447 19.2865 14.8155 18.6006Z" fill={color} />
</Svg>
)
}
export function AboutIcon({ width, height, color }: TIconProps) {
return (
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
<Path d="M13 16H14.5C14.7761 16 15 16.2239 15 16.5C15 16.7761 14.7761 17 14.5 17H10.5C10.2239 17 10 16.7761 10 16.5C10 16.2239 10.2239 16 10.5 16H12V11H10.5C10.2239 11 10 10.7761 10 10.5C10 10.2239 10.2239 10 10.5 10H12.5C12.7761 10 13 10.2239 13 10.5V16ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21ZM11.5 7H12.5C12.7761 7 13 7.22386 13 7.5V8.5C13 8.77614 12.7761 9 12.5 9H11.5C11.2239 9 11 8.77614 11 8.5V7.5C11 7.22386 11.2239 7 11.5 7Z" fill={color} />
</Svg>
)
}
2 changes: 2 additions & 0 deletions src/components/nav/Navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AboutSettings from '@comps/screens/Settings/About'
import type { RootStackParamList } from '@model/nav'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import AddressbookPage from '@screens/Addressbook'
Expand Down Expand Up @@ -88,6 +89,7 @@ export default function Navigator() {
<Stack.Screen name='Display settings' component={DisplaySettings} />
<Stack.Screen name='Security settings' component={SecuritySettings} />
<Stack.Screen name='Language settings' component={LanguageSettings} />
<Stack.Screen name='About settings' component={AboutSettings} />
<Stack.Screen name='BackupPage' component={BackupPage} />
</Stack.Navigator>
</View>
Expand Down
125 changes: 125 additions & 0 deletions src/components/screens/Settings/About.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import Button from '@comps/Button'
import usePrompt from '@comps/hooks/Prompt'
import { ChevronRightIcon } from '@comps/Icons'
import MyModal from '@comps/modal'
import Separator from '@comps/Separator'
import Toaster from '@comps/Toaster'
import Txt from '@comps/Txt'
import TopNav from '@nav/TopNav'
import { ThemeContext } from '@src/context/Theme'
import { globals } from '@styles'
import { isErr, openUrl } from '@util'
import { useContext, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'

import { version } from '../../../../package.json'

export default function AboutSettings() {
const { t } = useTranslation()
const { color, highlight } = useContext(ThemeContext)
const { prompt, openPromptAutoClose } = usePrompt()
const [visible, setVisible] = useState(false)
const [url, setUrl] = useState('')
const handlePress = (url: string) => {
setVisible(true)
setUrl(url)
}
const handleContinue = async () => {
setVisible(false)
await openUrl(url)?.catch(e => openPromptAutoClose({ msg: isErr(e) ? e.message : t('common.deepLinkErr') }))
}
return (
<View style={[styles.container, { backgroundColor: color.BACKGROUND }]}>
<TopNav screenName={t('topNav.about')} withBackBtn />
<View style={[globals(color).wrapContainer, styles.wrap]}>
<AboutRow
txt={t('common.readme')}
handlePress={() => handlePress('https://github.com/cashubtc/eNuts#readme')}
hasSeparator
/>
<AboutRow
txt={t('common.githubIssues')}
handlePress={() => handlePress('https://github.com/cashubtc/eNuts/issues')}
hasSeparator
/>
<AboutRow
txt={t('common.cashuRandD')}
handlePress={() => handlePress('https://t.me/CashuBTC')}
hasSeparator
/>
<AboutRow
txt={t('common.enutsRandD')}
handlePress={() => handlePress('https://t.me/eNutsWallet')}
/>
</View>
<Txt txt={`eNuts v${version}`} styles={[styles.version]} />
<MyModal type='bottom' animation='slide' visible={visible} close={() => setVisible(false)}>
<Text style={globals(color, highlight).modalHeader}>
{t('aboutToLeaveTo')}
</Text>
<Text style={globals(color, highlight).modalTxt}>
&quot;{url}&quot;
</Text>
<Button txt={t('common.continue')} onPress={() => void handleContinue()} />
<TouchableOpacity onPress={() => setVisible(false)}>
<Text style={[globals(color, highlight).pressTxt, styles.cancel]}>
{t('common.cancel')}
</Text>
</TouchableOpacity>
</MyModal>
{prompt.open && <Toaster success={prompt.success} txt={prompt.msg} />}
</View>
)
}

interface IAboutRowProps {
txt: string
handlePress: () => void
hasSeparator?: boolean
}

function AboutRow({ txt, handlePress, hasSeparator }: IAboutRowProps) {
const { color } = useContext(ThemeContext)
return (
<>
<TouchableOpacity
style={styles.aboutRow}
onPress={handlePress}
>
<Text style={[styles.aboutTxt, { color: color.TEXT }]}>
{txt}
</Text>
<ChevronRightIcon color={color.TEXT} />
</TouchableOpacity>
{hasSeparator && <Separator style={[{ marginVertical: 10 }]} />}
</>
)
}

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 110,
},
wrap: {
paddingVertical: 10,
marginBottom: 20,
},
aboutRow: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingVertical: 10,
},
aboutTxt: {
fontSize: 16,
},
version: {
fontWeight: '500',
textAlign: 'center',
},
cancel: {
marginTop: 25,
},
})
20 changes: 16 additions & 4 deletions src/components/screens/Settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import usePrompt from '@comps/hooks/Prompt'
import { ChevronRightIcon, LanguageIcon, LockIcon, PaletteIcon, TrashbinIcon2 } from '@comps/Icons'
import { AboutIcon, ChevronRightIcon, LanguageIcon, LockIcon, PaletteIcon, TrashbinIcon2 } from '@comps/Icons'
import Separator from '@comps/Separator'
import Toaster from '@comps/Toaster'
import Txt from '@comps/Txt'
Expand Down Expand Up @@ -39,20 +39,31 @@ export default function Settings({ navigation, route }: TSettingsPageProps) {
icon={<LockIcon color={color.TEXT} />}
onPress={() => navigation.navigate('Security settings')}
hasSeparator
hasChevron
/>
<SettingsMenuItem
txt={t('topNav.display')}
txtColor={color.TEXT}
icon={<PaletteIcon color={color.TEXT} />}
onPress={() => navigation.navigate('Display settings')}
hasSeparator
hasChevron
/>
<SettingsMenuItem
txt={t('topNav.language')}
txtColor={color.TEXT}
icon={<LanguageIcon color={color.TEXT} />}
onPress={() => navigation.navigate('Language settings')}
hasSeparator
hasChevron
/>
<SettingsMenuItem
txt={t('topNav.about')}
txtColor={color.TEXT}
icon={<AboutIcon color={color.TEXT} />}
onPress={() => navigation.navigate('About settings')}
hasSeparator
hasChevron
/>
<SettingsMenuItem
txt={t('delHistory')}
Expand All @@ -61,7 +72,7 @@ export default function Settings({ navigation, route }: TSettingsPageProps) {
onPress={() => setConfirm(true)}
/>
</View>
<Txt txt={`v${version}`} styles={[styles.version]} />
<Txt txt={`eNuts v${version}`} styles={[styles.version]} />
<BottomNav navigation={navigation} route={route} />
<QuestionModal
header={t('common.delHistoryQ')}
Expand All @@ -83,9 +94,10 @@ interface IMenuItemProps {
onPress: () => void
icon: React.ReactElement
hasSeparator?: boolean
hasChevron?: boolean
}

function SettingsMenuItem({ txt, txtColor, icon, onPress, hasSeparator }: IMenuItemProps) {
function SettingsMenuItem({ txt, txtColor, icon, onPress, hasSeparator, hasChevron }: IMenuItemProps) {
return (
<>
<TouchableOpacity
Expand All @@ -98,7 +110,7 @@ function SettingsMenuItem({ txt, txtColor, icon, onPress, hasSeparator }: IMenuI
{txt}
</Text>
</View>
{!txt.includes('Delete') &&
{hasChevron &&
<ChevronRightIcon color={txtColor} />
}
</TouchableOpacity>
Expand Down
2 changes: 2 additions & 0 deletions src/model/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type RootStackParamList = {
'Display settings': undefined
'Security settings': undefined
'Language settings': undefined
'About settings': undefined
BackupPage: {
token: string
}
Expand Down Expand Up @@ -92,6 +93,7 @@ export type TSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Set
export type TDisplaySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Display settings'>
export type TSecuritySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Security settings'>
export type TLanguageSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Language settings'>
export type TAboutSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'About settings'>
export type TBackupPageProps = NativeStackScreenProps<RootStackParamList, 'BackupPage'>
export type TAddressBookPageProps = NativeStackScreenProps<RootStackParamList, 'Address book'>
export type IContactPageProps = NativeStackScreenProps<RootStackParamList, 'Contact'>
Expand Down

0 comments on commit 5283c1a

Please sign in to comment.