very basic start of routing

This commit is contained in:
evan.steele 2024-12-04 21:53:06 -08:00
parent 0939ae402e
commit 69d5082363
8 changed files with 55 additions and 60 deletions

View File

@ -1,45 +0,0 @@
import { Tabs } from 'expo-router';
import React from 'react';
import { Platform } from 'react-native';
import { HapticTab } from '../components/HapticTab';
import { IconSymbol } from '../components/ui/IconSymbol';
import TabBarBackground from '../components/ui/TabBarBackground';
import { Colors } from '..//constants/Colors';
import { useColorScheme } from '../hooks/useColorScheme';
export default function TabLayout() {
const colorScheme = useColorScheme();
return (
<Tabs
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
headerShown: false,
tabBarButton: HapticTab,
tabBarBackground: TabBarBackground,
tabBarStyle: Platform.select({
ios: {
// Use a transparent background on iOS to show the blur effect
position: 'absolute',
},
default: {},
}),
}}>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
}}
/>
<Tabs.Screen
name="explore"
options={{
title: 'Explore',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
}}
/>
</Tabs>
);
}

View File

@ -1,22 +1,26 @@
import { View, Text, StyleSheet } from 'react-native'; import { View, Text, StyleSheet, Pressable } from 'react-native';
interface EnvironmentCardProps { interface EnvironmentCardProps {
name: string; name: string;
publicUrl: string; publicUrl: string;
status: number; status: number;
url: string; url: string;
id: number;
onPress: () => void;
} }
export default function EnvironmentCard({ name, publicUrl, status, url }: EnvironmentCardProps) { export default function EnvironmentCard({ name, publicUrl, status, url, id, onPress }: EnvironmentCardProps) {
return ( return (
<View style={styles.card}> <Pressable onPress={onPress}>
<Text style={styles.title}>{name}</Text> <View style={styles.card}>
{publicUrl && <Text>Public URL: {publicUrl}</Text>} <Text style={styles.title}>{name}</Text>
{status === 1 && <Text>Status: Running</Text>} {publicUrl && <Text>Public URL: {publicUrl}</Text>}
{status === 2 && <Text>Status: Stopped</Text>} {status === 1 && <Text>Status: Running</Text>}
{status === 3 && <Text>Status: Pending</Text>} {status === 2 && <Text>Status: Stopped</Text>}
<Text>URL: {url}</Text> {status === 3 && <Text>Status: Pending</Text>}
</View> <Text>URL: {url}</Text>
</View>
</Pressable>
); );
} }

14
app/envs/[env].tsx Normal file
View File

@ -0,0 +1,14 @@
import { Text, View } from 'react-native';
import { useLocalSearchParams, useGlobalSearchParams, Link } from 'expo-router';
export default function Route() {
const glob = useGlobalSearchParams();
const local = useLocalSearchParams();
return (
<View>
<Text>Glob: {local.env}</Text>
<Text>Local: {glob.env}</Text>
</View>
);
}

5
app/envs/_layout.tsx Normal file
View File

@ -0,0 +1,5 @@
import { Slot } from 'expo-router';
export default function HomeLayout() {
return <Slot />;
}

9
app/envs/index.tsx Normal file
View File

@ -0,0 +1,9 @@
import { View, Text } from "react-native";
export default function EnvIndex() {
return (
<View>
<Text>Environments</Text>
</View>
);
}

View File

@ -1,6 +1,7 @@
import { Text, View, ScrollView } from "react-native"; import { Text, View, ScrollView } from "react-native";
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context'; import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useRouter } from "expo-router";
import LoginForm from "./components/LoginForm"; import LoginForm from "./components/LoginForm";
import LogoutButton from "./components/LogoutButton"; import LogoutButton from "./components/LogoutButton";
@ -14,6 +15,7 @@ interface Environment {
PublicURL: string; PublicURL: string;
Status: number; Status: number;
URL: string; URL: string;
Id: number;
} }
export default function Index() { export default function Index() {
@ -28,6 +30,7 @@ export default function Index() {
} }
function MainContent() { function MainContent() {
const router = useRouter();
const { isAuthenticated, domain, username, authData } = useAuth(); const { isAuthenticated, domain, username, authData } = useAuth();
const [environmentData, setEnvironmentData] = useState<Environment[] | null>(null); const [environmentData, setEnvironmentData] = useState<Environment[] | null>(null);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@ -75,6 +78,11 @@ function MainContent() {
publicUrl={environment.PublicURL} publicUrl={environment.PublicURL}
status={environment.Status} status={environment.Status}
url={environment.URL} url={environment.URL}
id={environment.Id}
onPress={() => router.push({
pathname: `/envs/[env]`,
params: { env: environment.Id }
})}
/> />
))} ))}
</ScrollView> </ScrollView>

8
package-lock.json generated
View File

@ -18,7 +18,7 @@
"expo-font": "~13.0.1", "expo-font": "~13.0.1",
"expo-haptics": "~14.0.0", "expo-haptics": "~14.0.0",
"expo-linking": "~7.0.3", "expo-linking": "~7.0.3",
"expo-router": "~4.0.9", "expo-router": "~4.0.11",
"expo-splash-screen": "~0.29.13", "expo-splash-screen": "~0.29.13",
"expo-status-bar": "~2.0.0", "expo-status-bar": "~2.0.0",
"expo-symbols": "~0.2.0", "expo-symbols": "~0.2.0",
@ -8443,9 +8443,9 @@
} }
}, },
"node_modules/expo-router": { "node_modules/expo-router": {
"version": "4.0.9", "version": "4.0.11",
"resolved": "https://registry.npmjs.org/expo-router/-/expo-router-4.0.9.tgz", "resolved": "https://registry.npmjs.org/expo-router/-/expo-router-4.0.11.tgz",
"integrity": "sha512-bZupRd2nUWolihwhW2kqTTAVyhMaHJbtEFn49bOHtrfl0gkIHld+IecUIh+eJW6QTAcTOHCu5gVHLoJeM0mwjA==", "integrity": "sha512-2Qrd/fk98kC+CTg1umbuUaBaGkpdGStPpkSR99SoAjX6KWC1WhNMCv0hGFn7cRmSNOWQzgIfLGLERhRY1o4myw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@expo/metro-runtime": "4.0.0", "@expo/metro-runtime": "4.0.0",

View File

@ -25,7 +25,7 @@
"expo-font": "~13.0.1", "expo-font": "~13.0.1",
"expo-haptics": "~14.0.0", "expo-haptics": "~14.0.0",
"expo-linking": "~7.0.3", "expo-linking": "~7.0.3",
"expo-router": "~4.0.9", "expo-router": "~4.0.11",
"expo-splash-screen": "~0.29.13", "expo-splash-screen": "~0.29.13",
"expo-status-bar": "~2.0.0", "expo-status-bar": "~2.0.0",
"expo-symbols": "~0.2.0", "expo-symbols": "~0.2.0",