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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A screen that holds a form, and the keyboard that covers it.
|
|
3
|
+
*
|
|
4
|
+
* This was the same twenty lines pasted onto every screen with a text field —
|
|
5
|
+
* and pasted with DRIFT, which is the part that hurts: three screens, three
|
|
6
|
+
* different `behavior` values, so the keyboard pushed the layout differently
|
|
7
|
+
* depending on where you were.
|
|
8
|
+
*
|
|
9
|
+
* ANDROID TAKES NO `behavior`, AND THAT IS DELIBERATE. Expo sets
|
|
10
|
+
* `softwareKeyboardLayoutMode: 'resize'` by default, so the OS already shrinks
|
|
11
|
+
* the window when the keyboard opens. Adding `behavior="height"` on top makes
|
|
12
|
+
* the app correct for the same thing twice — the layout jumps, and inputs end
|
|
13
|
+
* up under the keyboard anyway. iOS does not resize, so it needs `padding`.
|
|
14
|
+
*
|
|
15
|
+
* SCROLLING IS ON BY DEFAULT. A form that fits today stops fitting on a small
|
|
16
|
+
* phone, in a larger font, or in a language with longer words. `flexGrow: 1`
|
|
17
|
+
* keeps a short form vertically centred while letting a long one scroll.
|
|
18
|
+
*
|
|
19
|
+
* A DRAG DISMISSES THE KEYBOARD, A TAP DOES NOT. `keyboardShouldPersistTaps`
|
|
20
|
+
* is what lets someone tap "Sign in" while the keyboard is still up: without
|
|
21
|
+
* it the first tap only closes the keyboard and the button appears dead.
|
|
22
|
+
*/
|
|
23
|
+
import type { ReactNode } from 'react';
|
|
24
|
+
import {
|
|
25
|
+
Keyboard,
|
|
26
|
+
KeyboardAvoidingView,
|
|
27
|
+
Platform,
|
|
28
|
+
ScrollView,
|
|
29
|
+
View,
|
|
30
|
+
type StyleProp,
|
|
31
|
+
type ViewStyle
|
|
32
|
+
} from 'react-native';
|
|
33
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
34
|
+
import { colors } from '../constants/theme';
|
|
35
|
+
|
|
36
|
+
export function KeyboardScreen({
|
|
37
|
+
children,
|
|
38
|
+
scroll = true,
|
|
39
|
+
offset = 0,
|
|
40
|
+
style,
|
|
41
|
+
contentStyle,
|
|
42
|
+
background
|
|
43
|
+
}: {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
/** Turn off for a screen that manages its own scrolling — a chat, a long list. */
|
|
46
|
+
scroll?: boolean;
|
|
47
|
+
/** Height of anything fixed above the form (a header), in points. */
|
|
48
|
+
offset?: number;
|
|
49
|
+
style?: StyleProp<ViewStyle>;
|
|
50
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
51
|
+
/** Rendered behind everything: a gradient, a grid, an image. */
|
|
52
|
+
background?: ReactNode;
|
|
53
|
+
}) {
|
|
54
|
+
const body = scroll ? (
|
|
55
|
+
<ScrollView
|
|
56
|
+
keyboardShouldPersistTaps="handled"
|
|
57
|
+
onScrollBeginDrag={Keyboard.dismiss}
|
|
58
|
+
contentContainerStyle={[{ flexGrow: 1 }, contentStyle]}
|
|
59
|
+
showsVerticalScrollIndicator={false}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</ScrollView>
|
|
63
|
+
) : (
|
|
64
|
+
<View style={[{ flex: 1 }, contentStyle]}>{children}</View>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View style={[{ flex: 1, backgroundColor: colors.background }, style]}>
|
|
69
|
+
{background}
|
|
70
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
71
|
+
<KeyboardAvoidingView
|
|
72
|
+
style={{ flex: 1 }}
|
|
73
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
74
|
+
keyboardVerticalOffset={offset}
|
|
75
|
+
>
|
|
76
|
+
{body}
|
|
77
|
+
</KeyboardAvoidingView>
|
|
78
|
+
</SafeAreaView>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Svg, { Path, Circle, Line } from "react-native-svg";
|
|
2
|
+
import { MUTED } from "../constants/theme";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Show or hide the password.
|
|
6
|
+
*
|
|
7
|
+
* `visible` describes what the FIELD is doing, not what the icon draws: when
|
|
8
|
+
* the password is visible the icon is the struck-through eye, because that is
|
|
9
|
+
* the action offered — hide it. Getting this backwards is the classic bug.
|
|
10
|
+
*/
|
|
11
|
+
interface PasswordEyeIconProps {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
size?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function PasswordEyeIcon({ visible, size = 18, color = MUTED }: PasswordEyeIconProps) {
|
|
18
|
+
if (visible) {
|
|
19
|
+
return (
|
|
20
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2}>
|
|
21
|
+
<Path
|
|
22
|
+
d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
|
+
/>
|
|
26
|
+
<Line x1="1" y1="1" x2="23" y2="23" strokeLinecap="round" />
|
|
27
|
+
</Svg>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2}>
|
|
33
|
+
<Path
|
|
34
|
+
d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"
|
|
35
|
+
strokeLinecap="round"
|
|
36
|
+
strokeLinejoin="round"
|
|
37
|
+
/>
|
|
38
|
+
<Circle cx="12" cy="12" r="3" />
|
|
39
|
+
</Svg>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screens behind the session, kept behind it.
|
|
3
|
+
*
|
|
4
|
+
* Signing out used to replace the top screen with the sign-in page and leave
|
|
5
|
+
* the whole stack behind it: a few taps on Back returned to the dashboard —
|
|
6
|
+
* signed out, with the previous person's data still on screen. `replace`, not
|
|
7
|
+
* `push`, and the decision waits for the session to finish restoring.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
import { useRouter, useSegments } from 'expo-router';
|
|
11
|
+
import { guard } from '../features/routes';
|
|
12
|
+
import { useAuth } from '../context/AuthContext';
|
|
13
|
+
|
|
14
|
+
export function SessionGuard({ children }: { children: React.ReactNode }) {
|
|
15
|
+
const { user, loading } = useAuth();
|
|
16
|
+
const segments = useSegments();
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const redirect = guard.shouldRedirectToLogin({
|
|
21
|
+
isLoading: loading,
|
|
22
|
+
isAuthenticated: Boolean(user),
|
|
23
|
+
route: segments as readonly string[]
|
|
24
|
+
});
|
|
25
|
+
if (redirect) router.replace(guard.loginRoute as never);
|
|
26
|
+
}, [user, loading, segments, router]);
|
|
27
|
+
|
|
28
|
+
return <>{children}</>;
|
|
29
|
+
}
|
|
@@ -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
|
+
});
|