The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 08:00 UTC
style(mobile): flatten segmented control surfaces (#20163)
Julius Marminge committed
Oct 15, 2026 at 22:41 UTC
09c5e7ac012db4f641ba00c1a73ab2b99468ba3d
1 file changed
+5
-92
apps/mobile/src/components/ui/SegmentedControl.tsx
+5
-92
@@ -1,6 +1,5 @@
1
import { useState } from "react";
2
import { I18nManager, Platform, Pressable, View } from "react-native";
3
-import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
3
import Animated, { useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
4
5
import { AppText } from "./AppText";
@@ -9,13 +8,13 @@ import type { SegmentedControlProps } from "./SegmentedControl.types";
8
9
export type { SegmentedControlProps } from "./SegmentedControl.types";
10
12
-/** Shared capsule control with native press targets and a raised selection. */
11
+/** Shared capsule control with native press targets and a flat, themed selection. */
12
export function SegmentedControl<Value extends string | number>(
13
props: SegmentedControlProps<Value>,
14
) {
15
const { colorScheme, colors } = useControlTheme();
16
const [layout, setLayout] = useState({ width: 0, height: 0 });
18
- const { width, height } = layout;
17
+ const { width } = layout;
18
const reduceMotion = useReducedMotion();
19
const selectedIndex = props.options.findIndex((option) => option.value === props.selected);
20
const segmentWidth = props.options.length ? Math.max(0, width - 6) / props.options.length : 0;
@@ -34,38 +33,20 @@ export function SegmentedControl<Value extends string | number>(
33
className="flex-row rounded-full p-[3px]"
34
style={{
35
minHeight,
37
- boxShadow: dark ? "0px 1px 2px #00000062" : "0px 1px 2px #00000014",
36
+ backgroundColor: colors[dark ? "--color-screen" : "--color-grouped-card"],
37
}}
38
>
40
- <CapsuleSurface
41
- width={width}
42
- height={height}
43
- dark={dark}
44
- fillTop={colors[dark ? "--color-screen" : "--color-grouped-card"]}
45
- fillBottom={colors["--color-card"]}
46
- edgeColor={colors["--color-foreground"]}
47
- />
39
{selectedIndex >= 0 && width > 0 ? (
40
<Animated.View
41
pointerEvents="none"
42
className="absolute bottom-[3px] start-[3px] top-[3px] rounded-full"
43
style={[
44
{
54
- boxShadow: dark ? "0px 1px 2px #00000046" : "0px 2px 3px #00000026",
45
+ backgroundColor: colors[dark ? "--color-secondary" : "--color-screen"],
46
},
47
selectionStyle,
48
]}
58
- >
59
- <CapsuleSurface
60
- width={segmentWidth}
61
- height={height - 6}
62
- dark={dark}
63
- fillTop={colors[dark ? "--color-secondary" : "--color-screen"]}
64
- fillBottom={colors[dark ? "--color-secondary" : "--color-screen"]}
65
- edgeColor={colors["--color-secondary-foreground"]}
66
- selected
67
- />
68
- </Animated.View>
49
+ />
50
) : null}
51
{props.options.map((option) => {
52
const selected = option.value === props.selected;
@@ -96,71 +77,3 @@ export function SegmentedControl<Value extends string | number>(
77
</View>
78
);
79
}
99
-
100
-/** Pen's inset well and raised selection use opposite vertical edge lighting. */
101
-function CapsuleSurface({
102
- width,
103
- height,
104
- dark,
105
- fillTop,
106
- fillBottom,
107
- edgeColor,
108
- selected = false,
109
-}: {
110
- width: number;
111
- height: number;
112
- dark: boolean;
113
- fillTop: string;
114
- fillBottom: string;
115
- edgeColor: string;
116
- selected?: boolean;
117
-}) {
118
- if (width <= 0 || height <= 0) return null;
119
- const edgeOpacity = selected
120
- ? dark
121
- ? [0.22, 0.02]
122
- : [0.13, 0.01]
123
- : dark
124
- ? [0.02, 0.16]
125
- : [0.27, 0.1];
126
- return (
127
- <Svg
128
- pointerEvents="none"
129
- width={width}
130
- height={height}
131
- style={{ position: "absolute", top: 0, left: 0 }}
132
- >
133
- <Defs>
134
- <LinearGradient id="fill" x1="0" y1="0" x2="0%" y2="100%">
135
- <Stop offset="0" stopColor={fillTop} />
136
- <Stop offset="1" stopColor={fillBottom} />
137
- </LinearGradient>
138
- <LinearGradient id="edge" x1="0" y1="0" x2="0%" y2="100%">
139
- <Stop offset="0" stopColor={edgeColor} stopOpacity={edgeOpacity[0]} />
140
- <Stop offset="1" stopColor={edgeColor} stopOpacity={edgeOpacity[1]} />
141
- </LinearGradient>
142
- </Defs>
143
- <Rect
144
- x={0.5}
145
- y={0.5}
146
- width={width - 1}
147
- height={height - 1}
148
- rx={(height - 1) / 2}
149
- fill="url(#fill)"
150
- />
151
- {selected && !dark ? (
152
- <Rect width={width} height={height} rx={height / 2} fill="white" fillOpacity={0.85} />
153
- ) : null}
154
- <Rect
155
- x={0.5}
156
- y={0.5}
157
- width={width - 1}
158
- height={height - 1}
159
- rx={(height - 1) / 2}
160
- fill="none"
161
- stroke="url(#edge)"
162
- strokeWidth={1}
163
- />
164
- </Svg>
165
- );
166
-}