create-astratra-app 1.2.0 → 1.4.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 +71 -0
- package/bin/create-astratra-app.js +9 -0
- package/package.json +3 -2
- package/src/bricks.js +437 -0
- package/src/createProject.js +99 -13
- package/templates/mobile/README.md +70 -0
- package/templates/mobile/app/_layout.tsx +58 -0
- package/templates/mobile/app/dashboard.tsx +73 -0
- package/templates/mobile/app/forgot-password.tsx +64 -0
- package/templates/mobile/app/home.tsx +32 -0
- package/templates/mobile/app/index.tsx +27 -0
- package/templates/mobile/app/login.tsx +118 -0
- package/templates/mobile/app/notifications.tsx +67 -0
- package/templates/mobile/app/onboarding/_layout.tsx +5 -0
- package/templates/mobile/app/onboarding/done.tsx +45 -0
- package/templates/mobile/app/onboarding/index.tsx +52 -0
- package/templates/mobile/app/settings.tsx +95 -0
- package/templates/mobile/app.config.js +37 -0
- package/templates/mobile/babel.config.js +17 -0
- package/templates/mobile/components/AnimatedPressable.tsx +34 -0
- package/templates/mobile/components/BrandBackground.tsx +33 -0
- package/templates/mobile/components/ErrorBoundary.tsx +28 -0
- package/templates/mobile/components/GlassPanel.tsx +67 -0
- package/templates/mobile/components/GridBackground.tsx +35 -0
- package/templates/mobile/components/KeyboardScreen.tsx +81 -0
- package/templates/mobile/components/PasswordEyeIcon.tsx +41 -0
- package/templates/mobile/components/SessionGuard.tsx +29 -0
- package/templates/mobile/components/dashboard/DashboardHeader.tsx +71 -0
- package/templates/mobile/components/dashboard/DashboardReveal.tsx +46 -0
- package/templates/mobile/components/dashboard/KpiBubble.tsx +169 -0
- package/templates/mobile/components/dashboard/MoreButton.tsx +65 -0
- package/templates/mobile/components/dashboard/NotificationBell.tsx +80 -0
- package/templates/mobile/components/dashboard/StaffTabBar.tsx +70 -0
- package/templates/mobile/components/dashboard/ToolCard.tsx +136 -0
- package/templates/mobile/components/glass/LiquidGlassSurface.tsx +266 -0
- package/templates/mobile/components/onboarding/StepScreen.tsx +185 -0
- package/templates/mobile/constants/dashboard.ts +50 -0
- package/templates/mobile/constants/theme.ts +104 -0
- package/templates/mobile/context/AuthContext.tsx +106 -0
- package/templates/mobile/eas.json +9 -0
- package/templates/mobile/env.example +2 -0
- package/templates/mobile/features/routes.ts +23 -0
- package/templates/mobile/gitignore +7 -0
- package/templates/mobile/i18n/config.ts +24 -0
- package/templates/mobile/i18n/locales/en.json +62 -0
- package/templates/mobile/i18n/locales/fr.json +62 -0
- package/templates/mobile/package.json +48 -0
- package/templates/mobile/services/push.ts +67 -0
- package/templates/mobile/services/session.ts +77 -0
- package/templates/mobile/tsconfig.json +8 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { Platform, StyleSheet, View, type ViewStyle } from "react-native";
|
|
3
|
+
import { BlurView } from "expo-blur";
|
|
4
|
+
import { GlassView, isGlassEffectAPIAvailable } from "expo-glass-effect";
|
|
5
|
+
import {
|
|
6
|
+
BackdropFilter,
|
|
7
|
+
Canvas,
|
|
8
|
+
Fill,
|
|
9
|
+
Group,
|
|
10
|
+
LinearGradient,
|
|
11
|
+
Path,
|
|
12
|
+
RadialGradient,
|
|
13
|
+
RoundedRect,
|
|
14
|
+
RuntimeShader,
|
|
15
|
+
Skia,
|
|
16
|
+
vec,
|
|
17
|
+
} from "@shopify/react-native-skia";
|
|
18
|
+
import type { SkRuntimeEffect } from "@shopify/react-native-skia";
|
|
19
|
+
import { colors } from "../../constants/theme";
|
|
20
|
+
|
|
21
|
+
export type LiquidGlassSurfaceProps = {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
cornerRadius?: number;
|
|
25
|
+
tintColor?: string;
|
|
26
|
+
tintOpacity?: number;
|
|
27
|
+
borderOpacity?: number;
|
|
28
|
+
refractionStrength?: number;
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
icon?: { path: string; size?: number; color?: string };
|
|
31
|
+
style?: ViewStyle;
|
|
32
|
+
nativeGlass?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const REFRACTION_SKSL = `
|
|
36
|
+
uniform shader image;
|
|
37
|
+
uniform float2 resolution;
|
|
38
|
+
uniform float strength;
|
|
39
|
+
uniform float cornerRadius;
|
|
40
|
+
|
|
41
|
+
half4 main(float2 pos) {
|
|
42
|
+
float2 center = resolution * 0.5;
|
|
43
|
+
float2 offset = pos - center;
|
|
44
|
+
float2 halfSize = resolution * 0.5;
|
|
45
|
+
|
|
46
|
+
// Distance to the nearest rounded-rect edge, normalized 0 (center) -> 1 (edge)
|
|
47
|
+
float2 d = abs(offset) / halfSize;
|
|
48
|
+
float edge = max(d.x, d.y);
|
|
49
|
+
|
|
50
|
+
// Lens bulge: displacement grows toward the edges, curves back to 0 at the exact
|
|
51
|
+
// center so the middle of the card stays undistorted (like the flat top of a
|
|
52
|
+
// glass dome), matching a plano-convex lens profile rather than a uniform blur.
|
|
53
|
+
float bulge = smoothstep(0.15, 1.0, edge) * (1.0 - edge * 0.25);
|
|
54
|
+
float2 dir = length(offset) > 0.0001 ? normalize(offset) : float2(0.0, 0.0);
|
|
55
|
+
float2 displaced = pos - dir * bulge * strength;
|
|
56
|
+
|
|
57
|
+
return image.eval(displaced);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
let cachedRefractionEffect: SkRuntimeEffect | null | undefined;
|
|
62
|
+
|
|
63
|
+
function getRefractionEffect() {
|
|
64
|
+
if (Platform.OS === "web" || !Skia?.RuntimeEffect?.Make) return null;
|
|
65
|
+
if (cachedRefractionEffect !== undefined) return cachedRefractionEffect;
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
cachedRefractionEffect = Skia.RuntimeEffect.Make(REFRACTION_SKSL) as SkRuntimeEffect | null;
|
|
69
|
+
} catch {
|
|
70
|
+
cachedRefractionEffect = null;
|
|
71
|
+
}
|
|
72
|
+
return cachedRefractionEffect;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function hexToRgba(hex: string, alpha: number) {
|
|
76
|
+
const v = hex.replace("#", "");
|
|
77
|
+
const r = parseInt(v.substring(0, 2), 16);
|
|
78
|
+
const g = parseInt(v.substring(2, 4), 16);
|
|
79
|
+
const b = parseInt(v.substring(4, 6), 16);
|
|
80
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default function LiquidGlassSurface({
|
|
84
|
+
width,
|
|
85
|
+
height,
|
|
86
|
+
cornerRadius = 18,
|
|
87
|
+
tintColor = colors.accent,
|
|
88
|
+
tintOpacity = 0.10,
|
|
89
|
+
borderOpacity = 0.55,
|
|
90
|
+
refractionStrength = 7,
|
|
91
|
+
children,
|
|
92
|
+
icon,
|
|
93
|
+
style,
|
|
94
|
+
nativeGlass = false,
|
|
95
|
+
}: LiquidGlassSurfaceProps) {
|
|
96
|
+
const skiaAvailable = Platform.OS !== "web" && Boolean(Skia?.RuntimeEffect?.Make);
|
|
97
|
+
const refractionEffect = useMemo(() => getRefractionEffect(), []);
|
|
98
|
+
const rrect = useMemo(
|
|
99
|
+
() => ({ rect: { x: 0, y: 0, width, height }, rx: cornerRadius, ry: cornerRadius }),
|
|
100
|
+
[width, height, cornerRadius]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const iconSkPath = useMemo(
|
|
104
|
+
() => (skiaAvailable && icon ? Skia.Path.MakeFromSVGString(icon.path) : null),
|
|
105
|
+
[icon, skiaAvailable]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const uniforms = useMemo(
|
|
109
|
+
() => ({ resolution: [width, height], strength: refractionStrength, cornerRadius }),
|
|
110
|
+
[width, height, refractionStrength, cornerRadius]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const iconSize = icon?.size ?? 26;
|
|
114
|
+
const nativeGlassAvailable = useMemo(() => {
|
|
115
|
+
if (!nativeGlass || Platform.OS !== "ios") return false;
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
return isGlassEffectAPIAvailable();
|
|
119
|
+
} catch {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}, [nativeGlass]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<View style={[styles.surface, { width, height, borderRadius: cornerRadius }, style]}>
|
|
126
|
+
{/* Teinte instantanée : un View à backgroundColor plein est composé dans la
|
|
127
|
+
même passe que le contenu, contrairement au blur/glass natif ou au canvas
|
|
128
|
+
Skia qui ont besoin d'une frame de plus pour se calculer. Sans ce calque,
|
|
129
|
+
une transition de navigation pilotée par geste (retour interactif) révèle
|
|
130
|
+
brièvement les couleurs brutes du contenu avant que l'effet verre réel ne
|
|
131
|
+
se pose dessus — visible surtout en sortant d'un écran sans bouton retour. */}
|
|
132
|
+
<View
|
|
133
|
+
pointerEvents="none"
|
|
134
|
+
style={[StyleSheet.absoluteFill, { borderRadius: cornerRadius, backgroundColor: hexToRgba(tintColor, tintOpacity) }]}
|
|
135
|
+
/>
|
|
136
|
+
{nativeGlassAvailable ? (
|
|
137
|
+
<GlassView
|
|
138
|
+
pointerEvents="none"
|
|
139
|
+
style={[StyleSheet.absoluteFill, { borderRadius: cornerRadius }]}
|
|
140
|
+
glassEffectStyle="regular"
|
|
141
|
+
tintColor={hexToRgba(tintColor, tintOpacity)}
|
|
142
|
+
colorScheme="light"
|
|
143
|
+
/>
|
|
144
|
+
) : (
|
|
145
|
+
<BlurView
|
|
146
|
+
pointerEvents="none"
|
|
147
|
+
intensity={34}
|
|
148
|
+
tint="light"
|
|
149
|
+
style={[StyleSheet.absoluteFill, { borderRadius: cornerRadius }]}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
{!skiaAvailable ? (
|
|
153
|
+
<View
|
|
154
|
+
pointerEvents="none"
|
|
155
|
+
style={[
|
|
156
|
+
StyleSheet.absoluteFill,
|
|
157
|
+
styles.webFallback,
|
|
158
|
+
{
|
|
159
|
+
borderRadius: cornerRadius,
|
|
160
|
+
borderColor: hexToRgba("#ffffff", Math.max(borderOpacity, 0.76)),
|
|
161
|
+
backgroundColor: hexToRgba(tintColor, tintOpacity),
|
|
162
|
+
},
|
|
163
|
+
]}
|
|
164
|
+
/>
|
|
165
|
+
) : null}
|
|
166
|
+
{skiaAvailable && refractionEffect ? <Canvas pointerEvents="none" style={StyleSheet.absoluteFill}>
|
|
167
|
+
<Group clip={rrect}>
|
|
168
|
+
{/* The color now lives in the reflection, not in an opaque card background. */}
|
|
169
|
+
<Fill color={hexToRgba("#ffffff", 0.08)} />
|
|
170
|
+
<RoundedRect x={0} y={0} width={width} height={height} r={cornerRadius} color={hexToRgba(tintColor, 0.07)}>
|
|
171
|
+
<LinearGradient
|
|
172
|
+
start={vec(0, 0)}
|
|
173
|
+
end={vec(width, height)}
|
|
174
|
+
colors={[hexToRgba("#ffffff", 0.34), hexToRgba(tintColor, 0.02)]}
|
|
175
|
+
/>
|
|
176
|
+
</RoundedRect>
|
|
177
|
+
<RoundedRect x={width * 0.08} y={-height * 0.28} width={width * 0.94} height={height * 0.76} r={height * 0.38} color={hexToRgba("#ffffff", 0.18)}>
|
|
178
|
+
<RadialGradient
|
|
179
|
+
c={vec(width * 0.48, height * 0.04)}
|
|
180
|
+
r={Math.max(width, height) * 0.62}
|
|
181
|
+
colors={[hexToRgba("#ffffff", 0.42), hexToRgba("#ffffff", 0.00)]}
|
|
182
|
+
/>
|
|
183
|
+
</RoundedRect>
|
|
184
|
+
|
|
185
|
+
{!nativeGlassAvailable && (
|
|
186
|
+
<BackdropFilter filter={<RuntimeShader source={refractionEffect} uniforms={uniforms} />}>
|
|
187
|
+
<RoundedRect
|
|
188
|
+
x={0}
|
|
189
|
+
y={0}
|
|
190
|
+
width={width}
|
|
191
|
+
height={height}
|
|
192
|
+
r={cornerRadius}
|
|
193
|
+
color={hexToRgba(tintColor, tintOpacity)}
|
|
194
|
+
/>
|
|
195
|
+
</BackdropFilter>
|
|
196
|
+
)}
|
|
197
|
+
|
|
198
|
+
<RoundedRect
|
|
199
|
+
x={0}
|
|
200
|
+
y={0}
|
|
201
|
+
width={width}
|
|
202
|
+
height={height}
|
|
203
|
+
r={cornerRadius}
|
|
204
|
+
color={hexToRgba(tintColor, nativeGlassAvailable ? tintOpacity * 0.48 : tintOpacity)}
|
|
205
|
+
/>
|
|
206
|
+
<RoundedRect
|
|
207
|
+
x={0.75}
|
|
208
|
+
y={0.75}
|
|
209
|
+
width={width - 1.5}
|
|
210
|
+
height={height - 1.5}
|
|
211
|
+
r={cornerRadius}
|
|
212
|
+
style="stroke"
|
|
213
|
+
strokeWidth={1.25}
|
|
214
|
+
color={hexToRgba("#ffffff", Math.max(borderOpacity, 0.76))}
|
|
215
|
+
/>
|
|
216
|
+
<RoundedRect
|
|
217
|
+
x={1.6}
|
|
218
|
+
y={1.6}
|
|
219
|
+
width={width - 3.2}
|
|
220
|
+
height={height - 3.2}
|
|
221
|
+
r={cornerRadius - 1}
|
|
222
|
+
style="stroke"
|
|
223
|
+
strokeWidth={0.65}
|
|
224
|
+
color={hexToRgba(tintColor, 0.26)}
|
|
225
|
+
/>
|
|
226
|
+
|
|
227
|
+
{iconSkPath && icon && (
|
|
228
|
+
<Group
|
|
229
|
+
transform={[
|
|
230
|
+
{ translateX: 16 },
|
|
231
|
+
{ translateY: 16 },
|
|
232
|
+
{ scale: iconSize / 24 },
|
|
233
|
+
]}
|
|
234
|
+
>
|
|
235
|
+
<Path
|
|
236
|
+
path={iconSkPath}
|
|
237
|
+
color={icon.color ?? "#ffffff"}
|
|
238
|
+
style="stroke"
|
|
239
|
+
strokeWidth={2.5}
|
|
240
|
+
strokeCap="round"
|
|
241
|
+
strokeJoin="round"
|
|
242
|
+
/>
|
|
243
|
+
</Group>
|
|
244
|
+
)}
|
|
245
|
+
</Group>
|
|
246
|
+
</Canvas> : null}
|
|
247
|
+
<View style={StyleSheet.absoluteFill} pointerEvents="box-none">
|
|
248
|
+
{children}
|
|
249
|
+
</View>
|
|
250
|
+
</View>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const styles = StyleSheet.create({
|
|
255
|
+
surface: {
|
|
256
|
+
overflow: "hidden",
|
|
257
|
+
shadowColor: "#18234f",
|
|
258
|
+
shadowOpacity: 0.12,
|
|
259
|
+
shadowRadius: 18,
|
|
260
|
+
shadowOffset: { width: 0, height: 9 },
|
|
261
|
+
elevation: 5,
|
|
262
|
+
},
|
|
263
|
+
webFallback: {
|
|
264
|
+
borderWidth: 1.25,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ReactNode, useEffect, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Animated,
|
|
6
|
+
Easing,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
ScrollView,
|
|
10
|
+
Keyboard,
|
|
11
|
+
Platform,
|
|
12
|
+
} from "react-native";
|
|
13
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
14
|
+
import { router } from "expo-router";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { MUTED, accentAlpha, colors, fontWeights, fonts } from "../../constants/theme";
|
|
17
|
+
import Pressable from "../AnimatedPressable";
|
|
18
|
+
|
|
19
|
+
/* A default, not a law: an onboarding is as long as the product needs.
|
|
20
|
+
Hard-coded, it silently mislabels "step 3 of 5" in a four-step flow. */
|
|
21
|
+
const DEFAULT_TOTAL_STEPS = 5;
|
|
22
|
+
|
|
23
|
+
interface StepScreenProps {
|
|
24
|
+
step: number; // 1-indexed
|
|
25
|
+
/** How many steps the flow has. Defaults to five. */
|
|
26
|
+
totalSteps?: number;
|
|
27
|
+
eyebrow: string;
|
|
28
|
+
title: string;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
onNext: () => void;
|
|
31
|
+
nextLabel?: string;
|
|
32
|
+
nextDisabled?: boolean;
|
|
33
|
+
onSkip?: () => void;
|
|
34
|
+
skipLabel?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The shell every step of a sign-up flow sits in: progress bar, title, content,
|
|
39
|
+
* primary button and an optional skip.
|
|
40
|
+
*
|
|
41
|
+
* It carries the keyboard handling too — a step screen almost always holds a
|
|
42
|
+
* form, and the layout has to survive the keyboard opening over it.
|
|
43
|
+
*/
|
|
44
|
+
export default function StepScreen({
|
|
45
|
+
step,
|
|
46
|
+
totalSteps = DEFAULT_TOTAL_STEPS,
|
|
47
|
+
eyebrow,
|
|
48
|
+
title,
|
|
49
|
+
children,
|
|
50
|
+
onNext,
|
|
51
|
+
nextLabel,
|
|
52
|
+
nextDisabled = false,
|
|
53
|
+
onSkip,
|
|
54
|
+
skipLabel,
|
|
55
|
+
}: StepScreenProps) {
|
|
56
|
+
const { t } = useTranslation();
|
|
57
|
+
const progressValues = useRef(
|
|
58
|
+
Array.from(
|
|
59
|
+
{ length: totalSteps },
|
|
60
|
+
(_, i) => new Animated.Value(i < step - 1 ? 1 : i === step - 1 ? 0.5 : 0),
|
|
61
|
+
),
|
|
62
|
+
).current;
|
|
63
|
+
const contentOpacity = useRef(new Animated.Value(0)).current;
|
|
64
|
+
const contentTranslate = useRef(new Animated.Value(8)).current;
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
Animated.parallel(
|
|
68
|
+
progressValues.map((value, i) =>
|
|
69
|
+
Animated.timing(value, {
|
|
70
|
+
toValue: i < step - 1 ? 1 : i === step - 1 ? 0.5 : 0,
|
|
71
|
+
duration: 280,
|
|
72
|
+
easing: Easing.out(Easing.cubic),
|
|
73
|
+
useNativeDriver: false,
|
|
74
|
+
}),
|
|
75
|
+
),
|
|
76
|
+
).start();
|
|
77
|
+
}, [progressValues, step]);
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
Animated.parallel([
|
|
81
|
+
Animated.timing(contentOpacity, {
|
|
82
|
+
toValue: 1,
|
|
83
|
+
duration: 280,
|
|
84
|
+
easing: Easing.out(Easing.cubic),
|
|
85
|
+
useNativeDriver: true,
|
|
86
|
+
}),
|
|
87
|
+
Animated.timing(contentTranslate, {
|
|
88
|
+
toValue: 0,
|
|
89
|
+
duration: 280,
|
|
90
|
+
easing: Easing.out(Easing.cubic),
|
|
91
|
+
useNativeDriver: true,
|
|
92
|
+
}),
|
|
93
|
+
]).start();
|
|
94
|
+
}, [contentOpacity, contentTranslate]);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<SafeAreaView style={styles.screen}>
|
|
98
|
+
<KeyboardAvoidingView
|
|
99
|
+
style={styles.screen}
|
|
100
|
+
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
101
|
+
>
|
|
102
|
+
<ScrollView
|
|
103
|
+
keyboardShouldPersistTaps="handled"
|
|
104
|
+
contentContainerStyle={{ flexGrow: 1 }}
|
|
105
|
+
onScrollBeginDrag={Keyboard.dismiss}
|
|
106
|
+
>
|
|
107
|
+
<View style={styles.topbar}>
|
|
108
|
+
{router.canGoBack() && (
|
|
109
|
+
<Pressable onPress={() => router.back()}>
|
|
110
|
+
<Text style={styles.back}>‹ {t("common.back")}</Text>
|
|
111
|
+
</Pressable>
|
|
112
|
+
)}
|
|
113
|
+
<View style={styles.progress}>
|
|
114
|
+
{Array.from({ length: totalSteps }).map((_, i) => (
|
|
115
|
+
<Animated.View
|
|
116
|
+
key={i}
|
|
117
|
+
style={[
|
|
118
|
+
styles.seg,
|
|
119
|
+
{
|
|
120
|
+
backgroundColor: progressValues[i].interpolate({
|
|
121
|
+
inputRange: [0, 0.5, 1],
|
|
122
|
+
outputRange: [accentAlpha(0.14), colors.accent, colors.accent],
|
|
123
|
+
}),
|
|
124
|
+
opacity: progressValues[i].interpolate({
|
|
125
|
+
inputRange: [0, 0.5, 1],
|
|
126
|
+
outputRange: [1, 0.55, 1],
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
]}
|
|
130
|
+
/>
|
|
131
|
+
))}
|
|
132
|
+
</View>
|
|
133
|
+
</View>
|
|
134
|
+
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
styles.content,
|
|
138
|
+
{ opacity: contentOpacity, transform: [{ translateY: contentTranslate }] },
|
|
139
|
+
]}
|
|
140
|
+
>
|
|
141
|
+
<Text style={styles.eyebrow}>
|
|
142
|
+
{eyebrow} · {t("common.step_progress", { step, total: totalSteps })}
|
|
143
|
+
</Text>
|
|
144
|
+
<Text style={styles.title}>{title}</Text>
|
|
145
|
+
|
|
146
|
+
<View style={styles.body}>{children}</View>
|
|
147
|
+
|
|
148
|
+
<Pressable
|
|
149
|
+
style={[styles.primary, nextDisabled && styles.primaryDisabled]}
|
|
150
|
+
onPress={onNext}
|
|
151
|
+
disabled={nextDisabled}
|
|
152
|
+
>
|
|
153
|
+
<Text style={styles.primaryText}>{nextLabel ?? t("common.continue")}</Text>
|
|
154
|
+
</Pressable>
|
|
155
|
+
|
|
156
|
+
{onSkip && (
|
|
157
|
+
<Pressable style={styles.ghost} onPress={onSkip}>
|
|
158
|
+
<Text style={styles.ghostText}>{skipLabel ?? t("common.skip")}</Text>
|
|
159
|
+
</Pressable>
|
|
160
|
+
)}
|
|
161
|
+
</Animated.View>
|
|
162
|
+
</ScrollView>
|
|
163
|
+
</KeyboardAvoidingView>
|
|
164
|
+
</SafeAreaView>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const styles = StyleSheet.create({
|
|
169
|
+
screen: { flex: 1, backgroundColor: colors.background },
|
|
170
|
+
topbar: { paddingHorizontal: 20, paddingTop: 8 },
|
|
171
|
+
back: { fontSize: 13, fontFamily: fonts.medium, fontWeight: fontWeights.medium, color: MUTED, marginBottom: 10 },
|
|
172
|
+
progress: { flexDirection: "row", gap: 5, marginBottom: 6 },
|
|
173
|
+
seg: { flex: 1, height: 4, borderRadius: 3, backgroundColor: accentAlpha(0.14) },
|
|
174
|
+
segDone: { backgroundColor: colors.accent },
|
|
175
|
+
segNow: { backgroundColor: colors.accent, opacity: 0.55 },
|
|
176
|
+
content: { flex: 1, padding: 22, paddingTop: 24 },
|
|
177
|
+
eyebrow: { fontSize: 11, fontFamily: fonts.bold, fontWeight: fontWeights.bold, color: "#12206e", textTransform: "uppercase", letterSpacing: 0.5, marginBottom: 6 },
|
|
178
|
+
title: { fontSize: 20, fontFamily: fonts.bold, fontWeight: fontWeights.bold, color: "#2f3350", marginBottom: 22, lineHeight: 26 },
|
|
179
|
+
body: { flex: 1 },
|
|
180
|
+
primary: { backgroundColor: colors.accent, borderRadius: 26, paddingVertical: 15, alignItems: "center" },
|
|
181
|
+
primaryDisabled: { opacity: 0.4 },
|
|
182
|
+
primaryText: { color: "#fff", fontFamily: fonts.bold, fontWeight: fontWeights.bold, fontSize: 14 },
|
|
183
|
+
ghost: { paddingVertical: 12, alignItems: "center" },
|
|
184
|
+
ghostText: { color: MUTED, fontFamily: fonts.semibold, fontWeight: fontWeights.semibold, fontSize: 13 },
|
|
185
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the dashboard shows, as data.
|
|
3
|
+
*
|
|
4
|
+
* Declared here rather than inside the screen so that changing a product's
|
|
5
|
+
* dashboard — or giving two roles two different ones — is an edit to a list,
|
|
6
|
+
* never a rewrite of a component.
|
|
7
|
+
*
|
|
8
|
+
* Icons are SVG path strings: a list of data must not have to import React to
|
|
9
|
+
* say what it looks like.
|
|
10
|
+
*/
|
|
11
|
+
import type { KpiItem } from '../components/dashboard/KpiBubble';
|
|
12
|
+
import type { StaffTab } from '../components/dashboard/StaffTabBar';
|
|
13
|
+
import type { ToolCardItem } from '../components/dashboard/ToolCard';
|
|
14
|
+
|
|
15
|
+
type Translate = (key: string) => string;
|
|
16
|
+
|
|
17
|
+
const ICONS = {
|
|
18
|
+
people: 'M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75',
|
|
19
|
+
chart: 'M18 20V10M12 20V4M6 20v-6',
|
|
20
|
+
settings: 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z',
|
|
21
|
+
bell: 'M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 0 1-3.4 0'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Replace these with the numbers your API actually returns. */
|
|
25
|
+
export function dashboardKpis(t: Translate): KpiItem[] {
|
|
26
|
+
return [
|
|
27
|
+
{ value: '—', label: t('dashboard.title'), color: '#3d5afe' },
|
|
28
|
+
{ value: '—', label: t('settings.title'), color: '#00b894' },
|
|
29
|
+
{ value: '—', label: t('notifications.title'), color: '#f39c12' }
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function dashboardTools(t: Translate): ToolCardItem[] {
|
|
34
|
+
return [
|
|
35
|
+
{ label: t('settings.title'), value: '', color: '#3d5afe', path: '/settings', icon: ICONS.settings },
|
|
36
|
+
{ label: t('notifications.title'), value: '', color: '#f39c12', path: '/notifications', icon: ICONS.bell }
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The bottom bar. `key` picks the icon from the bar's own set — keep it to a
|
|
42
|
+
* name that set knows, or the tab renders without one.
|
|
43
|
+
*/
|
|
44
|
+
export function dashboardTabs(t: Translate): StaffTab[] {
|
|
45
|
+
return [
|
|
46
|
+
{ key: 'home', label: t('dashboard.title'), path: '/dashboard' },
|
|
47
|
+
{ key: 'messages', label: t('notifications.title'), path: '/notifications' },
|
|
48
|
+
{ key: 'more', label: t('settings.title'), path: '/settings' }
|
|
49
|
+
];
|
|
50
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place colours, type and spacing are decided.
|
|
3
|
+
*
|
|
4
|
+
* THE SYSTEM FONT, ON PURPOSE. React Native does not map `fontWeight` onto a
|
|
5
|
+
* bundled font — a custom family needs one file per weight, and a missing one
|
|
6
|
+
* renders silently as regular. The system font honours numeric weights
|
|
7
|
+
* natively, so every weight below must be paired with its number.
|
|
8
|
+
*
|
|
9
|
+
* ONE SURFACE RECIPE. `card` is the translucent panel every component sits on.
|
|
10
|
+
* Defining it once is what keeps a header, a tile and a tab bar looking like
|
|
11
|
+
* the same material rather than three near-misses.
|
|
12
|
+
*/
|
|
13
|
+
import { Platform } from 'react-native';
|
|
14
|
+
|
|
15
|
+
const SYSTEM = Platform.select({ ios: 'System', android: 'sans-serif', default: 'System' });
|
|
16
|
+
|
|
17
|
+
export const fonts = { regular: SYSTEM, medium: SYSTEM, semibold: SYSTEM, bold: SYSTEM, extrabold: SYSTEM };
|
|
18
|
+
|
|
19
|
+
export const fontWeights = {
|
|
20
|
+
regular: '400',
|
|
21
|
+
medium: '500',
|
|
22
|
+
semibold: '600',
|
|
23
|
+
bold: '700',
|
|
24
|
+
extrabold: '800'
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* TWO TRIPLES DECIDE THE WHOLE IDENTITY.
|
|
29
|
+
*
|
|
30
|
+
* Every shade in this app is derived from them, so changing an application's
|
|
31
|
+
* look is changing these two lines — not hunting fifty-six literals across a
|
|
32
|
+
* dozen components. That hunt is exactly what makes one product's components
|
|
33
|
+
* look like another product.
|
|
34
|
+
*/
|
|
35
|
+
const INK_RGB = '13,18,53';
|
|
36
|
+
const ACCENT_RGB = '61,90,254';
|
|
37
|
+
|
|
38
|
+
/** `inkAlpha(0.55)` reads better than a copied rgba(), and follows INK_RGB. */
|
|
39
|
+
export const inkAlpha = (alpha: number) => `rgba(${INK_RGB},${alpha})`;
|
|
40
|
+
export const accentAlpha = (alpha: number) => `rgba(${ACCENT_RGB},${alpha})`;
|
|
41
|
+
|
|
42
|
+
/* Ink, in three weights. Named by role, not by shade: a component asks for
|
|
43
|
+
"muted", never for "55% of the ink colour". */
|
|
44
|
+
export const TEXT = `rgb(${INK_RGB})`;
|
|
45
|
+
export const MUTED = inkAlpha(0.55);
|
|
46
|
+
export const FAINT = inkAlpha(0.35);
|
|
47
|
+
|
|
48
|
+
export const colors = {
|
|
49
|
+
/* Deep enough for a translucent surface to read against it. Near-white here
|
|
50
|
+
made every glass panel disappear: the card and the page were the same
|
|
51
|
+
colour, so the login form looked like loose text on a page. */
|
|
52
|
+
background: '#dfe5f3',
|
|
53
|
+
surface: 'rgba(255,255,255,0.82)',
|
|
54
|
+
/* The same surface without transparency, for a device that cannot blur. */
|
|
55
|
+
surfaceOpaque: '#f7f9fe',
|
|
56
|
+
/* Just enough colour over a blur to keep text readable on any wallpaper. */
|
|
57
|
+
veil: 'rgba(255,255,255,0.42)',
|
|
58
|
+
border: 'rgba(255,255,255,0.95)',
|
|
59
|
+
text: TEXT,
|
|
60
|
+
muted: MUTED,
|
|
61
|
+
faint: FAINT,
|
|
62
|
+
accent: `rgb(${ACCENT_RGB})`,
|
|
63
|
+
/* Ink for anything sitting ON the accent. Reusing `text` there puts dark
|
|
64
|
+
ink on a saturated blue — legible enough to pass a screenshot, wrong
|
|
65
|
+
enough to fail a contrast check. */
|
|
66
|
+
onAccent: '#ffffff',
|
|
67
|
+
danger: '#e5484d',
|
|
68
|
+
positive: '#1f9d55',
|
|
69
|
+
/* Opaque white, for anything that must not let the page through. */
|
|
70
|
+
paper: '#ffffff'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** The translucent panel, spread into any surface that should read as glass. */
|
|
74
|
+
/**
|
|
75
|
+
* The one surface recipe — and it is platform-split for a reason.
|
|
76
|
+
*
|
|
77
|
+
* The shadow is what separates the panel from the page: a translucent white
|
|
78
|
+
* card on a light background, with only an edge, reads as nothing at all.
|
|
79
|
+
*
|
|
80
|
+
* BUT ANDROID DRAWS ELEVATION AGAINST AN OPAQUE BACKGROUND. Given a
|
|
81
|
+
* translucent one it paints a solid block behind the whole view — a white
|
|
82
|
+
* rectangle inside the card, which is exactly what it looked like. So Android
|
|
83
|
+
* gets an opaque surface and elevation; iOS keeps the translucent surface and
|
|
84
|
+
* the soft shadow it renders properly.
|
|
85
|
+
*/
|
|
86
|
+
export const card = {
|
|
87
|
+
backgroundColor: colors.surface,
|
|
88
|
+
borderWidth: 1,
|
|
89
|
+
borderColor: colors.border,
|
|
90
|
+
/* iOS only: Android ignores shadow*, and its `elevation` equivalent paints a
|
|
91
|
+
solid rectangle behind a translucent view. Surfaces that need lifting on
|
|
92
|
+
Android use a blur instead — see components/GlassPanel.tsx. */
|
|
93
|
+
...Platform.select({
|
|
94
|
+
ios: {
|
|
95
|
+
shadowColor: '#18234f',
|
|
96
|
+
shadowOpacity: 0.1,
|
|
97
|
+
shadowRadius: 18,
|
|
98
|
+
shadowOffset: { width: 0, height: 10 }
|
|
99
|
+
},
|
|
100
|
+
default: {}
|
|
101
|
+
})
|
|
102
|
+
} as const;
|
|
103
|
+
|
|
104
|
+
export const spacing = { xs: 4, sm: 8, md: 16, lg: 24, xl: 32 };
|