From 04572a8e5081b1e4871e273cde9dbaaa44c52fe0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 21:43:44 +0000 Subject: structure: Create apps dir and copy tooling dir from t3-turbo repo --- apps/mobile/.eslintrc.js | 4 + apps/mobile/.gitignore | 39 ++++ apps/mobile/.npmrc | 1 + apps/mobile/app.json | 57 +++++ apps/mobile/app/+not-found.tsx | 6 + apps/mobile/app/_layout.tsx | 53 +++++ apps/mobile/app/dashboard/(tabs)/_layout.tsx | 38 ++++ apps/mobile/app/dashboard/(tabs)/index.tsx | 31 +++ apps/mobile/app/dashboard/(tabs)/lists.tsx | 67 ++++++ apps/mobile/app/dashboard/(tabs)/search.tsx | 35 ++++ apps/mobile/app/dashboard/(tabs)/settings.tsx | 41 ++++ apps/mobile/app/dashboard/_layout.tsx | 38 ++++ apps/mobile/app/dashboard/add-link.tsx | 57 +++++ apps/mobile/app/dashboard/add-note.tsx | 53 +++++ apps/mobile/app/dashboard/archive.tsx | 11 + apps/mobile/app/dashboard/favourites.tsx | 11 + apps/mobile/app/dashboard/lists/[slug].tsx | 31 +++ apps/mobile/app/error.tsx | 9 + apps/mobile/app/index.tsx | 20 ++ apps/mobile/app/sharing.tsx | 99 +++++++++ apps/mobile/app/signin.tsx | 101 +++++++++ apps/mobile/assets/blur.jpeg | Bin 0 -> 178818 bytes apps/mobile/assets/icon.png | Bin 0 -> 2362 bytes apps/mobile/assets/splash.png | Bin 0 -> 117993 bytes apps/mobile/babel.config.js | 9 + apps/mobile/components/Logo.tsx | 11 + apps/mobile/components/bookmarks/BookmarkCard.tsx | 243 ++++++++++++++++++++++ apps/mobile/components/bookmarks/BookmarkList.tsx | 61 ++++++ apps/mobile/components/ui/ActionButton.tsx | 21 ++ apps/mobile/components/ui/Button.tsx | 81 ++++++++ apps/mobile/components/ui/Divider.tsx | 28 +++ apps/mobile/components/ui/FullPageSpinner.tsx | 9 + apps/mobile/components/ui/Input.tsx | 28 +++ apps/mobile/components/ui/Skeleton.tsx | 38 ++++ apps/mobile/components/ui/Toast.tsx | 183 ++++++++++++++++ apps/mobile/eas.json | 19 ++ apps/mobile/globals.css | 80 +++++++ apps/mobile/lib/last-shared-intent.ts | 15 ++ apps/mobile/lib/providers.tsx | 54 +++++ apps/mobile/lib/session.ts | 20 ++ apps/mobile/lib/settings.ts | 29 +++ apps/mobile/lib/storage-state.ts | 51 +++++ apps/mobile/lib/trpc.ts | 4 + apps/mobile/lib/utils.ts | 6 + apps/mobile/metro.config.js | 58 ++++++ apps/mobile/nativewind-env.d.ts | 1 + apps/mobile/package.json | 71 +++++++ apps/mobile/tailwind.config.ts | 73 +++++++ apps/mobile/tsconfig.json | 14 ++ 49 files changed, 2009 insertions(+) create mode 100644 apps/mobile/.eslintrc.js create mode 100644 apps/mobile/.gitignore create mode 100644 apps/mobile/.npmrc create mode 100644 apps/mobile/app.json create mode 100644 apps/mobile/app/+not-found.tsx create mode 100644 apps/mobile/app/_layout.tsx create mode 100644 apps/mobile/app/dashboard/(tabs)/_layout.tsx create mode 100644 apps/mobile/app/dashboard/(tabs)/index.tsx create mode 100644 apps/mobile/app/dashboard/(tabs)/lists.tsx create mode 100644 apps/mobile/app/dashboard/(tabs)/search.tsx create mode 100644 apps/mobile/app/dashboard/(tabs)/settings.tsx create mode 100644 apps/mobile/app/dashboard/_layout.tsx create mode 100644 apps/mobile/app/dashboard/add-link.tsx create mode 100644 apps/mobile/app/dashboard/add-note.tsx create mode 100644 apps/mobile/app/dashboard/archive.tsx create mode 100644 apps/mobile/app/dashboard/favourites.tsx create mode 100644 apps/mobile/app/dashboard/lists/[slug].tsx create mode 100644 apps/mobile/app/error.tsx create mode 100644 apps/mobile/app/index.tsx create mode 100644 apps/mobile/app/sharing.tsx create mode 100644 apps/mobile/app/signin.tsx create mode 100644 apps/mobile/assets/blur.jpeg create mode 100644 apps/mobile/assets/icon.png create mode 100644 apps/mobile/assets/splash.png create mode 100644 apps/mobile/babel.config.js create mode 100644 apps/mobile/components/Logo.tsx create mode 100644 apps/mobile/components/bookmarks/BookmarkCard.tsx create mode 100644 apps/mobile/components/bookmarks/BookmarkList.tsx create mode 100644 apps/mobile/components/ui/ActionButton.tsx create mode 100644 apps/mobile/components/ui/Button.tsx create mode 100644 apps/mobile/components/ui/Divider.tsx create mode 100644 apps/mobile/components/ui/FullPageSpinner.tsx create mode 100644 apps/mobile/components/ui/Input.tsx create mode 100644 apps/mobile/components/ui/Skeleton.tsx create mode 100644 apps/mobile/components/ui/Toast.tsx create mode 100644 apps/mobile/eas.json create mode 100644 apps/mobile/globals.css create mode 100644 apps/mobile/lib/last-shared-intent.ts create mode 100644 apps/mobile/lib/providers.tsx create mode 100644 apps/mobile/lib/session.ts create mode 100644 apps/mobile/lib/settings.ts create mode 100644 apps/mobile/lib/storage-state.ts create mode 100644 apps/mobile/lib/trpc.ts create mode 100644 apps/mobile/lib/utils.ts create mode 100644 apps/mobile/metro.config.js create mode 100644 apps/mobile/nativewind-env.d.ts create mode 100644 apps/mobile/package.json create mode 100644 apps/mobile/tailwind.config.ts create mode 100644 apps/mobile/tsconfig.json (limited to 'apps/mobile') diff --git a/apps/mobile/.eslintrc.js b/apps/mobile/.eslintrc.js new file mode 100644 index 00000000..53beac49 --- /dev/null +++ b/apps/mobile/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ["universe/native"], +}; diff --git a/apps/mobile/.gitignore b/apps/mobile/.gitignore new file mode 100644 index 00000000..2920e5a8 --- /dev/null +++ b/apps/mobile/.gitignore @@ -0,0 +1,39 @@ +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ + +# Native +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo + +#build files +ios/ +android/ diff --git a/apps/mobile/.npmrc b/apps/mobile/.npmrc new file mode 100644 index 00000000..d67f3748 --- /dev/null +++ b/apps/mobile/.npmrc @@ -0,0 +1 @@ +node-linker=hoisted diff --git a/apps/mobile/app.json b/apps/mobile/app.json new file mode 100644 index 00000000..e16baa37 --- /dev/null +++ b/apps/mobile/app.json @@ -0,0 +1,57 @@ +{ + "expo": { + "name": "Hoarder App", + "slug": "hoarder", + "scheme": "hoarder", + "version": "1.2.0", + "orientation": "portrait", + "icon": "./assets/icon.png", + "userInterfaceStyle": "light", + "splash": { + "image": "./assets/splash.png", + "resizeMode": "contain", + "backgroundColor": "#ffffff" + }, + "assetBundlePatterns": [ + "**/*" + ], + "ios": { + "supportsTablet": true, + "bundleIdentifier": "app.hoarder.hoardermobile", + "config": { + "usesNonExemptEncryption": false + } + }, + "android": { + "adaptiveIcon": { + "foregroundImage": "./assets/icon.png", + "backgroundColor": "#ffffff" + }, + "package": "app.hoarder.hoardermobile" + }, + "plugins": [ + "expo-router", + [ + "expo-share-intent", + { + "iosActivationRules": { + "NSExtensionActivationSupportsWebURLWithMaxCount": 1, + "NSExtensionActivationSupportsWebPageWithMaxCount": 0, + "NSExtensionActivationSupportsImageWithMaxCount": 0, + "NSExtensionActivationSupportsMovieWithMaxCount": 0, + "NSExtensionActivationSupportsText": true + } + } + ], + "expo-secure-store" + ], + "extra": { + "router": { + "origin": false + }, + "eas": { + "projectId": "d6d14643-ad43-4cd3-902a-92c5944d5e45" + } + } + } +} diff --git a/apps/mobile/app/+not-found.tsx b/apps/mobile/app/+not-found.tsx new file mode 100644 index 00000000..466505b6 --- /dev/null +++ b/apps/mobile/app/+not-found.tsx @@ -0,0 +1,6 @@ +import { View } from "react-native"; + +// This is kinda important given that the sharing modal always resolve to an unknown route +export default function NotFound() { + return ; +} diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx new file mode 100644 index 00000000..6304ced5 --- /dev/null +++ b/apps/mobile/app/_layout.tsx @@ -0,0 +1,53 @@ +import "@/globals.css"; +import "expo-dev-client"; + +import { useRouter } from "expo-router"; +import { Stack } from "expo-router/stack"; +import { useShareIntent } from "expo-share-intent"; +import { StatusBar } from "expo-status-bar"; +import { useEffect } from "react"; +import { View } from "react-native"; + +import { useLastSharedIntent } from "@/lib/last-shared-intent"; +import { Providers } from "@/lib/providers"; + +export default function RootLayout() { + const router = useRouter(); + const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntent(); + + const lastSharedIntent = useLastSharedIntent(); + + useEffect(() => { + const intentJson = JSON.stringify(shareIntent); + if (hasShareIntent && !lastSharedIntent.isPreviouslyShared(intentJson)) { + // TODO: Remove once https://github.com/achorein/expo-share-intent/issues/14 is fixed + lastSharedIntent.setIntent(intentJson); + router.replace({ + pathname: "sharing", + params: { shareIntent: intentJson }, + }); + resetShareIntent(); + } + }, [hasShareIntent]); + + return ( + + + + + + + + + + ); +} diff --git a/apps/mobile/app/dashboard/(tabs)/_layout.tsx b/apps/mobile/app/dashboard/(tabs)/_layout.tsx new file mode 100644 index 00000000..5b2d810a --- /dev/null +++ b/apps/mobile/app/dashboard/(tabs)/_layout.tsx @@ -0,0 +1,38 @@ +import { Tabs } from "expo-router"; +import { ClipboardList, Home, Search, Settings } from "lucide-react-native"; +import React from "react"; + +export default function TabLayout() { + return ( + + , + }} + /> + , + }} + /> + , + }} + /> + , + }} + /> + + ); +} diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsx new file mode 100644 index 00000000..b2349525 --- /dev/null +++ b/apps/mobile/app/dashboard/(tabs)/index.tsx @@ -0,0 +1,31 @@ +import { Link, Stack } from "expo-router"; +import { SquarePen, Link as LinkIcon } from "lucide-react-native"; +import { View } from "react-native"; + +import BookmarkList from "@/components/bookmarks/BookmarkList"; + +function HeaderRight() { + return ( + + + + + + + + + ); +} + +export default function Home() { + return ( + <> + , + }} + /> + + + ); +} diff --git a/apps/mobile/app/dashboard/(tabs)/lists.tsx b/apps/mobile/app/dashboard/(tabs)/lists.tsx new file mode 100644 index 00000000..b534ddda --- /dev/null +++ b/apps/mobile/app/dashboard/(tabs)/lists.tsx @@ -0,0 +1,67 @@ +import { Link } from "expo-router"; +import { useEffect, useState } from "react"; +import { FlatList, View } from "react-native"; + +import { api } from "@/lib/trpc"; + +export default function Lists() { + const [refreshing, setRefreshing] = useState(false); + const { data: lists, isPending } = api.lists.list.useQuery(); + const apiUtils = api.useUtils(); + + useEffect(() => { + setRefreshing(isPending); + }, [isPending]); + + if (!lists) { + // Add spinner + return ; + } + + const onRefresh = () => { + apiUtils.lists.list.invalidate(); + }; + + const links = [ + { + id: "fav", + logo: "⭐️", + name: "Favourites", + href: "/dashboard/favourites", + }, + { + id: "arch", + logo: "🗄️", + name: "Archive", + href: "/dashboard/archive", + }, + ]; + + links.push( + ...lists.lists.map((l) => ({ + id: l.id, + logo: l.icon, + name: l.name, + href: `/dashboard/lists/${l.id}`, + })), + ); + + return ( + ( + + + {l.item.logo} {l.item.name} + + + )} + data={links} + refreshing={refreshing} + onRefresh={onRefresh} + /> + ); +} diff --git a/apps/mobile/app/dashboard/(tabs)/search.tsx b/apps/mobile/app/dashboard/(tabs)/search.tsx new file mode 100644 index 00000000..980cab36 --- /dev/null +++ b/apps/mobile/app/dashboard/(tabs)/search.tsx @@ -0,0 +1,35 @@ +import { keepPreviousData } from "@tanstack/react-query"; +import { useState } from "react"; +import { View } from "react-native"; +import { useDebounce } from "use-debounce"; + +import BookmarkList from "@/components/bookmarks/BookmarkList"; +import { Divider } from "@/components/ui/Divider"; +import { Input } from "@/components/ui/Input"; +import { api } from "@/lib/trpc"; + +export default function Search() { + const [search, setSearch] = useState(""); + + const [query] = useDebounce(search, 200); + + const { data } = api.bookmarks.searchBookmarks.useQuery( + { text: query }, + { placeholderData: keepPreviousData }, + ); + + return ( + + + + {data && b.id)} />} + + ); +} diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx new file mode 100644 index 00000000..9f86d5ec --- /dev/null +++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx @@ -0,0 +1,41 @@ +import { useRouter } from "expo-router"; +import { useEffect } from "react"; +import { Text, View } from "react-native"; + +import Logo from "@/components/Logo"; +import { Button } from "@/components/ui/Button"; +import { useSession } from "@/lib/session"; +import { api } from "@/lib/trpc"; + +export default function Dashboard() { + const router = useRouter(); + + const { isLoggedIn, logout } = useSession(); + + useEffect(() => { + if (isLoggedIn !== undefined && !isLoggedIn) { + router.replace("signin"); + } + }, [isLoggedIn]); + + const { data, error, isLoading } = api.users.whoami.useQuery(); + + useEffect(() => { + if (error?.data?.code === "UNAUTHORIZED") { + logout(); + } + }, [error]); + + return ( + + + + + {isLoading ? "Loading ..." : data?.email} + + + +