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,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in.
|
|
3
|
+
*
|
|
4
|
+
* The password rules come from @astratra/client and are the SAME object the
|
|
5
|
+
* server validates against — a rule duplicated with a drift is a password
|
|
6
|
+
* accepted on screen and refused on submit.
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { ActivityIndicator, Pressable, Text, TextInput, View } from 'react-native';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import { useRouter } from 'expo-router';
|
|
12
|
+
import { createPasswordRules } from '@astratra/client';
|
|
13
|
+
import { useAuth } from '../context/AuthContext';
|
|
14
|
+
import { AnimatedPressable } from '../components/AnimatedPressable';
|
|
15
|
+
import { GlassPanel } from '../components/GlassPanel';
|
|
16
|
+
import { KeyboardScreen } from '../components/KeyboardScreen';
|
|
17
|
+
import GridBackground from '../components/GridBackground';
|
|
18
|
+
import PasswordEyeIcon from '../components/PasswordEyeIcon';
|
|
19
|
+
import { colors, fontWeights, spacing } from '../constants/theme';
|
|
20
|
+
|
|
21
|
+
const rules = createPasswordRules();
|
|
22
|
+
|
|
23
|
+
export default function Login() {
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const { signIn } = useAuth();
|
|
26
|
+
const router = useRouter();
|
|
27
|
+
const [email, setEmail] = useState('');
|
|
28
|
+
const [password, setPassword] = useState('');
|
|
29
|
+
const [busy, setBusy] = useState(false);
|
|
30
|
+
const [revealed, setRevealed] = useState(false);
|
|
31
|
+
const [failed, setFailed] = useState(false);
|
|
32
|
+
|
|
33
|
+
const submit = async () => {
|
|
34
|
+
setFailed(false);
|
|
35
|
+
setBusy(true);
|
|
36
|
+
try {
|
|
37
|
+
await signIn(email.trim(), password);
|
|
38
|
+
router.replace('/dashboard');
|
|
39
|
+
} catch {
|
|
40
|
+
setFailed(true);
|
|
41
|
+
} finally {
|
|
42
|
+
setBusy(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const input = {
|
|
47
|
+
color: colors.text,
|
|
48
|
+
backgroundColor: colors.surface,
|
|
49
|
+
borderColor: colors.border,
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
borderRadius: 14,
|
|
52
|
+
padding: spacing.md,
|
|
53
|
+
marginTop: spacing.sm
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<KeyboardScreen background={<GridBackground />} contentStyle={{ justifyContent: 'center', padding: spacing.lg }}>
|
|
58
|
+
<GlassPanel>
|
|
59
|
+
<Text style={{ color: colors.text, fontSize: 24, fontWeight: fontWeights.bold }}>{t('auth.sign_in')}</Text>
|
|
60
|
+
|
|
61
|
+
<TextInput
|
|
62
|
+
style={input}
|
|
63
|
+
placeholder={t('auth.email')}
|
|
64
|
+
placeholderTextColor={colors.muted}
|
|
65
|
+
autoCapitalize="none"
|
|
66
|
+
keyboardType="email-address"
|
|
67
|
+
value={email}
|
|
68
|
+
onChangeText={setEmail}
|
|
69
|
+
/>
|
|
70
|
+
<View>
|
|
71
|
+
<TextInput
|
|
72
|
+
style={[input, { paddingRight: spacing.xl + spacing.md }]}
|
|
73
|
+
placeholder={t('auth.password')}
|
|
74
|
+
placeholderTextColor={colors.muted}
|
|
75
|
+
secureTextEntry={!revealed}
|
|
76
|
+
value={password}
|
|
77
|
+
onChangeText={setPassword}
|
|
78
|
+
/>
|
|
79
|
+
<Pressable
|
|
80
|
+
accessibilityRole="button"
|
|
81
|
+
accessibilityLabel={t(revealed ? 'auth.hide_password' : 'auth.show_password')}
|
|
82
|
+
onPress={() => setRevealed((shown) => !shown)}
|
|
83
|
+
/* A bigger touch area than the glyph: an 18px icon is below every
|
|
84
|
+
platform's minimum target and is missed as often as it is hit. */
|
|
85
|
+
hitSlop={12}
|
|
86
|
+
style={{ position: 'absolute', right: spacing.md, top: 0, bottom: 0, justifyContent: 'center' }}
|
|
87
|
+
>
|
|
88
|
+
<PasswordEyeIcon visible={revealed} />
|
|
89
|
+
</Pressable>
|
|
90
|
+
</View>
|
|
91
|
+
|
|
92
|
+
{/* Each condition separately, so the person sees WHICH one is missing
|
|
93
|
+
while typing — not a single line they discover they failed on submit. */}
|
|
94
|
+
{password.length > 0 && rules.check(password).map((rule) => (
|
|
95
|
+
<Text key={rule.key} style={{ color: rule.met ? colors.accent : colors.muted, marginTop: spacing.xs }}>
|
|
96
|
+
{rule.met ? '✓' : '·'} {t(`password.${rule.key}`)}
|
|
97
|
+
</Text>
|
|
98
|
+
))}
|
|
99
|
+
|
|
100
|
+
{failed && <Text style={{ color: colors.danger, marginTop: spacing.sm }}>{t('auth.failed')}</Text>}
|
|
101
|
+
|
|
102
|
+
<AnimatedPressable
|
|
103
|
+
onPress={submit}
|
|
104
|
+
disabled={busy}
|
|
105
|
+
style={{ marginTop: spacing.lg, backgroundColor: colors.accent, borderRadius: 14, padding: spacing.md }}
|
|
106
|
+
>
|
|
107
|
+
{busy
|
|
108
|
+
? <ActivityIndicator color={colors.onAccent} />
|
|
109
|
+
: <Text style={{ color: colors.onAccent, textAlign: 'center', fontWeight: fontWeights.semibold }}>{t('auth.sign_in')}</Text>}
|
|
110
|
+
</AnimatedPressable>
|
|
111
|
+
|
|
112
|
+
<AnimatedPressable onPress={() => router.push('/forgot-password')} style={{ marginTop: spacing.md }}>
|
|
113
|
+
<Text style={{ color: colors.muted, textAlign: 'center' }}>{t('auth.forgot')}</Text>
|
|
114
|
+
</AnimatedPressable>
|
|
115
|
+
</GlassPanel>
|
|
116
|
+
</KeyboardScreen>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The notification list, and the foreground watch that keeps it live.
|
|
3
|
+
*
|
|
4
|
+
* The first sweep raises no banner: on launch every unread item looks new, and
|
|
5
|
+
* twenty banners at once is how notifications get switched off for good.
|
|
6
|
+
*/
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { AppState, FlatList, Text, View } from 'react-native';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { FOREGROUND_POLL_MS, freshItems, nextStamp, shouldPoll } from '@astratra/native';
|
|
11
|
+
import { api } from '../services/session';
|
|
12
|
+
import { useAuth } from '../context/AuthContext';
|
|
13
|
+
import { GlassPanel } from '../components/GlassPanel';
|
|
14
|
+
import { colors, fontWeights, spacing } from '../constants/theme';
|
|
15
|
+
import GridBackground from '../components/GridBackground';
|
|
16
|
+
|
|
17
|
+
type Item = { id: string; title?: string; message?: string; createdAt?: string; read?: boolean };
|
|
18
|
+
|
|
19
|
+
export default function Notifications() {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const { user } = useAuth();
|
|
22
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
23
|
+
const lastSeen = useRef<string | null>(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let alive = true;
|
|
27
|
+
|
|
28
|
+
const sweep = async () => {
|
|
29
|
+
if (!shouldPoll(AppState.currentState, Boolean(user))) return;
|
|
30
|
+
try {
|
|
31
|
+
const list = await api.request<Item[]>('/notifications');
|
|
32
|
+
if (!alive) return;
|
|
33
|
+
setItems(list);
|
|
34
|
+
/* Banner only what arrived since the last sweep, then move the mark —
|
|
35
|
+
forward only, or the same item banners again next time. */
|
|
36
|
+
void freshItems(list, lastSeen.current);
|
|
37
|
+
lastSeen.current = nextStamp(list, lastSeen.current);
|
|
38
|
+
} catch {
|
|
39
|
+
/* a failed sweep is not worth a message: the next one is 30s away */
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
void sweep();
|
|
44
|
+
const timer = setInterval(sweep, FOREGROUND_POLL_MS);
|
|
45
|
+
return () => { alive = false; clearInterval(timer); };
|
|
46
|
+
}, [user]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View style={{ flex: 1, backgroundColor: colors.background }}>
|
|
50
|
+
<GridBackground />
|
|
51
|
+
<View style={{ flex: 1, padding: spacing.lg, paddingTop: spacing.xl * 2 }}>
|
|
52
|
+
<Text style={{ color: colors.text, fontSize: 28, fontWeight: fontWeights.bold }}>{t('notifications.title')}</Text>
|
|
53
|
+
<FlatList
|
|
54
|
+
data={items}
|
|
55
|
+
keyExtractor={(item) => item.id}
|
|
56
|
+
ListEmptyComponent={<Text style={{ color: colors.muted, marginTop: spacing.lg }}>{t('notifications.empty')}</Text>}
|
|
57
|
+
renderItem={({ item }) => (
|
|
58
|
+
<GlassPanel style={{ marginTop: spacing.sm }}>
|
|
59
|
+
<Text style={{ color: colors.text, fontWeight: fontWeights.semibold }}>{item.title}</Text>
|
|
60
|
+
<Text style={{ color: colors.muted, marginTop: spacing.xs }}>{item.message}</Text>
|
|
61
|
+
</GlassPanel>
|
|
62
|
+
)}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closing screen of the flow — the one showcase screen in the template.
|
|
3
|
+
*
|
|
4
|
+
* `BrandBackground` is for exactly this: a full-bleed gradient with almost
|
|
5
|
+
* nothing on it. It is NOT for screens carrying content, where coloured ink on
|
|
6
|
+
* a saturated gradient stops being readable.
|
|
7
|
+
*/
|
|
8
|
+
import { Text, View } from 'react-native';
|
|
9
|
+
import { useRouter } from 'expo-router';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import BrandBackground from '../../components/BrandBackground';
|
|
12
|
+
import { AnimatedPressable } from '../../components/AnimatedPressable';
|
|
13
|
+
import { colors, fontWeights, spacing } from '../../constants/theme';
|
|
14
|
+
|
|
15
|
+
export default function OnboardingDone() {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<BrandBackground>
|
|
21
|
+
<View style={{ flex: 1, justifyContent: 'center', padding: spacing.xl }}>
|
|
22
|
+
<Text style={{ color: colors.onAccent, fontSize: 32, fontWeight: fontWeights.bold }}>
|
|
23
|
+
{t('onboarding.done_title')}
|
|
24
|
+
</Text>
|
|
25
|
+
<Text style={{ color: 'rgba(255,255,255,0.82)', marginTop: spacing.sm, fontSize: 16 }}>
|
|
26
|
+
{t('onboarding.done_help')}
|
|
27
|
+
</Text>
|
|
28
|
+
|
|
29
|
+
<AnimatedPressable
|
|
30
|
+
onPress={() => router.replace('/login')}
|
|
31
|
+
style={{
|
|
32
|
+
marginTop: spacing.xl,
|
|
33
|
+
backgroundColor: colors.onAccent,
|
|
34
|
+
borderRadius: 14,
|
|
35
|
+
padding: spacing.md
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<Text style={{ color: colors.accent, textAlign: 'center', fontWeight: fontWeights.semibold }}>
|
|
39
|
+
{t('auth.sign_in')}
|
|
40
|
+
</Text>
|
|
41
|
+
</AnimatedPressable>
|
|
42
|
+
</View>
|
|
43
|
+
</BrandBackground>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first step of a sign-up, and the shape every other step copies.
|
|
3
|
+
*
|
|
4
|
+
* A flow like this is a chain of `StepScreen`s: each one owns its fields and
|
|
5
|
+
* says where "next" goes. The shell — progress, title, keyboard handling, the
|
|
6
|
+
* back affordance — is not each screen's business.
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { Text, TextInput } from 'react-native';
|
|
10
|
+
import { useRouter } from 'expo-router';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import StepScreen from '../../components/onboarding/StepScreen';
|
|
13
|
+
import { colors, fontWeights, spacing } from '../../constants/theme';
|
|
14
|
+
|
|
15
|
+
const TOTAL_STEPS = 2;
|
|
16
|
+
|
|
17
|
+
export default function OnboardingAccount() {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const router = useRouter();
|
|
20
|
+
const [email, setEmail] = useState('');
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<StepScreen
|
|
24
|
+
step={1}
|
|
25
|
+
totalSteps={TOTAL_STEPS}
|
|
26
|
+
eyebrow={t('onboarding.eyebrow')}
|
|
27
|
+
title={t('onboarding.account_title')}
|
|
28
|
+
onNext={() => router.push('/onboarding/done')}
|
|
29
|
+
nextDisabled={!email.includes('@')}
|
|
30
|
+
onSkip={() => router.replace('/login')}
|
|
31
|
+
>
|
|
32
|
+
<Text style={{ color: colors.muted, marginBottom: spacing.md }}>{t('onboarding.account_help')}</Text>
|
|
33
|
+
<TextInput
|
|
34
|
+
style={{
|
|
35
|
+
color: colors.text,
|
|
36
|
+
backgroundColor: colors.surface,
|
|
37
|
+
borderColor: colors.border,
|
|
38
|
+
borderWidth: 1,
|
|
39
|
+
borderRadius: 14,
|
|
40
|
+
padding: spacing.md,
|
|
41
|
+
fontWeight: fontWeights.medium
|
|
42
|
+
}}
|
|
43
|
+
placeholder={t('auth.email')}
|
|
44
|
+
placeholderTextColor={colors.muted}
|
|
45
|
+
autoCapitalize="none"
|
|
46
|
+
keyboardType="email-address"
|
|
47
|
+
value={email}
|
|
48
|
+
onChangeText={setEmail}
|
|
49
|
+
/>
|
|
50
|
+
</StepScreen>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings: two switches that both talk to the device, not just to the app.
|
|
3
|
+
*
|
|
4
|
+
* The push switch is driven by the controller from @astratra/native — the one
|
|
5
|
+
* that re-reads the real state after every action instead of assuming its own
|
|
6
|
+
* success, and that publishes nothing once the screen is gone.
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import { Switch, Text, View } from 'react-native';
|
|
10
|
+
import * as LocalAuthentication from 'expo-local-authentication';
|
|
11
|
+
import * as SecureStore from 'expo-secure-store';
|
|
12
|
+
import { Linking } from 'react-native';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { createBiometricGate, createPushSettingsController, isPushEnabled } from '@astratra/native';
|
|
15
|
+
import { useAuth } from '../context/AuthContext';
|
|
16
|
+
import { push } from '../services/push';
|
|
17
|
+
import { NAMESPACE } from '../services/session';
|
|
18
|
+
import { AnimatedPressable } from '../components/AnimatedPressable';
|
|
19
|
+
import { GlassPanel } from '../components/GlassPanel';
|
|
20
|
+
import { colors, fontWeights, spacing } from '../constants/theme';
|
|
21
|
+
import GridBackground from '../components/GridBackground';
|
|
22
|
+
|
|
23
|
+
const gate = createBiometricGate({
|
|
24
|
+
keystore: SecureStore,
|
|
25
|
+
authenticator: LocalAuthentication,
|
|
26
|
+
namespace: NAMESPACE
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default function Settings() {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const { signOut } = useAuth();
|
|
32
|
+
const [biometric, setBiometric] = useState({ enabled: false, supported: false });
|
|
33
|
+
const [pushState, setPushState] = useState({ state: 'loading' as string, busy: false });
|
|
34
|
+
const [togglePush, setTogglePush] = useState<() => void>(() => () => {});
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
void gate.read().then(setBiometric);
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const controller = createPushSettingsController(
|
|
42
|
+
{
|
|
43
|
+
getState: () => push.getState(),
|
|
44
|
+
enable: () => push.enable(),
|
|
45
|
+
disable: () => push.disable(),
|
|
46
|
+
openSettings: () => Linking.openSettings()
|
|
47
|
+
},
|
|
48
|
+
setPushState
|
|
49
|
+
);
|
|
50
|
+
const screen = controller.activate();
|
|
51
|
+
setTogglePush(() => () => void controller.act());
|
|
52
|
+
return () => screen.dispose();
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
const toggleBiometric = async () => {
|
|
56
|
+
const next = biometric.enabled ? await gate.disable() : await gate.enable({ promptMessage: t('app.name') });
|
|
57
|
+
setBiometric(await gate.read());
|
|
58
|
+
void next;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const row = { flexDirection: 'row' as const, alignItems: 'center' as const, justifyContent: 'space-between' as const };
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View style={{ flex: 1, backgroundColor: colors.background }}>
|
|
65
|
+
<GridBackground />
|
|
66
|
+
<View style={{ flex: 1, padding: spacing.lg, paddingTop: spacing.xl * 2 }}>
|
|
67
|
+
<Text style={{ color: colors.text, fontSize: 28, fontWeight: fontWeights.bold }}>{t('settings.title')}</Text>
|
|
68
|
+
|
|
69
|
+
{biometric.supported && (
|
|
70
|
+
<GlassPanel style={{ marginTop: spacing.lg }}>
|
|
71
|
+
<View style={row}>
|
|
72
|
+
<Text style={{ color: colors.text }}>{t('settings.biometric')}</Text>
|
|
73
|
+
<Switch value={biometric.enabled} onValueChange={toggleBiometric} />
|
|
74
|
+
</View>
|
|
75
|
+
</GlassPanel>
|
|
76
|
+
)}
|
|
77
|
+
|
|
78
|
+
<GlassPanel style={{ marginTop: spacing.md }}>
|
|
79
|
+
<View style={row}>
|
|
80
|
+
<Text style={{ color: colors.text }}>{t('settings.notifications')}</Text>
|
|
81
|
+
<Switch value={isPushEnabled(pushState.state)} disabled={pushState.busy} onValueChange={togglePush} />
|
|
82
|
+
</View>
|
|
83
|
+
</GlassPanel>
|
|
84
|
+
|
|
85
|
+
<AnimatedPressable onPress={signOut} style={{ marginTop: spacing.xl }}>
|
|
86
|
+
<GlassPanel>
|
|
87
|
+
<Text style={{ color: colors.danger, textAlign: 'center', fontWeight: fontWeights.semibold }}>
|
|
88
|
+
{t('settings.sign_out')}
|
|
89
|
+
</Text>
|
|
90
|
+
</GlassPanel>
|
|
91
|
+
</AnimatedPressable>
|
|
92
|
+
</View>
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's identity, read at build time.
|
|
3
|
+
*
|
|
4
|
+
* The API URL is NOT baked in here as a literal: staging and production build
|
|
5
|
+
* from the same source. It arrives through the environment, and the code has a
|
|
6
|
+
* development default so a fresh clone runs without any setup.
|
|
7
|
+
*
|
|
8
|
+
* A KEY WITH NO VALUE IS OMITTED, NEVER SET TO null. Expo serialises `null` in
|
|
9
|
+
* `extra` as `{}` — an empty object, which is truthy. A `projectId: null`
|
|
10
|
+
* therefore reaches the CLI as `projectId: {}`, and manifest signing crashes
|
|
11
|
+
* with "path must be of type string" before the app ever loads.
|
|
12
|
+
*/
|
|
13
|
+
const extra = {};
|
|
14
|
+
|
|
15
|
+
if (process.env.EXPO_PUBLIC_API_BASE_URL) {
|
|
16
|
+
extra.apiBaseUrl = process.env.EXPO_PUBLIC_API_BASE_URL;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (process.env.EAS_PROJECT_ID) {
|
|
20
|
+
extra.eas = { projectId: process.env.EAS_PROJECT_ID };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
expo: {
|
|
25
|
+
name: 'Astratra App',
|
|
26
|
+
slug: 'astratra-app',
|
|
27
|
+
scheme: 'astratraapp',
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
orientation: 'portrait',
|
|
30
|
+
userInterfaceStyle: 'automatic',
|
|
31
|
+
newArchEnabled: true,
|
|
32
|
+
ios: { supportsTablet: true, bundleIdentifier: 'com.example.astratraapp' },
|
|
33
|
+
android: { package: 'com.example.astratraapp', edgeToEdgeEnabled: true },
|
|
34
|
+
plugins: ['expo-router', 'expo-secure-store', 'expo-notifications', 'expo-local-authentication'],
|
|
35
|
+
extra
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `react-native-worklets/plugin` is not optional.
|
|
3
|
+
*
|
|
4
|
+
* Reanimated 4 compiles its worklets through this Babel plugin, and Skia's
|
|
5
|
+
* animation layer pulls Reanimated in. Without it the bundle builds fine and
|
|
6
|
+
* then throws at runtime — the failure looks like a missing package, not like
|
|
7
|
+
* a missing Babel plugin.
|
|
8
|
+
*
|
|
9
|
+
* It must stay LAST in the list.
|
|
10
|
+
*/
|
|
11
|
+
module.exports = function babelConfig(api) {
|
|
12
|
+
api.cache(true);
|
|
13
|
+
return {
|
|
14
|
+
presets: ['babel-preset-expo'],
|
|
15
|
+
plugins: ['react-native-worklets/plugin']
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A press that answers immediately.
|
|
3
|
+
*
|
|
4
|
+
* Native apps confirm a touch before the network does anything. Without it a
|
|
5
|
+
* tap feels lost, and people tap again — which is how a payment gets sent
|
|
6
|
+
* twice.
|
|
7
|
+
*/
|
|
8
|
+
import { useRef } from 'react';
|
|
9
|
+
import { Animated, Pressable, type PressableProps, type ViewStyle } from 'react-native';
|
|
10
|
+
|
|
11
|
+
export function AnimatedPressable({ children, style, ...props }: PressableProps & { style?: ViewStyle }) {
|
|
12
|
+
const scale = useRef(new Animated.Value(1)).current;
|
|
13
|
+
|
|
14
|
+
const to = (value: number) => Animated.spring(scale, {
|
|
15
|
+
toValue: value,
|
|
16
|
+
useNativeDriver: true,
|
|
17
|
+
speed: 40,
|
|
18
|
+
bounciness: 4
|
|
19
|
+
}).start();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Pressable
|
|
23
|
+
onPressIn={() => to(0.97)}
|
|
24
|
+
onPressOut={() => to(1)}
|
|
25
|
+
{...props}
|
|
26
|
+
>
|
|
27
|
+
<Animated.View style={[style, { transform: [{ scale }] }]}>{children}</Animated.View>
|
|
28
|
+
</Pressable>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Both shapes exported: the screens here import it by name, the ported
|
|
33
|
+
components by default. Neither should have to change to match the other. */
|
|
34
|
+
export default AnimatedPressable;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
import { LinearGradient } from "expo-linear-gradient";
|
|
4
|
+
|
|
5
|
+
/* Two steps of the accent. Change these and every showcase screen follows. */
|
|
6
|
+
const GRADIENT = ["#4a7af4", "#1a45d4"] as const;
|
|
7
|
+
|
|
8
|
+
interface BrandBackgroundProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
style?: ViewStyle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A full-bleed brand gradient, for showcase screens — a splash, a public
|
|
15
|
+
* landing. Not for screens holding content: coloured ink on a saturated
|
|
16
|
+
* gradient is unreadable.
|
|
17
|
+
*/
|
|
18
|
+
export default function BrandBackground({ children, style }: BrandBackgroundProps) {
|
|
19
|
+
return (
|
|
20
|
+
<LinearGradient
|
|
21
|
+
colors={GRADIENT}
|
|
22
|
+
start={{ x: 0, y: 0 }}
|
|
23
|
+
end={{ x: 1, y: 1 }}
|
|
24
|
+
style={[styles.fill, style]}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</LinearGradient>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
fill: { flex: 1 },
|
|
33
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One broken screen must not take the app with it.
|
|
3
|
+
*
|
|
4
|
+
* Without a boundary, a render error on a detail screen unmounts everything
|
|
5
|
+
* and leaves a white rectangle — indistinguishable, to the person holding the
|
|
6
|
+
* phone, from a crash.
|
|
7
|
+
*/
|
|
8
|
+
import { Component, type ReactNode } from 'react';
|
|
9
|
+
import { Text, View } from 'react-native';
|
|
10
|
+
|
|
11
|
+
type State = { failed: boolean };
|
|
12
|
+
|
|
13
|
+
export class ErrorBoundary extends Component<{ children: ReactNode; fallback?: ReactNode }, State> {
|
|
14
|
+
state: State = { failed: false };
|
|
15
|
+
|
|
16
|
+
static getDerivedStateFromError(): State {
|
|
17
|
+
return { failed: true };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
render() {
|
|
21
|
+
if (!this.state.failed) return this.props.children;
|
|
22
|
+
return this.props.fallback ?? (
|
|
23
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24 }}>
|
|
24
|
+
<Text>Something went wrong on this screen.</Text>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The translucent surface — a real one, on both platforms.
|
|
3
|
+
*
|
|
4
|
+
* The first version blurred on iOS and painted a flat plate everywhere else.
|
|
5
|
+
* That was wrong: Android renders a genuine backdrop blur, it just has to be
|
|
6
|
+
* asked for by name (`experimentalBlurMethod`, handled by `blurPropsFor`).
|
|
7
|
+
* Asked properly, both platforms get the same material.
|
|
8
|
+
*
|
|
9
|
+
* THE BLUR IS A LAYER, NOT THE CONTAINER. It fills the panel behind the
|
|
10
|
+
* content, and the border and radius live on the wrapper. Putting content
|
|
11
|
+
* inside a BlurView makes the content itself blurry on some Android versions.
|
|
12
|
+
*
|
|
13
|
+
* NO `elevation` HERE. Android draws elevation against an opaque background:
|
|
14
|
+
* given a translucent one it paints a solid rectangle behind the whole view —
|
|
15
|
+
* a white block inside the card, which is exactly how it looked. The blur and
|
|
16
|
+
* the border do the separating instead.
|
|
17
|
+
*/
|
|
18
|
+
import { Platform, StyleSheet, View, type ViewProps } from 'react-native';
|
|
19
|
+
import { BlurView } from 'expo-blur';
|
|
20
|
+
import { blurPropsFor, resolveGlassMode } from '@astratra/native';
|
|
21
|
+
import { colors } from '../constants/theme';
|
|
22
|
+
|
|
23
|
+
const mode = resolveGlassMode({
|
|
24
|
+
platform: Platform.OS,
|
|
25
|
+
apiAvailable: true,
|
|
26
|
+
effectAvailable: Platform.OS === 'ios' && Number.parseInt(String(Platform.Version), 10) >= 26,
|
|
27
|
+
/* expo-blur covers iOS and Android; only the web build has no real blur. */
|
|
28
|
+
blurAvailable: Platform.OS !== 'web'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const blurred = mode !== 'fallback';
|
|
32
|
+
|
|
33
|
+
export function GlassPanel({ style, children, ...props }: ViewProps) {
|
|
34
|
+
return (
|
|
35
|
+
<View
|
|
36
|
+
style={[
|
|
37
|
+
{
|
|
38
|
+
borderRadius: 20,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: colors.border,
|
|
41
|
+
padding: 18,
|
|
42
|
+
overflow: 'hidden',
|
|
43
|
+
/* A blurred panel needs only a veil of colour; a flat one has to
|
|
44
|
+
carry the whole surface itself. */
|
|
45
|
+
backgroundColor: blurred ? colors.veil : colors.surfaceOpaque
|
|
46
|
+
},
|
|
47
|
+
Platform.OS === 'ios' ? styles.lift : null,
|
|
48
|
+
style
|
|
49
|
+
]}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
{blurred && <BlurView {...blurPropsFor(Platform.OS)} style={StyleSheet.absoluteFill} />}
|
|
53
|
+
{children}
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
/* iOS renders this softly; Android ignores shadow* entirely, and its
|
|
60
|
+
`elevation` equivalent is incompatible with a translucent background. */
|
|
61
|
+
lift: {
|
|
62
|
+
shadowColor: '#18234f',
|
|
63
|
+
shadowOpacity: 0.1,
|
|
64
|
+
shadowRadius: 18,
|
|
65
|
+
shadowOffset: { width: 0, height: 10 }
|
|
66
|
+
}
|
|
67
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import Svg, { Defs, Pattern, Path, RadialGradient, Stop, Mask, Rect } from "react-native-svg";
|
|
3
|
+
|
|
4
|
+
const CELL = 40;
|
|
5
|
+
/* Faint on purpose: the grid gives the glass something to refract, it is not
|
|
6
|
+
meant to be read as a grid. */
|
|
7
|
+
const LINE_COLOR = "rgba(61,90,254,0.08)";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The paper behind the glass.
|
|
11
|
+
*
|
|
12
|
+
* A translucent card over a flat, near-white background is invisible — there is
|
|
13
|
+
* nothing for it to sit on, so the panel reads as no panel at all. This is a
|
|
14
|
+
* 40px rule, faded radially towards the edges: enough texture for the surface
|
|
15
|
+
* to separate, not enough to notice.
|
|
16
|
+
*/
|
|
17
|
+
export default function GridBackground() {
|
|
18
|
+
return (
|
|
19
|
+
<Svg style={StyleSheet.absoluteFill} width="100%" height="100%">
|
|
20
|
+
<Defs>
|
|
21
|
+
<Pattern id="grid" width={CELL} height={CELL} patternUnits="userSpaceOnUse">
|
|
22
|
+
<Path d={`M ${CELL} 0 L 0 0 0 ${CELL}`} fill="none" stroke={LINE_COLOR} strokeWidth={1} />
|
|
23
|
+
</Pattern>
|
|
24
|
+
<RadialGradient id="fade" cx="50%" cy="45%" rx="75%" ry="60%">
|
|
25
|
+
<Stop offset="30%" stopColor="#fff" stopOpacity={1} />
|
|
26
|
+
<Stop offset="100%" stopColor="#fff" stopOpacity={0} />
|
|
27
|
+
</RadialGradient>
|
|
28
|
+
<Mask id="fadeMask">
|
|
29
|
+
<Rect width="100%" height="100%" fill="url(#fade)" />
|
|
30
|
+
</Mask>
|
|
31
|
+
</Defs>
|
|
32
|
+
<Rect width="100%" height="100%" fill="url(#grid)" mask="url(#fadeMask)" />
|
|
33
|
+
</Svg>
|
|
34
|
+
);
|
|
35
|
+
}
|