Skip to content

Commit 5754276

Browse files
fix: time picker initial value problem, locale problem and improve performance
1 parent fa35979 commit 5754276

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7691
-7740
lines changed

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "@react-native-community",
3-
"ignorePatterns": [".*.js", ".*.ts", "node_modules/", "lib/", "example/"]
3+
"ignorePatterns": [".*.js", ".*.ts", "node_modules/", "lib/", "example/"],
4+
"rules": {
5+
"react/react-in-jsx-scope": "off"
6+
}
47
}

declarations.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="@testing-library/jest-native" />

example/.gitignore

Lines changed: 38 additions & 0 deletions
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/App.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Welcome to your Expo app 👋
2+
3+
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
4+
5+
## Get started
6+
7+
1. Install dependencies
8+
9+
```bash
10+
npm install
11+
```
12+
13+
2. Start the app
14+
15+
```bash
16+
npx expo start
17+
```
18+
19+
In the output, you'll find options to open the app in a
20+
21+
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
22+
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
23+
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
24+
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
25+
26+
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
27+
28+
## Get a fresh project
29+
30+
When you're ready, run:
31+
32+
```bash
33+
npm run reset-project
34+
```
35+
36+
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
37+
38+
## Learn more
39+
40+
To learn more about developing your project with Expo, look at the following resources:
41+
42+
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
43+
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
44+
45+
## Join the community
46+
47+
Join our community of developers creating universal apps.
48+
49+
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
50+
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.

example/app.json

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,38 @@
66
"version": "1.0.0",
77
"githubUrl": "https://github.com/farhoudshapouran/react-native-ui-datepicker",
88
"orientation": "portrait",
9-
"icon": "./assets/icon.png",
10-
"userInterfaceStyle": "light",
11-
"splash": {
12-
"image": "./assets/splash.png",
13-
"resizeMode": "contain",
14-
"backgroundColor": "#ffffff"
15-
},
16-
"assetBundlePatterns": ["**/*"],
9+
"icon": "./assets/images/icon.png",
10+
"scheme": "myapp",
11+
"userInterfaceStyle": "automatic",
12+
"newArchEnabled": true,
1713
"ios": {
1814
"supportsTablet": true
1915
},
2016
"android": {
2117
"adaptiveIcon": {
22-
"foregroundImage": "./assets/adaptive-icon.png",
18+
"foregroundImage": "./assets/images/adaptive-icon.png",
2319
"backgroundColor": "#ffffff"
2420
}
2521
},
2622
"web": {
27-
"favicon": "./assets/calendar.png",
28-
"themeColor": "#FFFFFF",
29-
"display": "fullscreen"
23+
"bundler": "metro",
24+
"output": "static",
25+
"favicon": "./assets/images/favicon.png"
26+
},
27+
"plugins": [
28+
"expo-router",
29+
[
30+
"expo-splash-screen",
31+
{
32+
"image": "./assets/images/splash-icon.png",
33+
"imageWidth": 200,
34+
"resizeMode": "contain",
35+
"backgroundColor": "#ffffff"
36+
}
37+
]
38+
],
39+
"experiments": {
40+
"typedRoutes": true
3041
}
3142
}
3243
}

example/app/+not-found.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import { Link, Stack } from 'expo-router';
3+
import { StyleSheet, View, Text } from 'react-native';
4+
5+
export default function NotFoundScreen() {
6+
return (
7+
<>
8+
<Stack.Screen options={{ title: 'Oops!' }} />
9+
<View style={styles.container}>
10+
<Text>This screen doesn't exist.</Text>
11+
<Link href="/" style={styles.link}>
12+
<Text>Go to home screen!</Text>
13+
</Link>
14+
</View>
15+
</>
16+
);
17+
}
18+
19+
const styles = StyleSheet.create({
20+
container: {
21+
flex: 1,
22+
alignItems: 'center',
23+
justifyContent: 'center',
24+
padding: 20,
25+
},
26+
link: {
27+
marginTop: 15,
28+
paddingVertical: 15,
29+
},
30+
});

example/app/_layout.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {
2+
DarkTheme,
3+
DefaultTheme,
4+
ThemeProvider,
5+
} from '@react-navigation/native';
6+
import { useFonts } from 'expo-font';
7+
import { Slot, Stack } from 'expo-router';
8+
import * as SplashScreen from 'expo-splash-screen';
9+
import { StatusBar } from 'expo-status-bar';
10+
import { useEffect } from 'react';
11+
import 'react-native-reanimated';
12+
import { ReactScan } from 'react-scan/native';
13+
14+
import { useColorScheme } from '@/hooks/useColorScheme';
15+
16+
// Prevent the splash screen from auto-hiding before asset loading is complete.
17+
SplashScreen.preventAutoHideAsync();
18+
19+
export default function RootLayout() {
20+
const colorScheme = useColorScheme();
21+
const [loaded] = useFonts({
22+
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
23+
});
24+
25+
useEffect(() => {
26+
if (loaded) {
27+
SplashScreen.hideAsync();
28+
}
29+
}, [loaded]);
30+
31+
if (!loaded) {
32+
return null;
33+
}
34+
35+
return (
36+
// <ReactScan
37+
// options={{
38+
// enabled: true,
39+
// log: true,
40+
// animationWhenFlashing: 'fade-out',
41+
// }}
42+
// >
43+
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
44+
<Slot />
45+
<StatusBar style="auto" />
46+
</ThemeProvider>
47+
);
48+
}

example/src/App.tsx renamed to example/app/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
TouchableOpacity,
88
Pressable,
99
} from 'react-native';
10-
import ThemeSelector, { ITheme } from './components/ThemeSelector';
11-
import LocaleSelector from './components/LocaleSelector';
12-
import GithubLink from './components/GithubLink';
10+
import ThemeSelector, { ITheme } from '@/components/ThemeSelector';
11+
import LocaleSelector from '@/components/LocaleSelector';
12+
import GithubLink from '@/components/GithubLink';
1313
import BouncyCheckbox from 'react-native-bouncy-checkbox';
1414
import DateTimePicker, { DateType, ModeType } from 'react-native-ui-datepicker';
1515
import dayjs from 'dayjs';
@@ -30,7 +30,7 @@ const Themes: ITheme[] = [
3030
{ mainColor: '#FAD7DD', activeTextColor: '#932338' },
3131
];
3232

33-
export default function App() {
33+
export default function MainPage() {
3434
const [mode, setMode] = useState<ModeType>('single');
3535
const [timePicker, setTimePicker] = useState(false);
3636

@@ -55,7 +55,7 @@ export default function App() {
5555
);
5656

5757
const onChange = useCallback(
58-
(params) => {
58+
(params: any) => {
5959
if (mode === 'single') {
6060
setDate(params.date);
6161
} else if (mode === 'range') {
@@ -157,8 +157,9 @@ export default function App() {
157157
style={{
158158
flexDirection: 'row',
159159
alignItems: 'center',
160-
gap: 10,
161160
marginBottom: 20,
161+
gap: 10,
162+
paddingHorizontal: 120,
162163
}}
163164
>
164165
<BouncyCheckbox
@@ -169,11 +170,9 @@ export default function App() {
169170
fontSize: 14,
170171
color: '#000',
171172
marginLeft: -8,
172-
textDecorationLine: 'none',
173173
}}
174174
useNativeDriver={false}
175175
isChecked={timePicker}
176-
disableBuiltInState
177176
onPress={() => setTimePicker(!timePicker)}
178177
disabled={mode !== 'single'}
179178
/>
91.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)