Skip to content
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
39 changes: 32 additions & 7 deletions frontend/mobile/app/(tabs)/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Pressable, SafeAreaView, StyleSheet, Text, TextInput, View } from 'reac

import { isValidDestination } from '../../lib/address';
import { ContactPicker } from '../../components/ContactPicker';
import { QrScanner } from '../../components/QrScanner';
import type { Contact } from '../../hooks/useContacts';

/** expo-router yields `string | string[]` for a repeated query key. */
Expand All @@ -28,6 +29,7 @@ export default function SendScreen() {
const [recipient, setRecipient] = useState(() => firstValue(params.to));
const [amount, setAmount] = useState(() => firstValue(params.amount));
const [pickerOpen, setPickerOpen] = useState(false);
const [scannerOpen, setScannerOpen] = useState(false);

const trimmed = recipient.trim();
const recipientValid = isValidDestination(trimmed);
Expand All @@ -47,13 +49,23 @@ export default function SendScreen() {
<View style={styles.field}>
<View style={styles.labelRow}>
<Text style={styles.label}>RECIPIENT</Text>
<Pressable
accessibilityRole="button"
onPress={() => setPickerOpen(true)}
hitSlop={8}
>
<Text style={styles.contactLink}>Choose contact</Text>
</Pressable>
<View style={styles.labelActions}>
<Pressable
accessibilityRole="button"
accessibilityLabel="Scan a QR code"
onPress={() => setScannerOpen(true)}
hitSlop={8}
>
<Text style={styles.contactLink}>Scan QR</Text>
</Pressable>
<Pressable
accessibilityRole="button"
onPress={() => setPickerOpen(true)}
hitSlop={8}
>
<Text style={styles.contactLink}>Choose contact</Text>
</Pressable>
</View>
</View>
<TextInput
style={[styles.input, showError && styles.inputError]}
Expand Down Expand Up @@ -104,6 +116,15 @@ export default function SendScreen() {
</Pressable>
</View>

<QrScanner
visible={scannerOpen}
onScan={(address) => {
setRecipient(address);
setScannerOpen(false);
}}
onClose={() => setScannerOpen(false)}
/>

<ContactPicker
visible={pickerOpen}
onSelect={handleSelectContact}
Expand Down Expand Up @@ -132,6 +153,10 @@ const styles = StyleSheet.create({
field: {
gap: 8,
},
labelActions: {
flexDirection: 'row',
gap: 16,
},
labelRow: {
flexDirection: 'row',
justifyContent: 'space-between',
Expand Down
Loading
Loading