create-astratra-app 1.3.0 → 1.5.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 +21 -0
- package/package.json +3 -2
- package/src/bricks.js +8 -8
- package/src/createProject.js +66 -11
- 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,136 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { Animated, Easing, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import LiquidGlassSurface from "../glass/LiquidGlassSurface";
|
|
4
|
+
import Svg, { Path } from "react-native-svg";
|
|
5
|
+
|
|
6
|
+
import { TEXT, colors, fontWeights, fonts } from "../../constants/theme";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One tile on the dashboard.
|
|
10
|
+
*
|
|
11
|
+
* `icon` is an SVG path string, not a component: the tiles are declared as
|
|
12
|
+
* data — usually one list per role — and a list of data must not have to
|
|
13
|
+
* import React to say what it looks like.
|
|
14
|
+
*/
|
|
15
|
+
export type ToolCardItem = {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
color: string;
|
|
19
|
+
path?: string;
|
|
20
|
+
icon: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ToolCardProps = {
|
|
24
|
+
card: ToolCardItem;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
onPress?: () => void;
|
|
27
|
+
index?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Total horizontal padding of the grid's container, both sides added.
|
|
30
|
+
*
|
|
31
|
+
* The tile computes its own width, so it has to know how much room the
|
|
32
|
+
* parent already took. Hard-coded, a container with different padding makes
|
|
33
|
+
* every tile a few pixels too wide — and two of them stop fitting on a row,
|
|
34
|
+
* which reads as a broken layout rather than as a maths error.
|
|
35
|
+
*/
|
|
36
|
+
gridPadding?: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const CARD_HEIGHT = 130;
|
|
40
|
+
const DEFAULT_GRID_PADDING = 40;
|
|
41
|
+
const GRID_GAP = 12;
|
|
42
|
+
|
|
43
|
+
// iOS supportsTablet (app.json) : sur iPad/écran large, verrouiller à 2 colonnes fixes
|
|
44
|
+
// produisait des cartes disproportionnées (très larges, hauteur inchangée). On ajoute
|
|
45
|
+
// des colonnes par palier de largeur pour garder un ratio raisonnable.
|
|
46
|
+
function getColumnCount(width: number) {
|
|
47
|
+
if (width >= 900) return 4;
|
|
48
|
+
if (width >= 620) return 3;
|
|
49
|
+
return 2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default function ToolCard({
|
|
53
|
+
card,
|
|
54
|
+
disabled,
|
|
55
|
+
onPress,
|
|
56
|
+
index = 0,
|
|
57
|
+
gridPadding = DEFAULT_GRID_PADDING
|
|
58
|
+
}: ToolCardProps) {
|
|
59
|
+
const { width } = useWindowDimensions();
|
|
60
|
+
const columns = getColumnCount(width);
|
|
61
|
+
const cardWidth = Math.floor((width - gridPadding - GRID_GAP * (columns - 1)) / columns);
|
|
62
|
+
const isTextValue = Number.isNaN(Number.parseInt(card.value, 10));
|
|
63
|
+
const entrance = useRef(new Animated.Value(0)).current;
|
|
64
|
+
const press = useRef(new Animated.Value(0)).current;
|
|
65
|
+
|
|
66
|
+
// Une seule fois au montage — pas à chaque focus. Rejouer ce fondu (et
|
|
67
|
+
// recalculer le verre de chaque carte) à chaque retour sur le dashboard
|
|
68
|
+
// était invisible avec le bouton retour (transition rapide, non
|
|
69
|
+
// interruptible) mais bien visible pendant un retour par geste, lent et
|
|
70
|
+
// interruptible : la carte semblait se réinitialiser sous les yeux.
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const animation = Animated.timing(entrance, {
|
|
73
|
+
toValue: 1,
|
|
74
|
+
duration: 500,
|
|
75
|
+
delay: Math.min(index, 8) * 55 + 60,
|
|
76
|
+
easing: Easing.out(Easing.cubic),
|
|
77
|
+
useNativeDriver: true,
|
|
78
|
+
});
|
|
79
|
+
animation.start();
|
|
80
|
+
return () => animation.stop();
|
|
81
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
const animatePress = (toValue: number) => {
|
|
85
|
+
Animated.spring(press, { toValue, friction: 7, tension: 110, useNativeDriver: true }).start();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Animated.View style={[styles.wrapper, { width: cardWidth, opacity: entrance, transform: [{ translateY: Animated.add(entrance.interpolate({ inputRange: [0, 1], outputRange: [18, 0] }), press.interpolate({ inputRange: [0, 1], outputRange: [0, 2] })) }, { scale: press.interpolate({ inputRange: [0, 1], outputRange: [1, 0.975] }) }] }, disabled && styles.disabled]}>
|
|
90
|
+
<Pressable
|
|
91
|
+
accessibilityRole="button"
|
|
92
|
+
accessibilityLabel={card.label}
|
|
93
|
+
disabled={disabled}
|
|
94
|
+
onPress={onPress}
|
|
95
|
+
onPressIn={() => animatePress(1)}
|
|
96
|
+
onPressOut={() => animatePress(0)}
|
|
97
|
+
style={styles.pressable}
|
|
98
|
+
>
|
|
99
|
+
<LiquidGlassSurface
|
|
100
|
+
width={cardWidth}
|
|
101
|
+
height={CARD_HEIGHT}
|
|
102
|
+
cornerRadius={14}
|
|
103
|
+
tintColor={card.color}
|
|
104
|
+
tintOpacity={0.06}
|
|
105
|
+
borderOpacity={0.86}
|
|
106
|
+
refractionStrength={3}
|
|
107
|
+
nativeGlass
|
|
108
|
+
>
|
|
109
|
+
<View style={styles.content} pointerEvents="none">
|
|
110
|
+
<View style={[styles.iconWrap, { backgroundColor: card.color }]}>
|
|
111
|
+
<Svg width={16} height={16} viewBox="0 0 24 24">
|
|
112
|
+
<Path d={card.icon} fill="none" stroke={colors.paper} strokeWidth={2.5} strokeLinecap="round" strokeLinejoin="round" />
|
|
113
|
+
</Svg>
|
|
114
|
+
</View>
|
|
115
|
+
<View style={styles.copy}>
|
|
116
|
+
<Text style={[styles.label, { color: card.color }]} numberOfLines={2}>{card.label}</Text>
|
|
117
|
+
<Text style={[styles.value, isTextValue && styles.textValue, { color: card.color }]} numberOfLines={isTextValue ? 2 : 1}>{card.value}</Text>
|
|
118
|
+
</View>
|
|
119
|
+
</View>
|
|
120
|
+
</LiquidGlassSurface>
|
|
121
|
+
</Pressable>
|
|
122
|
+
</Animated.View>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const styles = StyleSheet.create({
|
|
127
|
+
wrapper: { height: CARD_HEIGHT },
|
|
128
|
+
pressable: { width: "100%", height: "100%" },
|
|
129
|
+
disabled: { opacity: 0.38 },
|
|
130
|
+
content: { flex: 1, paddingVertical: 13, paddingHorizontal: 11, justifyContent: "space-between" },
|
|
131
|
+
iconWrap: { width: 32, height: 32, borderRadius: 9, alignItems: "center", justifyContent: "center", shadowColor: TEXT, shadowOpacity: 0.12, shadowRadius: 8, shadowOffset: { width: 0, height: 4 } },
|
|
132
|
+
copy: { gap: 4 },
|
|
133
|
+
label: { fontSize: 11.5, lineHeight: 14, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, textTransform: "uppercase", letterSpacing: 0.5, opacity: 0.9 },
|
|
134
|
+
value: { fontSize: 21, lineHeight: 23, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, letterSpacing: -1 },
|
|
135
|
+
textValue: { fontSize: 15, lineHeight: 19, fontFamily: fonts.bold, fontWeight: fontWeights.bold, letterSpacing: 0 },
|
|
136
|
+
});
|
|
@@ -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
|
+
}
|