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
13 changes: 7 additions & 6 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ A bottom tab bar holds four tabs, in this order: **Recent, Collection, Decks, Sc
- A reload when the tab gains focus and a new page keep the tiles already shown and bring no skeleton grid back.
- With no copies, the tab shows its empty state with a **Scan cards** button, which opens the Scan tab. See Empty states.
- When the read fails, the tab shows the empty state "Could not load your collection" with a **Try again** button, which reloads the binder grid.
- One quiet meta line under each card shows the set icon in its rarity color, the collector number, and the condition when it is not NM. Foil and etched copies carry a sheen on the card image instead of a finish label. Later, badges also show whether the copy is in a deck, held by a planned swap, or protected.
- One quiet meta line under each card shows a warning shield when the copy is protected, the set icon in its rarity color, the collector number, and the condition when it is not NM. Foil and etched copies carry a sheen on the card image instead of a finish label. Later, badges also show whether the copy is in a deck or held by a planned swap.
- A price line under the meta line shows the copy's current price (owner decision, #120). A copy with no current price shows "–". A stale price has a clock symbol.
- Tapping a tile opens the copy page for that copy, from the binder and from search results alike.
- A native search bar sits under the large title. See Collection search. Filters: All, Free, Allocated, Protected.
Expand Down Expand Up @@ -474,9 +474,10 @@ Pushed screens cover the whole screen, including the app tab bar. There are **no
- **Price**: value rows for "Current price" with the stale clock, "Added" with the day, such as "12 October 2026", and "Purchase-day price", then the credit "Current prices from Scryfall, in USD". A missing price shows a text dim "–", and VoiceOver hears "no price". A stale current price adds the hint "The price may be out of date.";
- **Rules**: the Oracle text in a surface card, with each face's name over its text for a card with more than one face, then a "Commander" value row: "Legal", "Banned", "Not legal", or "Unknown".
- Section headings are lime body strong text.
- A ••• bar button with the `ellipsis` symbol sits on the right of the header, over the hero. VoiceOver reads it as "More". It opens the actions menu, a native menu of what the user can do to this copy. Its last item is **Delete copy**, in red.
- A ••• bar button with the `ellipsis` symbol sits on the right of the header, over the hero. VoiceOver reads it as "More". It opens the actions menu, a native menu of what the user can do to this copy. Its first item is **Protect** for a free copy or **Unprotect** for a protected copy. Its last item is **Delete copy**, in red.
- **Protect** and **Unprotect** act at once on this copy only, and the Protected chip changes. When the write fails, a native alert says "Could not protect this card" or "Could not unprotect this card" and "Check your connection.", and the copy stays as it was.
- **Delete copy** shows a native alert "Delete this copy?" with "It leaves your collection with its user tags. This cannot be undone.", **Delete copy** in red, and **Cancel**. After the delete, the app goes back to the binder, which reloads without the tile. When the delete fails, a native alert says "Could not delete this copy" and "Check your connection.", and the page stays.
- A copy that no longer exists, such as one deleted on another phone, shows a native alert "This card is no longer in your collection." with **OK**, which goes back to the binder.
- A copy that no longer exists, such as one deleted on another phone, shows a native alert "This card is no longer in your collection." with **OK**, which goes back to the binder. The same alert shows when the copy is gone by the time the user picks an action.
- When the read fails, the page shows the empty state "Could not load this card" with a **Try again** button. See Empty states.
- **Deck screen**, from the gallery or a deck tag:
- The top bar is a compact header: the commander picture, the deck name, and chips for priority, validity, and estimated bracket. When the deck is not valid, its violations and the bracket signals show under the chips. Nothing else goes in the header.
Expand Down Expand Up @@ -630,13 +631,13 @@ Liquid Glass is Apple's glass material from iOS 26 (owner decision, #113).
- The phone saves the scan batch for each account, so they survive a restart. Another account on the phone does not see them.
- **Binder tile.** One copy's card image with a meta line and a price line under it. There is no quantity badge and no chip.
- Until the image loads, the tile is a line-colored card shape.
- The meta line sits 4 px below the card image, centered, in meta text in text muted: the set's expansion symbol from Scryfall at 16 px tinted with the rarity color of the card printing (see Colors), then the collector number. When the card catalog has no symbol for the set, or it has not loaded, the set code in capitals takes its place. A copy that is not NM adds a text dim " · " and its condition: "[symbol] 136 · MP". Every condition uses the same text muted color.
- The meta line sits 4 px below the card image, centered, in meta text in text muted: the set's expansion symbol from Scryfall at 16 px tinted with the rarity color of the card printing (see Colors), then the collector number. A protected copy starts the line with an 11 px `shield.fill` symbol in warning, before the set symbol: "[shield] [symbol] 136". When the card catalog has no symbol for the set, or it has not loaded, the set code in capitals takes its place. A copy that is not NM adds a text dim " · " and its condition: "[symbol] 136 · MP". Every condition uses the same text muted color.
- The line never names the finish. A foil copy has a faint rainbow sheen over its card image, and an etched copy has a faint silver sheen. Nonfoil copies have none. The sheen does not move. It is a diagonal gradient at 30% opacity, so the card art reads normally.
- The price line sits 4 px below the meta line, centered, in price type (12 px, semibold) in text price, slightly brighter than the meta line. It shows the copy's current price in full, such as "$1,635.37". The price is the current Scryfall price for the card printing and finish. Condition and language do not change it. The currency is USD for now.
- A copy with no price for its card printing and finish shows a text dim "–". A price is never taken from another finish or card printing.
- A stale price, older than 24 hours, has a small 11 px `clock` symbol in text price before it. The symbol is neutral, not a warning.
- VoiceOver reads the tile as one button: the name, the set code in capitals and the collector number, then the finish when it is not nonfoil and the condition when it is not NM, in words, then the price or "no price": "Bloomvine Regent // Claim Territory, TDM 136, foil, moderately played, $1,635.37". A stale price adds the hint "The price may be out of date."
- Tapping the tile opens the copy page. The badges for decks, planned swaps, and protected copies come later.
- VoiceOver reads the tile as one button: the name, the set code in capitals and the collector number, then the finish when it is not nonfoil and the condition when it is not NM, in words, then "protected" for a protected copy, then the price or "no price": "Bloomvine Regent // Claim Territory, TDM 136, foil, moderately played, protected, $1,635.37". A stale price adds the hint "The price may be out of date."
- Tapping the tile opens the copy page. The badges for decks and planned swaps come later.
- **Empty states.** Every empty state uses one layout, variant C of the HTML prototype (`prototypes/empty-states/index.html` on `prototype/empty-states`, commit 961e3ae). The `EmptyState` molecule draws it, and each page passes its own illustration.
- From top to bottom: an illustration, a title in sheet title type in text white, one line of body text in text muted, and at most one primary (lime) button, 16 px apart. The text is centered.
- The illustration is made of shapes from the app in line color, such as empty binder slots or ghost rows. It uses no images. On the background, it fades downward into the background from 30% of its height (`gradients.emptyStateFade`). Over the camera and in batch review it does not fade.
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ Signed-in users read one copy with `supabase.rpc('get_copy', { query })`. The qu
- From its card: `type_line`, `faces` with each face's `name` and `oracle_text` in face order, and `commander_legality`.
- The function runs with the caller's rights, so another user's copy is refused with `not_found` on `copy_id`, like a copy that does not exist. A refused query has the code `invalid_argument` and the field at fault. An anonymous caller and the secret key are refused.

