|
| 1 | +import { View, Text, ViewStyle, TextStyle, Pressable, Linking, ScrollView } from "react-native" |
| 2 | +import { themed, useThemeName } from "../theme/theme" |
| 3 | +import { Icon, IconTypes } from "../components/Icon" |
| 4 | + |
| 5 | +export function HelpScreen() { |
| 6 | + return ( |
| 7 | + <ScrollView style={$container()}> |
| 8 | + <View style={$connectContainer()}> |
| 9 | + <Text style={$title()}>{"Let's Connect!"}</Text> |
| 10 | + <View style={$divider()} /> |
| 11 | + <View style={$connectRow()}> |
| 12 | + <ConnectItem |
| 13 | + icon="gitHub" |
| 14 | + title="GitHub Docs" |
| 15 | + url="https://github.com/infinitered/reactotron" |
| 16 | + /> |
| 17 | + <ConnectItem |
| 18 | + icon="messageSquare" |
| 19 | + title="Feedback" |
| 20 | + url="https://github.com/infinitered/reactotron/issues/new/choose" |
| 21 | + /> |
| 22 | + <ConnectItem |
| 23 | + icon="squirrel" |
| 24 | + title="Updates" |
| 25 | + url="https://github.com/infinitered/reactotron/releases" |
| 26 | + /> |
| 27 | + <ConnectItem icon="xLogo" title="@reactotron" url="https://x.com/reactotron" /> |
| 28 | + </View> |
| 29 | + <Text style={$title()}>Keystrokes</Text> |
| 30 | + <View style={$divider()} /> |
| 31 | + <View style={$keystrokesContainer()}> |
| 32 | + <Text style={$keystrokeSectionTitle()}>Navigation</Text> |
| 33 | + <KeystrokeItem title="Toggle Sidebar" keystrokes={["⌘", "b"]} /> |
| 34 | + {__DEV__ ? <KeystrokeItem title="Toggle Dev Menu" keystrokes={["⇧", "⌘", "d"]} /> : null} |
| 35 | + <KeystrokeItem title="Logs Tab" keystrokes={["⌘", "1"]} /> |
| 36 | + <KeystrokeItem title="Network Tab" keystrokes={["⌘", "2"]} /> |
| 37 | + <KeystrokeItem title="Performance Tab" keystrokes={["⌘", "3"]} /> |
| 38 | + <KeystrokeItem title="Plugins Tab" keystrokes={["⌘", "4"]} /> |
| 39 | + <KeystrokeItem title="Help Tab" keystrokes={["⌘", "5"]} /> |
| 40 | + <Text style={$keystrokeSectionTitle()}>Timeline</Text> |
| 41 | + <KeystrokeItem title="Clear Timeline Items" keystrokes={["⌘", "k"]} /> |
| 42 | + </View> |
| 43 | + </View> |
| 44 | + </ScrollView> |
| 45 | + ) |
| 46 | +} |
| 47 | + |
| 48 | +function KeystrokeItem({ title, keystrokes }: { title: string; keystrokes: string[] }) { |
| 49 | + return ( |
| 50 | + <View style={$keystrokeRowContainer()}> |
| 51 | + <View style={$keystrokeKeysContainer()}> |
| 52 | + {keystrokes.map((keystroke, index) => ( |
| 53 | + <View key={`${title}-${keystroke}`} style={$keystrokeContainer()}> |
| 54 | + <View style={$keystrokeKey()}> |
| 55 | + <Text style={$keystroke()}>{keystroke}</Text> |
| 56 | + </View> |
| 57 | + {index !== keystrokes.length - 1 && <Text style={$keystroke()}>+</Text>} |
| 58 | + </View> |
| 59 | + ))} |
| 60 | + </View> |
| 61 | + <Text style={$keystroke()}>{title}</Text> |
| 62 | + </View> |
| 63 | + ) |
| 64 | +} |
| 65 | + |
| 66 | +function ConnectItem({ icon, title, url }: { icon: IconTypes; title: string; url: string }) { |
| 67 | + const [themeName] = useThemeName() |
| 68 | + return ( |
| 69 | + <Pressable style={$connectItem()} onPress={() => Linking.openURL(url)}> |
| 70 | + {/* TODO: Hack to make the icon change color when theme changes */} |
| 71 | + <Icon icon={icon} size={24} key={`${themeName}-icon`} /> |
| 72 | + <Text style={$connectItemTitle()}>{title}</Text> |
| 73 | + </Pressable> |
| 74 | + ) |
| 75 | +} |
| 76 | + |
| 77 | +const $connectItemTitle = themed<TextStyle>(({ colors, spacing }) => ({ |
| 78 | + fontSize: 16, |
| 79 | + fontWeight: "bold", |
| 80 | + color: colors.mainText, |
| 81 | + marginTop: spacing.sm, |
| 82 | +})) |
| 83 | + |
| 84 | +const $title = themed<TextStyle>(({ colors, typography, spacing }) => ({ |
| 85 | + fontSize: 20, |
| 86 | + fontWeight: "bold", |
| 87 | + color: colors.mainText, |
| 88 | + fontFamily: typography.code.normal, |
| 89 | + marginTop: spacing.xl, |
| 90 | +})) |
| 91 | + |
| 92 | +const $divider = themed<ViewStyle>(({ colors, spacing }) => ({ |
| 93 | + height: 1, |
| 94 | + backgroundColor: colors.border, |
| 95 | + width: "100%", |
| 96 | + marginTop: spacing.md, |
| 97 | +})) |
| 98 | + |
| 99 | +const $container = themed<ViewStyle>(({ spacing }) => ({ |
| 100 | + padding: spacing.xl, |
| 101 | + flex: 1, |
| 102 | +})) |
| 103 | + |
| 104 | +const $connectContainer = themed<ViewStyle>(({ spacing }) => ({ |
| 105 | + paddingHorizontal: spacing.xl, |
| 106 | + paddingBottom: spacing.xl, |
| 107 | +})) |
| 108 | + |
| 109 | +const $connectRow = themed<ViewStyle>(({ spacing }) => ({ |
| 110 | + flexDirection: "row", |
| 111 | + justifyContent: "space-between", |
| 112 | + alignItems: "center", |
| 113 | + gap: spacing.md, |
| 114 | + marginTop: spacing.xl, |
| 115 | + flexWrap: "wrap", |
| 116 | +})) |
| 117 | + |
| 118 | +const $connectItem = themed<ViewStyle>(({ spacing, colors }) => ({ |
| 119 | + padding: spacing.xl, |
| 120 | + justifyContent: "center", |
| 121 | + alignItems: "center", |
| 122 | + backgroundColor: colors.cardBackground, |
| 123 | + borderRadius: 8, |
| 124 | + flex: 1, |
| 125 | + minWidth: 160, |
| 126 | +})) |
| 127 | + |
| 128 | +const $keystrokesContainer = themed<ViewStyle>(({ spacing }) => ({ |
| 129 | + justifyContent: "space-between", |
| 130 | + gap: spacing.md, |
| 131 | +})) |
| 132 | + |
| 133 | +const $keystrokeKey = themed<ViewStyle>(({ spacing, colors }) => ({ |
| 134 | + padding: spacing.xs, |
| 135 | + backgroundColor: colors.cardBackground, |
| 136 | + borderRadius: 8, |
| 137 | + width: 40, |
| 138 | + height: 40, |
| 139 | + justifyContent: "center", |
| 140 | + alignItems: "center", |
| 141 | +})) |
| 142 | + |
| 143 | +const $keystroke = themed<TextStyle>(({ colors, spacing }) => ({ |
| 144 | + fontSize: 16, |
| 145 | + fontWeight: "bold", |
| 146 | + color: colors.mainText, |
| 147 | +})) |
| 148 | + |
| 149 | +const $keystrokeContainer = themed<ViewStyle>(({ spacing }) => ({ |
| 150 | + flexDirection: "row", |
| 151 | + alignItems: "center", |
| 152 | + gap: spacing.xs, |
| 153 | +})) |
| 154 | + |
| 155 | +const $keystrokeKeysContainer = themed<ViewStyle>(({ spacing }) => ({ |
| 156 | + flexDirection: "row", |
| 157 | + alignItems: "center", |
| 158 | + gap: spacing.xs, |
| 159 | +})) |
| 160 | + |
| 161 | +const $keystrokeSectionTitle = themed<TextStyle>(({ colors, spacing }) => ({ |
| 162 | + fontSize: 16, |
| 163 | + fontWeight: "bold", |
| 164 | + color: colors.neutral, |
| 165 | + marginTop: spacing.xl, |
| 166 | +})) |
| 167 | + |
| 168 | +const $keystrokeRowContainer = themed<ViewStyle>(({ spacing }) => ({ |
| 169 | + flexDirection: "row", |
| 170 | + justifyContent: "space-between", |
| 171 | + alignItems: "center", |
| 172 | + gap: spacing.md, |
| 173 | + width: 400, |
| 174 | +})) |
0 commit comments