@vvedantb/native-ui 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/AmbientBackground.jsx +16 -28
- package/dist/Avatar.jsx +2 -2
- package/dist/BottomSheetContainer.jsx +1 -1
- package/dist/BulkActionBar.jsx +1 -1
- package/dist/Card.jsx +4 -4
- package/dist/Chip.jsx +2 -2
- package/dist/DateTimeField.jsx +1 -1
- package/dist/Dialog.jsx +3 -3
- package/dist/DropdownMenu.jsx +3 -3
- package/dist/EmptyState.jsx +4 -4
- package/dist/FloatingTabBar.jsx +2 -2
- package/dist/LabeledSwitchRow.jsx +2 -2
- package/dist/ListRow.jsx +2 -2
- package/dist/PinnedBotTile.jsx +2 -2
- package/dist/StatGrid.jsx +1 -1
- package/dist/Stepper.jsx +2 -2
- package/dist/Toast.jsx +1 -1
- package/dist/ai/activity-question.jsx +2 -2
- package/dist/ai/card-button.jsx +2 -2
- package/dist/ai/choice-question.jsx +8 -8
- package/dist/ai/message-action-sheet.jsx +2 -2
- package/dist/ai/message-quote.jsx +2 -2
- package/dist/ai/message.jsx +2 -2
- package/dist/ai/reply-quote-chip.jsx +2 -2
- package/dist/ai/subagent-cards.jsx +6 -6
- package/dist/ai/tool-approval-card.jsx +1 -1
- package/dist/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +252 -74
- package/dist/auth/SecondFactorScreen.jsx +18 -12
- package/dist/auth/SignInScreen.jsx +40 -17
- package/dist/crash/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +213 -0
- package/dist/entries/app-root.js +6 -0
- package/dist/entries/crash.js +5 -0
- package/dist/entries/theme.js +3 -0
- package/dist/examples/ParityGallery.jsx +2 -2
- package/dist/generative-ui/components.jsx +2 -2
- package/dist/index.js +3 -0
- package/dist/marketing/UpgradeToProCard.jsx +2 -2
- package/dist/media/ImageGallery.jsx +2 -2
- package/dist/motion.js +3 -2
- package/dist/neutralTheme.js +163 -0
- package/dist/primitives/card.jsx +2 -2
- package/dist/primitives/icon.jsx +0 -4
- package/dist/primitives/select.jsx +0 -2
- package/dist/primitives/text.jsx +13 -13
- package/dist/primitives/toast-drag-gesture.jsx +3 -2
- package/dist/settings/MoreFromProjectV.jsx +2 -2
- package/dist/settings/SettingsSection.jsx +1 -1
- package/dist/settings/ThemeModePicker.jsx +8 -11
- package/dist/themeModeStore.js +67 -0
- package/dist/themeModes.js +9 -0
- package/package.json +47 -19
- package/src/AmbientBackground.tsx +8 -26
- package/src/Avatar.tsx +2 -2
- package/src/BottomSheetContainer.tsx +1 -1
- package/src/BulkActionBar.tsx +2 -2
- package/src/Card.tsx +5 -5
- package/src/Chip.tsx +2 -2
- package/src/DateTimeField.tsx +2 -2
- package/src/Dialog.tsx +3 -3
- package/src/DropdownMenu.tsx +3 -3
- package/src/EmptyState.tsx +4 -4
- package/src/FloatingTabBar.tsx +2 -2
- package/src/LabeledSwitchRow.tsx +2 -2
- package/src/ListRow.tsx +2 -2
- package/src/PinnedBotTile.tsx +2 -2
- package/src/StatGrid.tsx +2 -2
- package/src/Stepper.tsx +2 -2
- package/src/Toast.tsx +2 -2
- package/src/ai/activity-question.tsx +1 -1
- package/src/ai/card-button.tsx +1 -1
- package/src/ai/choice-question.tsx +10 -10
- package/src/ai/message-action-sheet.tsx +2 -2
- package/src/ai/message-quote.tsx +2 -2
- package/src/ai/message.tsx +2 -2
- package/src/ai/reply-quote-chip.tsx +2 -2
- package/src/ai/subagent-cards.tsx +5 -5
- package/src/ai/tool-approval-card.tsx +4 -4
- package/src/app-root/AuthGroupGate.tsx +46 -0
- package/src/app-root/SsoCallbackScreen.tsx +62 -0
- package/src/app-root/fonts.ts +55 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AuthScreen.tsx +104 -3
- package/src/auth/SecondFactorScreen.tsx +20 -2
- package/src/auth/SignInScreen.tsx +119 -53
- package/src/crash/LastCrashDialog.tsx +42 -0
- package/src/crash/lastCrash.ts +239 -0
- package/src/entries/app-root.ts +6 -0
- package/src/entries/crash.ts +16 -0
- package/src/entries/theme.ts +6 -0
- package/src/examples/ParityGallery.tsx +2 -2
- package/src/generative-ui/components.tsx +3 -3
- package/src/highlight.ts +1 -1
- package/src/index.ts +5 -0
- package/src/marketing/UpgradeToProCard.tsx +2 -2
- package/src/media/ImageGallery.tsx +1 -1
- package/src/motion.ts +3 -2
- package/src/neutralTheme.ts +130 -0
- package/src/primitives/card.tsx +3 -3
- package/src/primitives/icon.tsx +0 -2
- package/src/primitives/select.tsx +0 -2
- package/src/primitives/text.tsx +13 -13
- package/src/primitives/toast-drag-gesture.tsx +2 -2
- package/src/settings/MoreFromProjectV.tsx +2 -2
- package/src/settings/SettingsSection.tsx +3 -3
- package/src/settings/ThemeModePicker.tsx +11 -19
- package/src/themeModeStore.ts +94 -0
- package/src/themeModes.ts +10 -0
- package/types/prism-react-renderer.d.ts +22 -0
|
@@ -89,8 +89,8 @@ export function ChoiceQuestion({
|
|
|
89
89
|
text
|
|
90
90
|
) : (
|
|
91
91
|
<Text
|
|
92
|
-
className={`${buttonText} font-instrument-sans-
|
|
93
|
-
style={[sizeStyle(buttonText), typeStyle("
|
|
92
|
+
className={`${buttonText} font-instrument-sans-medium`}
|
|
93
|
+
style={[sizeStyle(buttonText), typeStyle("medium"), { color: buttonColors(variant, scheme)?.color }]}
|
|
94
94
|
>
|
|
95
95
|
{text}
|
|
96
96
|
</Text>
|
|
@@ -127,9 +127,9 @@ export function ChoiceQuestion({
|
|
|
127
127
|
<View style={{ gap: 16 }}>
|
|
128
128
|
<View className="flex-row items-center justify-between" style={{ gap: 8 }}>
|
|
129
129
|
<Text
|
|
130
|
-
className="flex-1 font-instrument-sans-
|
|
130
|
+
className="flex-1 font-instrument-sans-medium"
|
|
131
131
|
// Web `text-[15px] leading-snug` (15 / 20.625); larger text steps up to 18.
|
|
132
|
-
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("
|
|
132
|
+
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("medium")]}
|
|
133
133
|
>
|
|
134
134
|
{question.question}
|
|
135
135
|
</Text>
|
|
@@ -229,7 +229,7 @@ export function ChoiceQuestion({
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* The question's topic, the web `Badge variant="secondary"` with Eva's
|
|
232
|
-
* `text-3xs font-
|
|
232
|
+
* `text-3xs font-medium` (10 / 14, 600) in a `px-2.5 py-0.5` pill. Drawn here
|
|
233
233
|
* because `Badge` sets its own size and weight.
|
|
234
234
|
*/
|
|
235
235
|
export function TopicBadge({ children }: { children: string }) {
|
|
@@ -243,10 +243,10 @@ export function TopicBadge({ children }: { children: string }) {
|
|
|
243
243
|
>
|
|
244
244
|
<Text
|
|
245
245
|
numberOfLines={1}
|
|
246
|
-
className="font-instrument-sans-
|
|
246
|
+
className="font-instrument-sans-medium"
|
|
247
247
|
style={[
|
|
248
248
|
{ fontSize, lineHeight: largerText ? 20 : 14, color: palette.defaultForeground[scheme] },
|
|
249
|
-
typeStyle("
|
|
249
|
+
typeStyle("medium"),
|
|
250
250
|
]}
|
|
251
251
|
>
|
|
252
252
|
{children}
|
|
@@ -373,13 +373,13 @@ function ChoiceRow({
|
|
|
373
373
|
) : mark === "other" ? (
|
|
374
374
|
<IconPencil size={glyph} color={muted} />
|
|
375
375
|
) : (
|
|
376
|
-
// Web `text-2xs font-
|
|
376
|
+
// Web `text-2xs font-medium tracking-wide`, at semibold: native-ui draws no bold face.
|
|
377
377
|
<Text
|
|
378
|
-
className="font-instrument-sans-
|
|
378
|
+
className="font-instrument-sans-medium"
|
|
379
379
|
style={[
|
|
380
380
|
{ fontSize: markText, lineHeight: largerText ? 20 : 16, color: muted },
|
|
381
381
|
trackingStyle(markText, "wide"),
|
|
382
|
-
typeStyle("
|
|
382
|
+
typeStyle("medium"),
|
|
383
383
|
]}
|
|
384
384
|
>
|
|
385
385
|
{mark}
|
|
@@ -149,8 +149,8 @@ export function MessageActionSheet({
|
|
|
149
149
|
}}
|
|
150
150
|
>
|
|
151
151
|
<Text
|
|
152
|
-
className={cn(body, "font-instrument-sans-
|
|
153
|
-
style={[sizeStyle(body), typeStyle("
|
|
152
|
+
className={cn(body, "font-instrument-sans-medium")}
|
|
153
|
+
style={[sizeStyle(body), typeStyle("medium"), textStyle("foreground", scheme)]}
|
|
154
154
|
>
|
|
155
155
|
{cancelLabel}
|
|
156
156
|
</Text>
|
package/src/ai/message-quote.tsx
CHANGED
|
@@ -49,8 +49,8 @@ export function MessageQuote({
|
|
|
49
49
|
<>
|
|
50
50
|
<Text
|
|
51
51
|
numberOfLines={1}
|
|
52
|
-
className={cn(caption, "font-instrument-sans-
|
|
53
|
-
style={[sizeStyle(caption), typeStyle("
|
|
52
|
+
className={cn(caption, "font-instrument-sans-medium")}
|
|
53
|
+
style={[sizeStyle(caption), typeStyle("medium"), { color: withAlpha(color, 0.75) }]}
|
|
54
54
|
>
|
|
55
55
|
{author}
|
|
56
56
|
</Text>
|
package/src/ai/message.tsx
CHANGED
|
@@ -287,8 +287,8 @@ export function MessageBotLabel({ name, avatar, className, testID = "message-bot
|
|
|
287
287
|
{avatar}
|
|
288
288
|
<Text
|
|
289
289
|
numberOfLines={1}
|
|
290
|
-
className={cn(size, "font-instrument-sans-
|
|
291
|
-
style={[sizeStyle(size), typeStyle("
|
|
290
|
+
className={cn(size, "font-instrument-sans-medium")}
|
|
291
|
+
style={[sizeStyle(size), typeStyle("medium"), { color: tokens.color.muted[scheme] }]}
|
|
292
292
|
>
|
|
293
293
|
{name}
|
|
294
294
|
</Text>
|
|
@@ -61,8 +61,8 @@ export function ReplyQuoteChip({
|
|
|
61
61
|
<View className="min-w-0 flex-1 py-2">
|
|
62
62
|
<Text
|
|
63
63
|
numberOfLines={1}
|
|
64
|
-
className={cn(caption, "font-instrument-sans-
|
|
65
|
-
style={[sizeStyle(caption), typeStyle("
|
|
64
|
+
className={cn(caption, "font-instrument-sans-medium")}
|
|
65
|
+
style={[sizeStyle(caption), typeStyle("medium"), textStyle("muted", scheme)]}
|
|
66
66
|
>
|
|
67
67
|
{author}
|
|
68
68
|
</Text>
|
|
@@ -56,7 +56,7 @@ function StatusPill({ status, testID }: { status: SubagentStatus; testID: string
|
|
|
56
56
|
className="rounded-full border px-2.5 py-0.5"
|
|
57
57
|
style={{ borderColor: colors.borderColor, backgroundColor: colors.backgroundColor }}
|
|
58
58
|
>
|
|
59
|
-
<Text className={cn(caption, "font-instrument-sans-
|
|
59
|
+
<Text className={cn(caption, "font-instrument-sans-medium")} style={[sizeStyle(caption), typeStyle("medium"), { color: colors.color }]}>
|
|
60
60
|
{STATUS_LABEL[status]}
|
|
61
61
|
</Text>
|
|
62
62
|
</View>
|
|
@@ -114,8 +114,8 @@ export function SubagentRunCard({
|
|
|
114
114
|
)}
|
|
115
115
|
<Text
|
|
116
116
|
numberOfLines={2}
|
|
117
|
-
className={cn(body, "min-w-0 flex-1 font-instrument-sans-
|
|
118
|
-
style={[sizeStyle(body), typeStyle("
|
|
117
|
+
className={cn(body, "min-w-0 flex-1 font-instrument-sans-medium")}
|
|
118
|
+
style={[sizeStyle(body), typeStyle("medium"), textStyle("foreground", scheme)]}
|
|
119
119
|
>
|
|
120
120
|
{title}
|
|
121
121
|
</Text>
|
|
@@ -218,8 +218,8 @@ export function SubagentResultCard({
|
|
|
218
218
|
{avatar}
|
|
219
219
|
<Text
|
|
220
220
|
numberOfLines={2}
|
|
221
|
-
className={cn(body, "min-w-0 flex-1 font-instrument-sans-
|
|
222
|
-
style={[sizeStyle(body), typeStyle("
|
|
221
|
+
className={cn(body, "min-w-0 flex-1 font-instrument-sans-medium")}
|
|
222
|
+
style={[sizeStyle(body), typeStyle("medium"), textStyle("foreground", scheme)]}
|
|
223
223
|
>
|
|
224
224
|
{title}
|
|
225
225
|
</Text>
|
|
@@ -157,8 +157,8 @@ function ToolCardBase({
|
|
|
157
157
|
<View className="flex-row items-center gap-2">
|
|
158
158
|
<IconTool size={largerText ? 20 : 16} color={tokens.color.muted[scheme]} />
|
|
159
159
|
<Text
|
|
160
|
-
className={cn(caption, "font-instrument-sans-
|
|
161
|
-
style={[sizeStyle(caption), typeStyle("
|
|
160
|
+
className={cn(caption, "font-instrument-sans-medium")}
|
|
161
|
+
style={[sizeStyle(caption), typeStyle("medium"), textStyle("muted", scheme)]}
|
|
162
162
|
>
|
|
163
163
|
{pending ? "Sending decision…" : heading}
|
|
164
164
|
</Text>
|
|
@@ -174,8 +174,8 @@ function ToolCardBase({
|
|
|
174
174
|
<Text
|
|
175
175
|
testID={`${testID}-name`}
|
|
176
176
|
numberOfLines={2}
|
|
177
|
-
className={cn(body, "font-instrument-sans-
|
|
178
|
-
style={[sizeStyle(body), typeStyle("
|
|
177
|
+
className={cn(body, "font-instrument-sans-medium")}
|
|
178
|
+
style={[sizeStyle(body), typeStyle("medium"), textStyle("foreground", scheme)]}
|
|
179
179
|
>
|
|
180
180
|
{toolName}
|
|
181
181
|
</Text>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useAuth } from "@clerk/expo";
|
|
2
|
+
import { Redirect, type Href } from "expo-router";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export type AuthGroupGateProps = {
|
|
6
|
+
/** The auth stack, shown when nothing redirects. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Wait for Clerk to load before anything else. Default `true`. */
|
|
9
|
+
waitForLoaded?: boolean;
|
|
10
|
+
/** Shown while waiting. Default: nothing. */
|
|
11
|
+
loading?: ReactNode;
|
|
12
|
+
/** Passed to `useAuth`. Unset keeps Clerk's own default. */
|
|
13
|
+
treatPendingAsSignedOut?: boolean;
|
|
14
|
+
/** Where a signed-in user goes. Default `/`. */
|
|
15
|
+
signedInHref?: Href;
|
|
16
|
+
/** `Redirect` `withAnchor`, for apps that open a tab group under the target. */
|
|
17
|
+
withAnchor?: boolean;
|
|
18
|
+
/** Leave signed-in users on the auth screens, for UI preview builds. */
|
|
19
|
+
skipSignedInRedirect?: boolean;
|
|
20
|
+
/** Where a signed-out user goes instead of the auth screens, for UI preview builds. */
|
|
21
|
+
previewHref?: Href;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The layout of an `(auth)` route group: waits for Clerk when asked, sends signed-in
|
|
26
|
+
* users on, and renders the auth stack otherwise. The app passes its own loading UI.
|
|
27
|
+
*/
|
|
28
|
+
export function AuthGroupGate({
|
|
29
|
+
children,
|
|
30
|
+
waitForLoaded = true,
|
|
31
|
+
loading = null,
|
|
32
|
+
treatPendingAsSignedOut,
|
|
33
|
+
signedInHref = "/",
|
|
34
|
+
withAnchor,
|
|
35
|
+
skipSignedInRedirect = false,
|
|
36
|
+
previewHref,
|
|
37
|
+
}: AuthGroupGateProps) {
|
|
38
|
+
const { isSignedIn, isLoaded } = useAuth(
|
|
39
|
+
treatPendingAsSignedOut === undefined ? undefined : { treatPendingAsSignedOut },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (waitForLoaded && !isLoaded) return loading;
|
|
43
|
+
if (isSignedIn && !skipSignedInRedirect) return <Redirect href={signedInHref} withAnchor={withAnchor} />;
|
|
44
|
+
if (previewHref) return <Redirect href={previewHref} />;
|
|
45
|
+
return children;
|
|
46
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useAuth } from "@clerk/expo";
|
|
2
|
+
import { Redirect, useRouter, type Href } from "expo-router";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import { Button } from "../Button";
|
|
6
|
+
import { CenteredSpinner } from "../Spinner";
|
|
7
|
+
|
|
8
|
+
export type SsoCallbackScreenProps = {
|
|
9
|
+
/** Where a signed-in user goes. Default `/`. */
|
|
10
|
+
signedInHref?: Href;
|
|
11
|
+
/** Where a signed-out user goes, or where the back button goes. Default `/sign-in`. */
|
|
12
|
+
signedOutHref?: Href;
|
|
13
|
+
/** `Redirect` `withAnchor` for the signed-in redirect. */
|
|
14
|
+
withAnchor?: boolean;
|
|
15
|
+
/** Passed to `useAuth`. Unset keeps Clerk's own default. */
|
|
16
|
+
treatPendingAsSignedOut?: boolean;
|
|
17
|
+
/** The waiting UI. Default: a centred spinner labelled "Signing in". */
|
|
18
|
+
loading?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Label of a ghost back button. When set, the screen stays on the waiting UI for a
|
|
21
|
+
* signed-out user and the button goes to `signedOutHref`. Unset: it redirects there.
|
|
22
|
+
*/
|
|
23
|
+
backLabel?: string;
|
|
24
|
+
/** Class of the view around `loading` and the back button. */
|
|
25
|
+
className?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const DEFAULT_LOADING = <CenteredSpinner label="Signing in" />;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The `sso-callback` route of the Google sign-in redirect. `useSSO` completes the
|
|
32
|
+
* session; this screen only waits for it, then opens the app.
|
|
33
|
+
*/
|
|
34
|
+
export function SsoCallbackScreen({
|
|
35
|
+
signedInHref = "/",
|
|
36
|
+
signedOutHref = "/sign-in",
|
|
37
|
+
withAnchor,
|
|
38
|
+
treatPendingAsSignedOut,
|
|
39
|
+
loading = DEFAULT_LOADING,
|
|
40
|
+
backLabel,
|
|
41
|
+
className = "flex-1 items-center justify-center gap-6 px-6",
|
|
42
|
+
}: SsoCallbackScreenProps) {
|
|
43
|
+
const { isLoaded, isSignedIn } = useAuth(
|
|
44
|
+
treatPendingAsSignedOut === undefined ? undefined : { treatPendingAsSignedOut },
|
|
45
|
+
);
|
|
46
|
+
const router = useRouter();
|
|
47
|
+
|
|
48
|
+
if (isLoaded && isSignedIn) return <Redirect href={signedInHref} withAnchor={withAnchor} />;
|
|
49
|
+
|
|
50
|
+
if (backLabel === undefined) {
|
|
51
|
+
return isLoaded ? <Redirect href={signedOutHref} /> : loading;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View className={className}>
|
|
56
|
+
{loading}
|
|
57
|
+
<Button variant="ghost" fullWidth={false} onPress={() => router.replace(signedOutHref)}>
|
|
58
|
+
{backLabel}
|
|
59
|
+
</Button>
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { InstrumentSans_400Regular } from "@expo-google-fonts/instrument-sans/400Regular";
|
|
2
|
+
import { InstrumentSans_500Medium } from "@expo-google-fonts/instrument-sans/500Medium";
|
|
3
|
+
import { InstrumentSans_600SemiBold } from "@expo-google-fonts/instrument-sans/600SemiBold";
|
|
4
|
+
import { InstrumentSans_700Bold } from "@expo-google-fonts/instrument-sans/700Bold";
|
|
5
|
+
import { InstrumentSans_400Regular_Italic } from "@expo-google-fonts/instrument-sans/400Regular_Italic";
|
|
6
|
+
import { InstrumentSans_500Medium_Italic } from "@expo-google-fonts/instrument-sans/500Medium_Italic";
|
|
7
|
+
import { InstrumentSans_600SemiBold_Italic } from "@expo-google-fonts/instrument-sans/600SemiBold_Italic";
|
|
8
|
+
import { InstrumentSans_700Bold_Italic } from "@expo-google-fonts/instrument-sans/700Bold_Italic";
|
|
9
|
+
import { useFonts } from "expo-font";
|
|
10
|
+
import * as SplashScreen from "expo-splash-screen";
|
|
11
|
+
import { useEffect } from "react";
|
|
12
|
+
|
|
13
|
+
/** The font sources `useFonts` takes: family name to module. */
|
|
14
|
+
export type FontMap = Record<string, number>;
|
|
15
|
+
|
|
16
|
+
export type InstrumentSansOptions = {
|
|
17
|
+
/** Also load the four italic weights. Default `false` (upright only). */
|
|
18
|
+
italics?: boolean;
|
|
19
|
+
/** More fonts to load with it, for example Michroma. */
|
|
20
|
+
extra?: FontMap;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const UPRIGHT: FontMap = {
|
|
24
|
+
InstrumentSans_400Regular,
|
|
25
|
+
InstrumentSans_500Medium,
|
|
26
|
+
InstrumentSans_600SemiBold,
|
|
27
|
+
InstrumentSans_700Bold,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const ITALIC: FontMap = {
|
|
31
|
+
InstrumentSans_400Regular_Italic,
|
|
32
|
+
InstrumentSans_500Medium_Italic,
|
|
33
|
+
InstrumentSans_600SemiBold_Italic,
|
|
34
|
+
InstrumentSans_700Bold_Italic,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** The Instrument Sans fonts the `font-instrument-sans*` classes use, plus any `extra`. */
|
|
38
|
+
export function instrumentSansFontMap({ italics = false, extra }: InstrumentSansOptions = {}): FontMap {
|
|
39
|
+
return { ...extra, ...UPRIGHT, ...(italics ? ITALIC : undefined) };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `[loaded, error]` as `useFonts` returns them, for the Instrument Sans map. */
|
|
43
|
+
export function useInstrumentSansFonts(options: InstrumentSansOptions = {}) {
|
|
44
|
+
return useFonts(instrumentSansFontMap(options));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Hides the native splash once `ready` is true. Call `SplashScreen.preventAutoHideAsync()`
|
|
49
|
+
* at module load in the app, so the call site keeps the timing. A failed hide is ignored.
|
|
50
|
+
*/
|
|
51
|
+
export function useHideSplashWhenReady(ready: boolean) {
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (ready) void SplashScreen.hideAsync().catch(() => {});
|
|
54
|
+
}, [ready]);
|
|
55
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { instrumentSansFontMap, useInstrumentSansFonts, useHideSplashWhenReady } from "./fonts";
|
|
2
|
+
export type { FontMap, InstrumentSansOptions } from "./fonts";
|
|
3
|
+
export { AuthGroupGate } from "./AuthGroupGate";
|
|
4
|
+
export type { AuthGroupGateProps } from "./AuthGroupGate";
|
|
5
|
+
export { SsoCallbackScreen } from "./SsoCallbackScreen";
|
|
6
|
+
export type { SsoCallbackScreenProps } from "./SsoCallbackScreen";
|
package/src/auth/AuthScreen.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState, type ReactNode } from "react";
|
|
2
2
|
import { Keyboard, KeyboardAvoidingView, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
4
|
import { cn } from "../cn";
|
|
4
5
|
import { textStyle, typeStyle } from "../controlStyles";
|
|
6
|
+
import { floatingShadow } from "../floating";
|
|
5
7
|
import { palette } from "../palette";
|
|
6
8
|
import { tokens } from "../tokens";
|
|
7
9
|
import { useScheme } from "../useScheme";
|
|
@@ -16,8 +18,20 @@ export type AuthScreenProps = {
|
|
|
16
18
|
footer?: ReactNode;
|
|
17
19
|
testID?: string;
|
|
18
20
|
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Default `"default"`: the centred column. `"hero"`: a coloured band with the
|
|
23
|
+
* header, title and subtitle, over a rounded sheet that holds the form.
|
|
24
|
+
*/
|
|
25
|
+
variant?: "default" | "hero";
|
|
26
|
+
/** The hero band and screen colour. Only used with `variant="hero"`. Default `"#db2777"`. */
|
|
27
|
+
heroColor?: string;
|
|
28
|
+
/** The hero title and subtitle colour. Only used with `variant="hero"`. Default `"#ffffff"`. */
|
|
29
|
+
heroForeground?: string;
|
|
19
30
|
};
|
|
20
31
|
|
|
32
|
+
const DEFAULT_HERO_COLOR = "#db2777";
|
|
33
|
+
const DEFAULT_HERO_FOREGROUND = "#ffffff";
|
|
34
|
+
|
|
21
35
|
/** Space under the form while the keyboard is open, on top of its height. */
|
|
22
36
|
const KEYBOARD_EXTRA = 24;
|
|
23
37
|
|
|
@@ -45,10 +59,37 @@ function useKeyboardHeight(): number {
|
|
|
45
59
|
* the scroll content gains the keyboard height as bottom space, so the focused
|
|
46
60
|
* field and the submit button scroll above the keyboard.
|
|
47
61
|
*/
|
|
48
|
-
export function AuthScreen({
|
|
62
|
+
export function AuthScreen({
|
|
63
|
+
title,
|
|
64
|
+
subtitle,
|
|
65
|
+
children,
|
|
66
|
+
header,
|
|
67
|
+
footer,
|
|
68
|
+
testID,
|
|
69
|
+
className,
|
|
70
|
+
variant = "default",
|
|
71
|
+
heroColor,
|
|
72
|
+
heroForeground,
|
|
73
|
+
}: AuthScreenProps) {
|
|
49
74
|
const scheme = useScheme();
|
|
50
75
|
const keyboardHeight = useKeyboardHeight();
|
|
51
76
|
const keyboardOpen = keyboardHeight > 0;
|
|
77
|
+
if (variant === "hero") {
|
|
78
|
+
return (
|
|
79
|
+
<HeroAuthScreen
|
|
80
|
+
title={title}
|
|
81
|
+
subtitle={subtitle}
|
|
82
|
+
header={header}
|
|
83
|
+
footer={footer}
|
|
84
|
+
testID={testID}
|
|
85
|
+
className={className}
|
|
86
|
+
heroColor={heroColor ?? DEFAULT_HERO_COLOR}
|
|
87
|
+
heroForeground={heroForeground ?? DEFAULT_HERO_FOREGROUND}
|
|
88
|
+
>
|
|
89
|
+
{children}
|
|
90
|
+
</HeroAuthScreen>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
52
93
|
return (
|
|
53
94
|
<KeyboardAvoidingView
|
|
54
95
|
// Padding on both platforms, as OverlayModal and PromptInput: Android `height` does nothing edge-to-edge.
|
|
@@ -69,8 +110,8 @@ export function AuthScreen({ title, subtitle, children, header, footer, testID,
|
|
|
69
110
|
<View className="gap-2">
|
|
70
111
|
<Text
|
|
71
112
|
accessibilityRole="header"
|
|
72
|
-
className="font-instrument-sans-
|
|
73
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
113
|
+
className="font-instrument-sans-medium text-2xl"
|
|
114
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
74
115
|
>
|
|
75
116
|
{title}
|
|
76
117
|
</Text>
|
|
@@ -88,6 +129,66 @@ export function AuthScreen({ title, subtitle, children, header, footer, testID,
|
|
|
88
129
|
);
|
|
89
130
|
}
|
|
90
131
|
|
|
132
|
+
type HeroAuthScreenProps = Omit<AuthScreenProps, "variant" | "heroColor" | "heroForeground"> & {
|
|
133
|
+
heroColor: string;
|
|
134
|
+
heroForeground: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/** The `variant="hero"` frame. Separate so only the hero reads the safe-area insets. */
|
|
138
|
+
function HeroAuthScreen({
|
|
139
|
+
title,
|
|
140
|
+
subtitle,
|
|
141
|
+
children,
|
|
142
|
+
header,
|
|
143
|
+
footer,
|
|
144
|
+
testID,
|
|
145
|
+
className,
|
|
146
|
+
heroColor,
|
|
147
|
+
heroForeground,
|
|
148
|
+
}: HeroAuthScreenProps) {
|
|
149
|
+
const scheme = useScheme();
|
|
150
|
+
const insets = useSafeAreaInsets();
|
|
151
|
+
return (
|
|
152
|
+
<KeyboardAvoidingView behavior="padding" className="flex-1" style={{ backgroundColor: heroColor }}>
|
|
153
|
+
<ScrollView
|
|
154
|
+
testID={testID}
|
|
155
|
+
className="flex-1"
|
|
156
|
+
contentContainerClassName="grow"
|
|
157
|
+
keyboardShouldPersistTaps="handled"
|
|
158
|
+
keyboardDismissMode="on-drag"
|
|
159
|
+
>
|
|
160
|
+
<View className="px-6 pb-6" style={{ paddingTop: insets.top + 24 }}>
|
|
161
|
+
{header}
|
|
162
|
+
<Text
|
|
163
|
+
accessibilityRole="header"
|
|
164
|
+
className="mt-10 mb-1 text-4xl font-instrument-sans-medium"
|
|
165
|
+
style={{ color: heroForeground }}
|
|
166
|
+
>
|
|
167
|
+
{title}
|
|
168
|
+
</Text>
|
|
169
|
+
{subtitle ? (
|
|
170
|
+
<Text className="text-lg font-instrument-sans-medium" style={{ color: heroForeground }}>
|
|
171
|
+
{subtitle}
|
|
172
|
+
</Text>
|
|
173
|
+
) : null}
|
|
174
|
+
</View>
|
|
175
|
+
<View
|
|
176
|
+
className={cn("grow rounded-t-[32px] px-6 pt-8", className)}
|
|
177
|
+
style={[
|
|
178
|
+
{ backgroundColor: tokens.color.surface[scheme], paddingBottom: insets.bottom + 24 },
|
|
179
|
+
floatingShadow,
|
|
180
|
+
]}
|
|
181
|
+
>
|
|
182
|
+
<View className="gap-4">{children}</View>
|
|
183
|
+
{footer ? (
|
|
184
|
+
<View className="mt-6 flex-row flex-wrap items-center justify-center gap-1">{footer}</View>
|
|
185
|
+
) : null}
|
|
186
|
+
</View>
|
|
187
|
+
</ScrollView>
|
|
188
|
+
</KeyboardAvoidingView>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
91
192
|
/** A separator, "or", a separator: between Google and the email fields. */
|
|
92
193
|
export function OrDivider({ label = "or" }: { label?: string }) {
|
|
93
194
|
const scheme = useScheme();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useState, type ReactNode } from "react";
|
|
4
4
|
import { Button } from "../Button";
|
|
5
5
|
import { Input } from "../Input";
|
|
6
|
-
import { AuthScreen, FieldError } from "./AuthScreen";
|
|
6
|
+
import { AuthScreen, FieldError, type AuthScreenProps } from "./AuthScreen";
|
|
7
7
|
|
|
8
8
|
export type SecondFactorScreenProps = {
|
|
9
9
|
title: string;
|
|
@@ -30,6 +30,12 @@ export type SecondFactorScreenProps = {
|
|
|
30
30
|
digitsOnly?: boolean;
|
|
31
31
|
/** Placeholder when `digitsOnly` is `false`. Default "Code". */
|
|
32
32
|
placeholder?: string;
|
|
33
|
+
/** Passed to `AuthScreen`. Default `"default"`. */
|
|
34
|
+
variant?: AuthScreenProps["variant"];
|
|
35
|
+
/** Passed to `AuthScreen`. Used with `variant="hero"`. */
|
|
36
|
+
heroColor?: string;
|
|
37
|
+
/** Passed to `AuthScreen`. Used with `variant="hero"`. */
|
|
38
|
+
heroForeground?: string;
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
/** A one-time code step: digits only, a Verify button, an inline error and a back link. */
|
|
@@ -47,6 +53,9 @@ export function SecondFactorScreen({
|
|
|
47
53
|
footer,
|
|
48
54
|
digitsOnly = true,
|
|
49
55
|
placeholder,
|
|
56
|
+
variant,
|
|
57
|
+
heroColor,
|
|
58
|
+
heroForeground,
|
|
50
59
|
}: SecondFactorScreenProps) {
|
|
51
60
|
const [code, setCode] = useState("");
|
|
52
61
|
const ready = code.length === codeLength && !loading;
|
|
@@ -56,7 +65,16 @@ export function SecondFactorScreen({
|
|
|
56
65
|
};
|
|
57
66
|
|
|
58
67
|
return (
|
|
59
|
-
<AuthScreen
|
|
68
|
+
<AuthScreen
|
|
69
|
+
testID={`${testIDPrefix}-screen`}
|
|
70
|
+
title={title}
|
|
71
|
+
subtitle={description}
|
|
72
|
+
header={header}
|
|
73
|
+
footer={footer}
|
|
74
|
+
variant={variant}
|
|
75
|
+
heroColor={heroColor}
|
|
76
|
+
heroForeground={heroForeground}
|
|
77
|
+
>
|
|
60
78
|
<Input
|
|
61
79
|
testID={`${testIDPrefix}-code`}
|
|
62
80
|
accessibilityLabel="Verification code"
|