### Protect a copy

Signed-in users protect or unprotect one of their copies with `supabase.rpc('set_copy_protected', { request })`. The request has `copy_id` and `protected`, `true` or `false`. `supabase/collection.ts` has the shared types. The copy page's actions menu calls it.

- It changes only that copy, in one transaction, and returns `copy_id` and `protected`. Doing what is already done changes nothing.
- Only a free copy can be protected. Protecting a copy that is not free is refused with `copy_not_free` on `copy_id`. Until decks exist, every copy is free.
- Another user's copy is refused with `not_found` on `copy_id`, like a copy that does not exist. A refused request has the code `invalid_argument` and the field at fault. An anonymous caller and the secret key are refused.

### Copy delete

Signed-in users delete one copy with `supabase.rpc('delete_copy', { request })`. The request has only `copy_id`. `supabase/collection.ts` has the shared type. The copy page deletes its copy through it.
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/app/(tabs)/(collection)/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function BinderTile({ copy, setIconUri }: { copy: CollectionCopyRow; setIconUri:
copy.name,
`${copy.set.toUpperCase()} ${copy.collector_number}`,
...spokenFinishAndCondition(copy),
...(copy.protected ? ['protected'] : []),
price ?? 'no price',
].join(', ')}
accessibilityHint={copy.price?.stale ? 'The price may be out of date.' : undefined}
Expand All @@ -85,6 +86,7 @@ function BinderTile({ copy, setIconUri }: { copy: CollectionCopyRow; setIconUri:
setIconUri={setIconUri}
collectorNumber={copy.collector_number}
condition={shownCondition(copy.condition)}
isProtected={copy.protected}
/>
<PriceLine price={price} stale={copy.price?.stale ?? false} />
</CardTile>
Expand Down
14 changes: 12 additions & 2 deletions apps/mobile/src/app/copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { router, Stack, useLocalSearchParams } from 'expo-router';
import { useEffect } from 'react';
import { Alert, View } from 'react-native';

import { deleteCopy } from '@/collection/copy-writes';
import { deleteCopy, setCopyProtected } from '@/collection/copy-writes';
import { copyPriceCurrency, useCopy } from '@/collection/use-copy';
import { DashedCardFrame } from '@/components/molecules/empty-state-illustrations';
import { ReadFailure } from '@/components/molecules/read-failure';
Expand Down Expand Up @@ -31,6 +31,14 @@ export default function CopyScreen() {
}
}

async function changeProtected(isProtected: boolean) {
if ((await setCopyProtected(copyId, isProtected)) === 'failed') {
Alert.alert(isProtected ? 'Could not protect this card' : 'Could not unprotect this card', 'Check your connection.');
return;
}
reload();
}

function confirmDelete() {
Alert.alert('Delete this copy?', 'It leaves your collection with its user tags. This cannot be undone.', [
{ text: 'Delete copy', style: 'destructive', onPress: deleteThisCopy },
Expand All @@ -42,7 +50,9 @@ export default function CopyScreen() {
<PushedScreen>
{read.status === 'loaded' ? (
<>
<Stack.Toolbar placement="right">{copyActionsMenu({ onDelete: confirmDelete })}</Stack.Toolbar>
<Stack.Toolbar placement="right">
{copyActionsMenu({ copy: read.copy, onSetProtected: changeProtected, onDelete: confirmDelete })}
</Stack.Toolbar>
<CopyPageContent copy={read.copy} currency={copyPriceCurrency} />
</>
) : null}
Expand Down
18 changes: 14 additions & 4 deletions apps/mobile/src/collection/copy-writes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import type { DeleteCopyRequest } from '@mtgscan/supabase/collection';
import type { CopyProtectedRequest, DeleteCopyRequest } from '@mtgscan/supabase/collection';
import { readSearchError } from '@mtgscan/supabase/search';

import { supabase } from '@/lib/supabase';

export type CopyWriteResult = 'done' | 'missing' | 'failed';

export async function deleteCopy(copyId: string): Promise<CopyWriteResult> {
const request: DeleteCopyRequest = { copy_id: copyId };
const { error } = await supabase.rpc('delete_copy', { request });
function resultOf(error: Parameters<typeof readSearchError>[0] | null): CopyWriteResult {
if (!error) {
return 'done';
}
return readSearchError(error).code === 'not_found' ? 'missing' : 'failed';
}

export async function setCopyProtected(copyId: string, isProtected: boolean): Promise<CopyWriteResult> {
const request: CopyProtectedRequest = { copy_id: copyId, protected: isProtected };
const { error } = await supabase.rpc('set_copy_protected', { request });
return resultOf(error);
}

export async function deleteCopy(copyId: string): Promise<CopyWriteResult> {
const request: DeleteCopyRequest = { copy_id: copyId };
const { error } = await supabase.rpc('delete_copy', { request });
return resultOf(error);
}
6 changes: 5 additions & 1 deletion apps/mobile/src/components/molecules/copy-meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ import type { ComponentProps } from 'react';
import { View } from 'react-native';

import { SetIcon } from '@/components/atoms/set-icon';
import { SymbolView } from '@/components/atoms/symbol-view';
import { Text } from '@/components/atoms/text';
import { sizes } from '@/theme';

type CopyMetaProps = {
setCode: string;
rarity: ComponentProps<typeof SetIcon>['rarity'];
setIconUri: string | undefined;
collectorNumber: string;
condition?: string;
isProtected?: boolean;
};

export function CopyMeta({ setCode, rarity, setIconUri, collectorNumber, condition }: CopyMetaProps) {
export function CopyMeta({ setCode, rarity, setIconUri, collectorNumber, condition, isProtected = false }: CopyMetaProps) {
const setLabel = setCode.toUpperCase();
return (
<View className="flex-row items-center justify-center gap-xs">
{isProtected && <SymbolView name="shield.fill" size={sizes.protectedSymbol} className="text-warning" />}
{setIconUri ? (
<View accessible accessibilityLabel={setLabel}>
<SetIcon uri={setIconUri} rarity={rarity} />
Expand Down
11 changes: 10 additions & 1 deletion apps/mobile/src/components/organisms/copy-actions-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import type { CopyDetails } from '@mtgscan/supabase/collection';
import { Stack } from 'expo-router';

import { colors } from '@/theme';

type CopyActionsMenuProps = {
copy: Pick<CopyDetails, 'protected' | 'free'>;
onSetProtected: (isProtected: boolean) => void;
onDelete: () => void;
};

export function copyActionsMenu({ onDelete }: CopyActionsMenuProps) {
export function copyActionsMenu({ copy, onSetProtected, onDelete }: CopyActionsMenuProps) {
return (
<Stack.Toolbar.Menu icon="ellipsis" tintColor={colors.text} accessibilityLabel="More">
{copy.protected ? (
<Stack.Toolbar.MenuAction onPress={() => onSetProtected(false)}>Unprotect</Stack.Toolbar.MenuAction>
) : null}
{!copy.protected && copy.free ? (
<Stack.Toolbar.MenuAction onPress={() => onSetProtected(true)}>Protect</Stack.Toolbar.MenuAction>
) : null}
<Stack.Toolbar.MenuAction destructive onPress={onDelete}>
Delete copy
</Stack.Toolbar.MenuAction>
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/src/primitive-catalog/primitive-catalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ function CardTiles() {
<CopyMeta setCode="m10" rarity="uncommon" setIconUri={m10Symbol} collectorNumber="216" />
<PriceLine price="$1.25" stale />
</CardTile>
<CardTile uri={solRing} accessibilityLabel="Sol Ring, M10 216, protected, $1.25">
<CopyMeta setCode="m10" rarity="rare" setIconUri={m10Symbol} collectorNumber="216" isProtected />
<PriceLine price="$1.25" stale={false} />
</CardTile>
{['CMM 464', 'C21 263'].map((caption) => (
<CardTile
key={caption}
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const sizes = {
setIcon: 16,
staleSymbol: 11,
chipSymbol: 11,
protectedSymbol: 11,
chipPadding: 9,
cardThumbnailWidth: 40,
cardThumbnailHeight: 56,
Expand Down
Loading
Loading