@magicred-1/react-native-lxmf 0.2.0 → 0.2.2
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/android/src/main/jniLibs/arm64-v8a/liblxmf_rn.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/liblxmf_rn.so +0 -0
- package/android/src/main/jniLibs/x86_64/liblxmf_rn.so +0 -0
- package/android/src/main/kotlin/expo/modules/lxmf/BleManager.kt +123 -54
- package/android/src/main/kotlin/expo/modules/lxmf/LxmfModule.kt +1 -0
- package/example/README.md +50 -0
- package/example/app/(tabs)/_layout.tsx +28 -0
- package/example/app/(tabs)/index.tsx +874 -0
- package/example/app/_layout.tsx +14 -0
- package/example/app/modal.tsx +29 -0
- package/example/app.json +72 -0
- package/example/assets/images/android-icon-background.png +0 -0
- package/example/assets/images/android-icon-foreground.png +0 -0
- package/example/assets/images/android-icon-monochrome.png +0 -0
- package/example/assets/images/favicon.png +0 -0
- package/example/assets/images/icon.png +0 -0
- package/example/assets/images/partial-react-logo.png +0 -0
- package/example/assets/images/react-logo.png +0 -0
- package/example/assets/images/react-logo@2x.png +0 -0
- package/example/assets/images/react-logo@3x.png +0 -0
- package/example/assets/images/splash-icon.png +0 -0
- package/example/components/external-link.tsx +25 -0
- package/example/components/haptic-tab.tsx +18 -0
- package/example/components/hello-wave.tsx +19 -0
- package/example/components/parallax-scroll-view.tsx +79 -0
- package/example/components/themed-text.tsx +60 -0
- package/example/components/themed-view.tsx +14 -0
- package/example/components/ui/collapsible.tsx +45 -0
- package/example/components/ui/icon-symbol.ios.tsx +32 -0
- package/example/components/ui/icon-symbol.tsx +41 -0
- package/example/constants/theme.ts +53 -0
- package/example/eslint.config.js +10 -0
- package/example/expo-env.d.ts +3 -0
- package/example/hooks/use-color-scheme.ts +1 -0
- package/example/hooks/use-color-scheme.web.ts +21 -0
- package/example/hooks/use-theme-color.ts +21 -0
- package/example/metro.config.js +37 -0
- package/example/package.json +52 -0
- package/example/scripts/reset-project.js +112 -0
- package/example/tsconfig.json +17 -0
- package/ios/BLEManager.swift +41 -6
- package/ios/LxmfModule.swift +13 -2
- package/package.json +15 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Stack } from 'expo-router';
|
|
2
|
+
import { StatusBar } from 'expo-status-bar';
|
|
3
|
+
import { LogBox } from 'react-native';
|
|
4
|
+
|
|
5
|
+
LogBox.ignoreLogs(['Unable to determine event arguments for "onModeChange"']);
|
|
6
|
+
|
|
7
|
+
export default function RootLayout() {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Stack screenOptions={{ headerShown: false }} />
|
|
11
|
+
<StatusBar style="auto" />
|
|
12
|
+
</>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Link } from 'expo-router';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { ThemedText } from '@/components/themed-text';
|
|
5
|
+
import { ThemedView } from '@/components/themed-view';
|
|
6
|
+
|
|
7
|
+
export default function ModalScreen() {
|
|
8
|
+
return (
|
|
9
|
+
<ThemedView style={styles.container}>
|
|
10
|
+
<ThemedText type="title">This is a modal</ThemedText>
|
|
11
|
+
<Link href="/" dismissTo style={styles.link}>
|
|
12
|
+
<ThemedText type="link">Go to home screen</ThemedText>
|
|
13
|
+
</Link>
|
|
14
|
+
</ThemedView>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const styles = StyleSheet.create({
|
|
19
|
+
container: {
|
|
20
|
+
flex: 1,
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
padding: 20,
|
|
24
|
+
},
|
|
25
|
+
link: {
|
|
26
|
+
marginTop: 15,
|
|
27
|
+
paddingVertical: 15,
|
|
28
|
+
},
|
|
29
|
+
});
|
package/example/app.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"expo": {
|
|
3
|
+
"name": "example-app",
|
|
4
|
+
"slug": "example-app",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"orientation": "portrait",
|
|
7
|
+
"icon": "./assets/images/icon.png",
|
|
8
|
+
"scheme": "exampleapp",
|
|
9
|
+
"userInterfaceStyle": "automatic",
|
|
10
|
+
"ios": {
|
|
11
|
+
"supportsTablet": true,
|
|
12
|
+
"bundleIdentifier": "com.fwazb.exampleapp",
|
|
13
|
+
"infoPlist": {
|
|
14
|
+
"NSBluetoothAlwaysUsageDescription": "AnonMesh uses Bluetooth to connect to LoRa relay nodes for offline Solana transactions.",
|
|
15
|
+
"NSBluetoothPeripheralUsageDescription": "AnonMesh uses Bluetooth to communicate with nearby mesh nodes.",
|
|
16
|
+
"NSLocalNetworkUsageDescription": "AnonMesh uses local network to connect to mesh relay nodes and Reticulum transport.",
|
|
17
|
+
"UIBackgroundModes": [
|
|
18
|
+
"bluetooth-central",
|
|
19
|
+
"bluetooth-peripheral"
|
|
20
|
+
],
|
|
21
|
+
"ITSAppUsesNonExemptEncryption": false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"android": {
|
|
25
|
+
"permissions": [
|
|
26
|
+
"android.permission.BLUETOOTH_SCAN",
|
|
27
|
+
"android.permission.BLUETOOTH_ADVERTISE",
|
|
28
|
+
"android.permission.BLUETOOTH_CONNECT",
|
|
29
|
+
"android.permission.BLUETOOTH",
|
|
30
|
+
"android.permission.BLUETOOTH_ADMIN",
|
|
31
|
+
"android.permission.ACCESS_FINE_LOCATION"
|
|
32
|
+
],
|
|
33
|
+
"adaptiveIcon": {
|
|
34
|
+
"backgroundColor": "#E6F4FE",
|
|
35
|
+
"foregroundImage": "./assets/images/android-icon-foreground.png",
|
|
36
|
+
"backgroundImage": "./assets/images/android-icon-background.png",
|
|
37
|
+
"monochromeImage": "./assets/images/android-icon-monochrome.png"
|
|
38
|
+
},
|
|
39
|
+
"predictiveBackGestureEnabled": false,
|
|
40
|
+
"package": "com.fwazb.exampleapp"
|
|
41
|
+
},
|
|
42
|
+
"web": {
|
|
43
|
+
"output": "static",
|
|
44
|
+
"favicon": "./assets/images/favicon.png"
|
|
45
|
+
},
|
|
46
|
+
"plugins": [
|
|
47
|
+
"expo-router",
|
|
48
|
+
[
|
|
49
|
+
"expo-splash-screen",
|
|
50
|
+
{
|
|
51
|
+
"image": "./assets/images/splash-icon.png",
|
|
52
|
+
"imageWidth": 200,
|
|
53
|
+
"resizeMode": "contain",
|
|
54
|
+
"backgroundColor": "#ffffff",
|
|
55
|
+
"dark": {
|
|
56
|
+
"backgroundColor": "#000000"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
],
|
|
61
|
+
"experiments": {
|
|
62
|
+
"typedRoutes": true,
|
|
63
|
+
"reactCompiler": true
|
|
64
|
+
},
|
|
65
|
+
"extra": {
|
|
66
|
+
"router": {},
|
|
67
|
+
"eas": {
|
|
68
|
+
"projectId": "a01c4460-cacc-4f87-a9c3-ea86c57623e9"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Href, Link } from 'expo-router';
|
|
2
|
+
import { openBrowserAsync, WebBrowserPresentationStyle } from 'expo-web-browser';
|
|
3
|
+
import { type ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
type Props = Omit<ComponentProps<typeof Link>, 'href'> & { href: Href & string };
|
|
6
|
+
|
|
7
|
+
export function ExternalLink({ href, ...rest }: Props) {
|
|
8
|
+
return (
|
|
9
|
+
<Link
|
|
10
|
+
target="_blank"
|
|
11
|
+
{...rest}
|
|
12
|
+
href={href}
|
|
13
|
+
onPress={async (event) => {
|
|
14
|
+
if (process.env.EXPO_OS !== 'web') {
|
|
15
|
+
// Prevent the default behavior of linking to the default browser on native.
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
// Open the link in an in-app browser.
|
|
18
|
+
await openBrowserAsync(href, {
|
|
19
|
+
presentationStyle: WebBrowserPresentationStyle.AUTOMATIC,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
|
|
2
|
+
import { PlatformPressable } from '@react-navigation/elements';
|
|
3
|
+
import * as Haptics from 'expo-haptics';
|
|
4
|
+
|
|
5
|
+
export function HapticTab(props: BottomTabBarButtonProps) {
|
|
6
|
+
return (
|
|
7
|
+
<PlatformPressable
|
|
8
|
+
{...props}
|
|
9
|
+
onPressIn={(ev) => {
|
|
10
|
+
if (process.env.EXPO_OS === 'ios') {
|
|
11
|
+
// Add a soft haptic feedback when pressing down on the tabs.
|
|
12
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
13
|
+
}
|
|
14
|
+
props.onPressIn?.(ev);
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
|
|
3
|
+
export function HelloWave() {
|
|
4
|
+
return (
|
|
5
|
+
<Animated.Text
|
|
6
|
+
style={{
|
|
7
|
+
fontSize: 28,
|
|
8
|
+
lineHeight: 32,
|
|
9
|
+
marginTop: -6,
|
|
10
|
+
animationName: {
|
|
11
|
+
'50%': { transform: [{ rotate: '25deg' }] },
|
|
12
|
+
},
|
|
13
|
+
animationIterationCount: 4,
|
|
14
|
+
animationDuration: '300ms',
|
|
15
|
+
}}>
|
|
16
|
+
👋
|
|
17
|
+
</Animated.Text>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import Animated, {
|
|
4
|
+
interpolate,
|
|
5
|
+
useAnimatedRef,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
useScrollOffset,
|
|
8
|
+
} from 'react-native-reanimated';
|
|
9
|
+
|
|
10
|
+
import { ThemedView } from '@/components/themed-view';
|
|
11
|
+
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
12
|
+
import { useThemeColor } from '@/hooks/use-theme-color';
|
|
13
|
+
|
|
14
|
+
const HEADER_HEIGHT = 250;
|
|
15
|
+
|
|
16
|
+
type Props = PropsWithChildren<{
|
|
17
|
+
headerImage: ReactElement;
|
|
18
|
+
headerBackgroundColor: { dark: string; light: string };
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
export default function ParallaxScrollView({
|
|
22
|
+
children,
|
|
23
|
+
headerImage,
|
|
24
|
+
headerBackgroundColor,
|
|
25
|
+
}: Props) {
|
|
26
|
+
const backgroundColor = useThemeColor({}, 'background');
|
|
27
|
+
const colorScheme = useColorScheme() ?? 'light';
|
|
28
|
+
const scrollRef = useAnimatedRef<Animated.ScrollView>();
|
|
29
|
+
const scrollOffset = useScrollOffset(scrollRef);
|
|
30
|
+
const headerAnimatedStyle = useAnimatedStyle(() => {
|
|
31
|
+
return {
|
|
32
|
+
transform: [
|
|
33
|
+
{
|
|
34
|
+
translateY: interpolate(
|
|
35
|
+
scrollOffset.value,
|
|
36
|
+
[-HEADER_HEIGHT, 0, HEADER_HEIGHT],
|
|
37
|
+
[-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75]
|
|
38
|
+
),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
scale: interpolate(scrollOffset.value, [-HEADER_HEIGHT, 0, HEADER_HEIGHT], [2, 1, 1]),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Animated.ScrollView
|
|
49
|
+
ref={scrollRef}
|
|
50
|
+
style={{ backgroundColor, flex: 1 }}
|
|
51
|
+
scrollEventThrottle={16}>
|
|
52
|
+
<Animated.View
|
|
53
|
+
style={[
|
|
54
|
+
styles.header,
|
|
55
|
+
{ backgroundColor: headerBackgroundColor[colorScheme] },
|
|
56
|
+
headerAnimatedStyle,
|
|
57
|
+
]}>
|
|
58
|
+
{headerImage}
|
|
59
|
+
</Animated.View>
|
|
60
|
+
<ThemedView style={styles.content}>{children}</ThemedView>
|
|
61
|
+
</Animated.ScrollView>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
container: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
},
|
|
69
|
+
header: {
|
|
70
|
+
height: HEADER_HEIGHT,
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
},
|
|
73
|
+
content: {
|
|
74
|
+
flex: 1,
|
|
75
|
+
padding: 32,
|
|
76
|
+
gap: 16,
|
|
77
|
+
overflow: 'hidden',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StyleSheet, Text, type TextProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { useThemeColor } from '@/hooks/use-theme-color';
|
|
4
|
+
|
|
5
|
+
export type ThemedTextProps = TextProps & {
|
|
6
|
+
lightColor?: string;
|
|
7
|
+
darkColor?: string;
|
|
8
|
+
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function ThemedText({
|
|
12
|
+
style,
|
|
13
|
+
lightColor,
|
|
14
|
+
darkColor,
|
|
15
|
+
type = 'default',
|
|
16
|
+
...rest
|
|
17
|
+
}: ThemedTextProps) {
|
|
18
|
+
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Text
|
|
22
|
+
style={[
|
|
23
|
+
{ color },
|
|
24
|
+
type === 'default' ? styles.default : undefined,
|
|
25
|
+
type === 'title' ? styles.title : undefined,
|
|
26
|
+
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
|
27
|
+
type === 'subtitle' ? styles.subtitle : undefined,
|
|
28
|
+
type === 'link' ? styles.link : undefined,
|
|
29
|
+
style,
|
|
30
|
+
]}
|
|
31
|
+
{...rest}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
default: {
|
|
38
|
+
fontSize: 16,
|
|
39
|
+
lineHeight: 24,
|
|
40
|
+
},
|
|
41
|
+
defaultSemiBold: {
|
|
42
|
+
fontSize: 16,
|
|
43
|
+
lineHeight: 24,
|
|
44
|
+
fontWeight: '600',
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
fontSize: 32,
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
lineHeight: 32,
|
|
50
|
+
},
|
|
51
|
+
subtitle: {
|
|
52
|
+
fontSize: 20,
|
|
53
|
+
fontWeight: 'bold',
|
|
54
|
+
},
|
|
55
|
+
link: {
|
|
56
|
+
lineHeight: 30,
|
|
57
|
+
fontSize: 16,
|
|
58
|
+
color: '#0a7ea4',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { View, type ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { useThemeColor } from '@/hooks/use-theme-color';
|
|
4
|
+
|
|
5
|
+
export type ThemedViewProps = ViewProps & {
|
|
6
|
+
lightColor?: string;
|
|
7
|
+
darkColor?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
|
|
11
|
+
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
|
|
12
|
+
|
|
13
|
+
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PropsWithChildren, useState } from 'react';
|
|
2
|
+
import { StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { ThemedText } from '@/components/themed-text';
|
|
5
|
+
import { ThemedView } from '@/components/themed-view';
|
|
6
|
+
import { IconSymbol } from '@/components/ui/icon-symbol';
|
|
7
|
+
import { Colors } from '@/constants/theme';
|
|
8
|
+
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
9
|
+
|
|
10
|
+
export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const theme = useColorScheme() ?? 'light';
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ThemedView>
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={styles.heading}
|
|
18
|
+
onPress={() => setIsOpen((value) => !value)}
|
|
19
|
+
activeOpacity={0.8}>
|
|
20
|
+
<IconSymbol
|
|
21
|
+
name="chevron.right"
|
|
22
|
+
size={18}
|
|
23
|
+
weight="medium"
|
|
24
|
+
color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
|
|
25
|
+
style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<ThemedText type="defaultSemiBold">{title}</ThemedText>
|
|
29
|
+
</TouchableOpacity>
|
|
30
|
+
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
|
|
31
|
+
</ThemedView>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
heading: {
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
gap: 6,
|
|
40
|
+
},
|
|
41
|
+
content: {
|
|
42
|
+
marginTop: 6,
|
|
43
|
+
marginLeft: 24,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export function IconSymbol({
|
|
5
|
+
name,
|
|
6
|
+
size = 24,
|
|
7
|
+
color,
|
|
8
|
+
style,
|
|
9
|
+
weight = 'regular',
|
|
10
|
+
}: {
|
|
11
|
+
name: SymbolViewProps['name'];
|
|
12
|
+
size?: number;
|
|
13
|
+
color: string;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
weight?: SymbolWeight;
|
|
16
|
+
}) {
|
|
17
|
+
return (
|
|
18
|
+
<SymbolView
|
|
19
|
+
weight={weight}
|
|
20
|
+
tintColor={color}
|
|
21
|
+
resizeMode="scaleAspectFit"
|
|
22
|
+
name={name}
|
|
23
|
+
style={[
|
|
24
|
+
{
|
|
25
|
+
width: size,
|
|
26
|
+
height: size,
|
|
27
|
+
},
|
|
28
|
+
style,
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Fallback for using MaterialIcons on Android and web.
|
|
2
|
+
|
|
3
|
+
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
4
|
+
import { SymbolWeight, SymbolViewProps } from 'expo-symbols';
|
|
5
|
+
import { ComponentProps } from 'react';
|
|
6
|
+
import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
|
|
7
|
+
|
|
8
|
+
type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof MaterialIcons>['name']>;
|
|
9
|
+
type IconSymbolName = keyof typeof MAPPING;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Add your SF Symbols to Material Icons mappings here.
|
|
13
|
+
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
|
|
14
|
+
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
|
|
15
|
+
*/
|
|
16
|
+
const MAPPING = {
|
|
17
|
+
'house.fill': 'home',
|
|
18
|
+
'paperplane.fill': 'send',
|
|
19
|
+
'chevron.left.forwardslash.chevron.right': 'code',
|
|
20
|
+
'chevron.right': 'chevron-right',
|
|
21
|
+
} as IconMapping;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
|
|
25
|
+
* This ensures a consistent look across platforms, and optimal resource usage.
|
|
26
|
+
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
|
|
27
|
+
*/
|
|
28
|
+
export function IconSymbol({
|
|
29
|
+
name,
|
|
30
|
+
size = 24,
|
|
31
|
+
color,
|
|
32
|
+
style,
|
|
33
|
+
}: {
|
|
34
|
+
name: IconSymbolName;
|
|
35
|
+
size?: number;
|
|
36
|
+
color: string | OpaqueColorValue;
|
|
37
|
+
style?: StyleProp<TextStyle>;
|
|
38
|
+
weight?: SymbolWeight;
|
|
39
|
+
}) {
|
|
40
|
+
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
|
|
41
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Below are the colors that are used in the app. The colors are defined in the light and dark mode.
|
|
3
|
+
* There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Platform } from 'react-native';
|
|
7
|
+
|
|
8
|
+
const tintColorLight = '#0a7ea4';
|
|
9
|
+
const tintColorDark = '#fff';
|
|
10
|
+
|
|
11
|
+
export const Colors = {
|
|
12
|
+
light: {
|
|
13
|
+
text: '#11181C',
|
|
14
|
+
background: '#fff',
|
|
15
|
+
tint: tintColorLight,
|
|
16
|
+
icon: '#687076',
|
|
17
|
+
tabIconDefault: '#687076',
|
|
18
|
+
tabIconSelected: tintColorLight,
|
|
19
|
+
},
|
|
20
|
+
dark: {
|
|
21
|
+
text: '#ECEDEE',
|
|
22
|
+
background: '#151718',
|
|
23
|
+
tint: tintColorDark,
|
|
24
|
+
icon: '#9BA1A6',
|
|
25
|
+
tabIconDefault: '#9BA1A6',
|
|
26
|
+
tabIconSelected: tintColorDark,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Fonts = Platform.select({
|
|
31
|
+
ios: {
|
|
32
|
+
/** iOS `UIFontDescriptorSystemDesignDefault` */
|
|
33
|
+
sans: 'system-ui',
|
|
34
|
+
/** iOS `UIFontDescriptorSystemDesignSerif` */
|
|
35
|
+
serif: 'ui-serif',
|
|
36
|
+
/** iOS `UIFontDescriptorSystemDesignRounded` */
|
|
37
|
+
rounded: 'ui-rounded',
|
|
38
|
+
/** iOS `UIFontDescriptorSystemDesignMonospaced` */
|
|
39
|
+
mono: 'ui-monospace',
|
|
40
|
+
},
|
|
41
|
+
default: {
|
|
42
|
+
sans: 'normal',
|
|
43
|
+
serif: 'serif',
|
|
44
|
+
rounded: 'normal',
|
|
45
|
+
mono: 'monospace',
|
|
46
|
+
},
|
|
47
|
+
web: {
|
|
48
|
+
sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
49
|
+
serif: "Georgia, 'Times New Roman', serif",
|
|
50
|
+
rounded: "'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Meiryo, 'MS PGothic', sans-serif",
|
|
51
|
+
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useColorScheme } from 'react-native';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useColorScheme as useRNColorScheme } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* To support static rendering, this value needs to be re-calculated on the client side for web
|
|
6
|
+
*/
|
|
7
|
+
export function useColorScheme() {
|
|
8
|
+
const [hasHydrated, setHasHydrated] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setHasHydrated(true);
|
|
12
|
+
}, []);
|
|
13
|
+
|
|
14
|
+
const colorScheme = useRNColorScheme();
|
|
15
|
+
|
|
16
|
+
if (hasHydrated) {
|
|
17
|
+
return colorScheme;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return 'light';
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learn more about light and dark modes:
|
|
3
|
+
* https://docs.expo.dev/guides/color-schemes/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Colors } from '@/constants/theme';
|
|
7
|
+
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
8
|
+
|
|
9
|
+
export function useThemeColor(
|
|
10
|
+
props: { light?: string; dark?: string },
|
|
11
|
+
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
|
|
12
|
+
) {
|
|
13
|
+
const theme = useColorScheme() ?? 'light';
|
|
14
|
+
const colorFromProps = props[theme];
|
|
15
|
+
|
|
16
|
+
if (colorFromProps) {
|
|
17
|
+
return colorFromProps;
|
|
18
|
+
} else {
|
|
19
|
+
return Colors[theme][colorName];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
4
|
+
const projectRoot = __dirname;
|
|
5
|
+
const moduleRoot = path.resolve(projectRoot, '..'); // expo-module/
|
|
6
|
+
const workspaceRoot = path.resolve(projectRoot, '../..'); // repo root
|
|
7
|
+
const config = getDefaultConfig(projectRoot);
|
|
8
|
+
|
|
9
|
+
// Minimize watchers
|
|
10
|
+
config.maxWorkers = 1;
|
|
11
|
+
config.watchFolders = [
|
|
12
|
+
projectRoot,
|
|
13
|
+
// Include the parent expo-module so Metro resolves local file: dependency
|
|
14
|
+
moduleRoot,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
// Blacklist huge directories and duplicate react-native copies
|
|
18
|
+
const blockList = [
|
|
19
|
+
/node_modules\/react-native\/ReactAndroid/,
|
|
20
|
+
/node_modules\/react-native\/ReactApple/,
|
|
21
|
+
// Prevent parent expo-module's react-native from shadowing the example's copy
|
|
22
|
+
/expo-module\/node_modules\/react-native\//,
|
|
23
|
+
/expo-module\/node_modules\/react\//,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
config.resolver.blockList = blockList;
|
|
27
|
+
config.resolver.unstable_enableSymlinks = true;
|
|
28
|
+
config.resolver.nodeModulesPaths = [
|
|
29
|
+
path.resolve(projectRoot, 'node_modules'),
|
|
30
|
+
path.resolve(workspaceRoot, 'node_modules'),
|
|
31
|
+
];
|
|
32
|
+
config.resolver.extraNodeModules = {
|
|
33
|
+
react: path.resolve(projectRoot, 'node_modules/react'),
|
|
34
|
+
'react-native': path.resolve(projectRoot, 'node_modules/react-native'),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = config;
|