Skip to content

Commit cc91c74

Browse files
committed
feat: add camera functionality with permission handling and image analysis, refactor color scheme hooks, and update themed components
1 parent 4cd1e48 commit cc91c74

34 files changed

+642
-372
lines changed

tree-disk-capture/app.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@
3535
"favicon": "./assets/images/favicon.png"
3636
},
3737
"plugins": [
38-
"expo-router"
38+
"expo-router",
39+
[
40+
"expo-camera",
41+
{
42+
"cameraPermission": "Allow $(PRODUCT_NAME) to access your camera",
43+
"microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone",
44+
"recordAudioAndroid": true
45+
}
46+
]
3947
],
4048
"experiments": {
4149
"tsconfigPaths": true,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { View, Text, Image } from 'react-native';
2+
import { useLocalSearchParams } from 'expo-router';
3+
import { useCaptures } from '@/hooks/use-captures';
4+
import { ThemedView } from '@/components/ThemedView';
5+
import { ThemedText } from '@/components/ThemedText';
6+
7+
export default function CaptureDetails() {
8+
const { id } = useLocalSearchParams();
9+
const { getCaptureById } = useCaptures();
10+
const capture = getCaptureById(id as string);
11+
12+
if (!capture) {
13+
return (
14+
<ThemedView className="flex-1 items-center justify-center p-4">
15+
<ThemedText className="text-xl">Capture not found</ThemedText>
16+
</ThemedView>
17+
);
18+
}
19+
20+
return (
21+
<ThemedView className="flex-1 p-4">
22+
<Image
23+
source={{ uri: capture.uri }}
24+
className="w-full h-64 rounded-lg mb-4"
25+
resizeMode="cover"
26+
/>
27+
<ThemedText className="text-lg mb-2">
28+
Predicted Age: {capture.analysis.predictedAge}
29+
</ThemedText>
30+
<ThemedText className="text-lg mb-2">
31+
Location: {capture.analysis.predictedLocation}
32+
</ThemedText>
33+
<ThemedText className="text-lg">
34+
Captured: {new Date(capture.timestamp).toLocaleDateString()}
35+
</ThemedText>
36+
</ThemedView>
37+
);
38+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function HistoryLayout() {
4+
return (
5+
<Stack
6+
screenOptions={{
7+
headerStyle: { backgroundColor: '#1f2937' },
8+
headerTintColor: '#fff',
9+
}}
10+
/>
11+
);
12+
}

tree-disk-capture/app/(tabs)/_layout.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

tree-disk-capture/app/(tabs)/index.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

tree-disk-capture/app/(tabs)/two.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

tree-disk-capture/app/_layout.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { ThemedView } from "@/components/ThemedView";
12
import "../global.css";
23
import FontAwesome from "@expo/vector-icons/FontAwesome";
34
import { useFonts } from "expo-font";
45
import { SplashScreen, Stack } from "expo-router";
56
import { memo, useEffect } from "react";
6-
import { View, StyleSheet } from "react-native";
7+
import { View, StyleSheet, StatusBar } from "react-native";
78

89
export {
910
// Catch any errors thrown by the Layout component.
@@ -39,10 +40,28 @@ export default function RootLayout() {
3940

4041
function RootLayoutNav() {
4142
return (
42-
<View style={StyleSheet.absoluteFill}>
43-
<Stack>
44-
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
43+
<ThemedView style={StyleSheet.absoluteFill}>
44+
<StatusBar/>
45+
<Stack
46+
screenOptions={{
47+
headerShown: false,
48+
presentation: 'fullScreenModal'
49+
}}
50+
>
51+
<Stack.Screen
52+
name="index"
53+
options={{
54+
title: 'Tree Rings',
55+
}}
56+
/>
57+
<Stack.Screen
58+
name="capture"
59+
options={{
60+
title: 'New Capture',
61+
presentation: 'fullScreenModal',
62+
}}
63+
/>
4564
</Stack>
46-
</View>
65+
</ThemedView>
4766
);
4867
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { View } from 'react-native';
2+
import { router } from 'expo-router';
3+
import { CameraContainer } from '@/components/camera/camera-container';
4+
import { useCamera } from '@/hooks/use-camera';
5+
import { PermissionRequest } from '@/components/camera/permission-request';
6+
import { ThemedView } from '@/components/ThemedView';
7+
8+
export default function Capture() {
9+
const { permission, requestPermission, handleCapture } = useCamera();
10+
11+
if (!permission?.granted) {
12+
return <PermissionRequest onRequestPermission={requestPermission} />;
13+
}
14+
15+
if (!permission) {
16+
// Camera permissions are still loading.
17+
return <ThemedView />;
18+
}
19+
20+
return (
21+
<CameraContainer
22+
onCapture={handleCapture}
23+
onCaptureSaved={() => router.replace('/')}
24+
/>
25+
);
26+
}

tree-disk-capture/app/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { View, ScrollView, Text } from 'react-native';
2+
import { router } from 'expo-router';
3+
import { HistoryList } from '@/components/history/history-list';
4+
import { NewCaptureButton } from '@/components/buttons/new-capture-button';
5+
import { useCaptures } from '@/hooks/use-captures';
6+
import { ThemedView } from '@/components/ThemedView';
7+
import { ThemedText } from '@/components/ThemedText';
8+
9+
export default function Home() {
10+
const { captures } = useCaptures();
11+
12+
return (
13+
<ThemedView className="flex-1 bg-gray-900">
14+
<NewCaptureButton onPress={() => router.push('/capture')} />
15+
<ThemedView className="flex-1">
16+
<ScrollView className="flex-1">
17+
<ThemedView className="p-4">
18+
<ThemedText className="text-white text-xl font-bold mb-4">History</ThemedText>
19+
<HistoryList captures={captures} />
20+
</ThemedView>
21+
</ScrollView>
22+
</ThemedView>
23+
</ThemedView>
24+
);
25+
}

tree-disk-capture/components/Collapsible.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)