TypeScript
fix(mobile): align iOS segmented controls with action colors (#20721)
Julius Marminge79ad856b4e72
diff --git a/apps/mobile/modules/t3-native-controls/ios/T3SegmentedControlView.swift b/apps/mobile/modules/t3-native-controls/ios/T3SegmentedControlView.swiftindex 9e60a85b7d2..d8d5abaa140 100644--- a/apps/mobile/modules/t3-native-controls/ios/T3SegmentedControlView.swift+++ b/apps/mobile/modules/t3-native-controls/ios/T3SegmentedControlView.swift@@ -15,12 +15,15 @@ final class T3SegmentedControlView: ExpoView {}}var selectedIndex = -1 { didSet { updateSelection() } }- var trackColor: UIColor = .secondarySystemBackground { didSet { control.backgroundColor = trackColor } }- var selectedColor: UIColor = .secondarySystemFill { didSet { control.selectedSegmentTintColor = selectedColor } }- var textColor: UIColor = .label { didSet { updateColors() } }- var mutedColor: UIColor = .secondaryLabel { didSet { updateColors() } }+ var trackColor: UIColor = .secondarySystemBackground { didSet { if trackColor != oldValue { control.backgroundColor = trackColor } } }+ var selectedColor: UIColor = .secondarySystemFill { didSet { if selectedColor != oldValue { control.selectedSegmentTintColor = selectedColor } } }+ var textColor: UIColor = .label { didSet { if textColor != oldValue { updateColors() } } }+ var mutedColor: UIColor = .secondaryLabel { didSet { if mutedColor != oldValue { updateColors() } } }var appearance = "light" {- didSet { overrideUserInterfaceStyle = appearance == "dark" ? .dark : .light }+ didSet {+ guard appearance != oldValue else { return }+ overrideUserInterfaceStyle = appearance == "dark" ? .dark : .light+ }}required init(appContext: AppContext? = nil) {@@ -31,11 +34,20 @@ final class T3SegmentedControlView: ExpoView {override func layoutSubviews() {super.layoutSubviews()- control.frame = bounds+ guard control.frame != bounds else { return }+ UIView.performWithoutAnimation {+ control.frame = bounds+ }}private func updateSelection() {- control.selectedSegmentIndex = labels.indices.contains(selectedIndex) ? selectedIndex : UISegmentedControl.noSegment+ let index = labels.indices.contains(selectedIndex) ? selectedIndex : UISegmentedControl.noSegment+ // React echoes native selections while UIKit is still settling the glass lens.+ guard control.selectedSegmentIndex != index else { return }+ UIView.performWithoutAnimation {+ control.selectedSegmentIndex = index+ control.layoutIfNeeded()+ }}private func updateColors() {diff --git a/apps/mobile/src/components/ui/SegmentedControl.ios.tsx b/apps/mobile/src/components/ui/SegmentedControl.ios.tsxindex d9a75166483..4862e99cdab 100644--- a/apps/mobile/src/components/ui/SegmentedControl.ios.tsx+++ b/apps/mobile/src/components/ui/SegmentedControl.ios.tsx@@ -29,14 +29,14 @@ export function SegmentedControl<Value extends string | number>() {const { colors, colorScheme } = useControlTheme();const trackColor = flattenThemeColor(- themeColorWithAlpha(colors["--color-primary"], colorScheme === "dark" ? 0.18 : 0.07),+ themeColorWithAlpha(colors["--color-prominent-action"], colorScheme === "dark" ? 0.18 : 0.07),colors["--color-screen"],);const selectedColor =- colorScheme === "dark" ? colors["--color-primary"] : colors["--color-secondary"];+ colorScheme === "dark" ? colors["--color-prominent-action"] : colors["--color-secondary"];const selectedTextColor =colorScheme === "dark"- ? colors["--color-primary-foreground"]+ ? colors["--color-prominent-action-foreground"]: colors["--color-secondary-foreground"];return (<View className={props.className}>diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsxindex d2ff0e48205..0d37f43d42d 100644--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx@@ -685,7 +685,6 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP><PullRequestIdentity pr={identity} params={params} /><SegmentedControl- className={Platform.OS === "android" ? undefined : "bg-grouped-card"}options={[{ value: "overview", label: "Overview" },...(guidesEnabled