diff --git a/apps/mobile/native/ios/Modules/TabBar/TabBarRootView.swift b/apps/mobile/native/ios/Modules/TabBar/TabBarRootView.swift index 4f4167fc0..d8b171b35 100644 --- a/apps/mobile/native/ios/Modules/TabBar/TabBarRootView.swift +++ b/apps/mobile/native/ios/Modules/TabBar/TabBarRootView.swift @@ -22,7 +22,7 @@ class TabBarRootView: ExpoView { if #available(iOS 18.0, *) { tabBarController.isTabBarHidden = true } - + return tabBarController }() diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 97fab415c..97692b2d4 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -61,6 +61,7 @@ "expo-clipboard": "7.0.1", "expo-constants": "17.0.8", "expo-dev-client": "5.0.20", + "expo-device": "7.0.3", "expo-document-picker": "13.0.3", "expo-file-system": "18.0.12", "expo-haptics": "14.0.1", diff --git a/apps/mobile/src/atoms/app.ts b/apps/mobile/src/atoms/app.ts index 8cd6b4801..8326e78e4 100644 --- a/apps/mobile/src/atoms/app.ts +++ b/apps/mobile/src/atoms/app.ts @@ -1,3 +1,4 @@ +import type { DeviceType } from "expo-device" import { atom } from "jotai" export const loadingVisibleAtom = atom(false) @@ -15,3 +16,9 @@ export const loadingAtom = atom<{ done: null, thenable: null, }) +/** + * Do not use directly + */ +export const appAtoms = { + deviceType: atom(null), +} diff --git a/apps/mobile/src/atoms/hooks/useDeviceType.ts b/apps/mobile/src/atoms/hooks/useDeviceType.ts new file mode 100644 index 000000000..f1836e35f --- /dev/null +++ b/apps/mobile/src/atoms/hooks/useDeviceType.ts @@ -0,0 +1,13 @@ +import { jotaiStore } from "@follow/utils" +import { useAtomValue } from "jotai" + +import { appAtoms } from "../app" + +export const useDeviceType = () => { + const deviceType = useAtomValue(appAtoms.deviceType) + return deviceType +} + +export const getDeviceType = () => { + return jotaiStore.get(appAtoms.deviceType) +} diff --git a/apps/mobile/src/components/common/NoLoginInfo.tsx b/apps/mobile/src/components/common/NoLoginInfo.tsx index c7b5e7172..9f4400f78 100644 --- a/apps/mobile/src/components/common/NoLoginInfo.tsx +++ b/apps/mobile/src/components/common/NoLoginInfo.tsx @@ -1,19 +1,17 @@ import { Pressable, Text } from "react-native" import { useColor } from "react-native-uikit-colors" -import { useNavigation } from "@/src/lib/navigation/hooks" -import { LoginScreen } from "@/src/screens/(modal)/LoginScreen" +import { destination } from "@/src/lib/navigation/biz/Destination" import { Logo } from "../ui/logo" export function NoLoginInfo({ target }: { target: "timeline" | "subscriptions" }) { const color = useColor("secondaryLabel") - const navigation = useNavigation() return ( navigation.presentControllerView(LoginScreen)} + onPress={() => destination.Login()} > {`Sign in to see your ${target}`} diff --git a/apps/mobile/src/components/ui/loading/index.tsx b/apps/mobile/src/components/ui/loading/index.tsx deleted file mode 100644 index 67dea6b23..000000000 --- a/apps/mobile/src/components/ui/loading/index.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { cn } from "@follow/utils/src/utils" -import type { FC, PropsWithChildren } from "react" -import { useEffect } from "react" -import { View } from "react-native" -import Animated, { - Easing, - interpolate, - useAnimatedStyle, - useDerivedValue, - useSharedValue, - withRepeat, - withTiming, -} from "react-native-reanimated" - -import { Loading3CuteLiIcon } from "@/src/icons/loading_3_cute_li" - -export const LoadingIndicator: FC< - { - size?: number - color?: string - className?: string - } & PropsWithChildren -> = ({ size = 36, color, children, className }) => { - const rotateValue = useSharedValue(0) - - const rotation = useDerivedValue(() => { - return interpolate(rotateValue.value, [0, 360], [0, 360]) - }) - - const animatedStyle = useAnimatedStyle(() => ({ - transform: [{ rotate: `${rotation.value}deg` }], - })) - useEffect(() => { - rotateValue.value = withRepeat( - withTiming(360, { duration: 1000, easing: Easing.linear }), - -1, - false, - ) - - return () => { - rotateValue.value = 0 - } - }, [rotateValue]) - return ( - - - - - {children} - - ) -} diff --git a/apps/mobile/src/initialize/device.ts b/apps/mobile/src/initialize/device.ts new file mode 100644 index 000000000..aebc1329b --- /dev/null +++ b/apps/mobile/src/initialize/device.ts @@ -0,0 +1,10 @@ +import { getDeviceTypeAsync } from "expo-device" + +import { appAtoms } from "../atoms/app" +import { jotaiStore } from "../lib/jotai" + +export function initDeviceType() { + getDeviceTypeAsync().then((type) => { + jotaiStore.set(appAtoms.deviceType, type) + }) +} diff --git a/apps/mobile/src/initialize/index.ts b/apps/mobile/src/initialize/index.ts index e8c4d6631..1971bbd50 100644 --- a/apps/mobile/src/initialize/index.ts +++ b/apps/mobile/src/initialize/index.ts @@ -8,6 +8,7 @@ import { initializeAppCheck } from "./app-check" import { initBackgroundFetch } from "./background" import { initCrashlytics } from "./crashlytics" import { initializeDayjs } from "./dayjs" +import { initDeviceType } from "./device" import { hydrateDatabaseToStore, hydrateQueryClient, hydrateSettings } from "./hydrate" import { migrateDatabase } from "./migration" import { initializePlayer } from "./player" @@ -17,6 +18,7 @@ export const initializeApp = async () => { console.log(`Initialize...`) const now = Date.now() + initDeviceType() initializeDb() await apm("migrateDatabase", migrateDatabase) diff --git a/apps/mobile/src/lib/navigation/StackNavigation.tsx b/apps/mobile/src/lib/navigation/StackNavigation.tsx index 96989b515..255e98c94 100644 --- a/apps/mobile/src/lib/navigation/StackNavigation.tsx +++ b/apps/mobile/src/lib/navigation/StackNavigation.tsx @@ -181,7 +181,8 @@ const ModalScreenStackItems: FC<{ if (!rootModalRoute) { return null } - const isStackModal = rootModalRoute.type !== "formSheet" + const isFormSheet = rootModalRoute.type === "formSheet" + const isStackModal = !isFormSheet const isFullScreen = rootModalRoute.type !== "modal" && rootModalRoute.type !== "formSheet" @@ -229,16 +230,20 @@ const ModalScreenStackItems: FC<{ ) } + return routes.map((route) => { return ( - - - + + + + + + + ) }) }) diff --git a/apps/mobile/src/lib/navigation/biz/Destination.ts b/apps/mobile/src/lib/navigation/biz/Destination.ts new file mode 100644 index 000000000..62b2cf99f --- /dev/null +++ b/apps/mobile/src/lib/navigation/biz/Destination.ts @@ -0,0 +1,29 @@ +import { DeviceType } from "expo-device" + +import { getDeviceType } from "@/src/atoms/hooks/useDeviceType" +import { LoginScreen } from "@/src/screens/(modal)/LoginScreen" + +import { isIOS } from "../../platform" +import { Navigation } from "../Navigation" + +class Destination { + private navigation = Navigation.rootNavigation + + get isIpad() { + return getDeviceType() === DeviceType.TABLET && isIOS + } + + get presentControllerView() { + return this.navigation.presentControllerView + } + + get pushControllerView() { + return this.navigation.pushControllerView + } + + Login() { + this.presentControllerView(LoginScreen, void 0, this.isIpad ? "formSheet" : "modal") + } +} + +export const destination = new Destination() diff --git a/apps/mobile/src/lib/platform.ts b/apps/mobile/src/lib/platform.ts index e23d31dc5..7eee243f1 100644 --- a/apps/mobile/src/lib/platform.ts +++ b/apps/mobile/src/lib/platform.ts @@ -1,7 +1,13 @@ import { Platform } from "react-native" +import { useDeviceType } from "../atoms/hooks/useDeviceType" + export const isIOS = Platform.OS === "ios" export const isAndroid = Platform.OS === "android" export const isNative = isIOS || isAndroid export const devicePlatform = isIOS ? "ios" : isAndroid ? "android" : "web" export const isWeb = !isNative + +export const useIsiPad = () => { + return useDeviceType() && isIOS +} diff --git a/apps/mobile/src/providers/migration.tsx b/apps/mobile/src/providers/migration.tsx index 0196d7273..baacbee73 100644 --- a/apps/mobile/src/providers/migration.tsx +++ b/apps/mobile/src/providers/migration.tsx @@ -2,7 +2,7 @@ import { deleteAsync } from "expo-file-system" import type { ReactNode } from "react" import { Button, Text, View } from "react-native" -import { LoadingIndicator } from "../components/ui/loading" +import { PlatformActivityIndicator } from "../components/ui/loading/PlatformActivityIndicator" import { getDbPath } from "../database" import { BugCuteReIcon } from "../icons/bug_cute_re" import { useDatabaseMigration } from "../initialize/migration" @@ -35,9 +35,8 @@ export const MigrationProvider = ({ children }: { children: ReactNode }) => { if (!success) { return ( - - Database Migrations... - + + Database Migrations... ) } diff --git a/apps/mobile/src/screens/(modal)/LoginScreen.tsx b/apps/mobile/src/screens/(modal)/LoginScreen.tsx index 4a7a6ec00..5409a4d28 100644 --- a/apps/mobile/src/screens/(modal)/LoginScreen.tsx +++ b/apps/mobile/src/screens/(modal)/LoginScreen.tsx @@ -1,9 +1,10 @@ -import { useEffect } from "react" -import { Text, TouchableOpacity } from "react-native" +import { Fragment, useEffect } from "react" +import { ScrollView, Text, TouchableOpacity } from "react-native" import { HeaderCloseOnly } from "@/src/components/layouts/header/HeaderElements" import { Navigation } from "@/src/lib/navigation/Navigation" import type { NavigationControllerView } from "@/src/lib/navigation/types" +import { useIsiPad } from "@/src/lib/platform" import { Login } from "@/src/modules/login" import { useWhoami } from "@/src/store/user/hooks" @@ -24,11 +25,15 @@ export const LoginScreen: NavigationControllerView = () => { exit() } }, [whoami]) + const isiPad = useIsiPad() + const Container = isiPad ? ScrollView : Fragment // For development purposes, we don't want to redirect to the home page automatically return ( <> - + + + {!!whoami?.id && __DEV__ && ( { ) } + +LoginScreen.sheetGrabberVisible = false diff --git a/apps/mobile/tsconfig.json b/apps/mobile/tsconfig.json index 60a419971..6467682bf 100644 --- a/apps/mobile/tsconfig.json +++ b/apps/mobile/tsconfig.json @@ -13,6 +13,6 @@ "jsx": "preserve", "types": ["@follow/types/global"] }, - "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts", "nativewind-env.d.ts"], + "include": ["**/*.ts", "**/*.tsx", "nativewind-env.d.ts"], "exclude": ["./native", "./web-app"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 52aa5d910..a68751b86 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -886,6 +886,9 @@ importers: expo-dev-client: specifier: 5.0.20 version: 5.0.20(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)) + expo-device: + specifier: 7.0.3 + version: 7.0.3(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)) expo-document-picker: specifier: 13.0.3 version: 13.0.3(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)) @@ -8870,6 +8873,11 @@ packages: peerDependencies: expo: '*' + expo-device@7.0.3: + resolution: {integrity: sha512-uNGhDYmpDj/3GySWZmRiYSt52Phdim11p0pXfgpCq/nMks0+UPZwl3D0vin5N8/gpVe5yzb13GYuFxiVoDyniw==} + peerDependencies: + expo: '*' + expo-document-picker@13.0.3: resolution: {integrity: sha512-348xcsiA/YhgWm1SuJNNdb5cUDpRJYCyIk8MhOU2MEDxbVRR+Q1TiUBTCIMVqaWHcxsFQzP56Wwv9n24qjeILg==} peerDependencies: @@ -14414,6 +14422,10 @@ packages: engines: {node: '>=14.17'} hasBin: true + ua-parser-js@0.7.40: + resolution: {integrity: sha512-us1E3K+3jJppDBa3Tl0L3MOJiGhe1C6P0+nIvQAFYbxlMAx0h81eOwLmU57xgqToduDDPx3y5QsdjPfDu+FgOQ==} + hasBin: true + ua-parser-js@1.0.40: resolution: {integrity: sha512-z6PJ8Lml+v3ichVojCiB8toQJBuwR42ySM4ezjXIqXK3M0HczmKQ3LF4rhU55PfD99KEEXQG6yb7iOMyvYuHew==} hasBin: true @@ -24599,6 +24611,11 @@ snapshots: expo: 52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1) expo-dev-menu-interface: 1.9.3(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)) + expo-device@7.0.3(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)): + dependencies: + expo: 52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1) + ua-parser-js: 0.7.40 + expo-document-picker@13.0.3(expo@52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1)): dependencies: expo: 52.0.46(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@expo/metro-runtime@4.0.1(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1)))(bufferutil@4.0.9)(encoding@0.1.13)(graphql@16.8.1)(react-native-webview@13.13.5(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1))(react-native@0.77.2(@babel/core@7.26.10)(@babel/preset-env@7.26.9(@babel/core@7.26.10))(@types/react@18.3.12)(bufferutil@4.0.9)(react@18.3.1))(react@18.3.1) @@ -31237,6 +31254,8 @@ snapshots: typescript@5.8.3: {} + ua-parser-js@0.7.40: {} + ua-parser-js@1.0.40: {} ufo@1.6.1: {}