Skip to content

Commit cf8e58f

Browse files
committed
chore: add new example app skeleton
1 parent 64c1e12 commit cf8e58f

33 files changed

+14760
-0
lines changed

example/.gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
*.orig.*
14+
*.jks
15+
*.p8
16+
*.p12
17+
*.key
18+
*.mobileprovision
19+
20+
# Metro
21+
.metro-health-check*
22+
23+
# debug
24+
npm-debug.*
25+
yarn-debug.*
26+
yarn-error.*
27+
28+
# macOS
29+
.DS_Store
30+
*.pem
31+
32+
# local env files
33+
.env*.local
34+
35+
# typescript
36+
*.tsbuildinfo
37+
38+
app-example

example/.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.expo/*
2+
android/*
3+
ios/*
4+
node_modules/*
5+
6+
package-lock.json
7+
README.md

example/.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSameLine": true,
4+
"bracketSpacing": true,
5+
"semi": false,
6+
"singleQuote": true
7+
}

example/app.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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": "myapp",
9+
"userInterfaceStyle": "automatic",
10+
"newArchEnabled": false,
11+
"ios": {
12+
"supportsTablet": true
13+
},
14+
"android": {
15+
"adaptiveIcon": {
16+
"foregroundImage": "./assets/images/adaptive-icon.png",
17+
"backgroundColor": "#ffffff"
18+
}
19+
},
20+
"web": {
21+
"bundler": "metro",
22+
"output": "static",
23+
"favicon": "./assets/images/favicon.png"
24+
},
25+
"plugins": [
26+
"expo-router",
27+
[
28+
"expo-splash-screen",
29+
{
30+
"image": "./assets/images/splash-icon.png",
31+
"imageWidth": 200,
32+
"resizeMode": "contain",
33+
"backgroundColor": "#ffffff"
34+
}
35+
]
36+
],
37+
"experiments": {
38+
"typedRoutes": true
39+
}
40+
}
41+
}

example/app/(app)/index.tsx

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Line from '@xmartlabs/react-native-line'
2+
import { Image, StyleSheet } from 'react-native'
3+
4+
import Logo from '@/assets/images/logo.png'
5+
import { LineButton } from '@/components/LineButton'
6+
import { ThemedView } from '@/components/ThemedView'
7+
8+
export default function () {
9+
function logIn() {
10+
return Line.login()
11+
}
12+
13+
return (
14+
<ThemedView style={styles.container}>
15+
<Image source={Logo} style={styles.logo} />
16+
<LineButton onPress={logIn} />
17+
</ThemedView>
18+
)
19+
}
20+
21+
const styles = StyleSheet.create({
22+
container: {
23+
alignItems: 'center',
24+
flex: 1,
25+
gap: 8,
26+
justifyContent: 'center',
27+
padding: 16,
28+
},
29+
logo: {
30+
height: 112,
31+
resizeMode: 'contain',
32+
},
33+
})

example/app/+not-found.tsx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Link, Stack } from 'expo-router'
2+
import { Fragment } from 'react'
3+
import { StyleSheet } from 'react-native'
4+
5+
import { ThemedText } from '@/components/ThemedText'
6+
import { ThemedView } from '@/components/ThemedView'
7+
8+
export default function () {
9+
return (
10+
<Fragment>
11+
<Stack.Screen options={{ title: strings.title }} />
12+
<ThemedView style={styles.container}>
13+
<ThemedText type="title">{strings.header}</ThemedText>
14+
<Link href="/" style={styles.link}>
15+
<ThemedText type="link">{strings.link}</ThemedText>
16+
</Link>
17+
</ThemedView>
18+
</Fragment>
19+
)
20+
}
21+
22+
const strings = {
23+
header: "This screen doesn't exist.",
24+
link: 'Go to home screen!',
25+
title: 'Oops!',
26+
}
27+
28+
const styles = StyleSheet.create({
29+
container: {
30+
alignItems: 'center',
31+
flex: 1,
32+
justifyContent: 'center',
33+
padding: 20,
34+
},
35+
link: {
36+
marginTop: 15,
37+
paddingVertical: 15,
38+
},
39+
})

example/app/_layout.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'react-native-reanimated'
2+
3+
import {
4+
DarkTheme,
5+
DefaultTheme,
6+
ThemeProvider,
7+
} from '@react-navigation/native'
8+
import { useFonts } from 'expo-font'
9+
import { Stack } from 'expo-router'
10+
import * as SplashScreen from 'expo-splash-screen'
11+
import { StatusBar } from 'expo-status-bar'
12+
import { useEffect } from 'react'
13+
14+
import SpaceMono from '@/assets/fonts/SpaceMono-Regular.ttf'
15+
import { useColorScheme } from '@/hooks/useColorScheme'
16+
17+
SplashScreen.preventAutoHideAsync()
18+
19+
export default function () {
20+
const colorScheme = useColorScheme()
21+
const [loaded] = useFonts({ SpaceMono })
22+
23+
useEffect(() => {
24+
if (loaded) {
25+
SplashScreen.hideAsync()
26+
}
27+
}, [loaded])
28+
29+
if (!loaded) {
30+
return null
31+
}
32+
33+
return (
34+
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
35+
<Stack>
36+
<Stack.Screen name="(app)/index" options={{ headerShown: false }} />
37+
<Stack.Screen name="+not-found" />
38+
</Stack>
39+
<StatusBar style="auto" />
40+
</ThemeProvider>
41+
)
42+
}
91.1 KB
Binary file not shown.
17.1 KB
Loading

example/assets/images/favicon.png

1.43 KB
Loading

example/assets/images/icon.png

21.9 KB
Loading

example/assets/images/line.png

2.36 KB
Loading

example/assets/images/logo.png

37 KB
Loading
4.96 KB
Loading

example/assets/images/react-logo.png

6.19 KB
Loading
13.9 KB
Loading
20.8 KB
Loading

example/assets/images/splash-icon.png

17.1 KB
Loading
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React, { FunctionComponent } from 'react'
2+
import { Image, StyleSheet, Text } from 'react-native'
3+
4+
import Line from '@/assets/images/line.png'
5+
import { PressableOpacity } from '@/components/PressableOpacity'
6+
import { VerticalDivider } from '@/components/VerticalDivider'
7+
import { BaseColors } from '@/constants/Colors'
8+
9+
interface Props {
10+
disabled?: boolean
11+
onPress?: VoidFunction
12+
size?: number
13+
}
14+
15+
export const LineButton: FunctionComponent<Props> = ({
16+
disabled = false,
17+
onPress,
18+
}) => {
19+
const backgroundColor = disabled ? BaseColors.White : BaseColors.Green
20+
const lineColor = disabled ? BaseColors.LightGray60PCT : BaseColors.Black8PCT
21+
const textColor = disabled ? BaseColors.Gray20PCT : BaseColors.White
22+
const tintColor = disabled ? BaseColors.Gray20PCT : BaseColors.White
23+
24+
const borderWidth = disabled ? 1 : 0
25+
26+
return (
27+
<PressableOpacity
28+
disabled={disabled}
29+
onPress={onPress}
30+
style={[styles.container, { backgroundColor, borderWidth }]}>
31+
<Image source={Line} style={[styles.image, { tintColor }]} />
32+
<VerticalDivider backgroundColor={lineColor} />
33+
<Text style={[styles.text, { color: textColor }]}>{strings.text}</Text>
34+
</PressableOpacity>
35+
)
36+
}
37+
38+
const strings = {
39+
text: 'Log In',
40+
}
41+
42+
const styles = StyleSheet.create({
43+
container: {
44+
alignItems: 'center',
45+
borderColor: BaseColors.LightGray60PCT,
46+
borderRadius: 12,
47+
borderWidth: 1,
48+
flexDirection: 'row',
49+
gap: 4,
50+
justifyContent: 'space-between',
51+
padding: 4,
52+
},
53+
image: {
54+
height: 50,
55+
width: 50,
56+
},
57+
text: {
58+
flex: 1,
59+
fontSize: 18,
60+
fontWeight: 'bold',
61+
textAlign: 'center',
62+
},
63+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { FunctionComponent } from 'react'
2+
import { Pressable, PressableProps, StyleSheet } from 'react-native'
3+
4+
export const PressableOpacity: FunctionComponent<PressableProps> = ({
5+
accessibilityRole = 'button',
6+
hitSlop = 16,
7+
style,
8+
...rest
9+
}) => (
10+
<Pressable
11+
accessibilityRole={accessibilityRole}
12+
hitSlop={hitSlop}
13+
style={state => [
14+
state.pressed && styles.opacity,
15+
typeof style === 'function' ? style(state) : style,
16+
]}
17+
{...rest}
18+
/>
19+
)
20+
21+
const styles = StyleSheet.create({
22+
opacity: {
23+
opacity: 0.5,
24+
},
25+
})

example/components/ThemedText.tsx

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { StyleSheet, Text, type TextProps } from 'react-native'
2+
3+
import { useThemeColor } from '@/hooks/useThemeColor'
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({ dark: darkColor, light: lightColor }, '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+
fontWeight: '600',
44+
lineHeight: 24,
45+
},
46+
link: {
47+
color: '#0A7EA4',
48+
fontSize: 16,
49+
lineHeight: 30,
50+
},
51+
subtitle: {
52+
fontSize: 20,
53+
fontWeight: 'bold',
54+
},
55+
title: {
56+
fontSize: 24,
57+
fontWeight: 'bold',
58+
lineHeight: 32,
59+
},
60+
})

example/components/ThemedView.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { View, type ViewProps } from 'react-native'
2+
3+
import { useThemeColor } from '@/hooks/useThemeColor'
4+
5+
export type ThemedViewProps = ViewProps & {
6+
lightColor?: string
7+
darkColor?: string
8+
}
9+
10+
export function ThemedView({
11+
style,
12+
lightColor,
13+
darkColor,
14+
...otherProps
15+
}: ThemedViewProps) {
16+
const backgroundColor = useThemeColor(
17+
{ dark: darkColor, light: lightColor },
18+
'background',
19+
)
20+
21+
return <View style={[{ backgroundColor }, style]} {...otherProps} />
22+
}

0 commit comments

Comments
 (0)