Skip to content

Commit 522f054

Browse files
UI changes (#26)
* get rid of the app header, and integrate the information from it to other places * make clear button only get rid of current clientId stuff * add a cursor pointer for clear button * Update app/screens/TimelineScreen.tsx Co-authored-by: Sean Barker <43788519+SeanBarker182@users.noreply.github.com> Signed-off-by: Steven Conner <steven.c.conner@gmail.com> * remove console log --------- Signed-off-by: Steven Conner <steven.c.conner@gmail.com> Co-authored-by: Sean Barker <43788519+SeanBarker182@users.noreply.github.com>
1 parent 79d0eb7 commit 522f054

File tree

10 files changed

+276
-209
lines changed

10 files changed

+276
-209
lines changed

app/app.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useMenuItem } from "./utils/useMenuItem"
1313
import { Titlebar } from "./components/Titlebar/Titlebar"
1414
import { Sidebar } from "./components/Sidebar/Sidebar"
1515
import { useSidebar } from "./state/useSidebar"
16-
import { AppHeader } from "./components/AppHeader"
1716
import { useGlobal, withGlobal } from "./state/useGlobal"
1817
import { MenuItemId } from "./components/Sidebar/SidebarMenu"
1918
import { HelpScreen } from "./screens/HelpScreen"
@@ -133,10 +132,7 @@ function App(): React.JSX.Element {
133132
<StatusBar barStyle={"dark-content"} backgroundColor={colors.background} />
134133
<View style={$mainContent}>
135134
<Sidebar />
136-
<View style={$contentContainer}>
137-
<AppHeader />
138-
{renderActiveItem()}
139-
</View>
135+
<View style={$contentContainer}>{renderActiveItem()}</View>
140136
</View>
141137
<PortalHost />
142138
</View>

app/components/AppHeader.tsx

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

app/components/ClearLogsButton.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Button } from "react-native"
2-
import { withGlobal } from "../state/useGlobal"
1+
import { Button, StyleProp, View, ViewStyle } from "react-native"
2+
import { useGlobal, withGlobal } from "../state/useGlobal"
33
import type { TimelineItem } from "../types"
44
import { useCallback } from "react"
55
import { useKeyboardEvents } from "../utils/system"
@@ -15,7 +15,18 @@ export function ClearLogsButton() {
1515
const [_timelineItems, setTimelineItems] = withGlobal<TimelineItem[]>("timelineItems", [], {
1616
persist: true,
1717
})
18-
const clearLogs = useCallback(() => setTimelineItems([]), [setTimelineItems])
18+
const [activeClientId] = useGlobal("activeClientId", "")
19+
const clearLogs = useCallback(() => {
20+
setTimelineItems((prev) => prev.filter((item) => item.clientId !== activeClientId))
21+
}, [setTimelineItems])
1922

20-
return <Button onPress={clearLogs} title="Clear" />
23+
return (
24+
<View style={$buttonContainer}>
25+
<Button onPress={clearLogs} title="Clear" />
26+
</View>
27+
)
28+
}
29+
30+
const $buttonContainer: StyleProp<ViewStyle> = {
31+
cursor: "pointer",
2132
}

app/components/ClientTab.tsx

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,61 @@
11
import type { ClientData } from "../types"
22
import { useGlobal } from "../state/useGlobal"
33
import { themed } from "../theme/theme"
4-
import { Pressable, Text, TextStyle, ViewStyle } from "react-native"
4+
import { Pressable, Text, TextStyle, View, ViewStyle } from "react-native"
55

66
const tabgroup = "activeClientId"
77

88
export function ClientTab({ clientId }: { clientId: string }) {
99
const [clientData] = useGlobal<ClientData>(`client-${clientId}`, {} as ClientData)
10-
11-
const label: string = (clientData?.name ?? clientId) + "\n"
12-
const os: string = clientData?.platform ?? "Unknown"
10+
const label: string = clientData?.name ?? clientId
11+
const platformVersion: string = clientData?.platformVersion ?? ""
1312

1413
const [activeTab, setActiveTab] = useGlobal(tabgroup, label, { persist: true })
1514
const active = activeTab === clientId
1615

16+
const getOsLabel = (os: string) => {
17+
switch (os) {
18+
case "ios":
19+
return "iOS"
20+
case "android":
21+
return "Android"
22+
default:
23+
return "Unknown OS"
24+
}
25+
}
26+
1727
return (
18-
<Pressable key={clientId} onPress={() => setActiveTab(clientId)} style={$container()}>
19-
<Text style={[$tab(), active ? $tabActive() : {}]}>{label}</Text>
20-
<Text style={$os()}>{os}</Text>
21-
</Pressable>
28+
<View style={[$container(), active && $containerActive()]}>
29+
<Pressable key={clientId} onPress={() => setActiveTab(clientId)}>
30+
<Text numberOfLines={2} style={[$tab(), active && $tabActive()]}>
31+
{`${label} - ${getOsLabel(clientData?.platform)} ${platformVersion}`}
32+
</Text>
33+
</Pressable>
34+
</View>
2235
)
2336
}
2437

