Skip to content
Draft
2 changes: 2 additions & 0 deletions apps/mobile/app/+native-intent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { isSharePath } from '../src/ui/share/share-path';
export async function redirectSystemPath({ path }: { path: string; initial: boolean }) {
if (isConnectOAuthCallback(path)) return null;
if (isSharePath(path)) return '/share';
const team = /^(?:deepseekbot:\/\/|\/)team\?(?:.*&)?i=([A-Za-z0-9_-]+)/u.exec(path);
if (team !== null) return `/pair/team?i=${team[1]}`;
const call = callLinkRedirect(
path,
__DEV__ && Application.applicationId?.endsWith('.dev') === true,
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ function RootNavigator() {
name="sign-in"
options={{ ...sheetScreenOptions(design, true), title: t.emailSignIn.title }}
/>
<Stack.Screen
name="member-pairing"
options={{ title: t.memberPairing.title, ...sheetScreenOptions(design, true) }}
/>
<Stack.Screen
name="host-connection"
options={{
Expand Down
21 changes: 21 additions & 0 deletions apps/mobile/app/host-connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ export default function HostConnectionScreen() {
return (
<SheetScreen onMount={mount}>
<SettingsForm header={header} testID="host-connection">
{host?.member ? (
<SettingsSection on={SHEET_GROUP}>
<SettingsRow
on={SHEET_GROUP}
icon="account"
title={t.memberPairing.signedInAs.replace('{name}', host.member.displayName)}
{...(host.member.username ? { detail: `@${host.member.username}` } : {})}
/>
<SettingsRow
on={SHEET_GROUP}
icon="qr"
testID="member-pair-another"
title={t.memberPairing.pairAnother}
detail={t.memberPairing.pairAnotherDetail}
disclosure
onPress={() =>
router.push({ pathname: '/member-pairing', params: { hostId: host.hostId } })
}
/>
</SettingsSection>
) : null}
{host && client ? (
<SettingsSection on={SHEET_GROUP} footer={copy.preferenceScope}>
{busy === 'preference' ? (
Expand Down
103 changes: 103 additions & 0 deletions apps/mobile/app/member-pairing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { useLocalSearchParams, useRouter } from 'expo-router';
import { useState } from 'react';
import { View } from 'react-native';
import Svg, { Path } from 'react-native-svg';

import { useHostSession } from '../src/host/host-session';
import { memberPairingOffer, type MemberPairingOffer } from '../src/host/team-client';
import { qrCode, radius, space } from '../src/ui/design/tokens';
import { useMounted } from '../src/ui/mounted';
import { Button } from '../src/ui/primitives/button';
import { SheetHeader } from '../src/ui/primitives/sheet-header';
import { SettingsForm, SettingsFormItem } from '../src/ui/primitives/settings-form';
import { SheetScreen } from '../src/ui/primitives/sheet-screen';
import { Text } from '../src/ui/primitives/text';
import { useStrings } from '../src/ui/strings';

const QR_SIZE = 220;

export default function MemberPairingScreen() {
const t = useStrings();
const copy = t.memberPairing;
const router = useRouter();
const { hostId } = useLocalSearchParams<{ hostId?: string }>();
const session = useHostSession(hostId);
const [offer, setOffer] = useState<MemberPairingOffer>();
const [failed, setFailed] = useState(false);
const [busy, setBusy] = useState(false);
const load = async (): Promise<void> => {
const client = session.client;
if (!client) return setFailed(true);
setBusy(true);
setFailed(false);
const result = await memberPairingOffer(client);
setBusy(false);
if (result.ok) setOffer(result.value);
else setFailed(true);
};
const mount = useMounted(() => {
void load();
return () => {};
}, [session.client]);
const expires =
offer === undefined
? ''
: new Date(offer.expiresAt).toLocaleTimeString(undefined, {
hour: '2-digit',
minute: '2-digit',
});
return (
<SheetScreen onMount={mount}>
<SettingsForm
header={<SheetHeader title={copy.title} onClose={() => router.back()} />}
testID="member-pairing"
>
<SettingsFormItem>
<View style={{ alignItems: 'center', gap: space.x4, paddingHorizontal: space.x5 }}>
<Text tone="muted" style={{ textAlign: 'center' }}>
{copy.hint}
</Text>
{offer ? (
<View
testID="member-pairing-qr"
accessible
accessibilityRole="image"
accessibilityLabel={copy.qrLabel}
style={{
padding: space.x4,
borderRadius: radius.md,
backgroundColor: qrCode.paper,
}}
>
<Svg
width={QR_SIZE}
height={QR_SIZE}
viewBox={`0 0 ${offer.qr.size} ${offer.qr.size}`}
>
<Path d={offer.qr.path} fill={qrCode.ink} />
</Svg>
</View>
) : null}
{offer ? (
<Text variant="meta" tone="muted">
{copy.expires.replace('{time}', expires)}
</Text>
) : null}
{failed ? (
<Text accessibilityRole="alert" tone="danger">
{copy.failed}
</Text>
) : null}
<Button
testID="member-pairing-refresh"
label={offer ? copy.refresh : t.retry}
busy={busy}
disabled={busy}
onPress={() => void load()}
/>
</View>
</SettingsFormItem>
</SettingsForm>
</SheetScreen>
);
}
1 change: 1 addition & 0 deletions apps/mobile/app/pair/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function PairLayout() {
<Stack.Screen name="index" options={{ title: t.pairTitle }} />
<Stack.Screen name="account" options={{ title: t.pairChoice.account }} />
<Stack.Screen name="tailscale" options={{ title: t.pairChoice.tailscale }} />
<Stack.Screen name="team" options={{ title: t.pairChoice.team }} />
</SheetStack>
);
}
9 changes: 9 additions & 0 deletions apps/mobile/app/pair/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ export default function PairChoiceScreen() {
})
}
/>
<SettingsRow
testID="pair-choice-team"
on={SHEET_GROUP}
title={t.pairChoice.team}
detail={t.pairChoice.teamDetail}
icon="account"
disclosure
onPress={() => router.push('/pair/team')}
/>
<SettingsRow
testID="pair-choice-account"
on={SHEET_GROUP}
Expand Down
Loading
Loading