Skip to content

Commit 52d2458

Browse files
authored
Implement state screen (#22)
* implement basic state screen * change no state * remove unused * add a comment * add a newline * clean up * add client id * support multiple subscriptions * remove some unused vars * separate by clientId * scope timeline items by client id * fix security issue * select a server when it connects * uncomment * make sanitize a util function * fix path * newline * more pollution checking
1 parent 165ef78 commit 52d2458

22 files changed

+504
-71
lines changed

app/app.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MenuItemId } from "./components/Sidebar/SidebarMenu"
1919
import { HelpScreen } from "./screens/HelpScreen"
2020
import { TimelineItem } from "./types"
2121
import { PortalHost } from "./components/Portal"
22+
import { StateScreen } from "./screens/StateScreen"
2223

2324
if (__DEV__) {
2425
// This is for debugging Reactotron with ... Reactotron!
@@ -115,6 +116,17 @@ function App(): React.JSX.Element {
115116
// and handle all websocket events.
116117
useEffect(() => connectToServer(), [])
117118

119+
const renderActiveItem = () => {
120+
switch (activeItem) {
121+
case "help":
122+
return <HelpScreen />
123+
case "state":
124+
return <StateScreen />
125+
default:
126+
return <TimelineScreen />
127+
}
128+
}
129+
118130
return (
119131
<View style={$container()}>
120132
<Titlebar />
@@ -123,7 +135,7 @@ function App(): React.JSX.Element {
123135
<Sidebar />
124136
<View style={$contentContainer}>
125137
<AppHeader />
126-
{activeItem === "help" ? <HelpScreen /> : <TimelineScreen />}
138+
{renderActiveItem()}
127139
</View>
128140
</View>
129141
<PortalHost />

app/components/ClientTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export function ClientTab({ clientId }: { clientId: string }) {
1212
const os: string = clientData?.platform ?? "Unknown"
1313

1414
const [activeTab, setActiveTab] = useGlobal(tabgroup, label, { persist: true })
15-
const active = activeTab === label
15+
const active = activeTab === clientId
1616

1717
return (
18-
<Pressable key={clientId} onPress={() => setActiveTab(label)} style={$container()}>
18+
<Pressable key={clientId} onPress={() => setActiveTab(clientId)} style={$container()}>
1919
<Text style={[$tab(), active ? $tabActive() : {}]}>{label}</Text>
2020
<Text style={$os()}>{os}</Text>
2121
</Pressable>

app/components/Divider.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { View } from "react-native"
2+
import { themed } from "../theme/theme"
3+
import { ViewStyle, StyleProp } from "react-native"
4+
5+
export function Divider({ extraStyles }: { extraStyles?: StyleProp<ViewStyle> }) {
6+
return <View style={[$divider(), extraStyles]} />
7+
}
8+
9+
const $divider = themed<ViewStyle>(({ colors }) => ({
10+
height: 1,
11+
backgroundColor: colors.border,
12+
width: "100%",
13+
}))

app/components/Icon.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,19 @@ export function Icon(props: IconProps) {
6666
}
6767

6868
export const iconRegistry = {
69-
panelLeftClose: require("../../assets/icons/panelLeftClose.png"),
70-
panelLeftOpen: require("../../assets/icons/panelLeftOpen.png"),
71-
plug: require("../../assets/icons/plug.png"),
72-
scrollText: require("../../assets/icons/scrollText.png"),
7369
chevronsLeftRightEllipsis: require("../../assets/icons/chevronsLeftRightEllipsis.png"),
7470
circleGauge: require("../../assets/icons/circleGauge.png"),
75-
questionMark: require("../../assets/icons/questionMark.png"),
71+
clipboard: require("../../assets/icons/clipboard.png"),
7672
gitHub: require("../../assets/icons/gitHub.png"),
7773
messageSquare: require("../../assets/icons/messageSquare.png"),
74+
panelLeftClose: require("../../assets/icons/panelLeftClose.png"),
75+
panelLeftOpen: require("../../assets/icons/panelLeftOpen.png"),
76+
plug: require("../../assets/icons/plug.png"),
77+
questionMark: require("../../assets/icons/questionMark.png"),
78+
scrollText: require("../../assets/icons/scrollText.png"),
7879
squirrel: require("../../assets/icons/squirrel.png"),
7980
xLogo: require("../../assets/icons/xLogo.png"),
81+
trash: require("../../assets/icons/trash.png"),
8082
}
8183

8284
const $imageStyleBase: ImageStyle = {

app/components/Sidebar/SidebarMenu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Icon } from "../Icon"
66
const MENU_ITEMS = [
77
{ id: "logs", label: "Logs", icon: "scrollText" },
88
{ id: "network", label: "Network", icon: "chevronsLeftRightEllipsis" },
9+
{ id: "state", label: "State", icon: "clipboard" },
910
{ id: "performance", label: "Performance", icon: "circleGauge" },
1011
{ id: "plugins", label: "Plugins", icon: "plug" },
1112
{ id: "help", label: "Help", icon: "questionMark" },

app/components/TimelineToolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type FilterType = "all" | "log" | "display" | "api.request" | "api.respon
44

55
export interface TimelineFilters {
66
types: FilterType[]
7+
clientId: string
78
// logLevel: LogLevel
89
// sortBy: SortBy
910
}

app/screens/HelpScreen.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { View, Text, ViewStyle, TextStyle, Pressable, Linking, ScrollView } from "react-native"
22
import { themed, useThemeName } from "../theme/theme"
33
import { Icon, IconTypes } from "../components/Icon"
4+
import { Divider } from "../components/Divider"
45

56
export function HelpScreen() {
67
return (
78
<ScrollView style={$container()}>
89
<View style={$connectContainer()}>
910
<Text style={$title()}>{"Let's Connect!"}</Text>
10-
<View style={$divider()} />
11+
<Divider extraStyles={$divider()} />
1112
<View style={$connectRow()}>
1213
<ConnectItem
1314
icon="gitHub"
@@ -27,7 +28,7 @@ export function HelpScreen() {
2728
<ConnectItem icon="xLogo" title="@reactotron" url="https://x.com/reactotron" />
2829
</View>
2930
<Text style={$title()}>Keystrokes</Text>
30-
<View style={$divider()} />
31+
<Divider extraStyles={$divider()} />
3132
<View style={$keystrokesContainer()}>
3233
<Text style={$keystrokeSectionTitle()}>Navigation</Text>
3334
<KeystrokeItem title="Toggle Sidebar" keystrokes={["⌘", "b"]} />
@@ -89,10 +90,7 @@ const $title = themed<TextStyle>(({ colors, typography, spacing }) => ({
8990
marginTop: spacing.xl,
9091
}))
9192

92-
const $divider = themed<ViewStyle>(({ colors, spacing }) => ({
93-
height: 1,
94-
backgroundColor: colors.border,
95-
width: "100%",
93+
const $divider = themed<ViewStyle>(({ spacing }) => ({
9694
marginTop: spacing.md,
9795
}))
9896

@@ -140,7 +138,7 @@ const $keystrokeKey = themed<ViewStyle>(({ spacing, colors }) => ({
140138
alignItems: "center",
141139
}))
142140

143-
const $keystroke = themed<TextStyle>(({ colors, spacing }) => ({
141+
const $keystroke = themed<TextStyle>(({ colors }) => ({
144142
fontSize: 16,
145143
fontWeight: "bold",
146144
color: colors.mainText,

0 commit comments

Comments
 (0)