Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split zaps #555

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/Components/TextContent/LinksPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const LinksPreview: React.FC<TextContentProps> = ({ urls, lnUrl }) => {
<View>
{decodedLnUrl && lnUrlPreview}
{Object.keys(urls).length > 0 && <View style={styles.previewCard}>{preview()}</View>}
{invoice && <LnPreview invoice={invoice} setInvoice={setInvoice} />}
{invoice && <LnPreview invoices={[invoice]} setInvoices={(arr) => setInvoice(arr[0])} />}
</View>
)
}
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@
"split": "Splits between {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "Kontakt hinzufügen",
"remove": "Entfernen",
"split": "Splits between {{count}}"
},
"notificationsFeed": {
"connectContactRelays": "Reconnect to contacts' relays",
"reposted": "Reposted",
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@
"split": "Splits between {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "Add contact",
"remove": "Remove",
"split": "Splits between {{count}}"
},
"notificationsFeed": {
"reposted": "Reposted",
"zap": "Zapped {{amount}}",
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@
"split": "Se reparte entre {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "Añadir contacto",
"remove": "Borrar",
"split": "Repartir entre {{count}}"
},
"notificationsFeed": {
"reposted": "Reposteado",
"zap": "Zap {{amount}}",
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@
"split": "Splits between {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "Ajouter un contact",
"remove": "Supprimer",
"split": "Splits between {{count}}"
},
"notificationsFeed": {
"reposted": "Reposted",
"zap": "Zapped {{amount}}",
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@
"split": "Splits between {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "Добавить контакт",
"remove": "Удалить",
"split": "Splits between {{count}}"
},
"notificationsFeed": {
"reposted": "Reposted",
"zap": "Zapped {{amount}}",
Expand Down
10 changes: 10 additions & 0 deletions frontend/Locales/zhCn.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@
"split": "Splits between {{count}}",
"zappers": "Zappers"
},
"splitZaps": {
"accept": "Split zaps",
"addPubKey": "Add public key",
"zapPubkeyTitle": "Add public key",
"zapPubkeyDescription": "Add any public key to be included into the split",
"zapPubkeyLabel": "Public key",
"addContact": "添加联系人",
"remove": "移除",
"split": "Splits between {{count}}"
},
"notificationsFeed": {
"reposted": "已转发",
"zap": "已赞赏{{amount}}",
Expand Down
2 changes: 1 addition & 1 deletion frontend/Pages/ProfileActionsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export const ProfileActionsPage: React.FC<ProfileActionsProps> = ({ route: { par
</Button>
</View>
</RBSheet>
{zapInvoice && <LnPreview invoice={zapInvoice} setInvoice={setZapInvoice} />}
{zapInvoice && <LnPreview invoices={[zapInvoice]} setInvoices={(arr) => setZapInvoice(arr[0])} />}
{showNotification && (
<Snackbar
style={styles.snackbar}
Expand Down
76 changes: 62 additions & 14 deletions frontend/Pages/SplitZapPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type ListRenderItem,
StyleSheet,
View,
Keyboard,
} from 'react-native'
import {
AnimatedFAB,
Expand All @@ -26,6 +27,7 @@ import { AppContext } from '../../Contexts/AppContext'
import { UserContext } from '../../Contexts/UserContext'
import ProfileData from '../../Components/ProfileData'
import { getNip19Key, getNpub } from '../../lib/nostr/Nip19'
import { useFocusEffect } from '@react-navigation/native'

interface SplitZapPageProps {
route: { params: { splits?: string[] } }
Expand All @@ -52,9 +54,16 @@ export const SplitZapPage: React.FC<SplitZapPageProps> = ({
loadUsers()
}, [])

useFocusEffect(
React.useCallback(() => {
loadUsers()
return () => { }
}, []),
)

const loadUsers: () => void = () => {
if (database && publicKey) {
getUsers(database, {}).then(setUsers)
getUsers(database, { order: 'id ASC' }).then(setUsers)
}
}

Expand Down Expand Up @@ -184,10 +193,27 @@ export const SplitZapPage: React.FC<SplitZapPageProps> = ({

return (
<View style={styles.main}>
<View>{numberSplits > 0 && <FlatList data={splitZaps} renderItem={renderZappedItem} />}</View>
<View>
<View style={styles.tabsNavigator}>
<View
style={[
styles.tab,
{ ...styles.tabActive, borderBottomColor: theme.colors.primary }
]}
>
<TouchableRipple style={styles.textWrapper}>
<Text style={styles.tabText}>
{t('splitZaps.split', { count: splitZaps.length })}
</Text>
</TouchableRipple>
</View>
</View>
<View>{numberSplits > 0 && <FlatList data={splitZaps} renderItem={renderZappedItem} />}</View>
</View>
<View>
<Button
mode='contained'
disabled={splitZaps.length < 1}
style={styles.spacer}
onPress={() => navigate('Send', { splits: splitZaps })}
>
Expand Down Expand Up @@ -247,17 +273,17 @@ export const SplitZapPage: React.FC<SplitZapPageProps> = ({
forceTextInputFocus={false}
/>
}
// left={
// <TextInput.Icon
// icon='qrcode'
// onPress={() => {
// bottomSheetCreateRef.current?.close()
// bottomSheetPubKeyRef.current?.close()
// navigate('QrReader')
// }}
// forceTextInputFocus={false}
// />
// }
// left={
// <TextInput.Icon
// icon='qrcode'
// onPress={() => {
// bottomSheetCreateRef.current?.close()
// bottomSheetPubKeyRef.current?.close()
// navigate('QrReader')
// }}
// forceTextInputFocus={false}
// />
// }
/>
<Button
mode='contained'
Expand All @@ -275,7 +301,7 @@ export const SplitZapPage: React.FC<SplitZapPageProps> = ({
bottomSheetCreateRef.current?.close()
}}
>
{t('splitZaps.openMessage')}
{t('splitZaps.addPubKey')}
</Button>
</View>
</RBSheet>
Expand All @@ -289,6 +315,28 @@ const styles = StyleSheet.create({
padding: 16,
justifyContent: 'space-between',
},
tabsNavigator: {
flexDirection: 'row',
alignItems: 'center',
height: 48,
},
tab: {
flex: 1,
height: '100%',
justifyContent: 'center',
alignContent: 'center',
},
tabText: {
textAlign: 'center',
},
tabActive: {
borderBottomWidth: 3,
},
textWrapper: {
justifyContent: 'center',
height: '100%',
textAlign: 'center',
},
spacer: {
marginBottom: 16,
},
Expand Down
100 changes: 51 additions & 49 deletions frontend/Pages/ZapPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,64 +243,66 @@ export const ZapPage: React.FC<ZapPageProps> = ({ route: { params: { note, user
</View>
</View>
<View>
<View style={[styles.montoSelection, styles.spacer]}>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('1000')}>
<Text>1k {getSatoshiSymbol(15)}</Text>
</Button>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('5000')}>
<Text>5k {getSatoshiSymbol(15)}</Text>
</Button>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('10000')}>
<Text>10k {getSatoshiSymbol(15)}</Text>
</Button>
<View>
<View style={[styles.montoSelection, styles.spacer]}>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('1000')}>
<Text>1k {getSatoshiSymbol(15)}</Text>
</Button>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('5000')}>
<Text>5k {getSatoshiSymbol(15)}</Text>
</Button>
<Button style={styles.montoButton} mode='outlined' onPress={() => setMonto('10000')}>
<Text>10k {getSatoshiSymbol(15)}</Text>
</Button>
</View>
<TextInput
style={styles.spacer}
mode='outlined'
label={t('lnPayment.monto') ?? ''}
onChangeText={setMonto}
value={monto}
keyboardType='decimal-pad'
/>
<TextInput
style={styles.spacer}
mode='outlined'
label={t('lnPayment.comment') ?? ''}
onChangeText={setComment}
value={comment}
/>
</View>
<TextInput
style={styles.spacer}
mode='outlined'
label={t('lnPayment.monto') ?? ''}
onChangeText={setMonto}
value={monto}
keyboardType='decimal-pad'
/>
<TextInput
style={styles.spacer}
mode='outlined'
label={t('lnPayment.comment') ?? ''}
onChangeText={setComment}
value={comment}
/>
</View>
<View>
<Button
style={styles.spacer}
mode='contained'
disabled={loading || monto === ''}
onPress={() => generateInvoice(false)}
loading={loading && !isZap}
>
{t('lnPayment.anonTip')}
</Button>
{zapPubkey && (
<View>
<Button
style={styles.spacer}
mode='contained'
disabled={loading || monto === ''}
onPress={() => generateInvoice(true)}
loading={loading && isZap}
onPress={() => generateInvoice(false)}
loading={loading && !isZap}
>
{t('lnPayment.zap')}
{t('lnPayment.anonTip')}
</Button>
{zapPubkey && (
<Button
style={styles.spacer}
mode='contained'
disabled={loading || monto === ''}
onPress={() => generateInvoice(true)}
loading={loading && isZap}
>
{t('lnPayment.zap')}
</Button>
)}
<Button mode='outlined' onPress={() => goBack()}>
{t('lnPayment.cancel')}
</Button>
</View>
{invoices.length > 0 && (
<LnPreview
invoices={invoices}
setInvoices={setInvoices}
/>
)}
<Button mode='outlined' onPress={() => goBack()}>
{t('lnPayment.cancel')}
</Button>
</View>
{invoices.length > 0 && (
<LnPreview
invoices={invoices}
setInvoices={setInvoices}
/>
)}
</View>
)
}
Expand Down
Loading