From 701dacf1fff805f238812cb423941eab6930b167 Mon Sep 17 00:00:00 2001 From: anhChillLe Date: Thu, 3 Aug 2023 14:01:09 +0700 Subject: [PATCH 1/2] Fix navigation --- package.json | 3 +- src/App.tsx | 14 ++++- src/actions/link_actions.ts | 4 +- src/pages/currentUser/edit_profile.tsx | 6 +-- src/pages/home/CollectionGroup.tsx | 2 +- src/pages/home/PhotoGroup.tsx | 2 +- src/pages/home/TopicGroup.tsx | 2 +- src/pages/home/UserGroup.tsx | 6 +-- src/pages/landing/landing_page.tsx | 23 ++++---- src/pages/search/search_screen.tsx | 56 +++++++++++--------- src/service/unsplash/service/current_user.ts | 2 +- 11 files changed, 71 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index a07668c..0b1840b 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "connect": "adb connect 192.168.200.31", "android": "react-native run-android", "ios": "react-native run-ios", + "ios-release":"npx react-native run-ios --mode Release", "lint": "eslint .", "start": "react-native start", "test": "jest", - "release": "cd android && ./gradlew assembleRelease && cd app/build/outputs/apk/release && adb install app-release.apk", + "android-release": "cd android && ./gradlew assembleRelease && cd app/build/outputs/apk/release && adb install app-release.apk", "build-release": "cd android && ./gradlew assembleRelease", "install-release": "cd android/app/build/outputs/apk/release && adb install app-release.apk", "setup-permission": "react-native setup-ios-permissions && cd ios && pod install" diff --git a/src/App.tsx b/src/App.tsx index 045c9a5..f0f0cd9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,20 @@ import React, { ReactElement } from "react" -import { Platform, StatusBar, useColorScheme } from "react-native" +import { Image, Platform, StatusBar, useColorScheme } from "react-native" import { Provider as PaperProvider } from "react-native-paper" import { SafeAreaProvider } from "react-native-safe-area-context" import { Provider as ReduxProvider } from "react-redux" import { darkTheme, lightTheme } from "./assets/themes" import RootStack from "./navigations/root_stack" import { store } from "./redux/store/store" +import { Images } from "./assets/images" +import FastImage from "react-native-fast-image" export default function App(): ReactElement { const colorScheme = useColorScheme() const isDarkMode = colorScheme === "dark" const theme = isDarkMode ? darkTheme : lightTheme + preloadImages() Platform.OS === "android" && StatusBar.setBackgroundColor(theme.colors.elevation.level1) StatusBar.setBarStyle(isDarkMode ? "light-content" : "dark-content") @@ -25,3 +28,12 @@ export default function App(): ReactElement { ) } + + +function preloadImages() { + const images = [Images.landing, Images.landing2] + const uris = images.map(image => ({ + uri: Image.resolveAssetSource(image).uri, + })) + FastImage.preload(uris) +} diff --git a/src/actions/link_actions.ts b/src/actions/link_actions.ts index 2b7163d..f8cdf4f 100644 --- a/src/actions/link_actions.ts +++ b/src/actions/link_actions.ts @@ -17,7 +17,7 @@ const openPortfolio = (portfolio_url: string) => { Linking.openURL(portfolio_url).catch((err) => console.error("Can not open Portfolio:", err)); }; -function LoginWidthUnsplash() { +function LoginWithUnsplash() { const baseUrl = "https://unsplash.com/oauth/authorize"; const clientId = `client_id=${ACCESS_KEY}`; const redirect = `redirect_uri=unsplash://app/login_success`; @@ -41,4 +41,4 @@ function LoginWidthUnsplash() { Linking.openURL(url); } -export { openInstagramProfile, openTwitterProfile, LoginWidthUnsplash, openPortfolio }; +export { openInstagramProfile, openTwitterProfile, LoginWithUnsplash, openPortfolio }; diff --git a/src/pages/currentUser/edit_profile.tsx b/src/pages/currentUser/edit_profile.tsx index d68337d..0a313a0 100644 --- a/src/pages/currentUser/edit_profile.tsx +++ b/src/pages/currentUser/edit_profile.tsx @@ -5,8 +5,8 @@ import { Avatar, Button, IconButton, Surface, Text } from "react-native-paper" import { useSafeAreaInsets } from "react-native-safe-area-context" import * as yup from "yup" import { BackAppBar, LoadingScreen, TextField } from "../../components" -import { useAppDispatch, useUserState } from "../../redux/store/store" import { updateCurrentUser } from "../../redux/features/user/action" +import { useAppDispatch, useUserState } from "../../redux/store/store" export default function EditUserProfile() { const state = useUserState() @@ -135,7 +135,7 @@ export default function EditUserProfile() { title="About" control={control} name="bio" - initValue={bio} + initValue={bio ?? ""} placeholder="Description about you" errors={errors} style={styles.field} @@ -144,7 +144,7 @@ export default function EditUserProfile() { title="Instagram" control={control} name="instagram_username" - initValue={instagram_username} + initValue={instagram_username ?? ""} placeholder="Instagram username" errors={errors} style={styles.field} diff --git a/src/pages/home/CollectionGroup.tsx b/src/pages/home/CollectionGroup.tsx index 911b2c5..a09618f 100644 --- a/src/pages/home/CollectionGroup.tsx +++ b/src/pages/home/CollectionGroup.tsx @@ -21,7 +21,7 @@ export default function CollectionGroup({ width }: { width: number }) { return ( <> - Hot collections + Collections }) return ( <> - Top of the week + Photos - Hot topics + Topics { - navigation.navigate(Screens.editUserProfile) + // navigation.navigate(Screens.editUserProfile) closeMenu() } const openCreateCollection = () => { - navigation.navigate(Screens.createCollection) + // navigation.navigate(Screens.createCollection) closeMenu() } diff --git a/src/pages/landing/landing_page.tsx b/src/pages/landing/landing_page.tsx index 1401ed2..469e2e3 100644 --- a/src/pages/landing/landing_page.tsx +++ b/src/pages/landing/landing_page.tsx @@ -1,15 +1,18 @@ -import { ImageBackground, StyleSheet, View } from "react-native" +import { ImageBackground, Platform, StatusBar, StyleSheet, View } from "react-native" import { Button, Text } from "react-native-paper" -import { LoginWidthUnsplash } from "../../actions/link_actions" +import { LoginWithUnsplash } from "../../actions/link_actions" import { Images } from "../../assets/images" import { Icons } from "../../assets/images/icons" -import { useAppNavigation } from "../../navigations/hooks" +import { useEffect } from "react" export default function LandingPage() { - const navigation = useAppNavigation() - const openApp = () => { - // navigation.navigate(ScreenName.main) - } + Platform.OS === "android" && + useEffect(() => { + StatusBar.setTranslucent(true) + return () => { + StatusBar.setTranslucent(false) + } + }, []) return ( @@ -22,7 +25,7 @@ export default function LandingPage() { - + */}