38+
const $containerActive = themed<ViewStyle>(({ colors }) => ({
39+
backgroundColor: colors.cardBackground,
40+
}))
41+
2542
const $container = themed<ViewStyle>(({ spacing }) => ({
26-
flexDirection: "column",
27-
alignItems: "flex-start",
2843
gap: spacing.xxs,
2944
cursor: "pointer",
45+
borderTopLeftRadius: 8,
46+
borderTopRightRadius: 8,
47+
height: 32,
48+
alignItems: "center",
49+
justifyContent: "center",
50+
paddingHorizontal: spacing.xl,
3051
}))
3152

32-
const $tab = themed<TextStyle>(({ spacing, colors }) => ({
33-
fontSize: spacing.md,
34-
color: colors.mainText,
35-
}))
36-
37-
const $tabActive = themed<TextStyle>(({ colors }) => ({
38-
borderBottomColor: colors.primary,
39-
color: colors.mainText,
40-
textDecorationLine: "underline",
53+
const $tabActive = themed<TextStyle>(() => ({
54+
fontWeight: "600",
4155
}))
4256

43-
const $os = themed<TextStyle>(({ colors }) => ({
44-
fontSize: 12,
57+
const $tab = themed<TextStyle>(({ colors }) => ({
58+
fontSize: 14,
4559
color: colors.mainText,
60+
textAlign: "center",
4661
}))

app/components/Sidebar/Sidebar.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { Animated, View, ViewStyle, StyleSheet } from "react-native"
1+
import { Animated, View, ViewStyle, StyleSheet, Pressable } from "react-native"
22
import { themed } from "../../theme/theme"
33
import { AnimatedReactotronLogo } from "./AnimatedReactotronLogo"
44
import { useSidebarAnimationProgress } from "./useSidebarAnimationProgress"
55
import { SidebarMenu } from "./SidebarMenu"
6+
import { Tooltip } from "../Tooltip"
7+
import { getReactotronAppId } from "../../state/connectToServer"
68

79
// Expanded sidebar width in px
810
const EXPANDED_WIDTH = 250
@@ -12,17 +14,23 @@ const COLLAPSED_WIDTH = 60
1214

1315
export const Sidebar = () => {
1416
const { progress, mounted } = useSidebarAnimationProgress()
17+
const reactotronAppId = getReactotronAppId()
1518

1619
const animatedWidth = progress.interpolate({
1720
inputRange: [0, 1],
1821
outputRange: [COLLAPSED_WIDTH, EXPANDED_WIDTH],
1922
})
23+
console.log("progress", progress)
2024

2125
return (
2226
<Animated.View style={[{ width: animatedWidth }, $overflowHidden]}>
2327
<View style={$container()}>
2428
<View style={$content()}>
25-
<AnimatedReactotronLogo progress={progress} mounted={mounted} />
29+
<Tooltip label={`Reactotron ID: ${reactotronAppId}`}>
30+
<Pressable disabled={true}>
31+
<AnimatedReactotronLogo progress={progress} mounted={mounted} />
32+
</Pressable>
33+
</Tooltip>
2634
<SidebarMenu progress={progress} mounted={mounted} collapsedWidth={COLLAPSED_WIDTH} />
2735
</View>
2836
</View>
@@ -48,4 +56,7 @@ const $container = themed<ViewStyle>((theme) => ({
4856
const $content = themed<ViewStyle>((theme) => ({
4957
flex: 1,
5058
padding: theme.spacing.sm,
59+
flexDirection: "column",
60+
justifyContent: "space-between",
61+
height: "100%",
5162
}))

0 commit comments

Comments
 (0)