Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bottom tabs #170

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
},
"sdkVersion": "51.0.0",
"platforms": ["ios", "android"],
"plugins": ["vxrn/expo-plugin"],
"plugins": [
"vxrn/expo-plugin",
[
"expo-build-properties",
{
"ios": {
"deploymentTarget": "14.0"
}
}
]
],
"android": {
"package": "dev.onestack.demo.social"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { desc, eq, sql } from 'drizzle-orm'
import { getURL, Stack, useLoader, type LoaderProps } from 'one'
import { Stack } from 'one'
import { RefreshControl } from 'react-native'
import { ScrollView } from 'tamagui'
import { db } from '~/code/db/connection'
import { likes, posts, replies, reposts, users } from '~/code/db/schema'
import { FeedCard } from '~/code/feed/FeedCard'
import { PageContainer } from '~/code/ui/PageContainer'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { Tabs } from 'one'
import { NativeTabs } from '../layouts/BottomTabs'
import { HomeIcons } from './HomeIcons'
import { useTheme } from 'tamagui'

export function HomeLayout() {
const theme = useTheme()

return (
<Tabs
<NativeTabs
screenOptions={{
headerShown: false,
tabBarActiveTintColor: theme.accentColor.val,
tabBarInactiveTintColor: theme.gray9.val,
}}
>
<Tabs.Screen
<NativeTabs.Screen
name="(feed)"
options={{
title: 'Feed',
tabBarIcon: ({ color }) => <HomeIcons.Home size={20} color={color} />,
}}
/>

<Tabs.Screen
<NativeTabs.Screen
name="notifications"
options={{
title: 'Notifications',
tabBarIcon: ({ color }) => <HomeIcons.Notifications size={20} color={color} />,
}}
/>

<Tabs.Screen
<NativeTabs.Screen
name="profile"
options={{
title: 'Profile',
tabBarIcon: ({ color }) => <HomeIcons.User size={20} color={color} />,
}}
/>
</Tabs>
</NativeTabs>
)
}
23 changes: 23 additions & 0 deletions examples/testflight/code/layouts/BottomTabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { withLayoutContext } from 'one'
import {
createNativeBottomTabNavigator,
type NativeBottomTabNavigationEventMap,
NativeBottomTabNavigationOptions,
// @ts-ignore
} from 'react-native-bottom-tabs/react-navigation'

// This should be imported from react-native-bottom-tabs/react-navigation which is
// exporting NativeBottomTabNavigationOptions but the types seem to be broken at
// at the moment..
import type { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs'

import type { ParamListBase, TabNavigationState } from '@react-navigation/native'

const { Navigator } = createNativeBottomTabNavigator()

export const NativeTabs = withLayoutContext<
BottomTabNavigationOptions,
typeof Navigator,
TabNavigationState<ParamListBase>,
NativeBottomTabNavigationEventMap
>(Navigator)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const PageContainer = styled(View, {
w: '100%',
maw: 600,
mx: 'auto',
bg: '$color1',

'$platform-web': {
py: '$4',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "example-recommended-appstore",
"name": "example-testflight",
"version": "1.1.311",
"private": true,
"type": "module",
Expand Down Expand Up @@ -33,11 +33,13 @@
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"expo": "~51.0.28",
"expo-build-properties": "^0.12.5",
"expo-modules-core": "^1.12.24",
"one": "1.1.311",
"postgres": "^3.4.4",
"react": "^18.3.1",
"react-native": "0.74.5",
"react-native-bottom-tabs": "^0.0.10",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import type { UserConfig } from 'vite'
import { one } from 'one/vite'
import { tamaguiPlugin } from '@tamagui/vite-plugin'
import { join } from 'node:path'
import { one } from 'one/vite'
import type { UserConfig } from 'vite'

const rnbtp = join(
import.meta.dirname,
'node_modules/react-native-bottom-tabs/lib/module/react-navigation/index.js'
)

export default {
resolve: {
alias: {
'react-native-bottom-tabs/react-navigation': rnbtp,
},
},

plugins: [
one({
web: {
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@
"fix": "manypkg fix",
"lint:fix": "ultra -r --no-pretty lint:fix",
"lint": "ultra -r --no-pretty lint",
"dev:example-test": "yarn workspace example-test dev",
"dev:example-zero": "yarn workspace example-zero dev",
"dev:example-tamagui": "yarn workspace example-tamagui dev",
"dev:example-basic": "yarn workspace example-basic dev",
"dev:example-recommended": "yarn workspace example-recommended dev",
"dev:example-weird-deps": "yarn workspace example-weird-deps dev",
"dev:example-fullstack": "yarn workspace example-fullstack dev",
"dev:example": "node -r esbuild-register ./scripts/dev.ts example",
"dev:test": "node -r esbuild-register ./scripts/dev.ts test",
"upgrade:tamagui": "yarn up '*tamagui*' '@tamagui/*'",
"upgrade:tamagui:canary": "yarn up '*tamagui*'@canary '@tamagui/*'@canary",
"test": "yarn turbo:run --concurrency=1 test",
Expand Down
1 change: 1 addition & 0 deletions packages/one/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export { setCurrentRequestHeaders } from './vite/headers'

export { build } from './vite/build'
export { one } from './vite/one'
export { resolvePath } from '@vxrn/resolve'
1 change: 1 addition & 0 deletions packages/one/types/vite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export { makePluginWebOnly } from './vite/makePluginWebOnly';
export { setCurrentRequestHeaders } from './vite/headers';
export { build } from './vite/build';
export { one } from './vite/one';
export { resolvePath } from '@vxrn/resolve';
//# sourceMappingURL=vite.d.ts.map
1 change: 1 addition & 0 deletions packages/resolve/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"composite": true,
},
"references": []
Expand Down
19 changes: 19 additions & 0 deletions scripts/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { execSync } from 'node:child_process'

const prefix = process.argv[2] // 'example' or 'test'
const workspace = process.argv[3] // The workspace name (e.g., 'basic', 'fullstack')

if (!prefix || !workspace) {
console.error('Usage: yarn dev:example <prefix> <workspace>')
console.error('Example: yarn dev:example example basic')
process.exit(1)
}

try {
const command = `yarn workspace ${prefix}-${workspace} dev`
console.info(`Running: ${command}`)
execSync(command, { stdio: 'inherit' })
} catch (error) {
console.error(`Failed to start workspace ${prefix}-${workspace}:`, error)
process.exit(1)
}
106 changes: 72 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8580,7 +8580,7 @@ __metadata:
languageName: node
linkType: hard

"ajv@npm:^8.0.1":
"ajv@npm:^8.0.1, ajv@npm:^8.11.0":
version: 8.17.1
resolution: "ajv@npm:8.17.1"
dependencies:
Expand Down Expand Up @@ -11850,39 +11850,6 @@ __metadata:
languageName: unknown
linkType: soft

"example-recommended-appstore@workspace:examples/one-testflight-demo":
version: 0.0.0-use.local
resolution: "example-recommended-appstore@workspace:examples/one-testflight-demo"
dependencies:
"@biomejs/biome": "npm:^1.8.3"
"@dotenvx/dotenvx": "npm:^1.12.1"
"@faker-js/faker": "npm:next"
"@tamagui/config": "npm:^1.115.0"
"@tamagui/image-next": "npm:^1.115.0"
"@tamagui/lucide-icons": "npm:^1.115.0"
"@tamagui/vite-plugin": "npm:^1.115.0"
"@vxrn/color-scheme": "npm:1.1.311"
better-sqlite3: "npm:^11.2.1"
dotenv: "npm:^16.4.5"
drizzle-kit: "npm:^0.24.2"
drizzle-orm: "npm:^0.33.0"
expo: "npm:~51.0.28"
expo-modules-core: "npm:^1.12.24"
one: "npm:1.1.311"
postgres: "npm:^3.4.4"
react: "npm:^18.3.1"
react-native: "npm:0.74.5"
react-native-reanimated: "npm:~3.10.1"
react-native-safe-area-context: "npm:4.10.5"
react-native-screens: "npm:3.31.1"
react-native-svg: "npm:15.2.0"
react-native-web: "npm:^0.19.12"
tamagui: "npm:^1.115.0"
tsx: "npm:^4.19.0"
vite: "npm:6.0.0-beta.1"
languageName: unknown
linkType: soft

"example-recommended@workspace:examples/one-recommended":
version: 0.0.0-use.local
resolution: "example-recommended@workspace:examples/one-recommended"
Expand Down Expand Up @@ -11999,6 +11966,41 @@ __metadata:
languageName: unknown
linkType: soft

"example-testflight@workspace:examples/testflight":
version: 0.0.0-use.local
resolution: "example-testflight@workspace:examples/testflight"
dependencies:
"@biomejs/biome": "npm:^1.8.3"
"@dotenvx/dotenvx": "npm:^1.12.1"
"@faker-js/faker": "npm:next"
"@tamagui/config": "npm:^1.115.0"
"@tamagui/image-next": "npm:^1.115.0"
"@tamagui/lucide-icons": "npm:^1.115.0"
"@tamagui/vite-plugin": "npm:^1.115.0"
"@vxrn/color-scheme": "npm:1.1.311"
better-sqlite3: "npm:^11.2.1"
dotenv: "npm:^16.4.5"
drizzle-kit: "npm:^0.24.2"
drizzle-orm: "npm:^0.33.0"
expo: "npm:~51.0.28"
expo-build-properties: "npm:^0.12.5"
expo-modules-core: "npm:^1.12.24"
one: "npm:1.1.311"
postgres: "npm:^3.4.4"
react: "npm:^18.3.1"
react-native: "npm:0.74.5"
react-native-bottom-tabs: "npm:^0.0.10"
react-native-reanimated: "npm:~3.10.1"
react-native-safe-area-context: "npm:4.10.5"
react-native-screens: "npm:3.31.1"
react-native-svg: "npm:15.2.0"
react-native-web: "npm:^0.19.12"
tamagui: "npm:^1.115.0"
tsx: "npm:^4.19.0"
vite: "npm:6.0.0-beta.1"
languageName: unknown
linkType: soft

"example-weird-deps@workspace:tests/weird-deps":
version: 0.0.0-use.local
resolution: "example-weird-deps@workspace:tests/weird-deps"
Expand Down Expand Up @@ -12099,6 +12101,18 @@ __metadata:
languageName: unknown
linkType: soft

"expo-build-properties@npm:^0.12.5":
version: 0.12.5
resolution: "expo-build-properties@npm:0.12.5"
dependencies:
ajv: "npm:^8.11.0"
semver: "npm:^7.6.0"
peerDependencies:
expo: "*"
checksum: 10/22a1c3fbe6ef00efe13976612766c665390df033d84203bb8d8133fec5d9291be333341119f35b4f5e60932b5829e9ac10c7aaa1a28cbfb5fa689b1b7917229a
languageName: node
linkType: hard

"expo-camera@npm:^15.0.16":
version: 15.0.16
resolution: "expo-camera@npm:15.0.16"
Expand Down Expand Up @@ -18040,6 +18054,23 @@ __metadata:
languageName: node
linkType: hard

"react-native-bottom-tabs@npm:^0.0.10":
version: 0.0.10
resolution: "react-native-bottom-tabs@npm:0.0.10"
dependencies:
sf-symbols-typescript: "npm:^2.0.0"
use-latest-callback: "npm:^0.2.1"
peerDependencies:
"@react-navigation/native": ">=6"
react: "*"
react-native: "*"
peerDependenciesMeta:
"@react-navigation/native":
optional: true
checksum: 10/81d0d365d330036649a7d35bfd13bbda06359e4d7acf63b031d826f85d211ff4b6d84fee798d53adc996d54b2a0514b9a3436793dd1b743d7e051d0ee5b313ff
languageName: node
linkType: hard

"react-native-gesture-handler@npm:^2.18.1":
version: 2.19.0
resolution: "react-native-gesture-handler@npm:2.19.0"
Expand Down Expand Up @@ -19279,6 +19310,13 @@ __metadata:
languageName: node
linkType: hard

"sf-symbols-typescript@npm:^2.0.0":
version: 2.0.0
resolution: "sf-symbols-typescript@npm:2.0.0"
checksum: 10/dde81c01265bdff16f527e1242af03793460c3c5f34ca6950ab1ca73a3bccd54ebabfcd56961658e72f94baac06ad620134a0bc03b0674dd543d4883c7d5e18f
languageName: node
linkType: hard

"shallow-clone@npm:^3.0.0":
version: 3.0.1
resolution: "shallow-clone@npm:3.0.1"
Expand Down