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,71 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { TEXT, colors, fontWeights, fonts, inkAlpha } from "../../constants/theme";
|
|
5
|
+
import NotificationBell from "./NotificationBell";
|
|
6
|
+
|
|
7
|
+
export type DashboardHeaderProps = {
|
|
8
|
+
name: string;
|
|
9
|
+
online: boolean;
|
|
10
|
+
/** Unread count for the bell. The screen owns the data; the header renders it. */
|
|
11
|
+
unread?: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function DashboardHeader({ name, online, unread = 0 }: DashboardHeaderProps) {
|
|
15
|
+
const { i18n, t } = useTranslation();
|
|
16
|
+
const locale = i18n.language || "fr";
|
|
17
|
+
const [clock, setClock] = useState(() => new Date().toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }));
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setClock(new Date().toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }));
|
|
21
|
+
const timer = setInterval(() => {
|
|
22
|
+
setClock(new Date().toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }));
|
|
23
|
+
}, 60000);
|
|
24
|
+
return () => clearInterval(timer);
|
|
25
|
+
}, [locale]);
|
|
26
|
+
|
|
27
|
+
const statusColor = online ? colors.positive : colors.danger;
|
|
28
|
+
const dateLabel = new Date().toLocaleDateString(locale, { weekday: "long", day: "numeric", month: "long", year: "numeric" });
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View style={styles.row}>
|
|
32
|
+
<View style={styles.left}>
|
|
33
|
+
<Text style={styles.date}>{dateLabel}</Text>
|
|
34
|
+
<View style={styles.greetRow}>
|
|
35
|
+
<Text style={styles.greeting}>{t("dashboard.greeting")} </Text>
|
|
36
|
+
<Text style={[styles.greeting, { color: colors.accent }]} numberOfLines={1}>{name}</Text>
|
|
37
|
+
</View>
|
|
38
|
+
<Text style={styles.subtitle}>{t("dashboard.header.subtitle")}</Text>
|
|
39
|
+
</View>
|
|
40
|
+
<View style={styles.right}>
|
|
41
|
+
{/* La cloche remplace la carte « Notifications » de la grille : elle
|
|
42
|
+
dit s'il y a quelque chose à lire sans qu'on l'ouvre. */}
|
|
43
|
+
<View style={styles.bellRow}>
|
|
44
|
+
<Text style={styles.clock}>{clock}</Text>
|
|
45
|
+
<NotificationBell unread={unread} accent={colors.accent} />
|
|
46
|
+
</View>
|
|
47
|
+
<View style={[styles.pill, { backgroundColor: `${statusColor}1A`, borderColor: `${statusColor}40` }]}>
|
|
48
|
+
<View style={[styles.dot, { backgroundColor: statusColor }]} />
|
|
49
|
+
<Text style={[styles.pillText, { color: statusColor }]}>
|
|
50
|
+
{online ? t("dashboard.header.online") : t("dashboard.header.offline")}
|
|
51
|
+
</Text>
|
|
52
|
+
</View>
|
|
53
|
+
</View>
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
row: { flexDirection: "row", justifyContent: "space-between", alignItems: "flex-start" },
|
|
60
|
+
left: { flex: 1, gap: 6 },
|
|
61
|
+
date: { fontSize: 11, fontFamily: fonts.semibold, fontWeight: fontWeights.semibold, color: inkAlpha(0.40) },
|
|
62
|
+
greetRow: { flexDirection: "row", flexWrap: "wrap" },
|
|
63
|
+
greeting: { fontSize: 22, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, color: TEXT, letterSpacing: -0.5 },
|
|
64
|
+
subtitle: { fontSize: 12.5, fontFamily: fonts.medium, fontWeight: fontWeights.medium, color: inkAlpha(0.40) },
|
|
65
|
+
right: { alignItems: "flex-end", gap: 6 },
|
|
66
|
+
bellRow: { flexDirection: "row", alignItems: "center", gap: 10 },
|
|
67
|
+
clock: { fontSize: 20, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, color: TEXT },
|
|
68
|
+
pill: { flexDirection: "row", alignItems: "center", gap: 6, paddingHorizontal: 10, paddingVertical: 4, borderRadius: 50, borderWidth: 1 },
|
|
69
|
+
dot: { width: 6, height: 6, borderRadius: 3 },
|
|
70
|
+
pillText: { fontSize: 9.5, fontFamily: fonts.bold, fontWeight: fontWeights.bold, letterSpacing: 0.6 },
|
|
71
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { Animated, Easing, type ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
type DashboardRevealProps = {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
delay?: number;
|
|
7
|
+
direction?: "up" | "left";
|
|
8
|
+
style?: ViewStyle;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function DashboardReveal({ children, delay = 0, direction = "up", style }: DashboardRevealProps) {
|
|
12
|
+
const progress = useRef(new Animated.Value(0)).current;
|
|
13
|
+
const offset = direction === "left" ? { x: -10, y: 0 } : { x: 0, y: 24 };
|
|
14
|
+
|
|
15
|
+
// Une seule fois au montage — pas à chaque focus (voir ToolCard.tsx pour le
|
|
16
|
+
// détail du bug que ce changement corrige : rejouer ce fondu à chaque retour
|
|
17
|
+
// sur le dashboard n'était visible que pendant un retour par geste, lent et
|
|
18
|
+
// interruptible, où l'utilisateur voit la carte/le verre se réinitialiser).
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const animation = Animated.timing(progress, {
|
|
21
|
+
toValue: 1,
|
|
22
|
+
duration: 500,
|
|
23
|
+
delay,
|
|
24
|
+
easing: Easing.out(Easing.bezier(0.16, 1, 0.3, 1)),
|
|
25
|
+
useNativeDriver: true,
|
|
26
|
+
});
|
|
27
|
+
animation.start();
|
|
28
|
+
return () => animation.stop();
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Animated.View
|
|
34
|
+
style={[style, {
|
|
35
|
+
opacity: progress,
|
|
36
|
+
transform: [
|
|
37
|
+
{ translateX: progress.interpolate({ inputRange: [0, 1], outputRange: [offset.x, 0] }) },
|
|
38
|
+
{ translateY: progress.interpolate({ inputRange: [0, 1], outputRange: [offset.y, 0] }) },
|
|
39
|
+
{ scale: direction === "up" ? progress.interpolate({ inputRange: [0, 1], outputRange: [0.94, 1] }) : 1 },
|
|
40
|
+
],
|
|
41
|
+
}]}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</Animated.View>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Animated, Easing, Platform, View, Text, StyleSheet, useWindowDimensions } from "react-native";
|
|
3
|
+
import { GlassView } from "expo-glass-effect";
|
|
4
|
+
import { LinearGradient } from "expo-linear-gradient";
|
|
5
|
+
import { accentAlpha, colors, fontWeights, fonts, inkAlpha } from "../../constants/theme";
|
|
6
|
+
|
|
7
|
+
export type KpiItem = { value: string; label: string; color: string };
|
|
8
|
+
export type KpiBubbleProps = { items: KpiItem[] };
|
|
9
|
+
|
|
10
|
+
export default function KpiBubble({ items }: KpiBubbleProps) {
|
|
11
|
+
const { width } = useWindowDimensions();
|
|
12
|
+
const gradientShift = useRef(new Animated.Value(0)).current;
|
|
13
|
+
const cellAnimations = useRef<Animated.Value[]>([]);
|
|
14
|
+
const [run, setRun] = useState(0);
|
|
15
|
+
const cardWidth = Math.max(width - 40, 300);
|
|
16
|
+
|
|
17
|
+
if (cellAnimations.current.length !== items.length) {
|
|
18
|
+
cellAnimations.current = items.map(() => new Animated.Value(0));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Une seule fois au montage — pas à chaque focus (voir ToolCard.tsx). Le
|
|
22
|
+
// GlassView natif recalculant son dégradé/fondu à chaque retour sur le
|
|
23
|
+
// dashboard était le principal responsable du flash de couleurs vives
|
|
24
|
+
// pendant un retour par geste (lent, interruptible).
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const gradientLoop = Animated.loop(
|
|
27
|
+
Animated.timing(gradientShift, {
|
|
28
|
+
toValue: 1,
|
|
29
|
+
duration: 8000,
|
|
30
|
+
easing: Easing.linear,
|
|
31
|
+
useNativeDriver: true,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
gradientLoop.start();
|
|
35
|
+
return () => gradientLoop.stop();
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const animation = Animated.stagger(
|
|
41
|
+
90,
|
|
42
|
+
cellAnimations.current.map((value) =>
|
|
43
|
+
Animated.timing(value, {
|
|
44
|
+
toValue: 1,
|
|
45
|
+
duration: 500,
|
|
46
|
+
easing: Easing.out(Easing.cubic),
|
|
47
|
+
useNativeDriver: true,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
animation.start();
|
|
52
|
+
return () => animation.stop();
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const gradientTranslate = gradientShift.interpolate({
|
|
57
|
+
inputRange: [0, 1],
|
|
58
|
+
outputRange: [0, -cardWidth],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<GlassView
|
|
63
|
+
glassEffectStyle="regular"
|
|
64
|
+
style={[styles.card, Platform.OS !== "ios" && styles.androidFallback]}
|
|
65
|
+
>
|
|
66
|
+
<Animated.View
|
|
67
|
+
pointerEvents="none"
|
|
68
|
+
style={[
|
|
69
|
+
styles.gradientTrack,
|
|
70
|
+
{
|
|
71
|
+
width: cardWidth * 2,
|
|
72
|
+
transform: [{ translateX: gradientTranslate }],
|
|
73
|
+
},
|
|
74
|
+
]}
|
|
75
|
+
>
|
|
76
|
+
<LinearGradient
|
|
77
|
+
colors={[
|
|
78
|
+
accentAlpha(0.10),
|
|
79
|
+
"rgba(52,168,83,0.08)",
|
|
80
|
+
"rgba(230,126,34,0.08)",
|
|
81
|
+
"rgba(124,58,237,0.10)",
|
|
82
|
+
accentAlpha(0.10),
|
|
83
|
+
]}
|
|
84
|
+
start={{ x: 0, y: 0.5 }}
|
|
85
|
+
end={{ x: 1, y: 0.5 }}
|
|
86
|
+
style={styles.gradientFill}
|
|
87
|
+
/>
|
|
88
|
+
</Animated.View>
|
|
89
|
+
|
|
90
|
+
<View style={styles.grid}>
|
|
91
|
+
{items.map((item, index) => (
|
|
92
|
+
<Animated.View
|
|
93
|
+
key={item.label}
|
|
94
|
+
style={[
|
|
95
|
+
styles.cell,
|
|
96
|
+
index % 2 === 0 && styles.cellRightDivider,
|
|
97
|
+
index < items.length - 2 && styles.cellBottomDivider,
|
|
98
|
+
{
|
|
99
|
+
opacity: cellAnimations.current[index],
|
|
100
|
+
transform: [
|
|
101
|
+
{
|
|
102
|
+
translateY: cellAnimations.current[index].interpolate({
|
|
103
|
+
inputRange: [0, 1],
|
|
104
|
+
outputRange: [12, 0],
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
scale: cellAnimations.current[index].interpolate({
|
|
109
|
+
inputRange: [0, 1],
|
|
110
|
+
outputRange: [0.94, 1],
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
]}
|
|
116
|
+
>
|
|
117
|
+
<KpiValue value={item.value} color={item.color} run={run} />
|
|
118
|
+
<Text style={styles.label}>{item.label.toUpperCase()}</Text>
|
|
119
|
+
<View style={styles.barTrack}>
|
|
120
|
+
<Animated.View style={[styles.colorBar, { backgroundColor: item.color, transform: [{ scaleX: cellAnimations.current[index].interpolate({ inputRange: [0, 1], outputRange: [0.05, 1] }) }] }]} />
|
|
121
|
+
</View>
|
|
122
|
+
</Animated.View>
|
|
123
|
+
))}
|
|
124
|
+
</View>
|
|
125
|
+
</GlassView>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function KpiValue({ value, color, run }: { value: string; color: string; run: number }) {
|
|
130
|
+
const progress = useRef(new Animated.Value(0)).current;
|
|
131
|
+
const [display, setDisplay] = useState(value);
|
|
132
|
+
const parsed = Number.parseFloat(value.replace(/[^0-9.-]/g, ""));
|
|
133
|
+
const suffix = value.replace(/[0-9.,\s-]/g, "").trim();
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!Number.isFinite(parsed)) { setDisplay(value); return; }
|
|
137
|
+
progress.setValue(0);
|
|
138
|
+
const listener = progress.addListener(({ value: current }) => {
|
|
139
|
+
const next = Math.round(parsed * current).toLocaleString();
|
|
140
|
+
setDisplay(suffix ? `${next} ${suffix}` : next);
|
|
141
|
+
});
|
|
142
|
+
const animation = Animated.timing(progress, { toValue: 1, duration: 720, easing: Easing.out(Easing.cubic), useNativeDriver: false });
|
|
143
|
+
animation.start();
|
|
144
|
+
return () => { animation.stop(); progress.removeListener(listener); };
|
|
145
|
+
}, [parsed, progress, run, suffix, value]);
|
|
146
|
+
|
|
147
|
+
return <Text style={[styles.value, { color }]}>{display}</Text>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const styles = StyleSheet.create({
|
|
151
|
+
card: {
|
|
152
|
+
borderRadius: 24,
|
|
153
|
+
overflow: "hidden",
|
|
154
|
+
backgroundColor: "rgba(255,255,255,0.72)",
|
|
155
|
+
borderWidth: 1,
|
|
156
|
+
borderColor: "rgba(255,255,255,0.92)",
|
|
157
|
+
},
|
|
158
|
+
androidFallback: { backgroundColor: "rgba(255,255,255,0.76)" },
|
|
159
|
+
gradientTrack: { ...StyleSheet.absoluteFillObject, opacity: 1 },
|
|
160
|
+
gradientFill: { flex: 1 },
|
|
161
|
+
grid: { flexDirection: "row", flexWrap: "wrap" },
|
|
162
|
+
cell: { width: "50%", alignItems: "center", paddingVertical: 18, paddingHorizontal: 8 },
|
|
163
|
+
cellRightDivider: { borderRightWidth: 1, borderRightColor: inkAlpha(0.07) },
|
|
164
|
+
cellBottomDivider: { borderBottomWidth: 1, borderBottomColor: inkAlpha(0.07) },
|
|
165
|
+
value: { fontSize: 22, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, letterSpacing: -0.5, textAlign: "center" },
|
|
166
|
+
label: { marginTop: 8, fontSize: 9.5, fontFamily: fonts.bold, fontWeight: fontWeights.bold, color: inkAlpha(0.42), letterSpacing: 0.5, textAlign: "center" },
|
|
167
|
+
barTrack: { width: 28, height: 3, marginTop: 9, overflow: "hidden", borderRadius: 2, backgroundColor: inkAlpha(0.06) },
|
|
168
|
+
colorBar: { width: "100%", height: "100%", borderRadius: 2 },
|
|
169
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { Animated, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import Svg, { Path } from "react-native-svg";
|
|
4
|
+
import { accentAlpha, colors, fontWeights, fonts } from "../../constants/theme";
|
|
5
|
+
import LiquidGlassSurface from "../glass/LiquidGlassSurface";
|
|
6
|
+
|
|
7
|
+
type MoreButtonProps = {
|
|
8
|
+
label: string;
|
|
9
|
+
onPress: () => void;
|
|
10
|
+
delay?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default function MoreButton({ label, onPress, delay = 0 }: MoreButtonProps) {
|
|
14
|
+
const { width } = useWindowDimensions();
|
|
15
|
+
const press = useRef(new Animated.Value(0)).current;
|
|
16
|
+
const entrance = useRef(new Animated.Value(0)).current;
|
|
17
|
+
// Une seule fois au montage — pas à chaque focus (voir ToolCard.tsx).
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const animation = Animated.timing(entrance, { toValue: 1, duration: 500, delay, useNativeDriver: true });
|
|
20
|
+
animation.start();
|
|
21
|
+
return () => animation.stop();
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
}, []);
|
|
24
|
+
const animatePress = (toValue: number) => {
|
|
25
|
+
Animated.spring(press, { toValue, friction: 7, tension: 110, useNativeDriver: true }).start();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Animated.View style={[styles.wrapper, { 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.985] }) }] }]}>
|
|
30
|
+
<Pressable accessibilityRole="button" accessibilityLabel={label} onPress={onPress} onPressIn={() => animatePress(1)} onPressOut={() => animatePress(0)} style={styles.pressable}>
|
|
31
|
+
<LiquidGlassSurface width={width - 40} height={48} cornerRadius={16} tintColor={colors.accent} tintOpacity={0.045} borderOpacity={0.84} refractionStrength={3} nativeGlass>
|
|
32
|
+
<View style={styles.button} pointerEvents="none">
|
|
33
|
+
<View style={styles.icon}>
|
|
34
|
+
<Svg width={16} height={16} viewBox="0 0 24 24">
|
|
35
|
+
<Path d="M12 5v14M5 12h14" fill="none" stroke={colors.accent} strokeWidth={2.4} strokeLinecap="round" />
|
|
36
|
+
</Svg>
|
|
37
|
+
</View>
|
|
38
|
+
<Text style={styles.label}>{label}</Text>
|
|
39
|
+
</View>
|
|
40
|
+
</LiquidGlassSurface>
|
|
41
|
+
</Pressable>
|
|
42
|
+
</Animated.View>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
wrapper: { alignSelf: "stretch", height: 48 },
|
|
48
|
+
pressable: { width: "100%", height: "100%" },
|
|
49
|
+
button: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
flexDirection: "row",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
gap: 9,
|
|
55
|
+
},
|
|
56
|
+
icon: {
|
|
57
|
+
width: 28,
|
|
58
|
+
height: 28,
|
|
59
|
+
borderRadius: 14,
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
backgroundColor: accentAlpha(0.10),
|
|
63
|
+
},
|
|
64
|
+
label: { color: colors.accent, fontFamily: fonts.bold, fontWeight: fontWeights.bold, fontSize: 12.5 },
|
|
65
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
3
|
+
import { router } from "expo-router";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import Svg, { Path } from "react-native-svg";
|
|
6
|
+
import AnimatedPressable from "../AnimatedPressable";
|
|
7
|
+
import { TEXT, card, colors, fontWeights, fonts } from "../../constants/theme";
|
|
8
|
+
|
|
9
|
+
const 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";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* La cloche, avec le nombre de notifications non lues.
|
|
13
|
+
*
|
|
14
|
+
* Elle remplace la carte « Notifications » qui occupait une place dans la
|
|
15
|
+
* grille de chaque tableau de bord. Une carte ne dit pas s'il y a quelque
|
|
16
|
+
* chose à lire : il fallait l'ouvrir pour le découvrir. Une cloche avec son
|
|
17
|
+
* compte le dit sans qu'on la touche, et rend sa place à ce qui compte.
|
|
18
|
+
*
|
|
19
|
+
* Le compte se rafraîchit à chaque retour sur l'écran : une notification lue
|
|
20
|
+
* ailleurs ne doit pas laisser une pastille qui ment.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The bell, and nothing else.
|
|
24
|
+
*
|
|
25
|
+
* It used to fetch its own count, which tied one small piece of chrome to an
|
|
26
|
+
* API shape and made it impossible to render in a test or a preview. The
|
|
27
|
+
* screen owns the data; the bell renders what it is given.
|
|
28
|
+
*/
|
|
29
|
+
export default function NotificationBell({
|
|
30
|
+
unread = 0,
|
|
31
|
+
accent,
|
|
32
|
+
onPress
|
|
33
|
+
}: {
|
|
34
|
+
unread?: number;
|
|
35
|
+
accent?: string;
|
|
36
|
+
/** Defaults to the notifications screen. */
|
|
37
|
+
onPress?: () => void;
|
|
38
|
+
}) {
|
|
39
|
+
const { t } = useTranslation();
|
|
40
|
+
|
|
41
|
+
/* Capped at 99+: three digits do not fit, and "1247 unread" helps nobody. */
|
|
42
|
+
const badge = useMemo(() => {
|
|
43
|
+
const value = Math.floor(Number(unread) || 0);
|
|
44
|
+
if (value <= 0) return null;
|
|
45
|
+
return value > 99 ? "99+" : String(value);
|
|
46
|
+
}, [unread]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<AnimatedPressable
|
|
50
|
+
accessibilityRole="button"
|
|
51
|
+
accessibilityLabel={badge ? t("notifications.unread_label", { count: unread }) : t("notifications.title")}
|
|
52
|
+
onPress={onPress ?? (() => router.push("/notifications" as never))}
|
|
53
|
+
style={styles.bell}
|
|
54
|
+
>
|
|
55
|
+
<View style={styles.inner}>
|
|
56
|
+
<Svg width={19} height={19} viewBox="0 0 24 24">
|
|
57
|
+
<Path d={BELL} fill="none" stroke={TEXT} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
|
|
58
|
+
</Svg>
|
|
59
|
+
{badge ? (
|
|
60
|
+
<View style={[styles.badge, accent ? { backgroundColor: accent } : null]}>
|
|
61
|
+
<Text style={styles.badgeText} numberOfLines={1}>{badge}</Text>
|
|
62
|
+
</View>
|
|
63
|
+
) : null}
|
|
64
|
+
</View>
|
|
65
|
+
</AnimatedPressable>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
bell: { borderRadius: 15 },
|
|
71
|
+
inner: { width: 44, height: 44, alignItems: "center", justifyContent: "center", borderRadius: 15, ...card },
|
|
72
|
+
/* La pastille déborde volontairement du cadre : posée dedans, elle
|
|
73
|
+
masquerait la cloche dès deux chiffres. */
|
|
74
|
+
badge: {
|
|
75
|
+
position: "absolute", top: -4, right: -5, minWidth: 20, paddingHorizontal: 5, paddingVertical: 1,
|
|
76
|
+
borderRadius: 50, backgroundColor: "#c34251", alignItems: "center", justifyContent: "center",
|
|
77
|
+
borderWidth: 2, borderColor: colors.background,
|
|
78
|
+
},
|
|
79
|
+
badgeText: { color: colors.paper, fontFamily: fonts.extrabold, fontWeight: fontWeights.extrabold, fontSize: 10 },
|
|
80
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { Animated, Pressable, StyleSheet, Text, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import Svg, { Path } from "react-native-svg";
|
|
5
|
+
import LiquidGlassSurface from "../glass/LiquidGlassSurface";
|
|
6
|
+
import { accentAlpha, colors, fontWeights, fonts, inkAlpha } from "../../constants/theme";
|
|
7
|
+
|
|
8
|
+
export type StaffTab = { key: string; label: string; path?: string };
|
|
9
|
+
export type StaffTabBarProps = { tabs: StaffTab[]; activeKey: string; onSelect: (tab: StaffTab) => void };
|
|
10
|
+
|
|
11
|
+
const ICONS: Record<string, string> = {
|
|
12
|
+
home: "M3 10.5 12 3l9 7.5V21a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1V10.5Z",
|
|
13
|
+
students: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm12 10v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75",
|
|
14
|
+
messages: "M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10Z",
|
|
15
|
+
oracle: "M12 2 2 7l10 5 10-5-10-5ZM2 17l10 5 10-5M2 12l10 5 10-5",
|
|
16
|
+
more: "M4 7h16M4 12h16M4 17h16",
|
|
17
|
+
assignments: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6",
|
|
18
|
+
grades: "M18 20V10M12 20V4M6 20v-6",
|
|
19
|
+
children: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z",
|
|
20
|
+
timetable: "M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function StaffTabBar({ tabs, activeKey, onSelect }: StaffTabBarProps) {
|
|
24
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
25
|
+
const insets = useSafeAreaInsets();
|
|
26
|
+
// Rendue en dehors du SafeAreaView (position absolute par-dessus tout l'écran) : on
|
|
27
|
+
// compense nous-mêmes l'inset bas (barre de gestes Android, home indicator iOS) pour
|
|
28
|
+
// que la barre ne soit jamais collée ou chevauchée par la zone système.
|
|
29
|
+
const bottomOffset = Math.max(18, insets.bottom + 8);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View style={[styles.wrapper, { bottom: bottomOffset }]}>
|
|
33
|
+
<LiquidGlassSurface width={screenWidth - 40} height={60} cornerRadius={22} tintColor={colors.paper} tintOpacity={0.10} borderOpacity={0.86} refractionStrength={3} nativeGlass>
|
|
34
|
+
<View style={styles.row}>
|
|
35
|
+
{tabs.map((tab) => <TabItem key={tab.key} tab={tab} active={tab.key === activeKey} onSelect={onSelect} />)}
|
|
36
|
+
</View>
|
|
37
|
+
</LiquidGlassSurface>
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function TabItem({ tab, active, onSelect }: { tab: StaffTab; active: boolean; onSelect: (tab: StaffTab) => void }) {
|
|
43
|
+
const press = useRef(new Animated.Value(0)).current;
|
|
44
|
+
const animate = (toValue: number) => Animated.spring(press, { toValue, friction: 7, tension: 115, useNativeDriver: true }).start();
|
|
45
|
+
const color = active ? colors.accent : inkAlpha(0.52);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Animated.View style={[styles.tabWrap, { transform: [{ scale: press.interpolate({ inputRange: [0, 1], outputRange: [1, 0.93] }) }] }]}>
|
|
49
|
+
<Pressable accessibilityRole="link" accessibilityLabel={tab.label} onPress={() => onSelect(tab)} onPressIn={() => animate(1)} onPressOut={() => animate(0)} style={styles.tab}>
|
|
50
|
+
<View style={[styles.iconShell, active && styles.iconShellActive]}>
|
|
51
|
+
<Svg width={20} height={20} viewBox="0 0 24 24">
|
|
52
|
+
<Path d={ICONS[tab.key] ?? ICONS.more} fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
|
|
53
|
+
</Svg>
|
|
54
|
+
</View>
|
|
55
|
+
<Text style={[styles.label, { color }, active && styles.labelActive]} numberOfLines={1}>{tab.label}</Text>
|
|
56
|
+
</Pressable>
|
|
57
|
+
</Animated.View>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
wrapper: { position: "absolute", left: 20, right: 20, alignItems: "center" },
|
|
63
|
+
row: { flex: 1, flexDirection: "row", paddingHorizontal: 4 },
|
|
64
|
+
tabWrap: { flex: 1 },
|
|
65
|
+
tab: { flex: 1, alignItems: "center", justifyContent: "center", gap: 4 },
|
|
66
|
+
iconShell: { width: 29, height: 27, alignItems: "center", justifyContent: "center", borderRadius: 10 },
|
|
67
|
+
iconShellActive: { backgroundColor: accentAlpha(0.12), borderWidth: 1, borderColor: accentAlpha(0.16) },
|
|
68
|
+
label: { fontFamily: fonts.medium, fontWeight: fontWeights.medium, fontSize: 9.5 },
|
|
69
|
+
labelActive: { fontFamily: fonts.bold, fontWeight: fontWeights.bold },
|
|
70
|
+
});
|
|
@@ -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
|
+
});
|