diff --git a/docs/design/wizard-design-guide.md b/docs/design/wizard-design-guide.md
index 9e6b7f0..36acb3c 100644
--- a/docs/design/wizard-design-guide.md
+++ b/docs/design/wizard-design-guide.md
@@ -142,6 +142,15 @@ Screens name the role, never the theme's colour (`c.text`, not `color.star`).
- Sizes: balance 56, amount entry 64, title 28, body 16, label 13, mono 13. Body never under 15.
- Sentence case everywhere. No all-caps labels except the Testnet badge.
- Addresses are shown in groups of 4 characters. Truncated form: first 10, an ellipsis, last 6.
+- **Every address goes through `Address`** (`src/components/address.tsx`), so it looks the same everywhere. Two forms:
+
+ | Form | Looks like | Where |
+ |---|---|---|
+ | **Short** | `utest1abcd…456789`, mono 15 in Text, one line | In a name's place: a list row, the amount screen's chip, a title. Inside a sentence ("You paid …", "Add … as a contact") it is `AddressInline`: mono 15 in Muted, so the words scan first |
+ | **Short, under a name** (`detail`) | Mono 13 in Muted | The line under a contact's or person's name, when there is no `.zcash` name to show instead |
+ | **Full** | Every character in groups of 4, mono 13, in lines of as many groups as fit (8, 6, 4 or 2, always even) so the groups stand in columns: odd columns in Text, even ones in Muted. Lines share one left edge, even when the block is centred | Where someone checks or copies it: Receive, the exchange address, a contact page, Technical details, Add a contact. With `copy`, tapping anywhere on it copies the whole address and its label says "Copied" |
+
+ No part of an address is dimmed or highlighted. Someone can make an address that starts and ends like yours (address poisoning), so the full form asks for every group to be read, not just the ends. The columns help with that: a full address runs to about 36 groups over five to seven lines, and a column's colour keeps your place, across and down, while comparing it with another screen. Every column weighs the same, and the spaces stay, so colour is never the only thing that separates the groups. Larger text gets fewer columns, never a wrapped line, so the columns hold at every text size. Muted passes AA on every ground (6.6–8.3:1). The short form stays one colour. Screen readers hear a short address as "address ending" and its last 6 characters one by one, the same ones the short form ends with; the full form is read group by group. The native confirmation and contact sheets draw the full form the same way (`AddressText` in `Kit.swift`, `Kit.address` in `Kit.kt`; mono, selectable).
## 6. Shape, space and motion
diff --git a/mobile/app/(tabs)/receive.tsx b/mobile/app/(tabs)/receive.tsx
index e0a2e84..6d273c7 100644
--- a/mobile/app/(tabs)/receive.tsx
+++ b/mobile/app/(tabs)/receive.tsx
@@ -1,12 +1,12 @@
-import { grouped, useWallet } from '@wizard/wallet-native';
+import { useWallet } from '@wizard/wallet-native';
import { router, useFocusEffect } from 'expo-router';
import { useCallback, useRef } from 'react';
import { Pressable, ScrollView, Share, StyleSheet, View } from 'react-native';
import { Art } from '../../src/art';
import {
+ Address,
Button,
CodeTile,
- CopyText,
Notice,
Screen,
ScreenHeader,
@@ -48,12 +48,7 @@ export default function Receive() {
caption={`Send only ${testnet ? 'test ' : ''}ZEC to this address.`}
/>
{address && (
-
+
)}
{error ? (
<>
diff --git a/mobile/app/contacts/[address].tsx b/mobile/app/contacts/[address].tsx
index 4b82783..b67062b 100644
--- a/mobile/app/contacts/[address].tsx
+++ b/mobile/app/contacts/[address].tsx
@@ -1,18 +1,10 @@
-import { contactFor, contactRecipient, grouped, useNames, useWallet } from '@wizard/wallet-native';
+import { contactFor, contactRecipient, useNames, useWallet } from '@wizard/wallet-native';
import { router, useLocalSearchParams } from 'expo-router';
import { Fragment, useMemo } from 'react';
import { Pressable, ScrollView, StyleSheet, View } from 'react-native';
import { sentTo } from '../../src/activity';
import { ActivityRow, RowSeparator, useFresh } from '../../src/activity-row';
-import {
- Avatar,
- Button,
- CopyText,
- HeaderLink,
- Screen,
- ScreenHeader,
- T,
-} from '../../src/components';
+import { Address, Avatar, Button, HeaderLink, Screen, ScreenHeader, T } from '../../src/components';
import { goToAmount, goToEditContact } from '../../src/navigation';
import { DriftChoice, usePayContact } from '../../src/pay-contact';
import { RequestRow } from '../../src/request-row';
@@ -96,12 +88,7 @@ export default function ContactPage() {
/>
)}
-
+
{(() => {
// What you're waiting on from them (issue #15, mock R6), newest first.
diff --git a/mobile/app/contacts/add.tsx b/mobile/app/contacts/add.tsx
index 4597b30..fffe55d 100644
--- a/mobile/app/contacts/add.tsx
+++ b/mobile/app/contacts/add.tsx
@@ -2,11 +2,10 @@ import {
CONTACT_NAME_MAX,
contactFor,
errorText,
- grouped,
normaliseName,
type Recipient,
resolveRecipient,
- shortAddress,
+ spokenAddress,
suggestedName,
useWallet,
when,
@@ -15,7 +14,16 @@ import { router, useLocalSearchParams } from 'expo-router';
import { useEffect, useMemo, useRef, useState } from 'react';
import { Pressable, ScrollView, StyleSheet, View } from 'react-native';
import { NOTHING_TO_PASTE, pasteText } from '../../src/clipboard';
-import { Avatar, Button, Notice, Screen, ScreenHeader, T, TextField } from '../../src/components';
+import {
+ Address,
+ Avatar,
+ Button,
+ Notice,
+ Screen,
+ ScreenHeader,
+ T,
+ TextField,
+} from '../../src/components';
import { scanFor } from '../../src/navigation';
import { themed } from '../../src/use-theme';
@@ -121,9 +129,7 @@ export default function AddContact() {
{found.zcashName ? {found.zcashName} : null}
-
- {grouped(found.address)}
-
+
Their name{full(r.name)}
) : (
-
- {shortAddress(r.address)}
-
+
)}
{`Paid ${paidWhen(r.at)}`}
@@ -195,7 +199,7 @@ export default function AddContact() {
{
setError(null);
@@ -227,7 +231,6 @@ const useStyles = themed((c) =>
StyleSheet.create({
body: { gap: 12, paddingBottom: 40 },
who: { alignItems: 'center', gap: 8, marginVertical: 12 },
- address: { textAlign: 'center' },
buttons: { flexDirection: 'row', gap: 10 },
people: { marginTop: 16, gap: 4 },
person: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 10 },
diff --git a/mobile/app/contacts/edit.tsx b/mobile/app/contacts/edit.tsx
index a86f375..5505e23 100644
--- a/mobile/app/contacts/edit.tsx
+++ b/mobile/app/contacts/edit.tsx
@@ -1,14 +1,9 @@
-import {
- CONTACT_NAME_MAX,
- contactFor,
- errorText,
- shortAddress,
- useWallet,
-} from '@wizard/wallet-native';
+import { CONTACT_NAME_MAX, contactFor, errorText, useWallet } from '@wizard/wallet-native';
import { router, useLocalSearchParams } from 'expo-router';
import { useState } from 'react';
import { Alert, Pressable, ScrollView, StyleSheet, View } from 'react-native';
import {
+ Address,
Avatar,
Button,
HeaderLink,
@@ -173,7 +168,7 @@ export default function EditContact() {
) : null}
Address
- {shortAddress(c.address)}
+
To pay a different address, delete this contact and add it again.
diff --git a/mobile/app/contacts/index.tsx b/mobile/app/contacts/index.tsx
index 53e2bdb..c93e0d8 100644
--- a/mobile/app/contacts/index.tsx
+++ b/mobile/app/contacts/index.tsx
@@ -2,7 +2,6 @@ import {
errorText,
resolveRecipient,
searchContacts,
- shortAddress,
sortContacts,
useWallet,
} from '@wizard/wallet-native';
@@ -11,6 +10,8 @@ import { useState } from 'react';
import { ActivityIndicator, FlatList, Pressable, StyleSheet, View } from 'react-native';
import { Art } from '../../src/art';
import {
+ Address,
+ AddressInline,
Avatar,
Button,
Notice,
@@ -110,7 +111,7 @@ export default function Contacts() {
- {`Add ${short(offer)} as a contact`}
+ Add as a contact
- {`Pay ${short(offer)}`}
+
+ Pay
+
{paying ? : null}
@@ -146,9 +149,13 @@ export default function Contacts() {
{c.name}
-
- {c.zcashName ?? shortAddress(c.address)}
-
+ {c.zcashName ? (
+
+ {c.zcashName}
+
+ ) : (
+
+ )}
)}
@@ -170,10 +177,10 @@ function noMatch(q: string) {
return `None of your contacts is called “${t}”.`;
}
-/** A name as typed; an address or link shortened so the line fits. */
-function short(input: string) {
+/** A name as typed; an address or link's address short, in mono, so the line fits. */
+function Offered({ input }: { input: string }) {
if (input.endsWith('.zcash')) return input;
- return shortAddress(input.replace(/^zcash:/i, '').split('?')[0]);
+ return ;
}
const useStyles = themed((c) =>
diff --git a/mobile/app/exchange-address.tsx b/mobile/app/exchange-address.tsx
index 6fe6a15..56df6c1 100644
--- a/mobile/app/exchange-address.tsx
+++ b/mobile/app/exchange-address.tsx
@@ -1,10 +1,10 @@
-import { grouped, useWallet } from '@wizard/wallet-native';
+import { useWallet } from '@wizard/wallet-native';
import { router } from 'expo-router';
import { ScrollView, Share, StyleSheet, View } from 'react-native';
import {
+ Address,
Button,
CodeTile,
- CopyText,
Notice,
Screen,
ScreenHeader,
@@ -41,9 +41,10 @@ export default function ExchangeAddress() {
caption={`Send only ${testnet ? 'test ' : ''}ZEC to this address.`}
/>
{address ? (
-
diff --git a/mobile/app/pay/amount.tsx b/mobile/app/pay/amount.tsx
index f5bfaaf..dd83354 100644
--- a/mobile/app/pay/amount.tsx
+++ b/mobile/app/pay/amount.tsx
@@ -9,7 +9,6 @@ import {
recipientKind,
replyId,
sendPayment,
- shortAddress,
stripReply,
usd,
usdText,
@@ -23,6 +22,7 @@ import { useEffect, useMemo, useReducer, useState } from 'react';
import { Animated, Keyboard, Pressable, StyleSheet, Text, View } from 'react-native';
import { Art } from '../../src/art';
import {
+ Address,
Avatar,
Button,
NetworkBadge,
@@ -185,7 +185,7 @@ export default function Amount() {
pathname: '/sent',
params: {
zatoshis: String(zats),
- name: shown ?? shortAddress(to.address),
+ name: shown ?? '',
address: to.address,
zcashName: to.name ? normaliseName(to.name) : '',
pending: r.status === 'pending' ? '1' : '',
@@ -206,9 +206,13 @@ export default function Amount() {
{to ? (
-
- {shown ?? shortAddress(to.address)}
-
+ {shown ? (
+
+ {shown}
+
+ ) : (
+
+ )}
) : (
Request from anyone
diff --git a/mobile/app/sent.tsx b/mobile/app/sent.tsx
index 9255cda..a0b0912 100644
--- a/mobile/app/sent.tsx
+++ b/mobile/app/sent.tsx
@@ -3,7 +3,7 @@ import { router, useLocalSearchParams } from 'expo-router';
import { useEffect } from 'react';
import { Animated, StyleSheet, useWindowDimensions, View } from 'react-native';
import { Art, TracedArt } from '../src/art';
-import { Button, NetworkBadge, Screen, T } from '../src/components';
+import { AddressInline, Button, NetworkBadge, Screen, T } from '../src/components';
import { isSentPreview } from '../src/flow-preview';
import { haptic } from '../src/haptics';
import { useBoth } from '../src/money';
@@ -40,6 +40,8 @@ export default function Sent() {
}, [pending, preview]);
const { contacts } = useWallet();
const both = useBoth();
+ // Who it went to: their name, or their address short in mono (design guide §5).
+ const who = p.name ? p.name : p.address ? : null;
const canSave = !!p.address && !contactFor(contacts, p.address);
const { width, height } = useWindowDimensions();
// The scene shrinks on short screens so Done never leaves the screen.
@@ -72,10 +74,10 @@ export default function Sent() {
{pending ? 'Not sent yet.' : request ? 'Request sent.' : 'Sent.'}
- {request && p.name ? To {p.name} : null}
+ {request && who ? To {who} : null}
{p.zatoshis ? (
- {both(Number(p.zatoshis))} to {p.name}
+ {both(Number(p.zatoshis))} to {who}
) : null}
{pending && request ? (
@@ -92,7 +94,7 @@ export default function Sent() {
) : request ? (
- {`${p.name || 'They'} will see it once it’s confirmed, in about a minute.`}
+ {who ?? 'They'} will see it once it’s confirmed, in about a minute.
) : (
Confirming, about 1 min
diff --git a/mobile/app/tx/[txid].tsx b/mobile/app/tx/[txid].tsx
index 3d95e6b..712be56 100644
--- a/mobile/app/tx/[txid].tsx
+++ b/mobile/app/tx/[txid].tsx
@@ -1,10 +1,8 @@
import {
type Contact,
contactFor,
- grouped,
type PastPrice,
parseRequestMemo,
- shortAddress,
type Tx,
usd,
useNames,
@@ -26,6 +24,8 @@ import {
} from '../../src/activity';
import { Art } from '../../src/art';
import {
+ Address,
+ AddressInline,
Amount,
Avatar,
Button,
@@ -297,11 +297,7 @@ function Title({
const line = (
{lead}
- {name ? (
- {name}
- ) : (
- {shortAddress(to)}
- )}
+ {name ? {name} : }
);
if (!contact) return line;
@@ -443,27 +439,13 @@ function Technical({
const n = nameOf(a);
return {
key: `to-${a}`,
- node: (
-
- ),
+ node: ,
};
});
if (tx.receivedOn)
rows.push({
key: 'on',
- node: (
-
- ),
+ node: ,
});
rows.push({
key: 'id',
@@ -526,7 +508,6 @@ const useStyles = themed((c) =>
title: { fontSize: 17, marginTop: 12, marginBottom: 2, textAlign: 'center' },
titleTap: { minHeight: 48, justifyContent: 'center' },
titleName: { fontFamily: font.textBold },
- titleMono: { fontFamily: font.mono, fontSize: 15 },
struck: { textDecorationLine: 'line-through' },
statusBlock: { alignItems: 'center', marginTop: 14, gap: 4, paddingHorizontal: 24 },
status: { flexDirection: 'row', alignItems: 'center', gap: 8 },
diff --git a/mobile/src/activity-row.tsx b/mobile/src/activity-row.tsx
index d93458a..30378ab 100644
--- a/mobile/src/activity-row.tsx
+++ b/mobile/src/activity-row.tsx
@@ -1,9 +1,9 @@
-import { type Tx, usePastPrice, useWallet } from '@wizard/wallet-native';
+import { shortAddress, type Tx, usePastPrice, useWallet } from '@wizard/wallet-native';
import { router } from 'expo-router';
import { useEffect, useRef, useState } from 'react';
import { Animated, Pressable, StyleSheet, View } from 'react-native';
import { describe, notesOf } from './activity';
-import { Amount, Avatar, T } from './components';
+import { AddressInline, Amount, Avatar, T } from './components';
import { useFade } from './motion';
import { useRequestMatch } from './requests';
import { space } from './theme';
@@ -65,7 +65,10 @@ export function ActivityRow({
)
) : (
<>
- {d.title}
+ {/* Two lines for an address, so its ending, the part people compare, isn't cut. */}
+
+
+
{note ? (
{note}
@@ -86,6 +89,19 @@ export function ActivityRow({
);
}
+/** A row's title, with a bare address in it drawn in mono. */
+function Title({ title, bare }: { title: string; bare?: string }) {
+ const at = bare ? title.indexOf(shortAddress(bare)) : -1;
+ if (!bare || at < 0) return title;
+ return (
+ <>
+ {title.slice(0, at)}
+
+ {title.slice(at + shortAddress(bare).length)}
+ >
+ );
+}
+
/** The hairline between rows, starting after the avatar (`noWho`: at the text). */
export function RowSeparator({ noWho }: { noWho?: boolean } = {}) {
const s = useStyles();
diff --git a/mobile/src/activity.test.ts b/mobile/src/activity.test.ts
index 6b965d0..159ca8f 100644
--- a/mobile/src/activity.test.ts
+++ b/mobile/src/activity.test.ts
@@ -50,7 +50,11 @@ group('describe', () => {
});
it('falls back to a short address for someone without a name', () => {
- expect(describe(tx({}), () => null).title).toMatch(/^You paid utest1/);
+ const d = describe(tx({}), () => null);
+ expect(d.title).toMatch(/^You paid utest1\S{4}…\S{6}$/);
+ expect(d.bare).toMatch(/^utest1/);
+ // Screen readers hear its last characters, not the ellipsis.
+ expect(d.spoken).toMatch(/^You paid address ending( \S){6},/);
});
it('shows a receipt as it arrived', () => {
diff --git a/mobile/src/activity.ts b/mobile/src/activity.ts
index 408df0a..8f51a59 100644
--- a/mobile/src/activity.ts
+++ b/mobile/src/activity.ts
@@ -3,6 +3,7 @@ import {
paidAmount,
parseRequestMemo,
shortAddress,
+ spokenAddress,
stripReply,
type Tx,
usd,
@@ -18,6 +19,8 @@ export type Described = {
/** The other side's address, for the avatar. */
who?: string;
name: string | null;
+ /** The address the title names, short, when there's no name: the row draws it in mono. */
+ bare?: string;
/** Signed zatoshis, as `paidAmount` reads them. */
amount: number;
/** Where the payment stands, for a row ("2 min ago", "Confirming"). */
@@ -68,6 +71,7 @@ export function describe(
title: sentRequest ? `You sent ${them} a request` : `You paid ${them}`,
who: to,
name,
+ bare: name || !to ? undefined : to,
};
} else if (tx.kind === 'received') {
// A private payment doesn't say who sent it, but a request's own address does (issue #15).
@@ -84,7 +88,9 @@ export function describe(
const first = notesOf(tx)[0];
const note = first ? ` Note: ${first}` : '';
const amounts = bothAmounts(amount, price, dollarsFirst, ', ');
- return { ...d, spoken: `${d.title}, ${amounts}, ${status}.${note}` };
+ // "You paid address ending 4 5 6 7 8 9", not the short form's letters and ellipsis.
+ const said = d.bare ? d.title.replace(shortAddress(d.bare), spokenAddress(d.bare)) : d.title;
+ return { ...d, spoken: `${said}, ${amounts}, ${status}.${note}` };
}
/** Money that arrived at an exchange address (#53): public, and not in the balance until made private. */
diff --git a/mobile/src/components/address.tsx b/mobile/src/components/address.tsx
new file mode 100644
index 0000000..9ca131b
--- /dev/null
+++ b/mobile/src/components/address.tsx
@@ -0,0 +1,168 @@
+import {
+ addressRows,
+ grouped,
+ groupsPerRow,
+ shortAddress,
+ spokenAddress,
+} from '@wizard/wallet-native';
+import { Fragment, useState } from 'react';
+import {
+ PixelRatio,
+ type StyleProp,
+ StyleSheet,
+ Text,
+ type TextStyle,
+ useWindowDimensions,
+ View,
+} from 'react-native';
+import { font, size, space } from '../theme';
+import { themed } from '../use-theme';
+import { CopyText } from './copy';
+import { T } from './text';
+
+/**
+ * An address, drawn the same way everywhere (design guide §5): always in
+ * Plex Mono, never moving, never under art. Two forms:
+ *
+ * - **short** (the default): first 10, an ellipsis, last 6, on one line. It
+ * stands in for a name in a list row, a chip or a title. With `detail` it is
+ * the small muted line under a name (§3.1).
+ * - **full**: every character in groups of four, in lines of as many groups
+ * as fit (an even number, at most 8), so the groups stand in columns:
+ * odd columns in Text, even ones in Muted. For the places someone checks or
+ * copies it. With `copy`, tapping anywhere on it copies the whole address.
+ *
+ * The ends are never picked out: an address can be made to share its first
+ * and last characters with someone else's, so the full form is read whole,
+ * and its columns weigh every part the same.
+ * Screen readers hear a short address by its last 6 characters, one by one.
+ */
+export function Address({
+ value,
+ form = 'short',
+ detail,
+ label,
+ copy,
+ hint = 'Copies the address',
+ center,
+ style,
+}: {
+ value: string;
+ form?: 'short' | 'full';
+ /** Short form under a name: mono 13 in Muted. */
+ detail?: boolean;
+ /** Full form: a label above it, such as "Address" or "Ana’s address". */
+ label?: string;
+ /** Full form: tap to copy, and the label says "Copied" for a moment. */
+ copy?: boolean;
+ hint?: string;
+ center?: boolean;
+ style?: StyleProp;
+}) {
+ const a = useStyles();
+ if (form === 'short') {
+ return (
+
+ {shortAddress(value)}
+
+ );
+ }
+ const columns = ;
+ if (copy)
+ return (
+
+ {columns}
+
+ );
+ return (
+ <>
+ {label ? {label} : null}
+ {columns}
+ >
+ );
+}
+
+/** Plex Mono's advance: every character is 0.6 of the font size wide. */
+const MONO_ADVANCE = 0.6;
+
+/**
+ * The full form as columns of groups (design guide §5): lines start at the
+ * same edge, so each column keeps its colour down the address. Odd columns in
+ * Text, even ones in Muted (both pass AA on every ground). The spaces stay, so
+ * colour is never the only thing that separates the groups. The width is
+ * measured, and guessed from the window until it is, so larger text gets
+ * fewer columns instead of a line that wraps. Its parent's width must not
+ * come from its content (CopyText stretches for this), or the columns
+ * would measure themselves and shrink.
+ */
+function Columns({
+ value,
+ center,
+ style,
+}: {
+ value: string;
+ center?: boolean;
+ style?: StyleProp;
+}) {
+ const a = useStyles();
+ const { width: window } = useWindowDimensions();
+ const [width, setWidth] = useState(window - 2 * space.gutter);
+ const charWidth = size.mono * MONO_ADVANCE * PixelRatio.getFontScale();
+ const rows = addressRows(value, groupsPerRow(width, charWidth));
+ return (
+ setWidth(e.nativeEvent.layout.width)}
+ style={[a.box, center && a.centered]}
+ >
+
+ {rows.map((row, r) => (
+ // biome-ignore lint/suspicious/noArrayIndexKey: lines repeat, and their order never changes.
+
+ {r > 0 ? '\n' : null}
+ {row.map((g, c) => (
+ // biome-ignore lint/suspicious/noArrayIndexKey: as above.
+
+ {c > 0 ? ` ${g}` : g}
+
+ ))}
+
+ ))}
+
+
+ );
+}
+
+/**
+ * A short address inside a sentence, such as "You paid utest1abcd…456789":
+ * the mono face at 15 in Muted, so the sentence's words scan first and the
+ * address reads as the detail it is. Put it inside a `T`.
+ */
+export function AddressInline({ value }: { value: string }) {
+ const a = useStyles();
+ return (
+
+ {shortAddress(value)}
+
+ );
+}
+
+const inline = StyleSheet.create({ mono: { fontFamily: font.mono, fontSize: size.monoName } });
+
+const useStyles = themed((c) =>
+ StyleSheet.create({
+ name: { fontSize: size.monoName },
+ detail: { color: c.muted },
+ // The same line height as CopyText's, so a full address reads alike everywhere.
+ full: { lineHeight: 20 },
+ center: { textAlign: 'center' },
+ // Its parent's full width, measured for the columns; centred, the block
+ // sits in the middle while its lines keep one left edge.
+ box: { alignSelf: 'stretch', alignItems: 'flex-start' },
+ centered: { alignItems: 'center' },
+ }),
+);
diff --git a/mobile/src/components/copy.tsx b/mobile/src/components/copy.tsx
index 2b86b29..6a361f5 100644
--- a/mobile/src/components/copy.tsx
+++ b/mobile/src/components/copy.tsx
@@ -1,5 +1,5 @@
import * as Clipboard from 'expo-clipboard';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react';
import { AccessibilityInfo, Animated, Pressable, StyleSheet } from 'react-native';
import { haptic } from '../haptics';
import { duration, useFade } from '../motion';
@@ -28,7 +28,8 @@ export function useCopy(): [copied: boolean, copy: (text: string) => Promise copy(value)}
style={({ pressed }) => [cx.block, center && cx.center, pressed && touch.pressed]}
>
- {shown ? : null}
-
- {display}
-
+ {shown ? (
+
+ ) : (
+ // No label: its line stays, empty, so "Copied" fades in without moving
+ // the value (design guide §6: an address never moves).
+
+ )}
+ {children ?? (
+
+ {display}
+
+ )}
);
}
@@ -71,7 +83,10 @@ function Label({ text, fade }: { text: string; fade: boolean }) {
const cx = StyleSheet.create({
block: { gap: 4 },
- center: { alignItems: 'center' },
+ // Full width, so what it holds (an address's columns) measures the space it
+ // has, not its own content: a centred block that shrank to fit would pick
+ // fewer columns, shrink again, and end at two.
+ center: { alignItems: 'center', alignSelf: 'stretch' },
value: { lineHeight: 20 },
centerText: { textAlign: 'center' },
});
diff --git a/mobile/src/components/index.ts b/mobile/src/components/index.ts
index d151a97..e28a9a9 100644
--- a/mobile/src/components/index.ts
+++ b/mobile/src/components/index.ts
@@ -1,5 +1,6 @@
// Shared pieces, after docs/design/wizard-design-guide.md §6–§7. One file
// per family; import them from here.
+export { Address, AddressInline } from './address';
export { Amount } from './amount';
export { Button, HeaderLink, SignButton, touch } from './buttons';
export { CodeTile } from './code-tile';
diff --git a/mobile/src/components/text.tsx b/mobile/src/components/text.tsx
index e7f1af8..1330d4f 100644
--- a/mobile/src/components/text.tsx
+++ b/mobile/src/components/text.tsx
@@ -16,16 +16,23 @@ export function T({
kind = 'body',
selectable,
numberOfLines,
+ accessibilityLabel,
}: {
children: ReactNode;
style?: StyleProp;
kind?: 'body' | 'label' | 'title' | 'mono' | 'dust';
selectable?: boolean;
numberOfLines?: number;
+ accessibilityLabel?: string;
}) {
const t = useTextStyles();
return (
-
+
{children}
);
diff --git a/mobile/src/pay-contact.tsx b/mobile/src/pay-contact.tsx
index ae97a7a..f23d4ec 100644
--- a/mobile/src/pay-contact.tsx
+++ b/mobile/src/pay-contact.tsx
@@ -3,12 +3,11 @@ import {
checkContact,
contactRecipient,
errorText,
- shortAddress,
useWallet,
} from '@wizard/wallet-native';
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
-import { Button, Notice, T } from './components';
+import { AddressInline, Button, Notice, T } from './components';
import { goToAmount } from './navigation';
/** An amount and note to start the amount screen with (Pay again, Try again). */
@@ -97,8 +96,12 @@ export function DriftChoice({
{`${drift.contact.zcashName} now points to a different address.`}
- Saved: {shortAddress(drift.contact.address)}
- Now: {shortAddress(drift.address)}
+
+ Saved:
+
+
+ Now:
+
{drift.error ? {drift.error} : null}
diff --git a/mobile/src/pay-people.test.ts b/mobile/src/pay-people.test.ts
index 363a658..9b8e7bd 100644
--- a/mobile/src/pay-people.test.ts
+++ b/mobile/src/pay-people.test.ts
@@ -16,7 +16,7 @@ group('payPeople', () => {
const p = payPeople([bo, ana], recents, '');
if (p.typing) throw new Error('typing');
expect(p.recent.map((x) => x.name)).toEqual(['Ana', null]);
- expect(p.recent[0].detail).toBe('ana.zcash');
+ expect(p.recent[0].zcashName).toBe('ana.zcash');
expect(p.contacts.map((x) => x.name)).toEqual(['Bo']);
});
diff --git a/mobile/src/pay-people.ts b/mobile/src/pay-people.ts
index cc3d162..6cf2fa9 100644
--- a/mobile/src/pay-people.ts
+++ b/mobile/src/pay-people.ts
@@ -1,11 +1,11 @@
-import { type Contact, type Recent, shortAddress } from '@wizard/wallet-native';
+import type { Contact, Recent } from '@wizard/wallet-native';
/** One person on Pay's first screen: a contact, or someone paid recently. */
export type PayPerson = {
address: string;
name: string | null;
- /** The `.zcash` name or short address under the name. */
- detail: string | null;
+ /** A contact's `.zcash` name, shown under its name instead of the address. */
+ zcashName: string | null;
contact: Contact | null;
};
@@ -22,7 +22,7 @@ function fromContact(c: Contact): PayPerson {
return {
address: c.address,
name: c.name,
- detail: c.zcashName ?? shortAddress(c.address),
+ zcashName: c.zcashName,
contact: c,
};
}
@@ -42,7 +42,7 @@ export function payPeople(contacts: Contact[], recents: Recent[], typed: string)
: {
address: r.address,
name: r.name,
- detail: r.name ? shortAddress(r.address) : null,
+ zcashName: null,
contact: null,
};
});
diff --git a/mobile/src/theme.ts b/mobile/src/theme.ts
index 6b5c41c..787de44 100644
--- a/mobile/src/theme.ts
+++ b/mobile/src/theme.ts
@@ -125,6 +125,8 @@ export const size = {
dust: 15,
label: 13,
mono: 13,
+ /** An address in a name's place: a list row, a chip, a sentence (Address). */
+ monoName: 15,
/** A recovery-phrase word, and what is typed into a secret field. */
monoLarge: 16,
/** Button words, and a strong value such as a total. */
diff --git a/mobile/src/who.tsx b/mobile/src/who.tsx
index 86a8c9c..42b9f55 100644
--- a/mobile/src/who.tsx
+++ b/mobile/src/who.tsx
@@ -5,28 +5,28 @@ import {
errorText,
type Recipient,
resolveRecipient,
- shortAddress,
useWallet,
} from '@wizard/wallet-native';
import { router, useNavigation } from 'expo-router';
import { useEffect, useRef, useState } from 'react';
import { Pressable, ScrollView, StyleSheet, View } from 'react-native';
import { NOTHING_TO_PASTE, pasteText } from './clipboard';
-import { Avatar, Button, Notice, Screen, ScreenHeader, T, TextField } from './components';
+import { Address, Avatar, Button, Notice, Screen, ScreenHeader, T, TextField } from './components';
import { goToAmount } from './navigation';
import { DriftChoice, usePayContact } from './pay-contact';
import { type PayPerson, payPeople } from './pay-people';
import { themed } from './use-theme';
+/** A name with its `.zcash` name or short address beneath; a bare address alone. */
function Person({
name,
- detail,
+ zcashName,
address,
busy,
onPress,
}: {
name: string | null;
- detail: string | null;
+ zcashName: string | null;
address: string;
busy?: boolean;
onPress: () => void;
@@ -42,11 +42,13 @@ function Person({
>
- {name ?? shortAddress(address)}
- {detail ? (
+ {name ? {name} : }
+ {name && zcashName ? (
- {detail}
+ {zcashName}
+ ) : name ? (
+
) : null}
@@ -133,7 +135,7 @@ export function Who({ ask = false }: { ask?: boolean }) {
pick(p)}
diff --git a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ConfirmSheet.kt b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ConfirmSheet.kt
index e690a29..e117546 100644
--- a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ConfirmSheet.kt
+++ b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ConfirmSheet.kt
@@ -31,8 +31,20 @@ object Format {
fun usd(zatoshis: ULong, usdPerZec: Double): String =
String.format(Locale.US, "$%,.2f", zatoshis.toDouble() / 100_000_000.0 * usdPerZec)
- /** The whole address in groups of four, so every character is visible. */
- fun grouped(address: String): String = address.chunked(4).joinToString(" ")
+ /**
+ * The whole address in groups of four, `perRow` to a line, so every character
+ * is visible and the groups stand in columns.
+ */
+ fun rows(address: String, perRow: Int): List> = address.chunked(4).chunked(perRow)
+
+ /**
+ * As many groups as fit on a line of `width`, at most 8, always even so each
+ * column keeps its colour; one character kept spare (format.ts `groupsPerRow`).
+ */
+ fun groupsPerRow(width: Float, charWidth: Float): Int {
+ val fit = (width / charWidth).toInt() / 5
+ return (fit - fit % 2).coerceIn(2, 8)
+ }
}
/**
@@ -128,7 +140,7 @@ object ConfirmSheet {
} else {
val to = LinearLayout(activity).apply { orientation = LinearLayout.VERTICAL }
if (label != null) to.addView(text(label, TextKind.STRONG))
- for (a in proposal.to) to.addView(text(Format.grouped(a), TextKind.MONO).apply { setTextIsSelectable(true) })
+ for (a in proposal.to) to.addView(Kit.address(activity, a))
// A public address says so (#54).
when (proposal.recipient) {
WalletRecipientKind.PUBLIC -> "Public address"
diff --git a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ContactSheet.kt b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ContactSheet.kt
index c0cb5f7..93447ad 100644
--- a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ContactSheet.kt
+++ b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/ContactSheet.kt
@@ -29,8 +29,7 @@ object ContactSheet {
// Who the user pays: the sheet keeps it out of the recent-apps preview.
val (dialog, body) = Kit.bottomSheet(activity)
fun add(v: View, top: Int = 12) = Kit.add(body, v, top)
- fun mono(s: String) =
- Kit.text(activity, Format.grouped(s), TextKind.MONO).apply { setTextIsSelectable(true) }
+ fun mono(s: String) = Kit.address(activity, s)
var done = false
fun finish(ok: Boolean) {
diff --git a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/Kit.kt b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/Kit.kt
index 6a2112e..b65b49f 100644
--- a/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/Kit.kt
+++ b/wallet-native/android/src/main/java/com/principlezerolabs/wizard/wallet/Kit.kt
@@ -6,6 +6,9 @@ import android.app.Dialog
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.InsetDrawable
+import android.text.SpannableStringBuilder
+import android.text.Spanned
+import android.text.style.ForegroundColorSpan
import android.view.Gravity
import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
@@ -126,6 +129,41 @@ object Kit {
setTextColor(color ?: if (kind.muted) Theme.muted else Theme.text)
}
+ /**
+ * A full address, as React Native's `Address form="full"` (design guide §5):
+ * groups of four in Plex Mono 13, in lines of as many groups as fit (an even
+ * number, at most 8), so the groups stand in columns, odd ones in Text and
+ * even ones in Muted. It re-lines itself once its width is known, so larger
+ * text gets fewer columns, never a wrapped line. Selectable; copies without colour.
+ */
+ fun address(activity: Activity, address: String) =
+ text(activity, "", TextKind.MONO).apply {
+ var perRow = 0
+ fun show(n: Int) {
+ if (n == perRow) return
+ perRow = n
+ val shown = SpannableStringBuilder()
+ Format.rows(address, n).forEachIndexed { r, row ->
+ if (r > 0) shown.append("\n")
+ row.forEachIndexed { c, g ->
+ if (c > 0) shown.append(" ")
+ val start = shown.length
+ shown.append(g)
+ if (c % 2 == 1) {
+ shown.setSpan(ForegroundColorSpan(Theme.muted), start, shown.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
+ }
+ }
+ }
+ text = shown
+ }
+ show(6)
+ addOnLayoutChangeListener { _, left, _, right, _, _, _, _, _ ->
+ val width = right - left - paddingLeft - paddingRight
+ if (width > 0) post { show(Format.groupsPerRow(width.toFloat(), paint.measureText("0"))) }
+ }
+ setTextIsSelectable(true)
+ }
+
/**
* React Native's `Button`: a 52dp capsule in Figtree SemiBold 17.
* PRIMARY is the one filled button on a screen. SECONDARY has a hairline
diff --git a/wallet-native/ios/ConfirmSheet.swift b/wallet-native/ios/ConfirmSheet.swift
index fe98867..3f44796 100644
--- a/wallet-native/ios/ConfirmSheet.swift
+++ b/wallet-native/ios/ConfirmSheet.swift
@@ -29,14 +29,17 @@ enum Format {
return f.string(from: NSNumber(value: value)) ?? String(format: "$%.2f", value)
}
- /// The whole address in groups of four, so every character is visible.
- static func grouped(_ address: String) -> String {
- var out = ""
+ /// The whole address in groups of four, `perRow` groups to a line, so every
+ /// character is visible and the groups stand in columns.
+ static func rows(_ address: String, _ perRow: Int) -> [[String]] {
+ var groups: [String] = []
for (i, c) in address.enumerated() {
- if i > 0 && i % 4 == 0 { out.append(" ") }
- out.append(c)
+ if i % 4 == 0 { groups.append("") }
+ groups[groups.count - 1].append(c)
+ }
+ return stride(from: 0, to: groups.count, by: perRow).map {
+ Array(groups[$0.. some View {
- Text(Format.grouped(address)).kit(.mono).textSelection(.enabled)
- }
+ private func mono(_ address: String) -> some View { AddressText(address) }
}
diff --git a/wallet-native/ios/Kit.swift b/wallet-native/ios/Kit.swift
index 7222c7b..f296543 100644
--- a/wallet-native/ios/Kit.swift
+++ b/wallet-native/ios/Kit.swift
@@ -171,6 +171,38 @@ struct KitPage: View {
}
}
+/// A full address, as React Native's `Address form="full"` (design guide §5):
+/// groups of four in Plex Mono 13, in lines of as many groups as fit (8, 6, 4
+/// or 2: always even), so the groups stand in columns, odd ones in Text and
+/// even ones in Muted. Larger text gets fewer columns, never a wrapped line.
+/// Selectable; copies without colour.
+struct AddressText: View {
+ let address: String
+ init(_ address: String) { self.address = address }
+
+ var body: some View {
+ ViewThatFits(in: .horizontal) {
+ lines(8)
+ lines(6)
+ lines(4)
+ lines(2)
+ }
+ }
+
+ private func lines(_ perRow: Int) -> some View {
+ Format.rows(address, perRow).enumerated().reduce(Text("")) { text, row in
+ row.element.enumerated().reduce(row.offset == 0 ? text : text + Text("\n")) { line, g in
+ line + Text(g.offset == 0 ? g.element : " \(g.element)")
+ .foregroundColor(g.offset % 2 == 0 ? Palette.text : Palette.muted)
+ }
+ }
+ .font(Face.mono)
+ // Its natural width, so ViewThatFits can tell whether the lines fit.
+ .fixedSize()
+ .textSelection(.enabled)
+ }
+}
+
/// A named value on a review sheet: the name in a label, the value under it.
struct DetailRow: View {
let name: String
diff --git a/wallet-native/src/format.test.ts b/wallet-native/src/format.test.ts
index d7f454b..6ae4886 100644
--- a/wallet-native/src/format.test.ts
+++ b/wallet-native/src/format.test.ts
@@ -1,9 +1,11 @@
import { describe, expect, it } from 'vitest';
import {
aboutMinutes,
+ addressRows,
dayChange,
errorText,
grouped,
+ groupsPerRow,
looksLikeName,
MAX_ZATOSHIS,
memoParam,
@@ -18,6 +20,7 @@ import {
shortAddress,
signedUsd,
signedZec,
+ spokenAddress,
usd,
usdText,
usdToZats,
@@ -89,6 +92,23 @@ describe('addresses', () => {
expect(grouped('abcdefghij')).toBe('abcd efgh ij');
expect(grouped(a).replace(/ /g, '')).toBe(a);
});
+ it('fits an even number of groups on a line, 2 to 8', () => {
+ // A group and its space are 5 characters; one is kept spare.
+ expect(groupsPerRow(10 * 29, 10)).toBe(4); // 28 usable: 5 fit, rounded down to 4
+ expect(groupsPerRow(10 * 30, 10)).toBe(6); // 29 usable: 6 groups take exactly 29
+ expect(groupsPerRow(10 * 100, 10)).toBe(8);
+ expect(groupsPerRow(10 * 5, 10)).toBe(2);
+ });
+ it('splits the address into lines of whole groups', () => {
+ const rows = addressRows(a, 4);
+ expect(rows[0]).toEqual(['utes', 't1ab', 'cdef', 'ghij']);
+ expect(rows.flat().join('')).toBe(a);
+ expect(rows.at(-1)?.length).toBeLessThanOrEqual(4);
+ });
+ it('speaks the last 6 characters one by one', () => {
+ expect(spokenAddress(a)).toBe('address ending 4 5 6 7 8 9');
+ expect(spokenAddress('short')).toBe('s h o r t');
+ });
});
describe('aboutMinutes', () => {
diff --git a/wallet-native/src/format.ts b/wallet-native/src/format.ts
index 2d42bda..d9c8169 100644
--- a/wallet-native/src/format.ts
+++ b/wallet-native/src/format.ts
@@ -124,6 +124,38 @@ export function grouped(a: string): string {
return a.replace(/(.{4})/g, '$1 ').trim();
}
+/**
+ * How many groups of four go on each line of a full address (design guide §5),
+ * given the width and one character's width: as many as fit, at most 8, and
+ * always an even number so each column keeps its colour from line to line.
+ * One character of the width is kept spare for rounding.
+ */
+export function groupsPerRow(width: number, charWidth: number): number {
+ // n groups and the spaces between them take 5n − 1 characters.
+ const spare = Math.floor(width / charWidth) - 1;
+ const fit = Math.floor((spare + 1) / 5);
+ return Math.max(2, Math.min(8, fit - (fit % 2)));
+}
+
+/** A full address as lines of `perRow` groups of four. */
+export function addressRows(a: string, perRow: number): string[][] {
+ const groups = a.match(/.{1,4}/g) ?? [];
+ const rows: string[][] = [];
+ for (let i = 0; i < groups.length; i += perRow) rows.push(groups.slice(i, i + perRow));
+ return rows;
+}
+
+/**
+ * What a screen reader says for an address: its last 6 characters one by one,
+ * the same ones the short form ends with, so they can be compared by ear.
+ * Reading a whole address aloud takes over a minute.
+ */
+export function spokenAddress(a: string): string {
+ return a.length <= 18
+ ? a.split('').join(' ')
+ : `address ending ${a.slice(-6).split('').join(' ')}`;
+}
+
/** "about 4 min" from blocks left; "under a minute" for one or two blocks. */
export function aboutMinutes(blocks: number): string {
const min = Math.ceil((blocks * BLOCK_SECONDS) / 60);