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
25 changes: 16 additions & 9 deletions apps/mobile/src/apps/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { allLayouts, chooseLayout, useLayout } from "../camera/layouts";
import { captureFact, collecting, endCollection, frameBox, frames, liveView, nextFolder, startCollection, toggles, type FrameChoice } from "../camera/state";
import { Button, Empty, FIXED, Hint, Icon, ListRow, makeStyles, num, RADIUS, SectionLabel, Seg, Sheet, SheetList, SIZE, Slider, toast, type, useTheme, Block, type IconName } from "../ui";
import { registerApp } from "./registry";
import { useCameraButtons } from "../settings";

/**
* The camera (docs/features/camera-layouts.md, docs/rewrite/03-capture.md): the phone takes photos; everything else
Expand All @@ -34,6 +35,7 @@ const sideways = (e: Edge) => e === "left" || e === "right";
const JUSTIFY: Record<Distribution, "flex-start" | "center" | "flex-end" | "space-between" | "space-around"> = { start: "flex-start", center: "center", end: "flex-end", between: "space-between", around: "space-around" };

function Camera({ active }: { active: boolean }) {
const sizes = useCameraButtons();
const s = useStyles();
const { width, height } = useWindowDimensions();
const project = useProject();
Expand Down Expand Up @@ -166,7 +168,7 @@ function Camera({ active }: { active: boolean }) {
if (c.kind === "readout") { const r = readout(i.control); return r ? <Text key={i.control} style={[s.tag, r.warn && s.tagWarn]} numberOfLines={1}>{r.text}</Text> : null; }
if (c.kind === "shutter") return (
<Pressable key="shutter" accessibilityRole="button" accessibilityLabel="Take a photo" disabled={!ready || busy || preview} onPress={() => void shoot()}
style={({ pressed }) => [s.shutter, pressed && { transform: [{ scale: 0.94 }] }, (!ready || busy) && { opacity: 0.6 }]}><View style={s.shutterInner} /></Pressable>
style={({ pressed }) => [s.shutter, { width: sizes.shutter, height: sizes.shutter, borderRadius: sizes.shutter / 2 }, pressed && { transform: [{ scale: 0.94 }] }, (!ready || busy) && { opacity: 0.6 }]}><View style={[s.shutterInner, { width: sizes.shutter - 16, height: sizes.shutter - 16, borderRadius: (sizes.shutter - 16) / 2 }]} /></Pressable>
);
if (i.control === "lenses") {
if (lensList.length < 2) return null;
Expand Down Expand Up @@ -200,7 +202,7 @@ function Camera({ active }: { active: boolean }) {
case "layout": return btn(undefined, () => setSheet("layout"));
case "uploads": return btn(undefined, () => openApp("setup", "uploads"), { text: counts.waiting ? String(counts.waiting) : undefined, warn: counts.stuck > 0 });
case "last": return (
<Pressable key="last" accessibilityRole="button" accessibilityLabel="Last photo" disabled={!last} onPress={() => last && openApp("media", last.id)} style={s.thumb}>
<Pressable key="last" accessibilityRole="button" accessibilityLabel="Last photo" disabled={!last} onPress={() => last && openApp("media", last.id)} style={[s.thumb, { width: sizes.size, height: sizes.size }]}>
{last && <Image source={queuedUri(last) ? { uri: queuedUri(last)! } : imageSource(last.id, "thumbnail")} style={StyleSheet.absoluteFill} />}
</Pressable>
);
Expand Down Expand Up @@ -367,15 +369,20 @@ function NameInput({ value, onChange, placeholder }: { value: string; onChange:
return <TextInput value={value} onChangeText={onChange} placeholder={placeholder} placeholderTextColor={c.textDim} maxLength={120} style={[s.input, { color: c.text, borderColor: c.border, backgroundColor: c.surface }]} />;
}

/** A camera control (ux-5-phone.md): outlined when off, filled in the accent colour when on; with text it is a pill. */
/**
* A camera control (ux-5-phone.md): black with a white outline and a white icon when off, so it reads over any
* picture (#426: no see-through fill, no muted outline); filled in the accent colour when on; with text a pill.
* Its size is this device's choice (Setup › Camera buttons).
*/
function CamButton({ icon, text, label, on, warn, disabled, onPress }: { icon?: IconName; text?: string; label: string; on?: boolean; warn?: boolean; disabled?: boolean; onPress: () => void }) {
const s = useStyles();
const { c } = useTheme();
const fg = on ? c.onAccent : disabled ? "rgba(255,255,255,.4)" : FIXED.white;
const sizes = useCameraButtons();
const fg = on ? c.onAccent : FIXED.white;
return (
<Pressable onPress={onPress} disabled={disabled} accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ selected: !!on, disabled }}
style={({ pressed }) => [s.cam, text !== undefined && s.camPill, on && { backgroundColor: c.accent, borderColor: c.accent }, warn && { borderColor: FIXED.record }, pressed && !on && { backgroundColor: "rgba(255,255,255,.16)" }]}>
{icon && <Icon name={icon} size={22} color={warn ? FIXED.record : fg} />}
style={({ pressed }) => [s.cam, { minWidth: sizes.size, height: sizes.size, borderRadius: sizes.size / 2 }, text !== undefined && s.camPill, on && { backgroundColor: c.accent, borderColor: c.accent }, warn && { borderColor: FIXED.record }, pressed && { opacity: 0.7 }, disabled && { opacity: 0.45 }]}>
{icon && <Icon name={icon} size={sizes.icon} color={warn ? FIXED.record : fg} />}
{text !== undefined && <Text style={[s.camText, { color: fg }]}>{text}</Text>}
</Pressable>
);
Expand All @@ -400,14 +407,14 @@ const useStyles = makeStyles(() => ({
tagWarn: { backgroundColor: FIXED.record },
strip: { flexDirection: "row", gap: 8, alignItems: "center" },
stripV: { flexDirection: "column" },
stepped: { flexDirection: "row", alignItems: "center", gap: 4, padding: 3, borderRadius: 28, borderWidth: 2, borderColor: "rgba(255,255,255,.5)" },
stepped: { flexDirection: "row", alignItems: "center", gap: 4, padding: 3, borderRadius: 28, borderWidth: 2, borderColor: FIXED.white, backgroundColor: FIXED.black },
steppedValue: { ...type("label", "bold"), color: FIXED.white, minWidth: 44, textAlign: "center", ...num },
ctl: { alignItems: "center", gap: 2 },
ctlLabel: { ...type("caption", "bold"), fontSize: 10, color: FIXED.white, opacity: 0.85 },
thumb: { width: SIZE.touchMin, height: SIZE.touchMin, borderRadius: RADIUS.sm, overflow: "hidden", borderWidth: 2, borderColor: "rgba(255,255,255,.5)", backgroundColor: "rgba(255,255,255,.08)" },
thumb: { width: SIZE.touchMin, height: SIZE.touchMin, borderRadius: RADIUS.sm, overflow: "hidden", borderWidth: 2, borderColor: FIXED.white, backgroundColor: FIXED.black },
shutter: { width: SIZE.shutter, height: SIZE.shutter, borderRadius: SIZE.shutter / 2, borderWidth: 4, borderColor: FIXED.white, alignItems: "center", justifyContent: "center" },
shutterInner: { width: SIZE.shutter - 16, height: SIZE.shutter - 16, borderRadius: (SIZE.shutter - 16) / 2, backgroundColor: FIXED.white },
cam: { minWidth: SIZE.touchMin, height: SIZE.touchMin, borderRadius: SIZE.touchMin / 2, borderWidth: 2, borderColor: "rgba(255,255,255,.7)", alignItems: "center", justifyContent: "center", flexDirection: "row", gap: 4 },
cam: { minWidth: SIZE.touchMin, height: SIZE.touchMin, borderRadius: SIZE.touchMin / 2, borderWidth: 2, borderColor: FIXED.white, backgroundColor: FIXED.black, alignItems: "center", justifyContent: "center", flexDirection: "row", gap: 4 },
camPill: { paddingHorizontal: 14 },
camText: { ...type("label", "bold"), ...num },
previewChip: { position: "absolute", left: 12, right: 12, top: "45%", flexDirection: "row", gap: 6, alignItems: "center", justifyContent: "center", backgroundColor: FIXED.white, borderRadius: 20, paddingVertical: 8 },
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/apps/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,19 @@ function PendingNote() {
}

function CameraPage({ back }: { back: () => void }) {
const local = settings.use();
const { layout } = useLayout();
const own = ownLayouts.use();
const { c } = useTheme();
const look = layout.body.look, opts = layout.body.options;
const edit = (p: Parameters<typeof editLayout>[1]) => editLayout(layout.id, p);
return (
<Screen header={<Header title="Camera" sub="The layout on this device, and your preferences" onBack={back} />}>
<Block>
<SectionLabel>Buttons on this device</SectionLabel>
<Seg accessibilityLabel="Camera button size" block value={local.cameraButtons ?? "m"} onChange={(v) => setSettings({ cameraButtons: v })} options={[{ id: "s", label: "Small" }, { id: "m", label: "Medium" }, { id: "l", label: "Large" }]} />
<Hint>The size of the camera's buttons and shutter here only: small suits a phone, large a tablet.</Hint>
</Block>
<Block><SectionLabel>Camera layout on this device</SectionLabel></Block>
{allLayouts().map((l) => <ListRow key={l.id} icon={l.builtin ? "lock" : "camera-layout"} title={l.name} meta={l.builtin ? "Built in" : undefined} selected={layout.id === l.id} trailing={null} onPress={() => chooseLayout(l.id)} />)}
<Block><Hint>{own.length ? "" : "Layouts of your own are made in the Studio (Camera layouts). "}Which controls a layout shows, and where, is arranged in the Studio; its look and options can be changed here too.</Hint></Block>
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ export interface LocalSettings {
/** Keep the active project's thumbnails and previews on the phone (Media without a connection). */
keepProject: boolean;
logging: boolean;
/** How large the camera's buttons are on this device (#426): small on a phone, large on a tablet. */
cameraButtons?: CameraButtonSize;
}
export type CameraButtonSize = "s" | "m" | "l";
/** The camera's button sizes (dp): the button, its icon, the shutter. */
export const CAMERA_BUTTONS: Record<CameraButtonSize, { size: number; icon: number; shutter: number }> = {
s: { size: 40, icon: 18, shutter: 64 },
m: { size: 48, icon: 22, shutter: 76 },
l: { size: 60, icon: 28, shutter: 92 },
};

export const settings = persisted<LocalSettings>("settings.v2", { offlineMode: false, keepProject: false, logging: false });
/** This device's camera button sizes. */
export const useCameraButtons = () => CAMERA_BUTTONS[settings.use().cameraButtons ?? "m"];

export function setSettings(change: Partial<LocalSettings>) {
settings.set((s) => ({ ...s, ...change }));
Expand Down
2 changes: 1 addition & 1 deletion docs/features/capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The phone takes photos. A capture is one photo: queued at once, visible in Media
- **Real lenses only** ([phone app](phone-app.md#this-device-srcdevicets-srclensests)): a lens is opened as the logical camera at the lens's zoom, or as a camera of its own. No digital zoom, so every photo is the full picture of one real lens and its EXIF describes it. A phone with one lens shows no lens rail.
- **Lens names**: as the phone calls them (0.5×, 1×, 5×), or by the reported full-frame focal length (Setup, Camera; the account's preference).
- **Built-in layout**: held upright, the lens rail above the control row; in landscape the control row stands at the right (beside the tab bar), the lens rail at the far left. Control row: uploads (count, red when something is stuck; opens Setup, Uploads), the last photo (opens it in Media), the shutter, the torch (filled when on). A strip over the picture names the project and the lens in use.
- Camera buttons are outlined when off and filled in the accent colour when on.
- Camera buttons are black with a white outline and a white icon when off, so they read over any picture, and filled in the accent colour when on (#426). Their size (with the shutter and the last-photo thumbnail) is chosen per device in Setup › Camera: small (40 dp), medium (48), large (60), kept in this device's settings (`cameraButtons`).

## What a capture produces (`src/media/pipeline.ts`)

Expand Down
Loading