Skip to content

Commit 3bbf29e

Browse files
committed
feat(new-phone): somewhat working navigation system
1 parent 8a9fa74 commit 3bbf29e

File tree

11 files changed

+107
-62
lines changed

11 files changed

+107
-62
lines changed

apps/new-phone-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@tanstack/react-query-devtools": "^5.62.8",
1818
"jotai": "^2.10.4",
1919
"jotai-devtools": "^0.10.1",
20+
"lucide-react": "^0.294.0",
2021
"react": "^19.0.0",
2122
"react-dom": "^19.0.0",
2223
"react-router": "^7.0.2"
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
import { AppGrid } from "@native/launcher/components/AppGrid"
1+
import { AppGrid } from '@native/launcher/components/AppGrid';
2+
import { Battery, Camera, MessageCircle, Phone, SignalMedium, Wifi } from 'lucide-react';
23

34
export const Launcher = () => {
4-
return (
5-
<div className="h-full w-full bg-gray-500 rounded-xl">
6-
<AppGrid />
5+
return (
6+
<div className="h-full w-full bg-gray-100 rounded-xl relative">
7+
<header className="px-4 py-2 flex justify-between">
8+
<div>
9+
<p>9.41</p>
710
</div>
8-
)
9-
}
11+
<div className="flex items-center space-x-2">
12+
<SignalMedium size={24} />
13+
<Wifi size={20} />
14+
<Battery />
15+
</div>
16+
</header>
17+
18+
<AppGrid />
19+
20+
<div className="absolute bottom-5 left-0 right-0 flex justify-center">
21+
<div className="bg-white shadow-md rounded-full p-4 flex space-x-6">
22+
<MessageCircle />
23+
<Camera />
24+
<Phone />
25+
</div>
26+
</div>
27+
</div>
28+
);
29+
};
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { AppRoute } from '@navigation/navigator';
1+
import { AppNavigation } from '@navigation/navigator';
22
import { Dialer } from './screens/Dialer';
33

44
export default {
5-
name: 'Phone',
6-
path: '/phone',
7-
Component: Dialer,
8-
} satisfies AppRoute;
5+
name: 'Phone',
6+
path: '/phone',
7+
Component: Dialer,
8+
} satisfies AppNavigation;
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { AppRoute } from '@navigation/navigator';
1+
import { MessagesLayout } from './screens/Layout';
2+
import { AppNavigation } from '@navigation/navigator';
23
import { Messages } from './screens/Messages';
34

45
export default {
5-
name: 'Messages',
6-
path: '/messages',
7-
Component: Messages,
8-
} satisfies AppRoute;
6+
name: 'Messaegs',
7+
path: '/messages',
8+
Component: MessagesLayout,
9+
children: [
10+
{
11+
index: true,
12+
Component: Messages,
13+
},
14+
],
15+
} satisfies AppNavigation;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Outlet } from 'react-router';
2+
3+
export function MessagesLayout() {
4+
return (
5+
<main className="bg-neutral-900 h-full w-full">
6+
<header>
7+
<p>Messages</p>
8+
</header>
9+
<Outlet />
10+
</main>
11+
);
12+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const Messages = () => {
2-
return (
3-
<div>
4-
<h1>Messages</h1>
5-
</div>
6-
)
7-
}
2+
return (
3+
<div className="px-4">
4+
<input className="bg-neutral-800 border border-neutral-700 rounded-full py-2 w-full indent-4 text-white outline-none focus:ring-2 active:ring-2 ring-neutral-500" />
5+
</div>
6+
);
7+
};

apps/new-phone-react/src/native/components/PhoneFrame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Outlet } from 'react-router';
33
export const PhoneFrame = () => {
44
return (
55
<div className="bg-red-200 min-h-screen min-w-screen">
6-
<div className="bg-white fixed bottom-5 right-5 w-[450px] h-[900px] rounded-xl shadow-lg">
6+
<div className="bg-white fixed bottom-5 right-5 w-[400px] h-[800px] rounded-xl shadow-lg">
77
<Outlet />
88
</div>
99
</div>
Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
import { Launcher } from "@apps/Launcher";
2-
import { PhoneFrame } from "@native/components/PhoneFrame";
3-
import { createHashRouter } from "react-router";
1+
import { Launcher } from '@apps/Launcher';
2+
import { PhoneFrame } from '@native/components/PhoneFrame';
3+
import { createHashRouter, RouteObject } from 'react-router';
44

5-
export interface AppRoute {
6-
name: string;
7-
path: string;
8-
Component: React.ComponentType;
9-
}
5+
export type AppNavigation = RouteObject & {
6+
name: string;
7+
};
108

11-
export const createRouter = (navigators: AppRoute[]) => {
12-
return createHashRouter([{
13-
path: "/",
14-
Component: PhoneFrame,
15-
children: [
16-
{
17-
index: true,
18-
Component: Launcher,
19-
},
20-
...navigators.map(({ path, Component }) => ({
21-
path,
22-
Component,
23-
})),
24-
]
25-
}])
9+
// not sure why we have this right now, but we might add some stuff in here later????
10+
function createRoutes(navigators: RouteObject[]): RouteObject[] {
11+
return navigators;
2612
}
2713

14+
export function createRouter(navigators: RouteObject[]) {
15+
return createHashRouter([
16+
{
17+
path: '/',
18+
Component: PhoneFrame,
19+
children: [
20+
{
21+
index: true,
22+
Component: Launcher,
23+
},
24+
...createRoutes(navigators),
25+
],
26+
},
27+
]);
28+
}
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import { useNavigators, useSetNavigator } from "@navigation/navigator.state";
1+
import { useNavigators, useSetNavigator } from '@navigation/navigator.state';
22

33
export const useInitApps = () => {
4-
const setNavigator = useSetNavigator();
4+
const setNavigator = useSetNavigator();
55

6-
const modules = import.meta.glob('/src/apps/*/app.routes.ts', { eager: true });
7-
const apps = Object.values(modules).map((mod) => mod.default).filter((app) => app);
6+
const modules = import.meta.glob('/src/apps/*/app.routes.ts', { eager: true });
7+
const apps = Object.values(modules)
8+
.map((mod) => mod.default)
9+
.filter((app) => app);
810

9-
for (const app of apps) {
10-
if (!app) {
11-
continue;
12-
}
13-
14-
setNavigator(app);
11+
for (const app of apps) {
12+
if (!app) {
13+
continue;
1514
}
1615

17-
return apps;
16+
setNavigator(app);
17+
}
18+
19+
return apps;
1820
};
1921

2022
export const useApps = () => {
21-
const navigator = useNavigators();
22-
return navigator;
23-
}
23+
const navigator = useNavigators();
24+
return navigator;
25+
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@
4343
"hooks": {
4444
"pre-commit": "npx run format:staged"
4545
}
46-
},
47-
"dependencies": {}
46+
}
4847
}

0 commit comments

Comments
 (0)