mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: update ui
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import React from "react";
|
||||
import { useTermSession } from "@/stores/terminal-sessions";
|
||||
import { Button, ScrollView, View } from "tamagui";
|
||||
import Icons from "@/components/ui/icons";
|
||||
|
||||
const SessionTabs = () => {
|
||||
const { sessions, curSession, setSession, remove } = useTermSession();
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
horizontal
|
||||
flexGrow={0}
|
||||
bg="$background"
|
||||
contentContainerStyle={{
|
||||
flexDirection: "row",
|
||||
pt: "$2",
|
||||
px: "$2",
|
||||
gap: "$2",
|
||||
}}
|
||||
>
|
||||
{sessions.map((session, idx) => (
|
||||
<View key={session.id} position="relative">
|
||||
<Button
|
||||
size="$3"
|
||||
borderBottomLeftRadius={0}
|
||||
borderBottomRightRadius={0}
|
||||
onPress={() => setSession(idx)}
|
||||
pl="$4"
|
||||
pr="$6"
|
||||
bg={curSession === idx ? "$blue7" : "$blue3"}
|
||||
>
|
||||
{session.label}
|
||||
</Button>
|
||||
<Button
|
||||
circular
|
||||
bg="$colorTransparent"
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
remove(idx);
|
||||
}}
|
||||
icon={<Icons name="close" size={16} />}
|
||||
size="$2"
|
||||
position="absolute"
|
||||
top="$1.5"
|
||||
right="$1"
|
||||
opacity={0.6}
|
||||
hoverStyle={{ opacity: 1 }}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
|
||||
<Button
|
||||
onPress={() => setSession(-1)}
|
||||
size="$2.5"
|
||||
bg="$colorTransparent"
|
||||
circular
|
||||
icon={<Icons name="plus" size={16} />}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
};
|
||||
|
||||
export default SessionTabs;
|
||||
@@ -0,0 +1,48 @@
|
||||
import React from "react";
|
||||
import InteractiveSession from "@/components/containers/interactive-session";
|
||||
import PagerView from "@/components/ui/pager-view";
|
||||
import { useTermSession } from "@/stores/terminal-sessions";
|
||||
import { Button, useMedia } from "tamagui";
|
||||
import SessionTabs from "./components/session-tabs";
|
||||
import HostsList from "../hosts/components/hosts-list";
|
||||
import Drawer from "expo-router/drawer";
|
||||
import { router } from "expo-router";
|
||||
import Icons from "@/components/ui/icons";
|
||||
|
||||
const TerminalPage = () => {
|
||||
const { sessions, curSession, setSession } = useTermSession();
|
||||
const session = sessions[curSession];
|
||||
const media = useMedia();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer.Screen
|
||||
options={{
|
||||
headerTitle: session?.label || "Terminal",
|
||||
headerRight: () => (
|
||||
<Button
|
||||
bg="$colorTransparent"
|
||||
icon={<Icons name="view-list" size={24} />}
|
||||
onPress={() => router.push("/terminal/sessions")}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
{sessions.length > 0 && media.gtSm ? <SessionTabs /> : null}
|
||||
|
||||
<PagerView
|
||||
style={{ flex: 1 }}
|
||||
page={curSession}
|
||||
onChangePage={setSession}
|
||||
EmptyComponent={HostsList}
|
||||
>
|
||||
{sessions.map((session) => (
|
||||
<InteractiveSession key={session.id} {...session} />
|
||||
))}
|
||||
</PagerView>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default TerminalPage;
|
||||
@@ -0,0 +1,93 @@
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { Button, ScrollView, View } from "tamagui";
|
||||
import { useTermSession } from "@/stores/terminal-sessions";
|
||||
import SearchInput from "@/components/ui/search-input";
|
||||
import Icons from "@/components/ui/icons";
|
||||
|
||||
const SessionsPage = () => {
|
||||
const { sessions, setSession, curSession, remove } = useTermSession();
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const sessionList = useMemo(() => {
|
||||
let items = sessions;
|
||||
|
||||
if (search) {
|
||||
items = items.filter((item) =>
|
||||
item.label.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [sessions, search]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Sessions",
|
||||
headerRight: () => (
|
||||
<Button
|
||||
bg="$colorTransparent"
|
||||
icon={<Icons name="plus" size={24} />}
|
||||
onPress={() => {
|
||||
router.back();
|
||||
router.push("/hosts");
|
||||
}}
|
||||
>
|
||||
New
|
||||
</Button>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
<View p="$3">
|
||||
<SearchInput
|
||||
placeholder="Search..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<ScrollView contentContainerStyle={{ px: "$3", pt: "$1" }}>
|
||||
{sessionList.map((session, idx) => (
|
||||
<View key={session.id} mb="$3" position="relative">
|
||||
<Button
|
||||
bg={idx !== curSession ? "$colorTransparent" : undefined}
|
||||
borderWidth={1}
|
||||
borderColor="$blue4"
|
||||
justifyContent="flex-start"
|
||||
textAlign="left"
|
||||
size="$5"
|
||||
pl="$4"
|
||||
icon={<Icons name="connection" size={16} />}
|
||||
onPress={() => {
|
||||
router.back();
|
||||
setTimeout(() => setSession(idx), 20);
|
||||
}}
|
||||
>
|
||||
{session.label}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
bg="$colorTransparent"
|
||||
circular
|
||||
size="$3"
|
||||
position="absolute"
|
||||
top="$2"
|
||||
right="$2"
|
||||
onPress={(e) => {
|
||||
e.stopPropagation();
|
||||
remove(idx);
|
||||
}}
|
||||
>
|
||||
<Icons name="close" size={16} />
|
||||
</Button>
|
||||
</View>
|
||||
))}
|
||||
</ScrollView>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SessionsPage;
|
||||
Reference in New Issue
Block a user