@oxyhq/services 6.9.25 → 6.9.27
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/lib/commonjs/ui/components/BottomSheet.js +15 -19
- package/lib/commonjs/ui/components/BottomSheet.js.map +1 -1
- package/lib/commonjs/ui/components/BottomSheetRouter.js +6 -9
- package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/commonjs/ui/components/Header.js +9 -12
- package/lib/commonjs/ui/components/Header.js.map +1 -1
- package/lib/commonjs/ui/components/SignInModal.js +24 -53
- package/lib/commonjs/ui/components/SignInModal.js.map +1 -1
- package/lib/commonjs/ui/components/StepBasedScreen.js +20 -7
- package/lib/commonjs/ui/components/StepBasedScreen.js.map +1 -1
- package/lib/commonjs/ui/components/feedback/feedbackStyles.js +2 -2
- package/lib/commonjs/ui/components/feedback/feedbackStyles.js.map +1 -1
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js +32 -29
- package/lib/commonjs/ui/components/modals/DeleteAccountModal.js.map +1 -1
- package/lib/commonjs/ui/components/payment/paymentStyles.js +6 -6
- package/lib/commonjs/ui/components/payment/paymentStyles.js.map +1 -1
- package/lib/commonjs/ui/constants/theme.js +3 -2
- package/lib/commonjs/ui/constants/theme.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +6 -1
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
- package/lib/commonjs/ui/hooks/useThemeColors.js +19 -17
- package/lib/commonjs/ui/hooks/useThemeColors.js.map +1 -1
- package/lib/commonjs/ui/hooks/useThemeStyles.js +20 -51
- package/lib/commonjs/ui/hooks/useThemeStyles.js.map +1 -1
- package/lib/commonjs/ui/hooks/useWebSSO.js +6 -1
- package/lib/commonjs/ui/hooks/useWebSSO.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +0 -8
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +37 -40
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/styles/authStyles.js +3 -3
- package/lib/commonjs/ui/styles/authStyles.js.map +1 -1
- package/lib/commonjs/ui/styles/theme.js +45 -9
- package/lib/commonjs/ui/styles/theme.js.map +1 -1
- package/lib/module/ui/components/BottomSheet.js +15 -19
- package/lib/module/ui/components/BottomSheet.js.map +1 -1
- package/lib/module/ui/components/BottomSheetRouter.js +6 -9
- package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/module/ui/components/Header.js +9 -12
- package/lib/module/ui/components/Header.js.map +1 -1
- package/lib/module/ui/components/SignInModal.js +25 -54
- package/lib/module/ui/components/SignInModal.js.map +1 -1
- package/lib/module/ui/components/StepBasedScreen.js +21 -8
- package/lib/module/ui/components/StepBasedScreen.js.map +1 -1
- package/lib/module/ui/components/feedback/feedbackStyles.js +2 -2
- package/lib/module/ui/components/feedback/feedbackStyles.js.map +1 -1
- package/lib/module/ui/components/modals/DeleteAccountModal.js +33 -30
- package/lib/module/ui/components/modals/DeleteAccountModal.js.map +1 -1
- package/lib/module/ui/components/payment/paymentStyles.js +6 -6
- package/lib/module/ui/components/payment/paymentStyles.js.map +1 -1
- package/lib/module/ui/constants/theme.js +3 -2
- package/lib/module/ui/constants/theme.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +6 -1
- package/lib/module/ui/hooks/useAuth.js.map +1 -1
- package/lib/module/ui/hooks/useThemeColors.js +18 -16
- package/lib/module/ui/hooks/useThemeColors.js.map +1 -1
- package/lib/module/ui/hooks/useThemeStyles.js +18 -49
- package/lib/module/ui/hooks/useThemeStyles.js.map +1 -1
- package/lib/module/ui/hooks/useWebSSO.js +6 -1
- package/lib/module/ui/hooks/useWebSSO.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +0 -8
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +38 -41
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/styles/authStyles.js +3 -3
- package/lib/module/ui/styles/authStyles.js.map +1 -1
- package/lib/module/ui/styles/theme.js +46 -9
- package/lib/module/ui/styles/theme.js.map +1 -1
- package/lib/typescript/commonjs/ui/components/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/Header.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/StepBasedScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/modals/DeleteAccountModal.d.ts +0 -8
- package/lib/typescript/commonjs/ui/components/modals/DeleteAccountModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/payment/types.d.ts +2 -0
- package/lib/typescript/commonjs/ui/components/payment/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/constants/theme.d.ts +3 -2
- package/lib/typescript/commonjs/ui/constants/theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useThemeColors.d.ts +13 -20
- package/lib/typescript/commonjs/ui/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useThemeStyles.d.ts +5 -28
- package/lib/typescript/commonjs/ui/hooks/useThemeStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/styles/theme.d.ts +8 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/Header.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/SignInModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/StepBasedScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/modals/DeleteAccountModal.d.ts +0 -8
- package/lib/typescript/module/ui/components/modals/DeleteAccountModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/payment/types.d.ts +2 -0
- package/lib/typescript/module/ui/components/payment/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/constants/theme.d.ts +3 -2
- package/lib/typescript/module/ui/constants/theme.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useThemeColors.d.ts +13 -20
- package/lib/typescript/module/ui/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useThemeStyles.d.ts +5 -28
- package/lib/typescript/module/ui/hooks/useThemeStyles.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/styles/theme.d.ts +8 -0
- package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ui/components/BottomSheet.tsx +12 -18
- package/src/ui/components/BottomSheetRouter.tsx +7 -9
- package/src/ui/components/Header.tsx +9 -12
- package/src/ui/components/SignInModal.tsx +17 -40
- package/src/ui/components/StepBasedScreen.tsx +22 -9
- package/src/ui/components/feedback/feedbackStyles.ts +2 -2
- package/src/ui/components/modals/DeleteAccountModal.tsx +25 -34
- package/src/ui/components/payment/paymentStyles.ts +6 -6
- package/src/ui/components/payment/types.ts +2 -0
- package/src/ui/constants/theme.ts +3 -2
- package/src/ui/hooks/useAuth.ts +4 -1
- package/src/ui/hooks/useThemeColors.ts +19 -18
- package/src/ui/hooks/useThemeStyles.ts +21 -56
- package/src/ui/hooks/useWebSSO.ts +4 -1
- package/src/ui/screens/AccountOverviewScreen.tsx +0 -8
- package/src/ui/screens/OxyAuthScreen.tsx +25 -31
- package/src/ui/styles/authStyles.ts +3 -3
- package/src/ui/styles/theme.ts +44 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
3
3
|
import { Colors } from '../constants/theme';
|
|
4
|
-
import { normalizeColorScheme } from '../utils/themeUtils';
|
|
5
4
|
|
|
6
5
|
export interface ThemeStyles {
|
|
7
6
|
textColor: string;
|
|
@@ -10,76 +9,42 @@ export interface ThemeStyles {
|
|
|
10
9
|
borderColor: string;
|
|
11
10
|
mutedTextColor: string;
|
|
12
11
|
isDarkTheme: boolean;
|
|
13
|
-
// Common semantic colors used across screens
|
|
14
12
|
primaryColor: string;
|
|
15
13
|
dangerColor: string;
|
|
16
14
|
successColor: string;
|
|
17
|
-
// Normalized color scheme and theme colors
|
|
18
15
|
colorScheme: 'light' | 'dark';
|
|
19
16
|
colors: typeof Colors.light;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - Base colors (text, background, borders)
|
|
28
|
-
* - Semantic colors (primary, danger, success)
|
|
29
|
-
* - Theme-aware calculations
|
|
30
|
-
* - Normalized color scheme and Colors object
|
|
31
|
-
*
|
|
32
|
-
* @param theme - Theme string ('light' | 'dark')
|
|
33
|
-
* @param colorSchemeFromHook - Optional color scheme from useColorScheme() hook. If not provided, will call useColorScheme() internally.
|
|
34
|
-
* @returns ThemeStyles object with consistent color values
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* const themeStyles = useThemeStyles(theme);
|
|
39
|
-
* <View style={{ backgroundColor: themeStyles.backgroundColor }}>
|
|
40
|
-
* <Text style={{ color: themeStyles.textColor }}>Hello</Text>
|
|
41
|
-
* </View>
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```tsx
|
|
46
|
-
* const colorScheme = useColorScheme();
|
|
47
|
-
* const themeStyles = useThemeStyles(theme, colorScheme);
|
|
48
|
-
* const iconColor = themeStyles.colors.iconSecurity;
|
|
49
|
-
* ```
|
|
20
|
+
* Returns theme styles for service screens.
|
|
21
|
+
* Delegates to bloom's useTheme() for all color values.
|
|
22
|
+
* The `theme` param is kept for backward compatibility but ignored —
|
|
23
|
+
* bloom's resolved mode (from BloomThemeProvider) is used instead.
|
|
50
24
|
*/
|
|
51
25
|
export const useThemeStyles = (
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
_theme?: string,
|
|
27
|
+
_colorSchemeFromHook?: string | null
|
|
54
28
|
): ThemeStyles => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
const bloomTheme = useTheme();
|
|
30
|
+
|
|
58
31
|
return useMemo(() => {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
32
|
+
const isDarkTheme = bloomTheme.isDark;
|
|
33
|
+
const colorScheme = isDarkTheme ? 'dark' : 'light';
|
|
61
34
|
const colors = Colors[colorScheme];
|
|
62
|
-
|
|
35
|
+
|
|
63
36
|
return {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
primaryColor: '#007AFF',
|
|
73
|
-
dangerColor: '#FF3B30',
|
|
74
|
-
successColor: '#34C759',
|
|
75
|
-
|
|
76
|
-
// Theme flag
|
|
37
|
+
textColor: bloomTheme.colors.text,
|
|
38
|
+
backgroundColor: bloomTheme.colors.background,
|
|
39
|
+
secondaryBackgroundColor: bloomTheme.colors.backgroundSecondary,
|
|
40
|
+
borderColor: bloomTheme.colors.border,
|
|
41
|
+
mutedTextColor: bloomTheme.colors.textSecondary,
|
|
42
|
+
primaryColor: bloomTheme.colors.primary,
|
|
43
|
+
dangerColor: bloomTheme.colors.error,
|
|
44
|
+
successColor: bloomTheme.colors.success,
|
|
77
45
|
isDarkTheme,
|
|
78
|
-
|
|
79
|
-
// Normalized color scheme and theme colors
|
|
80
46
|
colorScheme,
|
|
81
47
|
colors,
|
|
82
48
|
};
|
|
83
|
-
}, [
|
|
49
|
+
}, [bloomTheme]);
|
|
84
50
|
};
|
|
85
|
-
|
|
@@ -54,7 +54,10 @@ function isWebBrowser(): boolean {
|
|
|
54
54
|
function isIdentityProvider(authWebUrl?: string): boolean {
|
|
55
55
|
if (!isWebBrowser()) return false;
|
|
56
56
|
const hostname = window.location.hostname;
|
|
57
|
-
|
|
57
|
+
let idpHostname = 'auth.oxy.so';
|
|
58
|
+
if (authWebUrl) {
|
|
59
|
+
try { idpHostname = new URL(authWebUrl).hostname; } catch { /* malformed URL, use default */ }
|
|
60
|
+
}
|
|
58
61
|
return hostname === idpHostname;
|
|
59
62
|
}
|
|
60
63
|
|
|
@@ -698,14 +698,6 @@ const AccountOverviewScreen: React.FC<BaseScreenProps> = ({
|
|
|
698
698
|
username={user.username || ''}
|
|
699
699
|
onClose={() => setShowDeleteModal(false)}
|
|
700
700
|
onDelete={handleConfirmDelete}
|
|
701
|
-
colors={{
|
|
702
|
-
background: themeStyles.backgroundColor,
|
|
703
|
-
text: themeStyles.textColor,
|
|
704
|
-
secondaryText: themeStyles.isDarkTheme ? '#888888' : '#666666',
|
|
705
|
-
border: themeStyles.borderColor,
|
|
706
|
-
danger: '#FF3B30',
|
|
707
|
-
inputBackground: themeStyles.isDarkTheme ? '#333333' : '#F5F5F5',
|
|
708
|
-
}}
|
|
709
701
|
t={t}
|
|
710
702
|
/>
|
|
711
703
|
)}
|
|
@@ -20,11 +20,12 @@ import {
|
|
|
20
20
|
StyleSheet,
|
|
21
21
|
Linking,
|
|
22
22
|
Platform,
|
|
23
|
-
ActivityIndicator,
|
|
24
23
|
} from 'react-native';
|
|
25
24
|
import io, { type Socket } from 'socket.io-client';
|
|
26
25
|
import type { BaseScreenProps } from '../types/navigation';
|
|
27
|
-
import {
|
|
26
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
27
|
+
import { Button } from '@oxyhq/bloom/button';
|
|
28
|
+
import { Loading } from '@oxyhq/bloom/loading';
|
|
28
29
|
import { useOxy } from '../context/OxyContext';
|
|
29
30
|
import QRCode from 'react-native-qrcode-svg';
|
|
30
31
|
import OxyLogo from '../components/OxyLogo';
|
|
@@ -117,8 +118,17 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
117
118
|
onAuthenticated,
|
|
118
119
|
theme,
|
|
119
120
|
}) => {
|
|
120
|
-
const
|
|
121
|
-
const colors =
|
|
121
|
+
const bloomTheme = useTheme();
|
|
122
|
+
const colors = {
|
|
123
|
+
background: bloomTheme.colors.background,
|
|
124
|
+
text: bloomTheme.colors.text,
|
|
125
|
+
secondaryText: bloomTheme.colors.textSecondary,
|
|
126
|
+
primary: bloomTheme.colors.primary,
|
|
127
|
+
error: bloomTheme.colors.error,
|
|
128
|
+
border: bloomTheme.colors.border,
|
|
129
|
+
card: bloomTheme.colors.card,
|
|
130
|
+
inputBackground: bloomTheme.colors.backgroundSecondary,
|
|
131
|
+
};
|
|
122
132
|
const { oxyServices, signIn, switchSession } = useOxy();
|
|
123
133
|
|
|
124
134
|
const [authSession, setAuthSession] = useState<AuthSession | null>(null);
|
|
@@ -401,7 +411,7 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
401
411
|
if (isLoading) {
|
|
402
412
|
return (
|
|
403
413
|
<View style={[styles.container, { backgroundColor: colors.background }]}>
|
|
404
|
-
<
|
|
414
|
+
<Loading size="large" />
|
|
405
415
|
<Text style={[styles.loadingText, { color: colors.secondaryText }]}>
|
|
406
416
|
Preparing sign in...
|
|
407
417
|
</Text>
|
|
@@ -413,12 +423,9 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
413
423
|
return (
|
|
414
424
|
<View style={[styles.container, { backgroundColor: colors.background }]}>
|
|
415
425
|
<Text style={[styles.errorText, { color: colors.error }]}>{error}</Text>
|
|
416
|
-
<
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
>
|
|
420
|
-
<Text style={styles.buttonText}>Try Again</Text>
|
|
421
|
-
</TouchableOpacity>
|
|
426
|
+
<Button variant="primary" onPress={handleRefresh} style={{ width: '100%', borderRadius: 12 }}>
|
|
427
|
+
Try Again
|
|
428
|
+
</Button>
|
|
422
429
|
</View>
|
|
423
430
|
);
|
|
424
431
|
}
|
|
@@ -457,18 +464,19 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
457
464
|
</View>
|
|
458
465
|
|
|
459
466
|
{/* Open Oxy Auth Button */}
|
|
460
|
-
<
|
|
461
|
-
|
|
467
|
+
<Button
|
|
468
|
+
variant="primary"
|
|
462
469
|
onPress={handleOpenAuth}
|
|
470
|
+
icon={<OxyLogo width={20} height={20} fillColor={colors.card} style={styles.buttonIcon} />}
|
|
471
|
+
style={{ width: '100%', borderRadius: 12 }}
|
|
463
472
|
>
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
</TouchableOpacity>
|
|
473
|
+
Open Oxy Auth
|
|
474
|
+
</Button>
|
|
467
475
|
|
|
468
476
|
{/* Status */}
|
|
469
477
|
{isWaiting && (
|
|
470
478
|
<View style={styles.statusContainer}>
|
|
471
|
-
<
|
|
479
|
+
<Loading size="small" style={{ flex: undefined }} />
|
|
472
480
|
<Text style={[styles.statusText, { color: colors.secondaryText }]}>
|
|
473
481
|
Waiting for authorization...
|
|
474
482
|
</Text>
|
|
@@ -547,23 +555,9 @@ const styles = StyleSheet.create({
|
|
|
547
555
|
marginHorizontal: 16,
|
|
548
556
|
fontSize: 14,
|
|
549
557
|
},
|
|
550
|
-
button: {
|
|
551
|
-
flexDirection: 'row',
|
|
552
|
-
alignItems: 'center',
|
|
553
|
-
justifyContent: 'center',
|
|
554
|
-
paddingVertical: 16,
|
|
555
|
-
paddingHorizontal: 24,
|
|
556
|
-
borderRadius: 12,
|
|
557
|
-
width: '100%',
|
|
558
|
-
},
|
|
559
558
|
buttonIcon: {
|
|
560
559
|
marginRight: 10,
|
|
561
560
|
},
|
|
562
|
-
buttonText: {
|
|
563
|
-
color: 'white',
|
|
564
|
-
fontSize: 16,
|
|
565
|
-
fontWeight: '600',
|
|
566
|
-
},
|
|
567
561
|
statusContainer: {
|
|
568
562
|
flexDirection: 'row',
|
|
569
563
|
alignItems: 'center',
|
|
@@ -203,7 +203,7 @@ export const createAuthStyles = (colors: AuthThemeColors, theme: string) => Styl
|
|
|
203
203
|
width: '100%',
|
|
204
204
|
},
|
|
205
205
|
modernButtonText: {
|
|
206
|
-
color:
|
|
206
|
+
color: colors.background,
|
|
207
207
|
fontSize: 16,
|
|
208
208
|
fontWeight: '600',
|
|
209
209
|
letterSpacing: 0.5,
|
|
@@ -244,7 +244,7 @@ export const createAuthStyles = (colors: AuthThemeColors, theme: string) => Styl
|
|
|
244
244
|
},
|
|
245
245
|
modernUserAvatar: {
|
|
246
246
|
borderWidth: 4,
|
|
247
|
-
borderColor:
|
|
247
|
+
borderColor: `${colors.primary}33`,
|
|
248
248
|
},
|
|
249
249
|
statusIndicator: {
|
|
250
250
|
position: 'absolute',
|
|
@@ -254,7 +254,7 @@ export const createAuthStyles = (colors: AuthThemeColors, theme: string) => Styl
|
|
|
254
254
|
height: 20,
|
|
255
255
|
borderRadius: 10,
|
|
256
256
|
borderWidth: 3,
|
|
257
|
-
borderColor:
|
|
257
|
+
borderColor: colors.background,
|
|
258
258
|
},
|
|
259
259
|
modernUserDisplayName: {
|
|
260
260
|
fontFamily: fontFamilies.interBold,
|
package/src/ui/styles/theme.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Platform, StyleSheet, type TextStyle } from 'react-native';
|
|
2
|
+
import { useTheme as useBloomThemeHook, type ThemeColors as BloomThemeColors } from '@oxyhq/bloom';
|
|
2
3
|
import { fontFamilies } from './fonts';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* ThemeColors used by services style files.
|
|
7
|
+
* Maps to bloom's ThemeColors, with a few convenience aliases.
|
|
8
|
+
*/
|
|
4
9
|
export interface ThemeColors {
|
|
5
10
|
text: string;
|
|
6
11
|
background: string;
|
|
@@ -24,7 +29,26 @@ export interface Theme {
|
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Adapts bloom's ThemeColors into the services ThemeColors shape.
|
|
34
|
+
*/
|
|
35
|
+
function bloomColorsToThemeColors(bloomColors: BloomThemeColors): ThemeColors {
|
|
36
|
+
return {
|
|
37
|
+
text: bloomColors.text,
|
|
38
|
+
background: bloomColors.background,
|
|
39
|
+
inputBackground: bloomColors.backgroundSecondary,
|
|
40
|
+
placeholder: bloomColors.textTertiary,
|
|
41
|
+
primary: bloomColors.primary,
|
|
42
|
+
border: bloomColors.border,
|
|
43
|
+
error: bloomColors.error,
|
|
44
|
+
success: bloomColors.success,
|
|
45
|
+
warning: bloomColors.warning,
|
|
46
|
+
secondaryText: bloomColors.textSecondary,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Fallback colors when bloom context is not available */
|
|
51
|
+
const fallbackLight: ThemeColors = {
|
|
28
52
|
text: '#000000',
|
|
29
53
|
background: '#FFFFFF',
|
|
30
54
|
inputBackground: '#F5F5F5',
|
|
@@ -37,7 +61,7 @@ const lightColors: ThemeColors = {
|
|
|
37
61
|
secondaryText: '#666666',
|
|
38
62
|
};
|
|
39
63
|
|
|
40
|
-
const
|
|
64
|
+
const fallbackDark: ThemeColors = {
|
|
41
65
|
text: '#FFFFFF',
|
|
42
66
|
background: '#000000',
|
|
43
67
|
inputBackground: '#333333',
|
|
@@ -50,11 +74,11 @@ const darkColors: ThemeColors = {
|
|
|
50
74
|
secondaryText: '#BBBBBB',
|
|
51
75
|
};
|
|
52
76
|
|
|
53
|
-
const createTheme = (isDark: boolean): Theme => {
|
|
54
|
-
const
|
|
55
|
-
|
|
77
|
+
const createTheme = (isDark: boolean, colors?: ThemeColors): Theme => {
|
|
78
|
+
const themeColors = colors ?? (isDark ? fallbackDark : fallbackLight);
|
|
79
|
+
|
|
56
80
|
return {
|
|
57
|
-
colors,
|
|
81
|
+
colors: themeColors,
|
|
58
82
|
fonts: {
|
|
59
83
|
title: {
|
|
60
84
|
fontFamily: fontFamilies.interBold,
|
|
@@ -69,7 +93,7 @@ const createTheme = (isDark: boolean): Theme => {
|
|
|
69
93
|
fontFamily: fontFamilies.interSemiBold,
|
|
70
94
|
fontSize: 16,
|
|
71
95
|
fontWeight: '600',
|
|
72
|
-
color:
|
|
96
|
+
color: themeColors.background,
|
|
73
97
|
},
|
|
74
98
|
label: {
|
|
75
99
|
fontSize: 14,
|
|
@@ -84,8 +108,18 @@ export const getTheme = (theme: 'light' | 'dark'): Theme => {
|
|
|
84
108
|
return createTheme(theme === 'dark');
|
|
85
109
|
};
|
|
86
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Returns theme colors from bloom when available, with fallback to local colors.
|
|
113
|
+
* Prefer this hook for new code — it reads from bloom's ThemeProvider.
|
|
114
|
+
*/
|
|
87
115
|
export const useThemeColors = (theme: 'light' | 'dark'): ThemeColors => {
|
|
88
|
-
|
|
116
|
+
try {
|
|
117
|
+
const bloomTheme = useBloomThemeHook();
|
|
118
|
+
return bloomColorsToThemeColors(bloomTheme.colors);
|
|
119
|
+
} catch {
|
|
120
|
+
// Bloom provider not available, fall back to local colors
|
|
121
|
+
return getTheme(theme).colors;
|
|
122
|
+
}
|
|
89
123
|
};
|
|
90
124
|
|
|
91
125
|
// Common styles that can be reused across components
|
|
@@ -122,10 +156,10 @@ export const createCommonStyles = (theme: 'light' | 'dark') => {
|
|
|
122
156
|
fontFamily: fontFamilies.interSemiBold,
|
|
123
157
|
fontSize: 16,
|
|
124
158
|
fontWeight: '600',
|
|
125
|
-
color:
|
|
159
|
+
color: colors.background,
|
|
126
160
|
},
|
|
127
161
|
errorContainer: {
|
|
128
|
-
backgroundColor:
|
|
162
|
+
backgroundColor: `${colors.error}18`,
|
|
129
163
|
padding: 12,
|
|
130
164
|
borderRadius: 35,
|
|
131
165
|
marginBottom: 16,
|