design(mobile): unify Android Material layouts and native controls (#11841)

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
AlexandJulius Marminge authored and GitHub committed 2026-09-16 17:25:37 -07:00
1 parent 394af73e02
commit e106fe95cc
128 files changed
+5820 -2833

No files matched your search

@@ -8,6 +8,7 @@ import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Typeface
import android.os.Build
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.Spanned
@@ -164,6 +165,17 @@ private class SanitizingSelectionActionModeCallback(
}
}
internal fun applySelectionHandleColor(textView: TextView, color: Int) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return
textView.textSelectHandle?.mutate()?.apply { setTint(color) }?.let(textView::setTextSelectHandle)
textView.textSelectHandleLeft?.mutate()?.apply {
setTint(color)
}?.let(textView::setTextSelectHandleLeft)
textView.textSelectHandleRight?.mutate()?.apply {
setTint(color)
}?.let(textView::setTextSelectHandleRight)
}
class T3MarkdownTextSelectionModule : Module() {
private val chipImages = LruCache<String, Map<String, Any>>(128)
@@ -183,9 +195,23 @@ class T3MarkdownTextSelectionModule : Module() {
}
}.fontMetricsInt
private fun setSelectionHandleColor(reactTag: Int, color: Int) {
val reactContext = appContext.reactContext as? ReactContext ?: return
reactContext.runOnUiQueueThread {
val textView = runCatching {
UIManagerHelper.getUIManagerForReactTag(reactContext, reactTag)?.resolveView(reactTag)
}.getOrNull() as? TextView ?: return@runOnUiQueueThread
applySelectionHandleColor(textView, color)
}
}
override fun definition() = ModuleDefinition {
Name("T3MarkdownTextSelection")
Function("setSelectionHandleColor") { reactTag: Int, color: Int ->
setSelectionHandleColor(reactTag, color)
}
Function("renderContextChip") { payloadJson: String ->
val resources = appContext.reactContext?.resources ?: return@Function null
val metrics = resources.displayMetrics
@@ -0,0 +1,67 @@
package expo.modules.t3markdowntext
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.widget.TextView
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [36], manifest = Config.NONE)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class MarkdownSelectionColorTest {
private fun textView() = TextView(RuntimeEnvironment.getApplication()).apply {
setTextSelectHandle(ColorDrawable(Color.WHITE))
setTextSelectHandleLeft(ColorDrawable(Color.WHITE))
setTextSelectHandleRight(ColorDrawable(Color.WHITE))
}
private fun renderedColor(drawable: Drawable?): Int {
requireNotNull(drawable)
val bitmap = Bitmap.createBitmap(4, 4, Bitmap.Config.ARGB_8888)
drawable.setBounds(0, 0, 4, 4)
drawable.draw(Canvas(bitmap))
val color = bitmap.getPixel(2, 2)
bitmap.recycle()
return color
}
@Test
fun retintsAllHandlesWhenTheThemeChangesWithoutChangingTheHighlight() {
val text = textView()
val highlight = 0x52FF0088
text.highlightColor = highlight
for (color in listOf(Color.MAGENTA, Color.GREEN, Color.MAGENTA)) {
applySelectionHandleColor(text, color)
assertEquals(color, renderedColor(text.textSelectHandle))
assertEquals(color, renderedColor(text.textSelectHandleLeft))
assertEquals(color, renderedColor(text.textSelectHandleRight))
assertEquals(highlight, text.highlightColor)
}
}
@Test
fun doesNotTintOtherTextViewsSharingDrawableState() {
val original = ColorDrawable(Color.WHITE)
val first = textView().apply {
setTextSelectHandleLeft(original.constantState!!.newDrawable())
}
val second = textView().apply {
setTextSelectHandleLeft(original.constantState!!.newDrawable())
}
applySelectionHandleColor(first, Color.MAGENTA)
assertEquals(Color.MAGENTA, renderedColor(first.textSelectHandleLeft))
assertEquals(Color.WHITE, renderedColor(second.textSelectHandleLeft))
}
}
@@ -1,5 +1,15 @@
import React, { type Ref } from "react";
import { Platform, StyleSheet, Text as RNText, type TextProps, type ViewStyle } from "react-native";
import {
findNodeHandle,
Platform,
processColor,
StyleSheet,
Text as RNText,
type ColorValue,
type TextProps,
type ViewStyle,
} from "react-native";
import { setMarkdownSelectionHandleColor } from "./T3MarkdownTextSelectionModule";
import T3MarkdownTextRunNativeComponent from "./T3MarkdownTextRunNativeComponent";
import T3MarkdownTextNativeComponent from "./T3MarkdownTextNativeComponent";
import { flattenStyles } from "./util";
@@ -34,6 +44,7 @@ export type ContextMenuActionEvent = {
*/
export type MarkdownTextPrimitiveProps = Omit<TextProps, "onTextLayout"> & {
nativeTextRef?: Ref<RNText>;
selectionHandleColor?: ColorValue;
uiTextView?: boolean;
contextMenuConfig?: string;
contextClipboardConfig?: string;
@@ -116,7 +127,45 @@ function MarkdownTextPrimitiveInner({ nativeTextRef, ...props }: MarkdownTextPri
return <MarkdownTextPrimitiveChild {...props} />;
}
export function MarkdownTextPrimitive(props: MarkdownTextPrimitiveProps) {
function AndroidMarkdownText({
nativeTextRef,
selectionHandleColor,
onLayout,
contextClipboardConfig: _contextClipboardConfig,
...props
}: MarkdownTextPrimitiveProps) {
const textRef = React.useRef<RNText | null>(null);
React.useImperativeHandle<RNText | null, RNText | null>(nativeTextRef, () => textRef.current, []);
const color = processColor(selectionHandleColor);
const applyHandleColor = React.useCallback(() => {
if (!textRef.current || typeof color !== "number") return;
const reactTag = findNodeHandle(textRef.current);
if (reactTag !== null) setMarkdownSelectionHandleColor(reactTag, color);
}, [color]);
// RN's selectionColor only sets the highlight. Retint mounted handles when
// the theme changes, and after layout when the native view first exists.
React.useEffect(applyHandleColor, [applyHandleColor]);
return (
<RNText
ref={textRef}
{...props}
onLayout={(event) => {
applyHandleColor();
onLayout?.(event);
}}
/>
);
}
export function MarkdownTextPrimitive({
selectionHandleColor,
...props
}: MarkdownTextPrimitiveProps) {
if (Platform.OS === "android" && selectionHandleColor !== undefined) {
return <AndroidMarkdownText {...props} selectionHandleColor={selectionHandleColor} />;
}
if (Platform.OS !== "ios") {
const { nativeTextRef, contextClipboardConfig: _contextClipboardConfig, ...textProps } = props;
return <RNText ref={nativeTextRef} {...textProps} />;
@@ -133,7 +133,13 @@ function HighlightedCodeText(props: {
}
}
return (
<MarkdownTextPrimitive uiTextView selectable style={style}>
<MarkdownTextPrimitive
uiTextView
selectable
selectionColor={props.textStyle.selectionColor}
selectionHandleColor={props.textStyle.selectionHandleColor}
style={style}
>
{props.highlighted ? lines : props.content}
</MarkdownTextPrimitive>
);
@@ -174,8 +180,10 @@ function NativeCodeBlock(props: {
justifyContent: "space-between",
}}
>
<Text
<MarkdownTextPrimitive
selectable
selectionColor={props.textStyle.selectionColor}
selectionHandleColor={props.textStyle.selectionHandleColor}
style={{
flex: 1,
color: props.textStyle.mutedColor,
@@ -184,7 +192,7 @@ function NativeCodeBlock(props: {
}}
>
{languageLabel}
</Text>
</MarkdownTextPrimitive>
<CopyTextButton
accessibilityLabel={`Copy ${languageLabel.toLowerCase()} code`}
text={content}
@@ -332,8 +340,10 @@ function NativeMarkdownImage(props: {
}}
/>
{props.node.alt ? (
<Text
<MarkdownTextPrimitive
selectable
selectionColor={props.textStyle.selectionColor}
selectionHandleColor={props.textStyle.selectionHandleColor}
style={{
color: props.textStyle.mutedColor,
fontFamily: props.textStyle.fontFamily,
@@ -342,7 +352,7 @@ function NativeMarkdownImage(props: {
}}
>
{props.node.alt}
</Text>
</MarkdownTextPrimitive>
) : null}
</View>
);
@@ -338,6 +338,8 @@ export function NativeMarkdownSelectableText(props: {
}
uiTextView
selectable
selectionColor={props.textStyle.selectionColor}
selectionHandleColor={props.textStyle.selectionHandleColor}
style={{
flexShrink: 1,
minWidth: 0,
@@ -1,4 +1,6 @@
export interface NativeMarkdownTextStyle {
readonly selectionColor?: string;
readonly selectionHandleColor?: string;
readonly color: string;
readonly strongColor: string;
readonly mutedColor: string;
@@ -1,6 +1,7 @@
import { requireOptionalNativeModule } from "expo";
interface T3MarkdownTextSelectionNativeModule {
readonly setSelectionHandleColor?: (reactTag: number, color: number) => void;
readonly installCopySanitizer: (reactTag: number, contextClipboardConfig: string) => void;
readonly renderContextChip?: (payloadJson: string) => {
readonly uri: string;
@@ -20,6 +21,10 @@ export function installMarkdownCopySanitizer(reactTag: number, contextClipboardC
nativeModule?.installCopySanitizer(reactTag, contextClipboardConfig);
}
export function setMarkdownSelectionHandleColor(reactTag: number, color: number): void {
nativeModule?.setSelectionHandleColor?.(reactTag, color);
}
export function renderAndroidContextChip(payloadJson: string) {
return nativeModule?.renderContextChip?.(payloadJson) ?? null;
}
@@ -1,6 +1,7 @@
package expo.modules.t3nativecontrols
import android.content.Intent
import android.text.format.DateFormat
import androidx.core.content.FileProvider
import expo.modules.kotlin.Promise
import expo.modules.kotlin.modules.Module
@@ -15,6 +16,11 @@ class T3NativeControlsModule : Module() {
override fun definition() = ModuleDefinition {
Name("T3NativeControls")
Function("is24HourFormat") {
val context = appContext.reactContext ?: error("The app is not active.")
DateFormat.is24HourFormat(context)
}
AsyncFunction("openFile") { uri: String, mimeType: String, promise: Promise ->
check(filePreviewPromise == null) { "A document viewer is already open." }
val activity = appContext.currentActivity ?: error("The app is not active.")
+3 -7
View File
@@ -1,8 +1,7 @@
import { BlurTargetView } from "expo-blur";
import * as Linking from "expo-linking";
import * as SplashScreen from "expo-splash-screen";
import { useEffect } from "react";
import { StatusBar } from "react-native";
import { StatusBar, View } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { KeyboardProvider } from "react-native-keyboard-controller";
import { SafeAreaProvider } from "react-native-safe-area-context";
@@ -21,10 +20,8 @@ import {
import { RootStack } from "./Stack";
import { appAtomRegistry } from "./state/atom-registry";
import { OverlayPortalHost } from "./components/OverlayPortal";
import { appBlurTargetRef } from "./lib/appBlurTarget";
import { shouldHandleAppLink } from "./lib/appLinking";
import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
import "../global.css";
@@ -88,14 +85,13 @@ function AppContent() {
this, React Navigation defaults to its light theme and every native
header (glass buttons, title, materials) is forced light even when
the system is in dark mode. */}
{/* Blur target for Android dropdown backdrops — see appBlurTarget.ts. */}
<BlurTargetView ref={appBlurTargetRef} style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<IncomingShareProvider>
<Navigation linking={appLinking} theme={navigationTheme} />
</IncomingShareProvider>
<ConfirmDialogHost />
<ThreadArrangementHost />
</BlurTargetView>
</View>
{/* Anchored-menu overlays render here — in-window, so the
keyboard stays up while a dropdown is open. */}
<OverlayPortalHost />
@@ -6,12 +6,8 @@ import { BackHandler, Pressable, ScrollView, View } from "react-native";
import { useKeyboardState } from "react-native-keyboard-controller";
import Animated, { FadeIn } from "react-native-reanimated";
import { appBlurTargetRef } from "../lib/appBlurTarget";
import { cn } from "../lib/cn";
import { type AppSymbolName, SymbolView } from "./AppSymbol";
import { AppText as Text } from "./AppText";
import { OverlayPortal } from "./OverlayPortal";
import { GlassBackdrop } from "./GlassBackdrop";
import { MaterialMenuPopup } from "./MaterialMenuPopup";
const MENU_WIDTH = 250;
const SCREEN_MARGIN = 12;
@@ -27,6 +23,7 @@ type AnchorSnapshot = {
readonly y: number;
readonly width: number;
readonly height: number;
readonly keyboardWasVisible: boolean;
};
type OverlayFrame = {
@@ -53,13 +50,9 @@ export type AndroidAnchoredMenuProps = {
};
/**
* Token-styled anchored dropdown for Android, drop-in for the subset of the
* MenuView contract the app uses (actions with state/subtitle/image/
* attributes, one level of subactions). The native AppCompat PopupMenu caps
* out on theming — stock animation, item metrics, and submenu chrome — so
* ControlPillMenu renders this instead on Android while iOS keeps the native
* UIMenu. Styling follows the themed native popup (12dp radius, plain rows,
* trailing check glyph); submenus drill in under a muted parent-title header.
* Adapts the app's MenuView actions to Material dropdowns on Android. Editor
* menus render native Material rows in-window to retain keyboard focus; other
* menus use the native popup for placement, animation and dismissal.
*/
export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
const [anchor, setAnchor] = useState<AnchorSnapshot | null>(null);
@@ -89,9 +82,9 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
const open = useCallback(() => {
anchorRef.current?.measureInWindow((x, y, width, height) => {
setAnchor({ x, y, width, height });
setAnchor({ x, y, width, height, keyboardWasVisible: keyboardVisible });
});
}, []);
}, [keyboardVisible]);
const measureOverlay = useCallback(() => {
overlayRef.current?.measureInWindow((x, y, width, height) => {
@@ -100,18 +93,11 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
});
}, []);
// The dropdown renders in-window (no Modal takes focus), so the hardware
// back gesture needs explicit handling while it is open. Back steps out of
// a drilled-in submenu one level at a time (mirroring the tappable parent
// header) before closing the menu. Under predictive back
// (enableOnBackInvokedCallback) this stays correct: back reaches JS
// through always-registered OnBackPressedDispatcher callbacks (react-native
// core on Android 16+, withAndroidPredictiveBackCompat on 13-15), which
// also keeps the system from playing a "leave app" preview while the menu
// merely closes.
// The native popup owns back dismissal. In-window menus need a handler;
// back returns to the parent submenu before closing the overlay.
const submenuDepth = path.length;
useEffect(() => {
if (anchor === null) {
if (anchor === null || !anchor.keyboardWasVisible) {
return;
}
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
@@ -212,10 +198,20 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
onLayout={measureOverlay}
>
<Pressable accessible={false} className="absolute inset-0" onPress={close} />
{!placeable || local === null ? null : (
{!placeable || local === null ? null : !anchor.keyboardWasVisible ? (
<MaterialMenuPopup
anchor={local}
actions={levelActions}
title={props.title}
parent={parent}
onPress={onPressItem}
onBack={() => setPath((current) => current.slice(0, -1))}
onClose={close}
/>
) : (
<Animated.View
entering={FadeIn.duration(120)}
className="absolute w-[250px] overflow-hidden rounded-[12px] border border-border shadow-2xl"
className="absolute w-[250px] overflow-hidden rounded-[4px] bg-card-alt shadow-md"
style={{
left,
maxHeight,
@@ -224,93 +220,28 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
: { bottom: (rootHeight ?? 0) - local.y + ANCHOR_GAP }),
}}
>
<GlassBackdrop blurTarget={appBlurTargetRef} />
{/* Compose DropdownMenu takes popup focus in the pinned Expo UI version.
Keep editor menus in-window so opening one preserves the keyboard. */}
{/* keyboardShouldPersistTaps: the menu often opens over an
active editor; the first item tap must act, not just
dismiss the keyboard. */}
<ScrollView
contentContainerClassName="py-2"
bounces={false}
keyboardShouldPersistTaps="always"
showsVerticalScrollIndicator={false}
>
{parent !== null ? (
// Muted parent title as the submenu header; tapping it
// steps back, but it reads as a label, not a button.
<Pressable
className="px-3.5 pb-1 pt-2.5"
onPress={() => setPath((current) => current.slice(0, -1))}
>
<Text className="text-xs font-t3-bold text-foreground-muted">
{parent.title}
</Text>
</Pressable>
) : props.title ? (
<>
<View className="px-3.5 py-2">
<Text className="text-center text-xs text-foreground-muted">
{props.title}
</Text>
</View>
<View className="h-px bg-border" />
</>
) : null}
{levelActions.map((action, index) => {
const destructive = action.attributes?.destructive ?? false;
const disabled = action.attributes?.disabled ?? false;
const hasSubmenu = (action.subactions?.length ?? 0) > 0;
return (
<Pressable
key={action.id ?? `${index}-${action.title}`}
disabled={disabled}
className={cn(
"min-h-11 flex-row items-center gap-2.5 px-3.5 py-2.5 active:bg-subtle",
disabled && "opacity-45",
)}
onPress={() => onPressItem(action)}
>
<View className="flex-1 gap-0.5">
<Text
className={cn(
// Same face as the pill labels that open these menus.
"text-sm font-t3-bold",
destructive && "text-danger-foreground",
)}
>
{action.title}
</Text>
{action.subtitle ? (
<Text className="text-xs leading-snug text-foreground-muted">
{action.subtitle}
</Text>
) : null}
</View>
{hasSubmenu ? (
<SymbolView
name="chevron.right"
size={13}
tintColorClassName={"accent-icon-subtle"}
type="monochrome"
/>
) : action.state === "on" ? (
<SymbolView
name="checkmark"
size={15}
tintColorClassName={"accent-icon"}
type="monochrome"
/>
) : action.image ? (
<SymbolView
name={action.image as AppSymbolName}
size={15}
tintColorClassName={
destructive ? "accent-danger-foreground" : "accent-icon"
}
type="monochrome"
/>
) : null}
</Pressable>
);
})}
<MaterialMenuPopup
inline
anchor={local}
actions={levelActions}
title={props.title}
parent={parent}
onPress={onPressItem}
onBack={() => setPath((current) => current.slice(0, -1))}
onClose={close}
/>
</ScrollView>
</Animated.View>
)}
@@ -1,16 +1,21 @@
import type { ReactNode } from "react";
import { Pressable, View } from "react-native";
import { useState, type ReactNode } from "react";
import { View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
import type { AppSymbolName } from "./AppSymbol";
import { AppText as Text } from "./AppText";
import { cn } from "../lib/cn";
import { MaterialIconButton } from "./MaterialIconButton";
import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import { useMaterialToolbarHeight } from "./useMaterialToolbarHeight";
export interface AndroidHeaderAction {
readonly accessibilityLabel: string;
readonly icon: AppSymbolName;
readonly onPress: () => void;
readonly disabled?: boolean;
readonly selected?: boolean;
}
export function AndroidHeaderIconButton(props: {
@@ -18,73 +23,62 @@ export function AndroidHeaderIconButton(props: {
readonly icon: AppSymbolName;
readonly onPress?: () => void;
readonly disabled?: boolean;
readonly selected?: boolean;
}) {
return (
<Pressable
accessibilityLabel={props.accessibilityLabel}
accessibilityRole="button"
disabled={props.disabled}
hitSlop={8}
onPress={props.onPress}
className={cn(
"size-11 items-center justify-center rounded-full bg-subtle",
props.disabled && "opacity-55",
)}
>
<SymbolView
name={props.icon}
size={20}
tintColorClassName={props.disabled ? "accent-icon-subtle" : "accent-foreground"}
type="monochrome"
/>
</Pressable>
);
return <MaterialIconButton {...props} variant={props.selected ? "tonal" : "standard"} />;
}
export function AndroidScreenHeader(props: {
readonly title: string;
readonly subtitle?: string | null;
readonly actions?: ReadonlyArray<AndroidHeaderAction>;
readonly leading?: ReactNode;
readonly trailing?: ReactNode;
readonly onBack?: () => void;
readonly embedded?: boolean;
readonly hideBottomBorder?: boolean;
}) {
const insets = useSafeAreaInsets();
const titleTypography = useScaledTextRole("title");
const subtitleTypography = useScaledTextRole("label");
const materialToolbarHeight = useMaterialToolbarHeight();
const [headerWidth, setHeaderWidth] = useState(0);
const actions = props.actions ?? [];
const directCount = actions.length > 2 ? (headerWidth >= 600 ? 3 : 1) : actions.length;
const visibleActions = actions.slice(0, directCount);
const overflowActions = actions.slice(directCount);
return (
<View
className="border-b border-header-border bg-header px-3 pb-2.5"
onLayout={(event) => setHeaderWidth(event.nativeEvent.layout.width)}
className="border-b border-header-border bg-header px-2 pb-2"
style={{
paddingTop: props.embedded ? 8 : Math.max(insets.top, 12),
borderBottomWidth: props.hideBottomBorder ? 0 : undefined,
}}
>
<View className="min-h-12 flex-row items-center gap-2">
<View
style={{ minHeight: materialToolbarHeight }}
className="min-h-14 flex-row items-center gap-1"
>
{props.onBack ? (
<Pressable
<MaterialIconButton
accessibilityLabel="Navigate up"
accessibilityRole="button"
hitSlop={8}
icon="arrow.left"
onPress={props.onBack}
className="-mr-2 size-11 items-center justify-center"
>
<SymbolView
name="chevron.left"
size={24}
tintColorClassName={"accent-foreground"}
type="monochrome"
/>
</Pressable>
/>
) : null}
{props.leading}
<View className={cn("min-w-0 flex-1", !props.onBack && "pl-1")}>
<Text numberOfLines={1} className="text-lg font-t3-bold text-foreground">
<Text numberOfLines={1} style={titleTypography} className="text-foreground">
{props.title}
</Text>
{props.subtitle ? (
<Text
numberOfLines={1}
style={subtitleTypography}
className="mt-px text-[13px] font-t3-medium text-foreground-muted"
>
{props.subtitle}
@@ -92,15 +86,39 @@ export function AndroidScreenHeader(props: {
) : null}
</View>
{props.actions?.map((action) => (
{visibleActions.map((action) => (
<AndroidHeaderIconButton
key={action.accessibilityLabel}
accessibilityLabel={action.accessibilityLabel}
disabled={action.disabled}
selected={action.selected}
icon={action.icon}
onPress={action.onPress}
/>
))}
{overflowActions.length > 0 ? (
<AndroidAnchoredMenu
actions={overflowActions.map((action, index) => ({
id: String(index),
title: action.accessibilityLabel,
attributes: {
disabled: Boolean(action.disabled),
state: action.selected ? "on" : undefined,
},
}))}
onPressAction={({ nativeEvent }) =>
overflowActions[Number(nativeEvent.event)]?.onPress()
}
>
{(open) => (
<MaterialIconButton
accessibilityLabel="More actions"
icon="ellipsis"
onPress={open}
/>
)}
</AndroidAnchoredMenu>
) : null}
{props.trailing}
</View>
</View>
+9
View File
@@ -9,6 +9,7 @@ import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
import IconApps from "@tabler/icons-react-native/IconApps";
import IconArchive from "@tabler/icons-react-native/IconArchive";
import IconArrowBackUp from "@tabler/icons-react-native/IconArrowBackUp";
import IconArrowLeft from "@tabler/icons-react-native/IconArrowLeft";
import IconArrowDownCircle from "@tabler/icons-react-native/IconArrowDownCircle";
import IconArrowRightCircle from "@tabler/icons-react-native/IconArrowRightCircle";
import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
@@ -36,8 +37,10 @@ import IconClock from "@tabler/icons-react-native/IconClock";
import IconCode from "@tabler/icons-react-native/IconCode";
import IconCopy from "@tabler/icons-react-native/IconCopy";
import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
import IconDatabase from "@tabler/icons-react-native/IconDatabase";
import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
import IconDots from "@tabler/icons-react-native/IconDots";
import IconDotsVertical from "@tabler/icons-react-native/IconDotsVertical";
import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
import IconEdit from "@tabler/icons-react-native/IconEdit";
import IconExternalLink from "@tabler/icons-react-native/IconExternalLink";
@@ -97,6 +100,7 @@ import { withUniwind } from "uniwind";
const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
"arrow.branch": IconGitBranch,
"arrow.left": IconArrowLeft,
"arrow.clockwise": IconRefresh,
"arrow.down.circle": IconArrowDownCircle,
"arrow.right.circle": IconArrowRightCircle,
@@ -142,7 +146,10 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
"folder.badge.plus": IconFolderPlus,
"folder.fill": IconFolder,
gearshape: IconSettings,
hammer: IconHammer,
"info.circle": IconInfoCircle,
internaldrive: IconDatabase,
keyboard: IconKeyboard,
laptopcomputer: IconDeviceLaptop,
link: IconLink,
"line.3.horizontal": IconMenu2,
@@ -160,6 +167,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
"pin.slash": IconPinnedOff,
play: IconPlayerPlay,
plus: IconPlus,
minus: IconMinus,
"qrcode.viewfinder": IconQrcode,
"point.3.connected.trianglepath.dotted": IconNetwork,
"point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
@@ -209,6 +217,7 @@ const ANDROID_ICON_BY_MATERIAL_NAME: Record<string, Icon> = {
keyboard_arrow_down: IconChevronDown,
keyboard_arrow_up: IconChevronUp,
keyboard_hide: IconKeyboardHide,
more_vert: IconDotsVertical,
public: IconWorld,
remove: IconMinus,
terminal: IconTerminal2,
+15 -3
View File
@@ -1,4 +1,5 @@
import {
Platform,
Text as RNText,
TextInput as RNTextInput,
type TextInputProps as RNTextInputProps,
@@ -14,7 +15,13 @@ export type AppTextProps = RNTextProps & { readonly className?: string };
* Uses Uniwind className — no manual style parsing.
*/
export function AppText({ className, ...props }: AppTextProps) {
return <RNText className={cn("font-sans text-foreground", className)} {...props} />;
return (
<RNText
className={cn("font-sans text-foreground", className)}
selectionColorClassName={Platform.OS === "android" ? "accent-primary/32" : undefined}
{...props}
/>
);
}
export type AppTextInputProps = Omit<RNTextInputProps, "placeholderTextColor"> & {
@@ -35,8 +42,13 @@ export function AppTextInput({ className, ref, ...props }: AppTextInputProps) {
className,
)}
placeholderTextColorClassName="accent-placeholder"
selectionColorClassName="accent-foreground-secondary"
cursorColorClassName="accent-foreground-secondary"
selectionColorClassName={
Platform.OS === "android" ? "accent-primary/32" : "accent-foreground-secondary"
}
cursorColorClassName={
Platform.OS === "android" ? "accent-primary" : "accent-foreground-secondary"
}
selectionHandleColorClassName={Platform.OS === "android" ? "accent-primary" : undefined}
{...props}
/>
);
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useState } from "react";
import { Modal, Pressable, TextInput, View } from "react-native";
import { Platform, Modal, Pressable, TextInput, View } from "react-native";
import { cn } from "../lib/cn";
import { AppText } from "./AppText";
import { MaterialConfirmDialog } from "./MaterialConfirmDialog";
export type ConfirmDialogRequest = {
readonly title: string;
@@ -67,17 +68,35 @@ export function ConfirmDialogHost() {
setPresented(null);
}, [presented]);
const handleConfirm = useCallback(() => {
if (presented?.kind === "confirm") {
presented.request.onConfirm();
} else if (presented?.kind === "text-input") {
presented.request.onConfirm(inputValue);
}
setPresented(null);
}, [inputValue, presented]);
const handleConfirm = useCallback(
(nativeInputValue?: string) => {
if (presented?.kind === "confirm") {
presented.request.onConfirm();
} else if (presented?.kind === "text-input") {
presented.request.onConfirm(nativeInputValue ?? inputValue);
}
setPresented(null);
},
[inputValue, presented],
);
const confirmDisabled = presented?.kind === "text-input" && inputValue.trim().length === 0;
if (Platform.OS === "android")
return presented ? (
<MaterialConfirmDialog
key={`${presented.kind}:${presented.request.title}:${presented.kind === "text-input" ? presented.request.initialValue : ""}`}
request={presented.request}
inputInitialValue={
presented.kind === "text-input" ? presented.request.initialValue : undefined
}
onInputChange={setInputValue}
confirmDisabled={confirmDisabled}
onCancel={handleCancel}
onConfirm={handleConfirm}
/>
) : null;
return (
<Modal
visible={presented !== null}
@@ -102,7 +121,7 @@ export function ConfirmDialogHost() {
autoFocus
className="mt-4 rounded-xl border border-border bg-screen px-3 py-2.5 text-base text-foreground"
onChangeText={setInputValue}
onSubmitEditing={confirmDisabled ? undefined : handleConfirm}
onSubmitEditing={confirmDisabled ? undefined : () => handleConfirm()}
returnKeyType="done"
selectTextOnFocus
value={inputValue}
@@ -125,7 +144,7 @@ export function ConfirmDialogHost() {
accessibilityRole="button"
disabled={confirmDisabled}
className="min-h-10 items-center justify-center px-4 active:bg-subtle"
onPress={handleConfirm}
onPress={() => handleConfirm()}
>
<AppText
className={cn(
+45 -5
View File
@@ -19,12 +19,13 @@ import {
} from "react-native";
import { withUniwind } from "uniwind";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { cn } from "../lib/cn";
import { withMenuActionIconColors } from "../lib/menu-action-colors";
import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
import { SymbolView } from "./AppSymbol";
import { AppText as Text } from "./AppText";
import { MaterialIconButton } from "./MaterialIconButton";
import { MaterialButton } from "./MaterialButton";
const ThemedMenuView = withUniwind(
function NativeMenuView({
@@ -121,6 +122,47 @@ export function ControlPill(props: {
: "",
);
if (
Platform.OS === "android" &&
(variant === "pill" || variant === "primary") &&
props.label &&
props.onPress &&
!props.icon &&
!props.iconNode &&
!props.className &&
!props.activateOnPressIn &&
(!props.accessibilityLabel || props.accessibilityLabel === props.label)
) {
return (
<MaterialButton
label={props.label}
onPress={props.onPress}
disabled={props.disabled}
tone={variant === "primary" ? "primary" : "secondary"}
/>
);
}
if (
Platform.OS === "android" &&
props.accessibilityLabel &&
props.icon &&
!props.iconNode &&
!props.label &&
!props.className &&
!props.activateOnPressIn
) {
return (
<MaterialIconButton
accessibilityLabel={props.accessibilityLabel}
icon={props.icon}
onPress={props.onPress}
disabled={props.disabled}
variant={variant === "primary" ? "primary" : variant === "danger" ? "danger" : "tonal"}
/>
);
}
return (
<Pressable
accessibilityLabel={props.accessibilityLabel ?? props.label}
@@ -146,10 +188,8 @@ export function ControlPill(props: {
);
}
// iOS renders the native UIMenu (standard checkmark for `state: "on"`);
// Android renders the token-styled AndroidAnchoredMenu, since the native
// AppCompat popup can't be themed past its stock animation, metrics, and
// submenu chrome.
// iOS renders UIMenu; AndroidAnchoredMenu adapts the same actions to the
// selected Android appearance and keeps editor menus above the keyboard.
export function ControlPillMenu(
props: Omit<ComponentProps<typeof MenuView>, "children" | "themeVariant"> &
Pick<AccessibilityProps, "accessible" | "accessibilityLabel" | "accessibilityRole"> & {
+8 -2
View File
@@ -1,4 +1,5 @@
import { Pressable, View } from "react-native";
import type { ReactNode } from "react";
import { AppText as Text } from "./AppText";
@@ -7,6 +8,7 @@ export function EmptyState(props: {
readonly detail: string;
readonly actionLabel?: string;
readonly onAction?: () => void;
readonly action?: ReactNode;
readonly variant?: "card" | "plain";
}) {
if (props.variant === "plain") {
@@ -16,7 +18,9 @@ export function EmptyState(props: {
<Text className="mt-2 text-center font-sans text-base leading-normal text-foreground-muted">
{props.detail}
</Text>
{props.actionLabel && props.onAction ? (
{props.action ? (
<View className="mt-5">{props.action}</View>
) : props.actionLabel && props.onAction ? (
<Pressable
className="mt-5 rounded-full bg-primary px-5 py-3 active:opacity-70"
onPress={props.onAction}
@@ -36,7 +40,9 @@ export function EmptyState(props: {
<Text className="mt-2 font-sans text-sm leading-relaxed text-foreground-muted">
{props.detail}
</Text>
{props.actionLabel && props.onAction ? (
{props.action ? (
<View className="mt-4 self-start">{props.action}</View>
) : props.actionLabel && props.onAction ? (
<Pressable
className="mt-4 self-start rounded-full bg-primary px-4 py-2.5 active:opacity-70"
onPress={props.onAction}
+2 -19
View File
@@ -1,22 +1,13 @@
import { BlurView } from "expo-blur";
import { useContext, type RefObject } from "react";
import { Platform, StyleSheet, View, type ColorValue } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { GlassBlurTargetContext } from "../lib/glassBlurTarget";
import { themeColorWithAlpha } from "../lib/mobileTheme";
/** Frosted backdrop for containers that clip their children to their shape. */
export function GlassBackdrop(props: {
readonly fallbackColor?: ColorValue;
readonly blurTarget?: RefObject<View | null>;
}) {
export function GlassBackdrop(props: { readonly fallbackColor?: ColorValue }) {
const { themeAppearance } = useAppearancePreferences();
const inheritedBlurTarget = useContext(GlassBlurTargetContext);
const target = props.blurTarget ?? inheritedBlurTarget;
const supportsBlur =
Platform.OS === "ios" ||
(Platform.OS === "android" && Platform.Version >= 31 && target !== undefined);
const supportsBlur = Platform.OS === "ios";
const colorStyle =
props.fallbackColor === undefined
? undefined
@@ -24,17 +15,9 @@ export function GlassBackdrop(props: {
return (
<>
{/* Android samples a separate target. An opaque backing prevents any
transparent pixels in that sample from exposing the unblurred feed.
iOS samples its actual backdrop, so a backing there would hide it. */}
{Platform.OS === "android" ? (
<View pointerEvents="none" className="absolute inset-0 bg-card" style={colorStyle} />
) : null}
{supportsBlur ? (
<BlurView
pointerEvents="none"
blurTarget={target}
blurMethod="dimezisBlurViewSdk31Plus"
intensity={80}
tint={themeAppearance === "dark" ? "dark" : "default"}
style={StyleSheet.absoluteFill}
+8 -18
View File
@@ -1,5 +1,5 @@
import { GlassView, isGlassEffectAPIAvailable } from "expo-glass-effect";
import type { ReactNode, Ref, RefObject } from "react";
import type { ReactNode, Ref } from "react";
import {
Platform,
useColorScheme,
@@ -28,7 +28,6 @@ interface GlassSurfaceProps extends ViewProps {
readonly chrome?: "default" | "none";
/** Base color for the frosted tint, or solid fill when blur is unavailable. */
readonly fallbackColor?: ColorValue;
readonly blurTarget?: RefObject<View | null>;
/** Uniwind styling used only when native Liquid Glass is unavailable. */
readonly fallbackClassName?: string;
}
@@ -41,7 +40,6 @@ export function GlassSurface({
tintColor,
tintColorClassName,
fallbackColor,
blurTarget,
fallbackClassName,
className,
style,
@@ -49,23 +47,15 @@ export function GlassSurface({
}: GlassSurfaceProps) {
const isDarkMode = useColorScheme() === "dark";
const supportsGlass = Platform.OS === "ios" && isGlassEffectAPIAvailable();
const hasShadow = chrome !== "none" && Platform.OS !== "android";
const surfaceStyle: ViewStyle = {
borderRadius: 32,
overflow: "hidden",
shadowColor: chrome === "none" ? "transparent" : "#000000",
shadowOpacity: chrome === "none" ? 0 : isDarkMode ? 0.22 : 0.08,
shadowRadius: chrome === "none" ? 0 : 28,
shadowOffset:
chrome === "none"
? {
width: 0,
height: 0,
}
: {
width: 0,
height: 14,
},
elevation: chrome === "none" ? 0 : 12,
shadowColor: hasShadow ? "#000000" : "transparent",
shadowOpacity: hasShadow ? (isDarkMode ? 0.22 : 0.08) : 0,
shadowRadius: hasShadow ? 28 : 0,
shadowOffset: { width: 0, height: hasShadow ? 14 : 0 },
elevation: hasShadow ? 12 : 0,
};
if (supportsGlass) {
@@ -103,7 +93,7 @@ export function GlassSurface({
)}
style={[surfaceStyle, style]}
>
<GlassBackdrop blurTarget={blurTarget} fallbackColor={fallbackColor} />
<GlassBackdrop fallbackColor={fallbackColor} />
{children}
</View>
);
@@ -0,0 +1,94 @@
import {
Box,
Button,
CircularProgressIndicator,
FilledTonalButton,
Host,
Row,
Text,
TextButton,
} from "@expo/ui/jetpack-compose";
import { defaultMinSize, fillMaxWidth, size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import type { MaterialButtonProps } from "./MaterialButton";
export function MaterialButton(props: MaterialButtonProps) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const typography = useScaledTextRole("footnote");
const tone = props.tone ?? "secondary";
const Component =
tone === "text" ? TextButton : tone === "secondary" ? FilledTonalButton : Button;
const containerColor =
tone === "primary"
? colors["--color-primary"]
: tone === "danger"
? colors["--color-danger"]
: tone === "text"
? "#00000000"
: colors["--color-secondary"];
const contentColor =
tone === "primary"
? colors["--color-primary-foreground"]
: tone === "danger"
? colors["--color-danger-foreground"]
: tone === "text"
? colors["--color-primary"]
: colors["--color-secondary-foreground"];
return (
<View
accessible
accessibilityRole="button"
accessibilityLabel={props.label}
accessibilityState={{
disabled: Boolean(props.disabled || props.loading),
busy: Boolean(props.loading),
}}
accessibilityActions={[{ name: "activate" }]}
onAccessibilityAction={() => {
if (!props.disabled && !props.loading) props.onPress();
}}
style={props.fullWidth ? { width: "100%" } : { alignSelf: "flex-start" }}
>
<View importantForAccessibility="no-hide-descendants">
<Host
matchContents={props.fullWidth ? { vertical: true } : true}
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={props.fullWidth ? { width: "100%" } : { alignSelf: "flex-start" }}
>
<Component
enabled={!props.disabled && !props.loading}
onClick={props.onPress}
modifiers={[
defaultMinSize({ minHeight: 48 }),
...(props.fullWidth ? [fillMaxWidth()] : []),
]}
colors={{
containerColor,
contentColor,
disabledContainerColor: colors["--color-subtle-strong"],
disabledContentColor: colors["--color-foreground-muted"],
}}
>
<Row verticalAlignment="center">
{props.loading ? (
<>
<CircularProgressIndicator
modifiers={[size(18, 18)]}
strokeWidth={2}
color={colors["--color-foreground-muted"]}
/>
<Box modifiers={[size(8, 1)]} />
</>
) : null}
<Text style={{ ...typography, fontWeight: "500" }}>{props.label}</Text>
</Row>
</Component>
</Host>
</View>
</View>
);
}
@@ -0,0 +1,24 @@
import { Pressable } from "react-native";
import { AppText } from "./AppText";
export interface MaterialButtonProps {
readonly label: string;
readonly onPress: () => void;
readonly disabled?: boolean;
readonly loading?: boolean;
readonly tone?: "primary" | "secondary" | "danger" | "text";
readonly fullWidth?: boolean;
}
export function MaterialButton(props: MaterialButtonProps) {
return (
<Pressable
accessibilityRole="button"
disabled={props.disabled}
onPress={props.onPress}
className="min-h-12 justify-center rounded-full bg-secondary px-6"
>
<AppText>{props.label}</AppText>
</Pressable>
);
}
@@ -0,0 +1,96 @@
import {
AlertDialog,
Host,
OutlinedTextField,
Text,
TextButton,
useNativeState,
} from "@expo/ui/jetpack-compose";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import type { MaterialConfirmDialogProps } from "./MaterialConfirmDialog";
export function MaterialConfirmDialog(props: MaterialConfirmDialogProps) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const titleTypography = useScaledTextRole("title");
const bodyTypography = useScaledTextRole("footnote");
const inputTypography = useScaledTextRole("body");
const inputState = useNativeState(props.inputInitialValue ?? "");
const inputSelection = useNativeState({ start: 0, end: props.inputInitialValue?.length ?? 0 });
const confirm = () => {
if (props.confirmDisabled) return;
const value = props.inputInitialValue === undefined ? undefined : inputState.get();
if (value !== undefined && !value.trim()) return;
props.onConfirm(value);
};
return (
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{ height: 0, width: 0 }}
>
<AlertDialog
onDismissRequest={props.onCancel}
tonalElevation={0}
colors={{
containerColor: colors["--color-card-alt"],
titleContentColor: colors["--color-foreground"],
textContentColor: colors["--color-foreground-secondary"],
}}
>
<AlertDialog.Title>
<Text style={titleTypography}>{props.request.title}</Text>
</AlertDialog.Title>
{props.inputInitialValue !== undefined ? (
<AlertDialog.Text>
<OutlinedTextField
autoFocus
singleLine
value={inputState}
selection={inputSelection}
onValueChange={props.onInputChange}
textStyle={inputTypography}
keyboardOptions={{ imeAction: "done" }}
keyboardActions={{
onDone: confirm,
}}
colors={{
focusedTextColor: colors["--color-foreground"],
unfocusedTextColor: colors["--color-foreground"],
focusedIndicatorColor: colors["--color-primary"],
unfocusedIndicatorColor: colors["--color-border"],
cursorColor: colors["--color-primary"],
}}
>
<OutlinedTextField.Label>
<Text style={bodyTypography}>{props.request.title}</Text>
</OutlinedTextField.Label>
</OutlinedTextField>
</AlertDialog.Text>
) : props.request.message ? (
<AlertDialog.Text>
<Text style={bodyTypography}>{props.request.message}</Text>
</AlertDialog.Text>
) : null}
<AlertDialog.DismissButton>
<TextButton onClick={props.onCancel} colors={{ contentColor: colors["--color-primary"] }}>
<Text style={bodyTypography}>{props.request.cancelText ?? "Cancel"}</Text>
</TextButton>
</AlertDialog.DismissButton>
<AlertDialog.ConfirmButton>
<TextButton
onClick={confirm}
enabled={!props.confirmDisabled}
colors={{
contentColor:
colors[props.request.destructive ? "--color-danger" : "--color-primary"],
}}
>
<Text style={bodyTypography}>{props.request.confirmText}</Text>
</TextButton>
</AlertDialog.ConfirmButton>
</AlertDialog>
</Host>
);
}
@@ -0,0 +1,17 @@
import type { ConfirmDialogRequest } from "./ConfirmDialogHost";
export interface MaterialConfirmDialogProps {
readonly request: Pick<
ConfirmDialogRequest,
"title" | "message" | "cancelText" | "confirmText" | "destructive"
>;
readonly inputInitialValue?: string;
readonly onInputChange?: (value: string) => void;
readonly confirmDisabled?: boolean;
readonly onCancel: () => void;
readonly onConfirm: (inputValue?: string) => void;
}
export function MaterialConfirmDialog(_props: MaterialConfirmDialogProps) {
return null;
}
@@ -0,0 +1,86 @@
import {
Box,
ExtendedFloatingActionButton,
FloatingActionButton,
Host,
LargeFloatingActionButton,
Text,
} from "@expo/ui/jetpack-compose";
import { size } from "@expo/ui/jetpack-compose/modifiers";
import { View, type StyleProp, type ViewStyle } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
export function MaterialFloatingActionButton(props: {
readonly onPress: () => void;
readonly label: string;
readonly icon: AppSymbolName;
readonly variant?: "extended" | "large";
readonly expanded?: boolean;
readonly tone?: "primary" | "secondary";
readonly className?: string;
readonly style?: StyleProp<ViewStyle>;
}) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const typography = useScaledTextRole("footnote");
const primary = props.tone === "primary";
const containerColor = colors[primary ? "--color-primary" : "--color-thread-selected"];
const contentColor =
colors[primary ? "--color-primary-foreground" : "--color-thread-selected-foreground"];
const Component =
props.variant === "extended"
? ExtendedFloatingActionButton
: props.variant === "large"
? LargeFloatingActionButton
: FloatingActionButton;
const iconSize = props.variant === "large" ? 36 : 24;
return (
<View
accessible
accessibilityRole="button"
accessibilityLabel={props.label}
accessibilityActions={[{ name: "activate" }]}
onAccessibilityAction={props.onPress}
className={props.className}
style={props.style}
>
<View importantForAccessibility="no-hide-descendants">
<Host matchContents colorScheme={themeAppearance} ignoreSafeAreaKeyboardInsets>
<Component
containerColor={containerColor}
onClick={props.onPress}
expanded={props.expanded}
>
<Component.Icon>
<Box modifiers={[size(iconSize, iconSize)]} />
</Component.Icon>
{props.variant === "extended" ? (
<ExtendedFloatingActionButton.Text>
<Text color={contentColor} style={{ ...typography, fontWeight: "500" }}>
{props.label}
</Text>
</ExtendedFloatingActionButton.Text>
) : null}
</Component>
</Host>
</View>
{/* The RN icon stays outside Compose so it cannot intercept native button taps. */}
<View
pointerEvents="none"
className="absolute inset-y-0 justify-center"
style={
props.variant === "extended" ? { left: 16 } : { left: 0, right: 0, alignItems: "center" }
}
>
<SymbolView
name={props.icon}
size={iconSize}
tintColorClassName={
primary ? "accent-primary-foreground" : "accent-thread-selected-foreground"
}
/>
</View>
</View>
);
}
@@ -0,0 +1,46 @@
import type { ComponentProps } from "react";
import { Pressable } from "react-native";
import type { MaterialFloatingActionButton as AndroidMaterialFloatingActionButton } from "./MaterialFloatingActionButton.android";
import { AppText } from "./AppText";
import { SymbolView } from "./AppSymbol";
import { cn } from "../lib/cn";
export function MaterialFloatingActionButton(
props: ComponentProps<typeof AndroidMaterialFloatingActionButton>,
) {
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={props.label}
onPress={props.onPress}
className={cn(
"min-h-14 min-w-14 flex-row items-center justify-center gap-2 rounded-2xl px-4",
props.tone === "primary" ? "bg-primary" : "bg-thread-selected",
props.className,
)}
style={props.style}
>
<SymbolView
name={props.icon}
size={24}
tintColorClassName={
props.tone === "primary"
? "accent-primary-foreground"
: "accent-thread-selected-foreground"
}
/>
{props.variant === "extended" && props.expanded !== false ? (
<AppText
className={cn(
"text-sm",
props.tone === "primary"
? "text-primary-foreground"
: "text-thread-selected-foreground",
)}
>
{props.label}
</AppText>
) : null}
</Pressable>
);
}
@@ -0,0 +1,87 @@
import {
FilledIconButton,
FilledTonalIconButton,
Host,
IconButton,
} from "@expo/ui/jetpack-compose";
import { size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
export function MaterialIconButton(props: {
readonly accessibilityLabel: string;
readonly icon: AppSymbolName;
readonly onPress?: () => void;
readonly disabled?: boolean;
readonly selected?: boolean;
readonly variant?: "standard" | "primary" | "tonal" | "danger";
}) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const variant = props.variant ?? "standard";
const Component =
variant === "standard"
? IconButton
: variant === "tonal"
? FilledTonalIconButton
: FilledIconButton;
const containerColor =
variant === "primary"
? colors["--color-primary"]
: variant === "danger"
? colors["--color-danger"]
: colors["--color-secondary"];
const iconTint = props.disabled
? "accent-icon-subtle"
: variant === "primary"
? "accent-primary-foreground"
: variant === "danger"
? "accent-danger-foreground"
: variant === "tonal"
? "accent-secondary-foreground"
: "accent-foreground";
return (
<View
accessible
accessibilityLabel={props.accessibilityLabel}
accessibilityRole="button"
accessibilityState={{ disabled: Boolean(props.disabled), selected: props.selected }}
accessibilityActions={[{ name: "activate" }]}
onAccessibilityAction={() => {
if (!props.disabled) props.onPress?.();
}}
style={{ width: 48, height: 48 }}
>
<View importantForAccessibility="no-hide-descendants">
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{ width: 48, height: 48 }}
>
<Component
onClick={props.onPress}
enabled={!props.disabled}
modifiers={[size(48, 48)]}
colors={
variant === "standard"
? undefined
: { containerColor, disabledContainerColor: colors["--color-subtle-strong"] }
}
>
{null}
</Component>
</Host>
</View>
{/* Keep RN SVG measurement outside Compose; the native button owns touch and ripple. */}
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<SymbolView
name={props.icon === "ellipsis" ? { ios: "ellipsis", android: "more_vert" } : props.icon}
size={24}
tintColorClassName={iconTint}
type="monochrome"
/>
</View>
</View>
);
}
@@ -0,0 +1,23 @@
import { Pressable } from "react-native";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
export function MaterialIconButton(props: {
readonly accessibilityLabel: string;
readonly icon: AppSymbolName;
readonly onPress?: () => void;
readonly disabled?: boolean;
readonly selected?: boolean;
readonly variant?: "standard" | "primary" | "tonal" | "danger";
}) {
return (
<Pressable
{...props}
accessibilityRole="button"
accessibilityState={{ disabled: Boolean(props.disabled), selected: props.selected }}
className="size-12 items-center justify-center"
>
<SymbolView name={props.icon} size={24} tintColorClassName="accent-foreground" />
</Pressable>
);
}
@@ -0,0 +1,57 @@
import type { ComponentProps, ReactNode } from "react";
import { Platform, Pressable, View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { cn } from "../lib/cn";
import { AppText } from "./AppText";
import { SymbolView } from "./AppSymbol";
/** Shared geometry for Material navigation and selection lists. Group rows in one card. */
export function MaterialListRow({
title,
subtitle,
leading,
trailing,
className,
...props
}: Omit<ComponentProps<typeof Pressable>, "children"> & {
readonly title: string;
readonly subtitle?: string | null;
readonly leading?: ReactNode;
readonly trailing?: ReactNode;
}) {
const { themeVariables } = useAppearancePreferences();
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={[title, subtitle].filter(Boolean).join(", ")}
android_ripple={{ color: themeVariables["--color-subtle-strong"] }}
// Give the scroll view time to claim drags before starting the ripple.
unstable_pressDelay={Platform.OS === "android" ? 50 : undefined}
{...props}
className={cn(
"flex-row items-center gap-4 overflow-hidden bg-card px-4 py-3",
subtitle ? "min-h-18" : "min-h-14",
props.disabled && "opacity-45",
className,
)}
>
{leading ? <View className="size-6 items-center justify-center">{leading}</View> : null}
<View className="min-w-0 flex-1 gap-1">
<AppText className="text-base text-foreground" numberOfLines={2}>
{title}
</AppText>
{subtitle ? (
<AppText className="text-sm text-foreground-muted" numberOfLines={2}>
{subtitle}
</AppText>
) : null}
</View>
{trailing !== undefined ? (
trailing
) : !props.disabled ? (
<SymbolView name="chevron.right" size={16} tintColorClassName="accent-chevron" />
) : null}
</Pressable>
);
}
@@ -0,0 +1,153 @@
import {
Box,
Column,
DropdownMenu,
DropdownMenuItem,
Host,
RNHostView,
Text,
} from "@expo/ui/jetpack-compose";
import { padding, size, width } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import type { MaterialMenuPopupProps } from "./MaterialMenuPopup";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
function MenuIcon(props: {
readonly name: AppSymbolName;
readonly destructive?: boolean;
readonly disabled?: boolean;
}) {
return (
<RNHostView matchContents modifiers={[size(24, 24)]}>
<View style={{ width: 24, height: 24 }} importantForAccessibility="no-hide-descendants">
<SymbolView
name={props.name}
size={24}
type="monochrome"
tintColorClassName={
props.disabled
? "accent-icon-subtle"
: props.destructive
? "accent-danger-foreground"
: "accent-foreground"
}
/>
</View>
</RNHostView>
);
}
/** Native popup positioned at the original trigger, outside virtualized rows. */
export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const foreground = colors["--color-foreground"];
const muted = colors["--color-foreground-muted"];
const items = (
<>
{props.parent ? (
<DropdownMenuItem onClick={props.onBack} modifiers={[width(250)]}>
<DropdownMenuItem.LeadingIcon>
<MenuIcon name="arrow.left" />
</DropdownMenuItem.LeadingIcon>
<DropdownMenuItem.Text>
<Text color={foreground} style={{ typography: "bodyLarge" }}>
{props.parent.title}
</Text>
</DropdownMenuItem.Text>
</DropdownMenuItem>
) : props.title ? (
<Text color={muted} style={{ typography: "bodySmall" }} modifiers={[padding(16, 8, 16, 8)]}>
{props.title}
</Text>
) : null}
{props.actions.map((action, index) => (
<DropdownMenuItem
key={action.id ?? `${index}-${action.title}`}
enabled={!action.attributes?.disabled}
modifiers={[width(250)]}
elementColors={{
textColor: action.attributes?.destructive
? colors["--color-danger-foreground"]
: foreground,
disabledTextColor: muted,
}}
onClick={() => props.onPress(action)}
>
<DropdownMenuItem.Text>
<Column>
<Text
style={{ typography: "bodyLarge" }}
color={
action.attributes?.disabled
? muted
: action.attributes?.destructive
? colors["--color-danger-foreground"]
: foreground
}
>
{action.title}
</Text>
{action.subtitle ? (
<Text color={muted} style={{ typography: "bodySmall" }}>
{action.subtitle}
</Text>
) : null}
</Column>
</DropdownMenuItem.Text>
{action.image ? (
<DropdownMenuItem.LeadingIcon>
<MenuIcon
name={action.image as AppSymbolName}
destructive={action.attributes?.destructive}
disabled={action.attributes?.disabled}
/>
</DropdownMenuItem.LeadingIcon>
) : null}
{(action.subactions?.length ?? 0) > 0 ? (
<DropdownMenuItem.TrailingIcon>
<MenuIcon name="chevron.right" disabled={action.attributes?.disabled} />
</DropdownMenuItem.TrailingIcon>
) : action.state === "on" ? (
<DropdownMenuItem.TrailingIcon>
<MenuIcon name="checkmark" disabled={action.attributes?.disabled} />
</DropdownMenuItem.TrailingIcon>
) : null}
</DropdownMenuItem>
))}
</>
);
if (props.inline) {
return (
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
matchContents
style={{ width: 250 }}
>
<Column>{items}</Column>
</Host>
);
}
return (
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{
position: "absolute",
left: props.anchor.x,
top: props.anchor.y,
width: props.anchor.width,
height: props.anchor.height,
}}
>
<DropdownMenu expanded onDismissRequest={props.onClose} color={colors["--color-card-alt"]}>
<DropdownMenu.Trigger>
<Box modifiers={[size(props.anchor.width, props.anchor.height)]} />
</DropdownMenu.Trigger>
<DropdownMenu.Items>{items}</DropdownMenu.Items>
</DropdownMenu>
</Host>
);
}
@@ -0,0 +1,22 @@
import type { MenuAction } from "@react-native-menu/menu";
export interface MaterialMenuPopupProps {
readonly anchor: {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
};
readonly actions: readonly MenuAction[];
readonly title?: string;
readonly parent: MenuAction | null;
readonly onPress: (action: MenuAction) => void;
readonly onBack: () => void;
readonly onClose: () => void;
/** Keep the editor's window focus and keyboard while showing native menu rows. */
readonly inline?: boolean;
}
export function MaterialMenuPopup(_props: MaterialMenuPopupProps) {
return null;
}
@@ -0,0 +1,17 @@
import type { ComponentProps } from "react";
import { MaterialFloatingActionButton } from "./MaterialFloatingActionButton.android";
import type { MaterialNewThreadButton as SharedMaterialNewThreadButton } from "./MaterialNewThreadButton.shared";
export function MaterialNewThreadButton(
props: ComponentProps<typeof SharedMaterialNewThreadButton>,
) {
return (
<MaterialFloatingActionButton
{...props}
icon="square.and.pencil"
label="New thread"
tone="primary"
variant={props.extended ? "extended" : "large"}
/>
);
}
@@ -0,0 +1,40 @@
import { Pressable, type StyleProp, type ViewStyle } from "react-native";
import { cn } from "../lib/cn";
import { AppText } from "./AppText";
import { SymbolView } from "./AppSymbol";
/** Shared compose action for the floating button and empty workspace. */
export function MaterialNewThreadButton(props: {
readonly onPress: () => void;
readonly extended?: boolean;
readonly expanded?: boolean;
readonly className?: string;
readonly style?: StyleProp<ViewStyle>;
}) {
return (
<Pressable
accessibilityLabel="New thread"
accessibilityRole="button"
onPress={props.onPress}
className={cn(
"items-center justify-center bg-primary shadow-lg active:opacity-70",
props.extended
? "h-[56px] flex-row gap-[8px] rounded-[16px] px-[16px]"
: "size-[80px] rounded-[20px]",
props.className,
)}
style={props.style}
>
<SymbolView
name="square.and.pencil"
size={props.extended ? 24 : 28}
tintColorClassName="accent-primary-foreground"
type="monochrome"
/>
{props.extended && props.expanded !== false ? (
<AppText className="text-[16px] font-t3-medium text-primary-foreground">New thread</AppText>
) : null}
</Pressable>
);
}
@@ -0,0 +1 @@
export { MaterialNewThreadButton } from "./MaterialNewThreadButton.shared";
@@ -0,0 +1,55 @@
import { Host, RadioButton } from "@expo/ui/jetpack-compose";
import { size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
/** The enclosing radio row owns selection, touch and accessibility. */
export function MaterialRadioIndicator({ selected }: { readonly selected: boolean }) {
const { themeAppearance, themeVariables, systemColorsActive } = useAppearancePreferences();
// Expo's radio button cannot override colors in the pinned SDK. Custom
// themes need their exact accent rather than a generated Material palette.
if (!systemColorsActive) {
return (
<View
pointerEvents="none"
importantForAccessibility="no-hide-descendants"
style={{ width: 24, height: 24, alignItems: "center", justifyContent: "center" }}
>
<View
style={{
width: 20,
height: 20,
borderRadius: 10,
borderWidth: 2,
borderColor: themeVariables[selected ? "--color-primary" : "--color-foreground-muted"],
alignItems: "center",
justifyContent: "center",
}}
>
{selected ? (
<View
style={{
width: 10,
height: 10,
borderRadius: 5,
backgroundColor: themeVariables["--color-primary"],
}}
/>
) : null}
</View>
</View>
);
}
return (
<View pointerEvents="none" importantForAccessibility="no-hide-descendants">
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{ width: 24, height: 24 }}
>
<RadioButton selected={selected} modifiers={[size(24, 24)]} />
</Host>
</View>
);
}
@@ -0,0 +1,8 @@
import { SymbolView } from "./AppSymbol";
/** The enclosing radio row owns selection, touch and accessibility. */
export function MaterialRadioIndicator({ selected }: { readonly selected: boolean }) {
return selected ? (
<SymbolView name="checkmark" size={16} tintColorClassName="accent-icon" />
) : null;
}
@@ -0,0 +1,33 @@
import type { ReactNode } from "react";
import { Platform, View } from "react-native";
/** Keeps the header surface visible behind rounded Android content corners. */
export function MaterialScreenContent({
children,
insetHorizontal = false,
fitToContents = false,
}: {
readonly children: ReactNode;
/** Match the master-list gutters for secondary panes, not full-width content. */
readonly insetHorizontal?: boolean;
/** Allow native form sheets to measure their content instead of filling a fixed detent. */
readonly fitToContents?: boolean;
}) {
if (Platform.OS !== "android") return children;
return (
<View className={fitToContents ? "shrink bg-header" : "flex-1 bg-header"}>
<View
className="overflow-hidden rounded-t-[28px] bg-sheet-solid"
style={{
flexShrink: 1,
flexGrow: fitToContents ? 0 : 1,
flexBasis: fitToContents ? "auto" : 0,
marginHorizontal: insetHorizontal ? 4 : 0,
}}
>
{children}
</View>
</View>
);
}
@@ -0,0 +1,37 @@
import { SegmentedButton, SingleChoiceSegmentedButtonRow, Text } from "@expo/ui/jetpack-compose";
import { defaultMinSize, fillMaxWidth } from "@expo/ui/jetpack-compose/modifiers";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import type { SegmentedControlProps } from "./SegmentedControl";
/** Compose content shared by screen controls and native dialogs, inside their existing Host. */
export function MaterialSegmentedButtons<Value extends number | string>(
props: SegmentedControlProps<Value>,
) {
const { themeVariables: colors } = useAppearancePreferences();
const typography = useScaledTextRole("footnote");
return (
<SingleChoiceSegmentedButtonRow modifiers={[fillMaxWidth()]}>
{props.options.map((option) => (
<SegmentedButton
key={String(option.value)}
selected={option.value === props.selected}
onClick={() => props.onSelect(option.value)}
modifiers={[defaultMinSize({ minHeight: 48 })]}
colors={{
activeContainerColor: colors["--color-secondary"],
activeContentColor: colors["--color-secondary-foreground"],
inactiveContainerColor: "transparent",
inactiveContentColor: colors["--color-foreground"],
activeBorderColor: colors["--color-border"],
inactiveBorderColor: colors["--color-border"],
}}
>
<SegmentedButton.Label>
<Text style={typography}>{option.label}</Text>
</SegmentedButton.Label>
</SegmentedButton>
))}
</SingleChoiceSegmentedButtonRow>
);
}
@@ -0,0 +1,40 @@
import { Host } from "@expo/ui/jetpack-compose";
import { MaterialSegmentedButtons } from "./MaterialSegmentedButtons.android";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import type { SegmentedControlProps } from "./SegmentedControl";
export function MaterialSegmentedControl<Value extends number | string>(
props: SegmentedControlProps<Value>,
) {
const { themeAppearance } = useAppearancePreferences();
return (
<View className={props.className}>
<View importantForAccessibility="no-hide-descendants">
<Host
matchContents={{ vertical: true }}
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{ width: "100%" }}
>
<MaterialSegmentedButtons {...props} />
</Host>
</View>
<View pointerEvents="none" className="absolute inset-0 flex-row">
{props.options.map((option) => (
<View
key={String(option.value)}
accessible
accessibilityRole={props.role ?? "button"}
accessibilityLabel={option.accessibilityLabel ?? option.label}
accessibilityState={{ selected: option.value === props.selected }}
accessibilityActions={[{ name: "activate" }]}
onAccessibilityAction={() => props.onSelect(option.value)}
className="flex-1"
/>
))}
</View>
</View>
);
}
@@ -0,0 +1,7 @@
import type { SegmentedControlProps } from "./SegmentedControl";
export function MaterialSegmentedControl<Value extends number | string>(
_props: SegmentedControlProps<Value>,
) {
return null;
}
@@ -0,0 +1,49 @@
import { Host, Switch as ComposeSwitch } from "@expo/ui/jetpack-compose";
import { View } from "react-native";
import type { ThemedSwitchProps } from "./ThemedSwitch";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
/** Material's native switch, with the same palette and accessibility contract as our RN controls. */
export function MaterialSwitch(props: ThemedSwitchProps) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const toggle = () => {
if (!props.disabled) props.onValueChange?.(!props.value);
};
return (
<View
accessible
accessibilityLabel={props.accessibilityLabel}
accessibilityHint={props.accessibilityHint}
accessibilityRole="switch"
accessibilityState={{ checked: Boolean(props.value), disabled: Boolean(props.disabled) }}
accessibilityActions={[{ name: "activate", label: "Toggle" }]}
onAccessibilityAction={toggle}
style={props.style}
testID={props.testID}
>
<View importantForAccessibility="no-hide-descendants">
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
style={{ width: 52, height: 48 }}
>
<ComposeSwitch
value={Boolean(props.value)}
enabled={!props.disabled}
onCheckedChange={props.onValueChange ?? undefined}
colors={{
checkedTrackColor: colors["--color-switch-active-track"],
checkedThumbColor: colors["--color-switch-active-thumb"],
checkedBorderColor: colors["--color-switch-active-track"],
uncheckedTrackColor: colors["--color-switch-inactive-track"],
uncheckedThumbColor: colors["--color-switch-inactive-thumb"],
uncheckedBorderColor: colors["--color-switch-inactive-thumb"],
}}
/>
</Host>
</View>
</View>
);
}
@@ -0,0 +1 @@
export { Switch as MaterialSwitch } from "react-native";
@@ -0,0 +1,19 @@
import type { ComponentProps } from "react";
import { Platform, ScrollView } from "react-native";
/** Keeps forms and settings readable inside a wide pane while its surface fills the screen. */
export function ScreenScrollView(props: ComponentProps<typeof ScrollView>) {
return (
<ScrollView
{...props}
contentContainerStyle={[
props.contentContainerStyle,
Platform.OS === "android" && {
width: "100%",
maxWidth: 720,
alignSelf: "center",
},
]}
/>
);
}
@@ -2,8 +2,9 @@ import { Platform, Pressable, View } from "react-native";
import Animated, { Easing, LinearTransition, ReduceMotion } from "react-native-reanimated";
import { AppText as Text } from "./AppText";
import { cn } from "../lib/cn";
import { MaterialSegmentedControl } from "./MaterialSegmentedControl";
export function SegmentedControl<Value extends number | string>(props: {
export interface SegmentedControlProps<Value extends number | string> {
readonly options: readonly {
readonly value: Value;
readonly label: string;
@@ -11,18 +12,26 @@ export function SegmentedControl<Value extends number | string>(props: {
}[];
readonly selected: Value;
readonly onSelect: (value: Value) => void;
/** The tab bar is full height; filters under it are shorter so it stays primary. */
/** Compact sizing applies to the non-Material control. */
readonly size?: "default" | "compact";
/** "tab" for the view switcher; filters stay plain buttons. */
readonly role?: "tab" | "button";
readonly className?: string;
}) {
}
export function SegmentedControl<Value extends number | string>(
props: SegmentedControlProps<Value>,
) {
const compact = props.size === "compact";
if (Platform.OS === "android") {
return <MaterialSegmentedControl {...props} />;
}
return (
<View
accessible={false}
className={cn(
"flex-row overflow-hidden rounded-full border-continuous bg-card",
"flex-row overflow-hidden",
"rounded-full border-continuous bg-card",
props.className,
)}
>
@@ -31,7 +40,7 @@ export function SegmentedControl<Value extends number | string>(props: {
layout={LinearTransition.duration(200)
.easing(Easing.out(Easing.cubic))
.reduceMotion(ReduceMotion.System)}
className="absolute bottom-0 top-0 rounded-full bg-subtle-strong"
className="absolute inset-y-0 rounded-full bg-subtle-strong"
style={{
width: `${100 / props.options.length}%`,
start: `${
+16 -52
View File
@@ -1,63 +1,27 @@
import { Platform, Pressable, Switch, View, type SwitchProps } from "react-native";
import { Platform, Switch, type SwitchProps } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { SymbolView } from "./AppSymbol";
import { MaterialSwitch } from "./MaterialSwitch";
export function ThemedSwitch(props: SwitchProps) {
const { materialYouStyleLayoutActive } = useAppearancePreferences();
if (materialYouStyleLayoutActive) {
return (
<Pressable
accessibilityHint={props.accessibilityHint}
accessibilityLabel={props.accessibilityLabel}
accessibilityRole="switch"
accessibilityState={{ checked: Boolean(props.value), disabled: props.disabled }}
disabled={props.disabled}
hitSlop={8}
onPress={() => props.onValueChange?.(!props.value)}
style={props.style}
testID={props.testID}
className={props.disabled ? "opacity-40" : "active:opacity-70"}
>
<View
className={
props.value
? "h-8 w-[52px] items-end justify-center rounded-full border-2 border-switch-active-track bg-switch-active-track px-0.5"
: "h-8 w-[52px] items-start justify-center rounded-full border-2 border-switch-inactive-thumb bg-switch-inactive-track px-0.5"
}
>
<View
className={
props.value
? "size-6 items-center justify-center rounded-full bg-switch-active-thumb"
: "size-6 items-center justify-center rounded-full bg-switch-inactive-thumb"
}
>
<SymbolView
name={props.value ? "checkmark" : "xmark"}
size={13}
tintColorClassName={
props.value ? "accent-switch-active-track" : "accent-switch-inactive-track"
}
type="monochrome"
/>
</View>
</View>
</Pressable>
);
export type ThemedSwitchProps = Pick<
SwitchProps,
| "accessibilityHint"
| "accessibilityLabel"
| "disabled"
| "onValueChange"
| "style"
| "testID"
| "value"
>;
export function ThemedSwitch(props: ThemedSwitchProps) {
if (Platform.OS === "android") {
return <MaterialSwitch {...props} />;
}
return (
<Switch
{...props}
ios_backgroundColorClassName="accent-switch-inactive-track"
thumbColorClassName={
Platform.OS === "android"
? props.value
? "accent-switch-active-thumb"
: "accent-switch-inactive-thumb"
: undefined
}
trackColorOffClassName="accent-switch-inactive-track"
trackColorOnClassName="accent-switch-active-track"
/>
@@ -0,0 +1,11 @@
import { useWindowDimensions } from "react-native";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
/** Reserve the same title/subtitle space in every pane, including icon-only and search headers. */
export function useMaterialToolbarHeight() {
const title = useScaledTextRole("title");
const subtitle = useScaledTextRole("label");
const { fontScale } = useWindowDimensions();
return Math.ceil(Math.max(56, (title.lineHeight + subtitle.lineHeight) * fontScale + 1));
}
@@ -40,6 +40,7 @@ import {
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
} from "../layout/native-mail-search-toolbar";
import type { ArchivedThreadGroup, ArchivedThreadSortOrder } from "./archivedThreadList";
import { SettingsScreenContent } from "../settings/components/SettingsScreen";
export interface ArchivedThreadsHeaderEnvironment {
readonly environmentId: EnvironmentId;
@@ -146,6 +147,7 @@ function ArchivedThreadsHeader(props: {
className="border-b border-header-border bg-header px-3 pb-2.5"
style={{
paddingTop: Math.max(insets.top, 12),
borderBottomWidth: 0,
}}
>
<View className="min-h-12 flex-row items-center gap-2">
@@ -159,7 +161,7 @@ function ArchivedThreadsHeader(props: {
<SymbolView
name="chevron.left"
size={24}
tintColorClassName={"accent-foreground"}
tintColorClassName="accent-foreground"
type="monochrome"
/>
</Pressable>
@@ -167,7 +169,7 @@ function ArchivedThreadsHeader(props: {
<SymbolView
name="magnifyingglass"
size={17}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
/>
<TextInput
@@ -197,7 +199,7 @@ function ArchivedThreadsHeader(props: {
: "line.3.horizontal.decrease.circle"
}
size={16}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
/>
</Pressable>
@@ -455,7 +457,7 @@ function ArchivedThreadRow(props: {
<SymbolView
name="archivebox.fill"
size={15}
tintColorClassName={"accent-icon-subtle"}
tintColorClassName="accent-icon-subtle"
type="monochrome"
/>
</View>
@@ -477,7 +479,7 @@ function ArchivedThreadRow(props: {
<SymbolView
name="arrow.triangle.branch"
size={10}
tintColorClassName={"accent-icon-subtle"}
tintColorClassName="accent-icon-subtle"
type="monochrome"
/>
<Text
@@ -615,7 +617,7 @@ export function ArchivedThreadsScreen(props: {
if (isInitialLoad) {
return (
<View className="items-center py-16">
<ActivityIndicator colorClassName={"accent-icon"} />
<ActivityIndicator colorClassName="accent-icon" />
<Text className="mt-3 text-sm text-foreground-muted">Loading archive...</Text>
</View>
);
@@ -646,37 +648,39 @@ export function ArchivedThreadsScreen(props: {
sortOrder={props.sortOrder}
/>
<GestureDetector gesture={archiveScrollGesture}>
<LegendList
className="flex-1"
contentContainerStyle={{
paddingBottom: 32,
paddingHorizontal: 16,
paddingTop: 4,
}}
contentInsetAdjustmentBehavior="automatic"
data={listItems}
estimatedItemSize={62}
getItemType={(item) => item.kind}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
keyExtractor={(item) => item.key}
ListEmptyComponent={listEmptyComponent}
ListHeaderComponent={
props.error ? <ArchiveError message={props.error} onRetry={props.onRefresh} /> : null
}
onScrollBeginDrag={() => openSwipeableRef.current?.close()}
refreshControl={
<RefreshControl
onRefresh={props.onRefresh}
refreshing={props.isLoading && !isInitialLoad}
tintColorClassName={String("accent-icon")}
/>
}
renderItem={renderListItem}
showsVerticalScrollIndicator={false}
/>
</GestureDetector>
<SettingsScreenContent>
<GestureDetector gesture={archiveScrollGesture}>
<LegendList
className="flex-1"
contentContainerStyle={{
paddingBottom: 32,
paddingHorizontal: 16,
paddingTop: 4,
}}
contentInsetAdjustmentBehavior="automatic"
data={listItems}
estimatedItemSize={62}
getItemType={(item) => item.kind}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
keyExtractor={(item) => item.key}
ListEmptyComponent={listEmptyComponent}
ListHeaderComponent={
props.error ? <ArchiveError message={props.error} onRetry={props.onRefresh} /> : null
}
onScrollBeginDrag={() => openSwipeableRef.current?.close()}
refreshControl={
<RefreshControl
onRefresh={props.onRefresh}
refreshing={props.isLoading && !isInitialLoad}
tintColorClassName={String("accent-icon")}
/>
}
renderItem={renderListItem}
showsVerticalScrollIndicator={false}
/>
</GestureDetector>
</SettingsScreenContent>
</View>
);
}
@@ -1,8 +1,9 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { NativeHeaderToolbar } from "../../native/StackHeader";
import { useAuth } from "@clerk/expo";
import { StackActions, useNavigation } from "@react-navigation/native";
import { useCallback, useEffect, useState } from "react";
import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
import { Platform, Pressable, RefreshControl, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
@@ -6,11 +6,13 @@ import { useAtomValue } from "@effect/atom-react";
import * as Cause from "effect/Cause";
import { AsyncResult } from "effect/unstable/reactivity";
import { useCallback, useState } from "react";
import { Alert, Pressable, View } from "react-native";
import { Platform, Alert, Pressable, View } from "react-native";
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
import { MaterialButton } from "../../components/MaterialButton";
import { MaterialIconButton } from "../../components/MaterialIconButton";
import { ThemedSwitch } from "../../components/ThemedSwitch";
import { cn } from "../../lib/cn";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
@@ -142,7 +144,7 @@ export function ConnectionEnvironmentRow(props: {
<SymbolView
name="chevron.down"
size={12}
tintColorClassName={"accent-icon-subtle"}
tintColorClassName="accent-icon-subtle"
type="monochrome"
style={{
transform: [{ rotate: props.expanded ? "180deg" : "0deg" }],
@@ -193,49 +195,79 @@ export function ConnectionEnvironmentRow(props: {
</>
)}
<View className="flex-row justify-end gap-2">
{props.environment.isRelayManaged ? null : (
{Platform.OS === "android" ? (
<View className="flex-row items-center justify-end gap-2">
{props.environment.isRelayManaged ? null : (
<View className="flex-1">
<MaterialButton
label="Save"
tone="primary"
fullWidth
onPress={() => {
void handleSave();
}}
/>
</View>
)}
<MaterialIconButton
accessibilityLabel="Reconnect environment"
icon="arrow.clockwise"
variant="tonal"
disabled={!enabled}
onPress={() => props.onReconnect(props.environment.environmentId)}
/>
<MaterialIconButton
accessibilityLabel="Remove environment"
icon="trash"
variant="danger"
onPress={() => props.onRemove(props.environment.environmentId)}
/>
</View>
) : (
<View className="flex-row justify-end gap-2">
{props.environment.isRelayManaged ? null : (
<Pressable
className="min-h-[42px] flex-1 flex-row items-center justify-center gap-1.5 rounded-[14px] bg-primary px-3.5 py-2.5 active:opacity-70"
onPress={handleSave}
>
<SymbolView
name="checkmark"
size={13}
tintColorClassName="accent-primary-foreground"
type="monochrome"
/>
<Text className="text-xs font-t3-bold tracking-[0.8px] uppercase text-primary-foreground">
Save
</Text>
</Pressable>
)}
<Pressable
className="min-h-[42px] flex-1 flex-row items-center justify-center gap-1.5 rounded-[14px] bg-primary px-3.5 py-2.5 active:opacity-70"
onPress={handleSave}
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-input-border bg-input active:opacity-70 disabled:opacity-40"
disabled={!enabled}
onPress={() => props.onReconnect(props.environment.environmentId)}
>
<SymbolView
name="checkmark"
size={13}
tintColorClassName={"accent-primary-foreground"}
name="arrow.clockwise"
size={14}
tintColorClassName="accent-icon-subtle"
type="monochrome"
/>
<Text className="text-xs font-t3-bold tracking-[0.8px] uppercase text-primary-foreground">
Save
</Text>
</Pressable>
)}
<Pressable
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-input-border bg-input active:opacity-70 disabled:opacity-40"
disabled={!enabled}
onPress={() => props.onReconnect(props.environment.environmentId)}
>
<SymbolView
name="arrow.clockwise"
size={14}
tintColorClassName={"accent-icon-subtle"}
type="monochrome"
/>
</Pressable>
<Pressable
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-danger-border bg-danger active:opacity-70"
onPress={() => props.onRemove(props.environment.environmentId)}
>
<SymbolView
name="trash"
size={14}
tintColorClassName={"accent-danger-foreground"}
type="monochrome"
/>
</Pressable>
</View>
<Pressable
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-danger-border bg-danger active:opacity-70"
onPress={() => props.onRemove(props.environment.environmentId)}
>
<SymbolView
name="trash"
size={14}
tintColorClassName="accent-danger-foreground"
type="monochrome"
/>
</Pressable>
</View>
)}
</Animated.View>
) : null}
</Animated.View>
@@ -3,6 +3,7 @@ import { Platform, Pressable } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { cn } from "../../lib/cn";
import { MaterialButton } from "../../components/MaterialButton";
const CARD_SHADOW = Platform.select({
ios: {
@@ -32,8 +33,19 @@ export function ConnectionSheetButton(props: {
readonly disabled?: boolean;
readonly tone?: "primary" | "secondary" | "danger";
readonly compact?: boolean;
readonly fullWidth?: boolean;
readonly onPress: () => void;
}) {
if (Platform.OS === "android")
return (
<MaterialButton
label={props.label}
disabled={props.disabled}
onPress={props.onPress}
tone={props.tone}
fullWidth={props.fullWidth}
/>
);
const tone = props.tone ?? "secondary";
const textColorClassName =
@@ -1,13 +1,18 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { CameraView, useCameraPermissions } from "expo-camera";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import {
StackActions,
useNavigation,
useRoute,
type StaticScreenProps,
} from "@react-navigation/native";
import { AsyncResult } from "effect/unstable/reactivity";
import { useCallback, useEffect, useRef, useState } from "react";
import { Alert, Linking, Platform, ScrollView, View } from "react-native";
import { Alert, Linking, Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { ErrorBanner } from "../../components/ErrorBanner";
import { ConnectionSheetButton } from "./ConnectionSheetButton";
@@ -30,6 +35,7 @@ export function ConnectionsNewRouteScreen({
pairingConnectionError,
} = useRemoteConnections();
const navigation = useNavigation();
const routeName = useRoute().name;
const params = route.params ?? {};
// Deep-link prefill exists for development automation only. A production
// link must not arrive with attacker-chosen host and token already filled.
@@ -181,33 +187,27 @@ export function ConnectionsNewRouteScreen({
}, [connectAndClose, routePairingUrl, shouldAutoConnect]);
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SettingsScreen
formSheet={routeName === "ConnectionsNew"}
title={showScanner ? "Scan QR Code" : "Add Environment"}
actions={[
{
accessibilityLabel: showScanner ? "Close scanner" : "Scan QR code",
icon: showScanner ? "xmark" : "camera",
onPress: () => {
if (showScanner) {
closeScanner();
} else {
void openScanner();
}
},
},
]}
>
<NativeStackScreenOptions
options={{
// Android renders its own in-screen header below instead of the native bar.
...(Platform.OS === "android" ? { headerShown: false } : null),
title: showScanner ? "Scan QR Code" : "Add Environment",
}}
options={{ title: showScanner ? "Scan QR Code" : "Add Environment" }}
/>
{Platform.OS === "android" ? (
<AndroidScreenHeader
title={showScanner ? "Scan QR Code" : "Add Environment"}
onBack={() => navigation.goBack()}
actions={[
{
accessibilityLabel: showScanner ? "Close scanner" : "Scan QR code",
icon: showScanner ? "xmark" : "camera",
onPress: () => {
if (showScanner) {
closeScanner();
} else {
void openScanner();
}
},
},
]}
/>
) : (
{Platform.OS !== "android" ? (
<NativeHeaderToolbar placement="right">
<NativeHeaderToolbar.Button
icon={showScanner ? "xmark" : "qrcode.viewfinder"}
@@ -222,7 +222,7 @@ export function ConnectionsNewRouteScreen({
tintColor={headerIconColor}
/>
</NativeHeaderToolbar>
)}
) : null}
<ScrollView
contentInsetAdjustmentBehavior="automatic"
@@ -293,19 +293,21 @@ export function ConnectionsNewRouteScreen({
{pairingConnectionError ? <ErrorBanner message={pairingConnectionError} /> : null}
<ConnectionSheetButton
icon="plus"
label={isSubmitting ? "Pairing..." : "Add environment"}
disabled={connectDisabled}
tone="primary"
onPress={() => {
void handleSubmit();
}}
/>
<View className={Platform.OS === "android" ? "flex-row justify-end" : undefined}>
<ConnectionSheetButton
icon="plus"
label={isSubmitting ? "Pairing..." : "Add environment"}
disabled={connectDisabled}
tone="primary"
onPress={() => {
void handleSubmit();
}}
/>
</View>
</View>
)}
</View>
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,9 +1,10 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { NativeHeaderToolbar } from "../../native/StackHeader";
import { useNavigation } from "@react-navigation/native";
import { SymbolView } from "../../components/AppSymbol";
import type { EnvironmentId } from "@t3tools/contracts";
import { useCallback, useState } from "react";
import { Platform, ScrollView, View } from "react-native";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
@@ -1,12 +1,14 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import Constants from "expo-constants";
import * as Updates from "expo-updates";
import { useEffect, useState } from "react";
import { ActivityIndicator, Platform, Pressable, ScrollView, View } from "react-native";
import { ActivityIndicator, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text } from "../../components/AppText";
import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { SettingsSection } from "../settings/components/SettingsSection";
import {
formatStartupCrashReport,
@@ -71,7 +73,7 @@ export function SettingsDiagnosticsRouteScreen() {
};
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SettingsScreen title="Diagnostics">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentInset={{ bottom: Math.max(insets.bottom, 18) }}
@@ -115,7 +117,7 @@ export function SettingsDiagnosticsRouteScreen() {
<SymbolView
name={copied ? "checkmark" : "doc.on.doc"}
size={22}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
@@ -131,7 +133,7 @@ export function SettingsDiagnosticsRouteScreen() {
</Text>
</View>
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -145,7 +147,7 @@ function EmptyState(props: {
<SymbolView
name={props.icon}
size={28}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
@@ -0,0 +1,122 @@
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { BackHandler, Keyboard, Pressable, TextInput, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidHeaderIconButton, AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { SymbolView } from "../../components/AppSymbol";
/** Keep Files search in the same header row on compact and expanded layouts. */
export function MaterialFilesHeader(props: {
readonly projectName: string;
readonly searchQuery: string;
readonly onSearchQueryChange: (query: string) => void;
readonly onRefresh: () => void;
readonly onBack?: () => void;
readonly leading?: ReactNode;
}) {
const insets = useSafeAreaInsets();
const searchRef = useRef<TextInput>(null);
const [searchOpen, setSearchOpen] = useState(false);
const searching = searchOpen || props.searchQuery.length > 0;
const { onSearchQueryChange } = props;
const closeSearch = useCallback(() => {
onSearchQueryChange("");
setSearchOpen(false);
Keyboard.dismiss();
}, [onSearchQueryChange]);
useEffect(() => {
if (!searching) return;
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
closeSearch();
return true;
});
return () => subscription.remove();
}, [closeSearch, searching]);
return (
<View>
{/* Keep the title/subtitle's natural height, including larger text, while searching. */}
<View
pointerEvents={searching ? "none" : "auto"}
accessibilityElementsHidden={searching}
importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
style={{ opacity: searching ? 0 : 1 }}
>
<AndroidScreenHeader
title="Files"
subtitle={props.projectName}
hideBottomBorder
onBack={props.onBack}
leading={props.leading}
actions={[
{
accessibilityLabel: "Search files",
icon: "magnifyingglass",
onPress: () => setSearchOpen(true),
},
{
accessibilityLabel: "Refresh files",
icon: "arrow.clockwise",
onPress: props.onRefresh,
},
]}
/>
</View>
{searching ? (
<View
className="absolute inset-0 bg-header px-2 pb-2"
style={{ paddingTop: Math.max(insets.top, 12) }}
>
<View className="min-h-14 flex-1 flex-row items-center gap-1">
<AndroidHeaderIconButton
accessibilityLabel="Close file search"
icon="arrow.left"
onPress={closeSearch}
/>
<View className="h-12 min-w-0 flex-1 flex-row items-center gap-2 rounded-full border border-input-border bg-input px-3">
<SymbolView
name="magnifyingglass"
size={18}
tintColorClassName="accent-foreground-muted"
/>
<TextInput
ref={searchRef}
accessibilityLabel="Search files"
autoFocus
autoCapitalize="none"
autoCorrect={false}
returnKeyType="search"
placeholder="Search files"
placeholderTextColorClassName="accent-placeholder"
selectionColorClassName="accent-primary/32"
cursorColorClassName="accent-primary"
selectionHandleColorClassName="accent-primary"
className="min-w-0 flex-1 py-2 font-sans text-base text-foreground"
value={props.searchQuery}
onChangeText={onSearchQueryChange}
/>
{props.searchQuery.length > 0 ? (
<Pressable
accessibilityLabel="Clear file search"
accessibilityRole="button"
hitSlop={10}
onPress={() => {
onSearchQueryChange("");
searchRef.current?.focus();
}}
>
<SymbolView
name="xmark.circle.fill"
size={18}
tintColorClassName="accent-foreground-muted"
/>
</Pressable>
) : null}
</View>
</View>
</View>
) : null}
</View>
);
}
@@ -4,6 +4,7 @@ import type { ComponentType } from "react";
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
FlatList,
Platform,
RefreshControl,
ScrollView,
Text as NativeText,
@@ -73,6 +74,7 @@ const HighlightedSourceLine = memo(function HighlightedSourceLine(props: {
</NativeText>
<NativeText
selectable
selectionColorClassName={Platform.OS === "android" ? "accent-primary/32" : undefined}
numberOfLines={props.wordBreak ? undefined : 1}
className="flex-1 font-normal text-foreground"
style={{
@@ -102,6 +104,9 @@ const HighlightedSourceLine = memo(function HighlightedSourceLine(props: {
<NativeText
key={`${start}:${token.content.length}:${token.color ?? ""}`}
selectable
selectionColorClassName={
Platform.OS === "android" ? "accent-primary/32" : undefined
}
style={{
color: token.color ?? undefined,
fontFamily: REVIEW_MONO_FONT_FAMILY,
@@ -274,6 +279,7 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
<MarkdownTextPrimitive
uiTextView
selectable
selectionColorClassName={Platform.OS === "android" ? "accent-primary/32" : undefined}
style={{
color: foreground,
fontFamily: REVIEW_MONO_FONT_FAMILY,
@@ -15,8 +15,8 @@ import {
import { mediaFileReference } from "@t3tools/client-runtime/media-reference";
import { AndroidHeaderIconButton, AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { AppText as Text } from "../../components/AppText";
import { AudioFilePreview } from "../../components/AudioFilePreview";
import { ControlPillMenu } from "../../components/ControlPill";
import { EmptyState } from "../../components/EmptyState";
@@ -43,7 +43,10 @@ import {
createNativeMailSearchToolbarItem,
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
} from "../layout/native-mail-search-toolbar";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import {
AndroidWorkspaceSidebarButton,
WorkspaceSidebarToolbar,
} from "../layout/workspace-sidebar-toolbar";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { ThreadRouteScreen } from "../threads/ThreadRouteScreen";
import { FileMarkdownPreview } from "./FileMarkdownPreview";
@@ -52,6 +55,7 @@ import { useFileTreeEntries } from "./useFileTreeEntries";
import { preloadWorkspaceFileContents } from "./preload-workspace-file";
import { SourceFileSurface } from "./SourceFileSurface";
import { ThreadFileNavigatorPane } from "./thread-file-navigator-pane";
import { MaterialFilesHeader } from "./MaterialFilesHeader";
import { WorkspaceFileImagePreview } from "./WorkspaceFileImagePreview";
import { WorkspaceFilePreviewError } from "./WorkspaceFilePreviewError";
import { WorkspaceFileVideoPreview } from "./WorkspaceFileVideoPreview";
@@ -328,10 +332,9 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
useAdaptiveWorkspaceLayout();
const [searchQuery, setSearchQuery] = useState("");
const isAndroid = Platform.OS === "android";
const { themeAppearance: highlightTheme, materialYouStyleLayoutActive } =
useAppearancePreferences();
const { themeAppearance: highlightTheme } = useAppearancePreferences();
const theme = useUniwindTheme();
const screenColor = theme["--color-screen"];
const headerColor = theme["--color-header"];
const sheetSurfaceColor = theme["--color-sheet-solid"];
const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace(
props.route.params,
@@ -451,7 +454,7 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
<NativeStackScreenOptions
options={{
contentStyle: {
backgroundColor: materialYouStyleLayoutActive ? screenColor : sheetSurfaceColor,
backgroundColor: Platform.OS === "android" ? headerColor : sheetSurfaceColor,
},
headerShown: !isAndroid,
unstable_headerSubtitle:
@@ -484,46 +487,16 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
/>
{isAndroid ? (
<>
<AndroidScreenHeader
title="Files"
subtitle={projectName}
onBack={handleReturnToThread}
hideBottomBorder={materialYouStyleLayoutActive}
actions={[
{
accessibilityLabel: "Refresh files",
icon: "arrow.clockwise",
onPress: entriesQuery.refresh,
},
]}
/>
<View
className={
materialYouStyleLayoutActive
? "mx-4 my-2 min-h-12 flex-row items-center gap-2 rounded-full border border-input-border bg-input px-3.5"
: "flex-row items-center gap-2 border-b border-border px-3 py-2"
}
>
<SymbolView
name="magnifyingglass"
size={17}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
{
<MaterialFilesHeader
projectName={projectName}
leading={<AndroidWorkspaceSidebarButton />}
searchQuery={searchQuery}
onSearchQueryChange={setSearchQuery}
onRefresh={entriesQuery.refresh}
onBack={handleReturnToThread}
/>
<TextInput
accessibilityLabel="Search files"
autoCapitalize="none"
autoCorrect={false}
className={
materialYouStyleLayoutActive
? "min-h-10 flex-1 py-2 text-sm text-foreground"
: "min-h-10 flex-1 rounded-xl py-2 text-sm"
}
placeholder="Search files"
value={searchQuery}
onChangeText={setSearchQuery}
/>
</View>
}
</>
) : (
<>
@@ -548,26 +521,28 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
)}
</>
)}
<FileTreeBrowser
key={JSON.stringify([environmentId, cwd])}
entries={entriesQuery.entries}
loadedDirectories={entriesQuery.loadedDirectories}
onLoadDirectory={entriesQuery.loadDirectory}
error={entriesQuery.error}
isPending={entriesQuery.isPending}
searchQuery={searchQuery}
searchTruncated={entriesQuery.searchTruncated}
selectedPath={null}
onPreviewFile={handlePreviewFile}
onRefresh={entriesQuery.refresh}
onSelectFile={handleSelectFile}
/>
<FilesToolbarBottomFade />
<MaterialScreenContent insetHorizontal={layout.usesSplitView}>
<FileTreeBrowser
key={JSON.stringify([environmentId, cwd])}
entries={entriesQuery.entries}
loadedDirectories={entriesQuery.loadedDirectories}
onLoadDirectory={entriesQuery.loadDirectory}
error={entriesQuery.error}
isPending={entriesQuery.isPending}
searchQuery={searchQuery}
searchTruncated={entriesQuery.searchTruncated}
selectedPath={null}
onPreviewFile={handlePreviewFile}
onRefresh={entriesQuery.refresh}
onSelectFile={handleSelectFile}
/>
<FilesToolbarBottomFade />
</MaterialScreenContent>
</>
);
return materialYouStyleLayoutActive ? (
<View className="flex-1" style={{ backgroundColor: screenColor }}>
return Platform.OS === "android" ? (
<View className="flex-1" style={{ backgroundColor: headerColor }}>
{content}
</View>
) : (
@@ -933,6 +908,8 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
<AndroidScreenHeader
title={basename(relativePath)}
subtitle={headerSubtitle}
leading={<AndroidWorkspaceSidebarButton />}
hideBottomBorder
onBack={handleBack}
trailing={
<>
@@ -942,6 +919,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
panes.auxiliaryPaneVisible ? "Hide file navigator" : "Show file navigator"
}
icon="sidebar.right"
selected={panes.auxiliaryPaneVisible}
onPress={toggleAuxiliaryPane}
/>
) : null}
@@ -1007,25 +985,27 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
))}
</NativeHeaderToolbar.Menu>
</NativeHeaderToolbar>
<FileContent
key={previewKey}
activeMode={resolvedActiveMode}
cwd={cwd}
environmentId={environmentId}
previewUri={previewUri}
previewFailure={assetPreview._tag === "Failure" ? assetPreview.reason : null}
onRetryPreview={handleRetryPreview}
videoSource={videoSource}
mediaSource={mediaSource}
resolveVideoUri={assetPreview.refresh}
fileContents={fileData?.contents ?? null}
fileError={fileQuery.error}
initialLine={targetLine}
relativePath={relativePath}
threadId={threadId}
truncated={fileData?.truncated ?? false}
onRefresh={() => fileQuery.refresh()}
/>
<MaterialScreenContent>
<FileContent
key={previewKey}
activeMode={resolvedActiveMode}
cwd={cwd}
environmentId={environmentId}
previewUri={previewUri}
previewFailure={assetPreview._tag === "Failure" ? assetPreview.reason : null}
onRetryPreview={handleRetryPreview}
videoSource={videoSource}
mediaSource={mediaSource}
resolveVideoUri={assetPreview.refresh}
fileContents={fileData?.contents ?? null}
fileError={fileQuery.error}
initialLine={targetLine}
relativePath={relativePath}
threadId={threadId}
truncated={fileData?.truncated ?? false}
onRefresh={() => fileQuery.refresh()}
/>
</MaterialScreenContent>
<FilePreviewModal
source={fullScreenPreview}
onRequestClose={() => setFullScreenPreview(null)}
@@ -1,5 +1,6 @@
import type { EnvironmentId } from "@t3tools/contracts";
import { SymbolView } from "../../components/AppSymbol";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { useCallback, useMemo, useState, type ComponentProps } from "react";
import { Platform, Pressable, View, type NativeSyntheticEvent } from "react-native";
import {
@@ -11,6 +12,7 @@ import {
} from "react-native-screens";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { MaterialFilesHeader } from "./MaterialFilesHeader";
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
@@ -149,59 +151,68 @@ export function ThreadFileNavigatorPane(props: {
}
return (
<View className="flex-1 border-l border-border bg-sheet">
<View className="border-b border-border" style={{ paddingTop: props.headerInset }}>
<View className="h-12 flex-row items-center gap-2 px-3">
<View className="min-w-0 flex-1">
<Text className="text-sm font-t3-bold text-foreground">Files</Text>
<Text className="text-xs text-foreground-muted" numberOfLines={1}>
{props.projectName}
</Text>
<View
className={
Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-l border-border bg-sheet"
}
>
<View
className={Platform.OS === "android" ? "bg-header" : "border-b border-border"}
style={{ paddingTop: Platform.OS === "android" ? 0 : props.headerInset }}
>
{Platform.OS === "android" ? (
<MaterialFilesHeader
projectName={props.projectName}
searchQuery={searchQuery}
onSearchQueryChange={setSearchQuery}
onRefresh={entriesQuery.refresh}
/>
) : (
<View className="h-12 flex-row items-center gap-2 px-3">
<View className="min-w-0 flex-1">
<Text className="text-sm font-t3-bold text-foreground">Files</Text>
<Text className="text-xs text-foreground-muted" numberOfLines={1}>
{props.projectName}
</Text>
</View>
<Pressable
accessibilityRole="button"
accessibilityLabel="Refresh files"
hitSlop={8}
className="h-8 w-8 items-center justify-center rounded-full active:bg-subtle"
onPress={entriesQuery.refresh}
>
<SymbolView
name="arrow.clockwise"
size={14}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
</Pressable>
</View>
<Pressable
accessibilityRole="button"
accessibilityLabel="Refresh files"
hitSlop={8}
className="h-8 w-8 items-center justify-center rounded-full active:bg-subtle"
onPress={entriesQuery.refresh}
>
)}
{Platform.OS !== "android" ? (
<View className="flex-row items-center gap-2 border-t border-border px-3 py-2">
<SymbolView
name="arrow.clockwise"
size={14}
tintColorClassName={"accent-icon-muted"}
name="magnifyingglass"
size={15}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel="Close files"
hitSlop={8}
className="h-8 w-8 items-center justify-center rounded-full active:bg-subtle"
onPress={toggleAuxiliaryPane}
>
<SymbolView name="xmark" size={14} tintColorClassName="accent-icon-muted" />
</Pressable>
</View>
<View className="flex-row items-center gap-2 border-t border-border px-3 py-2">
<SymbolView
name="magnifyingglass"
size={15}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
/>
<TextInput
accessibilityLabel="Search files"
autoCapitalize="none"
autoCorrect={false}
clearButtonMode="while-editing"
className="min-h-10 flex-1 rounded-xl py-2 text-sm"
placeholder="Search files"
value={searchQuery}
onChangeText={setSearchQuery}
/>
</View>
<TextInput
accessibilityLabel="Search files"
autoCapitalize="none"
autoCorrect={false}
clearButtonMode="while-editing"
className="min-h-10 flex-1 rounded-xl py-2 text-sm"
placeholder="Search files"
value={searchQuery}
onChangeText={setSearchQuery}
/>
</View>
) : null}
</View>
{fileTree}
<MaterialScreenContent insetHorizontal>{fileTree}</MaterialScreenContent>
</View>
);
}
@@ -0,0 +1,44 @@
import { useCallback, useRef, useState, type ComponentProps } from "react";
import { View, type NativeScrollEvent, type NativeSyntheticEvent } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { MaterialNewThreadButton } from "../../components/MaterialNewThreadButton";
import type { AndroidHomeFabLayout as SharedAndroidHomeFabLayout } from "./AndroidHomeFab.shared";
import { useWorkspaceState } from "../../state/workspace";
import { MaterialFabScrollContext } from "./MaterialFabScrollContext";
import { updateMaterialFabScroll } from "./material-fab-scroll";
export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidHomeFabLayout>) {
const insets = useSafeAreaInsets();
const { state } = useWorkspaceState();
const [expanded, setExpanded] = useState(true);
const scrollState = useRef({ anchor: 0, expanded: true });
const onScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
const next = updateMaterialFabScroll(
scrollState.current,
contentOffset.y,
contentSize.height - layoutMeasurement.height,
);
if (next.expanded !== scrollState.current.expanded) setExpanded(next.expanded);
scrollState.current = next;
}, []);
return (
<View className="flex-1">
<MaterialFabScrollContext value={onScroll}>{props.children}</MaterialFabScrollContext>
{state.hasConnections ? (
<MaterialNewThreadButton
extended
expanded={expanded}
onPress={props.onStartNewTask}
className="absolute right-5"
style={{
bottom: props.sidebar
? Math.max(insets.bottom, 12) + 6
: Math.max(insets.bottom, 16) + 16,
}}
/>
) : null}
</View>
);
}
@@ -0,0 +1,10 @@
import type { ReactNode } from "react";
/** Other platforms render the list without Android's floating action button. */
export function AndroidHomeFabLayout(props: {
readonly onStartNewTask: () => void;
readonly children: ReactNode;
readonly sidebar?: boolean;
}) {
return <>{props.children}</>;
}
@@ -1,48 +1 @@
import type { ReactNode } from "react";
import { Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/AppSymbol";
/**
* Android-only wrapper that overlays a bottom-right new-task FAB on a thread
* list. Other platforms render children unchanged.
*/
export function AndroidHomeFabLayout(props: {
readonly onStartNewTask: () => void;
readonly children: ReactNode;
}) {
if (Platform.OS !== "android") {
return <>{props.children}</>;
}
return <AndroidHomeFab {...props} />;
}
function AndroidHomeFab(props: {
readonly onStartNewTask: () => void;
readonly children: ReactNode;
}) {
const insets = useSafeAreaInsets();
return (
<View className="flex-1">
{props.children}
<Pressable
accessibilityLabel="New task"
accessibilityRole="button"
onPress={props.onStartNewTask}
className="absolute right-5 size-14 items-center justify-center rounded-full bg-primary shadow-lg"
style={{
bottom: Math.max(insets.bottom, 16) + 16,
}}
>
<SymbolView
name="square.and.pencil"
size={22}
tintColorClassName={"accent-primary-foreground"}
type="monochrome"
/>
</Pressable>
</View>
);
}
export { AndroidHomeFabLayout } from "./AndroidHomeFab.shared";
+12 -127
View File
@@ -1,18 +1,11 @@
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
import type { MenuAction } from "@react-native-menu/menu";
import Constants from "expo-constants";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import { useCallback, useMemo, useRef } from "react";
import { Platform, Pressable, Text as RNText, TextInput, View } from "react-native";
import { Platform } from "react-native";
import type { SearchBarCommands } from "react-native-screens";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { ControlPillMenu } from "../../components/ControlPill";
import { SymbolView } from "../../components/AppSymbol";
import { T3Wordmark } from "../../components/T3Wordmark";
import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
import { resolveMobileStageLabel } from "../../lib/mobileBranding";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
@@ -22,7 +15,7 @@ import {
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
} from "../layout/native-mail-search-toolbar";
import type { HomeProjectSortOrder } from "./homeThreadList";
import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
import { MaterialThreadListToolbar } from "./MaterialThreadListToolbar";
import {
buildHomeListFilterMenu,
type HomeListFilterMenuEnvironment,
@@ -67,9 +60,6 @@ function checkedMenuState(checked: boolean) {
}
function AndroidHomeHeader(props: HomeHeaderProps) {
const { materialYouStyleLayoutActive } = useAppearancePreferences();
const insets = useSafeAreaInsets();
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
// Thread List v2 lays the list out in fixed creation order, so the
// sort/group filter controls would be silently ignored — hide them and
// key the "customized" icon state off the environment filter alone.
@@ -200,120 +190,15 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
return (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<View
className={
materialYouStyleLayoutActive
? "bg-header pb-3"
: "border-b border-header-border bg-header pb-3"
}
style={{
paddingHorizontal: HOME_HORIZONTAL_INSET,
paddingTop: Math.max(insets.top, 12),
}}
>
<View className="w-full max-w-[720px] self-center gap-3">
<View className="flex-row items-center gap-2.5">
{/* Brand slot doubles as the connection status surface: while an
environment reconnects, the lockup fades to a status label in
place (no layout shift in the list below). */}
<WorkspaceConnectionTitle
grow
onPress={props.onOpenEnvironments}
brand={
<View className="flex-row items-center gap-2">
{/* Mirrors the desktop SidebarBrand: T3 mark + muted "Code". */}
<T3Wordmark colorClassName="accent-icon" height={15} />
<RNText className="-ml-0.5 text-[21px] font-t3-medium tracking-[-0.5px] text-foreground-muted">
Code
</RNText>
<View className="rounded-full bg-subtle px-2 py-0.75">
<RNText className="text-[11px] font-t3-bold tracking-[1.1px] text-foreground-muted uppercase">
{stageLabel}
</RNText>
</View>
</View>
}
/>
<ControlPillMenu
actions={menuActions}
isAnchoredToRight
onPressAction={handleMenuAction}
>
<Pressable
accessibilityLabel="Filter and sort threads"
accessibilityRole="button"
className="size-11 items-center justify-center rounded-full bg-subtle"
>
<SymbolView
name={
hasCustomListOptions
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle"
}
size={16}
tintColorClassName={"accent-icon"}
type="monochrome"
/>
</Pressable>
</ControlPillMenu>
{/* Built identically to the filter button so the two circles
match exactly (ControlPill sizes via Tailwind classes and
resolves to a different box). */}
<Pressable
accessibilityLabel="Open settings"
accessibilityRole="button"
onPress={props.onOpenSettings}
className="size-11 items-center justify-center rounded-full bg-subtle"
>
<SymbolView
name="gearshape"
size={18}
tintColorClassName={"accent-icon"}
type="monochrome"
/>
</Pressable>
</View>
<View
className={
materialYouStyleLayoutActive
? "min-h-12 flex-row items-center gap-2.5 rounded-full border border-input-border bg-input px-3.5"
: "min-h-12 flex-row items-center gap-2.5 rounded-2xl border border-input-border bg-input px-3.5"
}
>
<SymbolView
name="magnifyingglass"
size={17}
tintColorClassName={"accent-foreground-muted"}
type="monochrome"
/>
<TextInput
accessibilityLabel="Search threads"
autoCapitalize="none"
onChangeText={props.onSearchQueryChange}
placeholder="Search threads"
placeholderTextColorClassName="accent-placeholder"
className="flex-1 py-2.5 text-base font-sans text-foreground"
value={props.searchQuery}
/>
{props.searchQuery.length > 0 ? (
<Pressable
accessibilityLabel="Clear search"
hitSlop={10}
onPress={() => props.onSearchQueryChange("")}
>
<SymbolView
name="xmark.circle.fill"
size={17}
tintColorClassName={"accent-foreground-muted"}
type="monochrome"
/>
</Pressable>
) : null}
</View>
</View>
</View>
<MaterialThreadListToolbar
searchQuery={props.searchQuery}
onSearchQueryChange={props.onSearchQueryChange}
filterActions={menuActions}
filterCustomized={hasCustomListOptions}
onFilterAction={handleMenuAction}
onOpenSettings={props.onOpenSettings}
onOpenEnvironments={props.onOpenEnvironments}
/>
</>
);
}
@@ -11,7 +11,11 @@ import { useWorkspaceState } from "../../state/workspace";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import {
AndroidWorkspaceSidebarButton,
WorkspaceSidebarToolbar,
} from "../layout/workspace-sidebar-toolbar";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { checkForAppUpdateOnLaunch, startAppUpdateForegroundRecheck } from "../updates/app-updates";
import { AndroidHomeFabLayout } from "./AndroidHomeFab";
import { HomeScreen } from "./HomeScreen";
@@ -27,7 +31,7 @@ import { getConnectionAwareBrandHeaderOptions } from "./WorkspaceConnectionTitle
export function HomeRouteScreen() {
const { width: windowWidth } = useWindowDimensions();
const { layout } = useAdaptiveWorkspaceLayout();
const { layout, panes } = useAdaptiveWorkspaceLayout();
const projects = useProjects();
const threads = useThreadShells();
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
@@ -126,8 +130,24 @@ export function HomeRouteScreen() {
/>
}
/>
{Platform.OS === "android" ? (
<AndroidScreenHeader title="Threads" leading={<AndroidWorkspaceSidebarButton />} />
) : null}
<WorkspaceEmptyDetail
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
onAddConnection={
Platform.OS === "android" && !catalogState.hasConnections
? () =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: "SettingsEnvironmentNew" },
})
: undefined
}
onStartNewTask={
Platform.OS === "android" && panes.primarySidebarVisible
? undefined
: () => navigation.navigate("NewTaskSheet", { screen: "NewTask" })
}
/>
</>
);
+58 -14
View File
@@ -30,13 +30,13 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { cn } from "../../lib/cn";
import { AppText as Text } from "../../components/AppText";
import { EmptyState } from "../../components/EmptyState";
import { MaterialFloatingActionButton } from "../../components/MaterialFloatingActionButton";
import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
import type { SavedRemoteConnection } from "../../lib/connection";
import { scopedProjectKey } from "../../lib/scopedEntities";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { useThreadSearch } from "../../state/queries";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import { usePendingThreadOrder } from "../../state/thread-order";
@@ -83,6 +83,7 @@ import {
type HomeProjectSortOrder,
} from "./homeThreadList";
import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "./thread-swipe-actions";
import { useMaterialFabScroll } from "./MaterialFabScrollContext";
/* ─── Types ──────────────────────────────────────────────────────────── */
@@ -219,7 +220,6 @@ function HomeTopContentSpacer() {
/* ─── Main screen ────────────────────────────────────────────────────── */
export function HomeScreen(props: HomeScreenProps) {
const { materialYouStyleLayoutActive } = useAppearancePreferences();
const [groupDisplayStates, setGroupDisplayStates] = useState<
ReadonlyMap<string, HomeGroupDisplayState>
>(() => new Map());
@@ -315,7 +315,9 @@ export function HomeScreen(props: HomeScreenProps) {
const handleScrollBeginDrag = useCallback(() => {
openSwipeableRef.current?.close();
}, []);
const onMaterialFabScroll = useMaterialFabScroll();
const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
onScroll: onMaterialFabScroll,
onScrollBeginDrag: handleScrollBeginDrag,
});
@@ -1104,11 +1106,11 @@ export function HomeScreen(props: HomeScreenProps) {
if (!hasAnyThreads) {
return (
<View className={materialYouStyleLayoutActive ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View
className={cn(
"flex-1 items-center justify-center bg-screen px-8",
materialYouStyleLayoutActive && "overflow-hidden rounded-t-[28px]",
Platform.OS === "android" && "overflow-hidden rounded-t-[28px]",
)}
style={{
paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
@@ -1121,11 +1123,22 @@ export function HomeScreen(props: HomeScreenProps) {
detail={emptyState.detail}
actionLabel={!props.catalogState.hasReadyEnvironment ? "Add environment" : undefined}
onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
action={
Platform.OS === "android" && !props.catalogState.hasReadyEnvironment ? (
<MaterialFloatingActionButton
label="Add environment"
icon="plus"
variant="extended"
tone="primary"
onPress={props.onAddConnection}
/>
) : undefined
}
variant="plain"
/>
{emptyState.loading ? (
<View className="mt-4 items-center">
<ActivityIndicator colorClassName={"accent-icon-muted"} />
<ActivityIndicator colorClassName="accent-icon-muted" />
</View>
) : null}
</View>
@@ -1142,41 +1155,72 @@ export function HomeScreen(props: HomeScreenProps) {
const listEmpty = !hasResults ? (
hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
<EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
<EmptyState
title="No results"
detail={`No threads matching "${props.searchQuery}".`}
variant={Platform.OS === "android" ? "plain" : undefined}
/>
) : selectedProjectScope !== null ? (
<EmptyState
title={`No threads in ${selectedProjectScope.title}`}
detail="Choose another project or create a new task."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
) : selectedEnvironmentLabel ? (
<EmptyState
title={`No threads in ${selectedEnvironmentLabel}`}
detail="Choose another environment or create a new task."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
) : (
<EmptyState title="No threads yet" detail="Create a task to start a new coding session." />
<EmptyState
title="No threads yet"
detail="Create a task to start a new coding session."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
)
) : null;
// Use the v2 project scope for its empty state. Snoozed threads need no
// special empty state: their shelf header is a list row even while collapsed.
const v2ListEmpty =
hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
<EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
<EmptyState
title="No results"
detail={`No threads matching "${props.searchQuery}".`}
variant={Platform.OS === "android" ? "plain" : undefined}
/>
) : v2ScopedProjectGroup !== null ? (
<EmptyState
title={`No threads in ${v2ScopedProjectGroup.title}`}
detail="Choose another project or create a new task."
variant={Platform.OS === "android" ? "plain" : undefined}
/>
) : (
listEmpty
);
if (
Platform.OS === "android" &&
(threadListV2Enabled ? threadListV2Items.length === 0 : listLayout.items.length === 0)
) {
return (
<View className="flex-1 bg-header">
<View
className="flex-1 items-center justify-center overflow-hidden rounded-t-[28px] bg-screen px-4"
style={{ paddingBottom: insets.bottom }}
>
{threadListV2Enabled ? v2ListEmpty : listEmpty}
</View>
</View>
);
}
if (threadListV2Enabled) {
return (
<View className={materialYouStyleLayoutActive ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View
className={
materialYouStyleLayoutActive
Platform.OS === "android"
? "flex-1 overflow-hidden rounded-t-[28px] bg-screen"
: "flex-1 bg-screen"
}
@@ -1216,7 +1260,7 @@ export function HomeScreen(props: HomeScreenProps) {
paddingBottom:
Platform.OS === "ios"
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
: Math.max(insets.bottom, 16) + 88,
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? 148 : 88),
}}
/>
</SwipeableScrollGateProvider>
@@ -1226,10 +1270,10 @@ export function HomeScreen(props: HomeScreenProps) {
}
return (
<View className={materialYouStyleLayoutActive ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
<View
className={
materialYouStyleLayoutActive
Platform.OS === "android"
? "flex-1 overflow-hidden rounded-t-[28px] bg-screen"
: "flex-1 bg-screen"
}
@@ -1270,7 +1314,7 @@ export function HomeScreen(props: HomeScreenProps) {
paddingBottom:
Platform.OS === "ios"
? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
: Math.max(insets.bottom, 16) + 88,
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? 148 : 88),
}}
scrollIndicatorInsets={
Platform.OS === "ios"
@@ -0,0 +1,10 @@
import { createContext, useContext } from "react";
import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native";
export const MaterialFabScrollContext = createContext<
((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined
>(undefined);
export function useMaterialFabScroll() {
return useContext(MaterialFabScrollContext);
}
@@ -0,0 +1,178 @@
import { useCallback, useEffect, useRef, useState, type ComponentProps } from "react";
import {
BackHandler,
Keyboard,
Pressable,
TextInput,
View,
type LayoutChangeEvent,
} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { MenuAction } from "@react-native-menu/menu";
import { AndroidHeaderIconButton } from "../../components/AndroidScreenHeader";
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
import { MaterialFloatingActionButton } from "../../components/MaterialFloatingActionButton";
import { AndroidAnchoredMenu } from "../../components/AndroidAnchoredMenu";
import { ControlPillMenu } from "../../components/ControlPill";
import { SymbolView } from "../../components/AppSymbol";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
import { useWorkspaceState } from "../../state/workspace";
import { useMaterialToolbarHeight } from "../../components/useMaterialToolbarHeight";
/** One toolbar height for the compact list and expanded sidebar, including search. */
export function MaterialThreadListToolbar(props: {
readonly searchQuery: string;
readonly onSearchQueryChange: (query: string) => void;
readonly filterActions: MenuAction[];
readonly filterCustomized: boolean;
readonly onFilterAction: NonNullable<ComponentProps<typeof ControlPillMenu>["onPressAction"]>;
readonly onOpenSettings: () => void;
readonly onOpenEnvironments: () => void;
readonly sidebar?: boolean;
readonly onLayout?: (event: LayoutChangeEvent) => void;
readonly onRequestVisibility?: () => void;
}) {
const insets = useSafeAreaInsets();
const toolbarHeight = useMaterialToolbarHeight();
const { state } = useWorkspaceState();
const { onRequestVisibility, onSearchQueryChange } = props;
const searchRef = useRef<TextInput>(null);
const [searchOpen, setSearchOpen] = useState(false);
const searching = searchOpen || props.searchQuery.length > 0;
const openSearch = useCallback(() => {
onRequestVisibility?.();
setSearchOpen(true);
searchRef.current?.focus();
return true;
}, [onRequestVisibility]);
useHardwareKeyboardCommand("focusSearch", openSearch);
const closeSearch = useCallback(() => {
onSearchQueryChange("");
setSearchOpen(false);
Keyboard.dismiss();
}, [onSearchQueryChange]);
useEffect(() => {
if (!searching) return;
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
closeSearch();
return true;
});
return () => subscription.remove();
}, [closeSearch, searching]);
const filterIcon = props.filterCustomized
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle";
const searchField = (
<View className="h-12 min-w-0 flex-1 flex-row items-center gap-2 rounded-full border border-input-border bg-input px-3">
<SymbolView name="magnifyingglass" size={18} tintColorClassName="accent-foreground-muted" />
<TextInput
ref={searchRef}
accessibilityLabel="Search threads"
autoFocus={true}
autoCapitalize="none"
autoCorrect={false}
returnKeyType="search"
placeholder="Search"
placeholderTextColorClassName="accent-placeholder"
selectionColorClassName="accent-primary/32"
cursorColorClassName="accent-primary"
selectionHandleColorClassName="accent-primary"
className="min-w-0 flex-1 py-2 font-sans text-base text-foreground"
value={props.searchQuery}
onChangeText={onSearchQueryChange}
/>
{props.searchQuery.length > 0 ? (
<Pressable
accessibilityLabel="Clear search"
accessibilityRole="button"
hitSlop={10}
onPress={() => {
props.onSearchQueryChange("");
searchRef.current?.focus();
}}
>
<SymbolView
name="xmark.circle.fill"
size={18}
tintColorClassName="accent-foreground-muted"
/>
</Pressable>
) : null}
</View>
);
return (
<>
<View
onLayout={props.onLayout}
className={
props.sidebar
? "absolute inset-x-0 top-0 z-[4] bg-header px-2 pb-2"
: "bg-header px-2 pb-2"
}
style={{ paddingTop: Math.max(insets.top, 12) }}
>
<View className="flex-row items-center gap-1" style={{ minHeight: toolbarHeight }}>
{searching ? (
<>
<AndroidHeaderIconButton
accessibilityLabel="Close search"
icon="arrow.left"
onPress={closeSearch}
/>
{searchField}
</>
) : (
<>
{/* Match the visible inset of the trailing 48dp icon button. */}
<View className="min-w-0 flex-1 pl-4">
<WorkspaceConnectionTitle
grow
onPress={props.onOpenEnvironments}
brand={<CompactBrandTitle allowFontScaling={false} />}
/>
</View>
<AndroidHeaderIconButton
accessibilityLabel="Search threads"
icon="magnifyingglass"
onPress={openSearch}
/>
<AndroidHeaderIconButton
accessibilityLabel="Open settings"
icon="gearshape"
onPress={props.onOpenSettings}
/>
</>
)}
</View>
</View>
{/* Sit 8dp above the 56dp extended New thread FAB. */}
{state.hasConnections ? (
<View
className="absolute right-5 z-[5]"
style={{
bottom:
(props.sidebar ? Math.max(insets.bottom, 12) + 6 : Math.max(insets.bottom, 16) + 16) +
56 +
8,
}}
>
<AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
{(open) => (
<MaterialFloatingActionButton
label="Filter and sort threads"
icon={filterIcon}
onPress={open}
/>
)}
</AndroidAnchoredMenu>
</View>
) : null}
</>
);
}
@@ -0,0 +1,40 @@
import { describe, expect, it } from "vite-plus/test";
import { updateMaterialFabScroll, type MaterialFabScrollState } from "./material-fab-scroll";
describe("Material FAB scroll direction", () => {
const initial: MaterialFabScrollState = { anchor: 0, expanded: true };
it("shrinks scrolling down and expands scrolling up without returning to the top", () => {
const collapsed = updateMaterialFabScroll(initial, 80, 500);
expect(collapsed.expanded).toBe(false);
const lower = updateMaterialFabScroll(collapsed, 180, 500);
expect(lower.expanded).toBe(false);
expect(updateMaterialFabScroll(lower, 160, 500).expanded).toBe(true);
});
it("accumulates travel but ignores jitter around a direction change", () => {
let state = updateMaterialFabScroll(initial, 10, 500);
expect(state.expanded).toBe(true);
state = updateMaterialFabScroll(state, 14, 500);
expect(state.expanded).toBe(false);
state = updateMaterialFabScroll(state, 100, 500);
state = updateMaterialFabScroll(state, 95, 500);
state = updateMaterialFabScroll(state, 98, 500);
expect(state.expanded).toBe(false);
expect(updateMaterialFabScroll(state, 88, 500).expanded).toBe(true);
});
it("does not expand from bottom bounce or collapse from top bounce", () => {
const bottom = updateMaterialFabScroll(initial, 500, 500);
const bounce = updateMaterialFabScroll(bottom, 560, 500);
expect(updateMaterialFabScroll(bounce, 500, 500).expanded).toBe(false);
expect(updateMaterialFabScroll(initial, -50, 500)).toEqual(initial);
});
it("expands near the top and when filtering leaves a non-scrollable list", () => {
const collapsed = updateMaterialFabScroll(initial, 80, 500);
expect(updateMaterialFabScroll(collapsed, 5, 500).expanded).toBe(true);
expect(updateMaterialFabScroll(collapsed, 80, -20)).toEqual(initial);
});
});
@@ -0,0 +1,17 @@
export interface MaterialFabScrollState {
readonly anchor: number;
readonly expanded: boolean;
}
/** Ignore small direction changes and overscroll; always show the label at the top. */
export function updateMaterialFabScroll(
state: MaterialFabScrollState,
offset: number,
maxOffset: number,
): MaterialFabScrollState {
const y = Math.max(0, Math.min(offset, Math.max(0, maxOffset)));
if (y <= 8) return { anchor: y, expanded: true };
const anchor = state.expanded ? Math.min(state.anchor, y) : Math.max(state.anchor, y);
if (Math.abs(y - anchor) >= 12) return { anchor: y, expanded: !state.expanded };
return { anchor, expanded: state.expanded };
}
@@ -22,7 +22,7 @@ import {
useState,
type ReactNode,
} from "react";
import { useWindowDimensions, View } from "react-native";
import { Platform, useWindowDimensions, View } from "react-native";
import Animated, {
useAnimatedStyle,
useDerivedValue,
@@ -56,7 +56,6 @@ import {
} from "../keyboard/hardwareKeyboardCommands";
import { AndroidHomeFabLayout } from "../home/AndroidHomeFab";
import { HomeListOptionsProvider } from "../home/home-list-options";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar";
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
@@ -234,7 +233,6 @@ function AdaptiveWorkspaceLayoutContent(
},
) {
const projectGroupingMode = props.projectGroupingMode;
const { materialYouStyleLayoutActive } = useAppearancePreferences();
const { width, height } = useWindowDimensions();
const pathname = props.pathname;
const navigation = useNavigation();
@@ -582,7 +580,7 @@ function AdaptiveWorkspaceLayoutContent(
style={sidebarAnimatedStyle}
>
<View className="flex-1" style={{ width: layout.listPaneWidth }}>
<AndroidHomeFabLayout onStartNewTask={handleStartNewTask}>
<AndroidHomeFabLayout sidebar onStartNewTask={handleStartNewTask}>
<ThreadNavigationSidebar
width={layout.listPaneWidth}
visible={panes.primarySidebarVisible}
@@ -602,7 +600,7 @@ function AdaptiveWorkspaceLayoutContent(
) : null}
<View
className={
materialYouStyleLayoutActive
Platform.OS === "android"
? "flex-1 overflow-hidden bg-header"
: "flex-1 overflow-hidden bg-screen"
}
@@ -611,7 +609,12 @@ function AdaptiveWorkspaceLayoutContent(
<View
collapsable={false}
style={
contentSettledWidth !== null ? { flex: 1, width: contentSettledWidth } : { flex: 1 }
contentSettledWidth !== null
? {
flex: 1,
width: contentSettledWidth,
}
: { flex: 1 }
}
>
<WorkspaceContentWidthContext
@@ -1,40 +1,69 @@
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { SymbolView } from "../../components/AppSymbol";
import { Pressable, View } from "react-native";
import { Platform, Pressable, View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { MaterialNewThreadButton } from "../../components/MaterialNewThreadButton";
import { MaterialFloatingActionButton } from "../../components/MaterialFloatingActionButton";
import { EmptyState } from "../../components/EmptyState";
export function WorkspaceEmptyDetail(props: { readonly onStartNewTask?: () => void }) {
const { materialYouStyleLayoutActive } = useAppearancePreferences();
export function WorkspaceEmptyDetail(props: {
readonly onStartNewTask?: () => void;
readonly onAddConnection?: () => void;
}) {
return (
<View
className={
materialYouStyleLayoutActive
Platform.OS === "android"
? "flex-1 items-center justify-center px-10"
: "flex-1 items-center justify-center bg-screen px-10"
}
>
<View className="max-w-[360px] items-center gap-3">
<SymbolView
name="sidebar.left"
size={34}
tintColorClassName={"accent-icon-subtle"}
type="hierarchical"
/>
<Text className="text-center text-xl font-t3-bold">Select a thread</Text>
<Text className="text-center text-base text-foreground-muted">
Choose a thread from the sidebar or start a new task.
</Text>
{props.onStartNewTask ? (
<Pressable
accessibilityRole="button"
className="mt-2 flex-row items-center gap-2 rounded-full bg-primary px-5 py-3 active:opacity-70"
onPress={props.onStartNewTask}
>
<Text className="text-base font-t3-bold text-primary-foreground">New Task</Text>
</Pressable>
) : null}
</View>
{props.onAddConnection ? (
<View className="w-full max-w-[430px]">
<EmptyState
title="No environments connected"
detail="Add an environment to load projects and start coding sessions."
variant="plain"
action={
<MaterialFloatingActionButton
label="Add environment"
icon="plus"
variant="extended"
tone="primary"
onPress={props.onAddConnection}
/>
}
/>
</View>
) : (
<View className="max-w-[360px] items-center gap-3">
<SymbolView
name="sidebar.left"
size={34}
tintColorClassName="accent-icon-subtle"
type="hierarchical"
/>
<Text className="text-center text-xl font-t3-bold">Select a thread</Text>
<Text className="text-center text-base text-foreground-muted">
{Platform.OS === "android"
? "Choose a thread from the sidebar or start a new thread."
: "Choose a thread from the sidebar or start a new task."}
</Text>
{props.onStartNewTask ? (
Platform.OS === "android" ? (
<MaterialNewThreadButton extended className="mt-2" onPress={props.onStartNewTask} />
) : (
<Pressable
accessibilityRole="button"
className="mt-2 flex-row items-center gap-2 rounded-full bg-primary px-5 py-3 active:opacity-70"
onPress={props.onStartNewTask}
>
<Text className="text-base font-t3-bold text-primary-foreground">New Task</Text>
</Pressable>
)
) : null}
</View>
)}
</View>
);
}
@@ -1,5 +1,5 @@
import { useCallback, useMemo, useRef, useState } from "react";
import { Pressable, StyleSheet, View, type AccessibilityActionEvent } from "react-native";
import { Platform, Pressable, StyleSheet, View, type AccessibilityActionEvent } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { runOnJS } from "react-native-reanimated";
import { cn } from "../../lib/cn";
@@ -79,6 +79,7 @@ export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) {
className={cn(
"h-full self-center bg-border opacity-70",
dragging ? "w-0.5 bg-primary opacity-100" : "w-px",
Platform.OS === "android" && !dragging && "opacity-0",
)}
style={[styles.line, dragging && styles.activeLine]}
/>
@@ -2,8 +2,26 @@ import { NativeHeaderToolbar } from "../../native/StackHeader";
import type { ReactNode } from "react";
import { Platform } from "react-native";
import { AndroidHeaderIconButton } from "../../components/AndroidScreenHeader";
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
export function AndroidWorkspaceSidebarButton() {
const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
if (Platform.OS !== "android" || !layout.usesSplitView) return null;
return (
<AndroidHeaderIconButton
accessibilityLabel={
panes.primarySidebarVisible ? "Hide thread sidebar" : "Show thread sidebar"
}
icon="sidebar.left"
selected={panes.primarySidebarVisible}
onPress={togglePrimarySidebar}
/>
);
}
export function WorkspaceSidebarToolbar(
props: {
readonly children?: ReactNode;
@@ -1,3 +1,7 @@
import { MaterialListRow } from "../../components/MaterialListRow";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { MaterialButton } from "../../components/MaterialButton";
import {
addProjectRemoteSourceLabel,
addProjectRemoteSourcePathHint,
@@ -41,14 +45,13 @@ import {
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
import { SymbolView } from "../../components/AppSymbol";
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { ActivityIndicator, Alert, Pressable, ScrollView, View } from "react-native";
import { Platform, ActivityIndicator, Alert, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import * as Arr from "effect/Array";
import * as Cause from "effect/Cause";
import * as Order from "effect/Order";
import { AsyncResult } from "effect/unstable/reactivity";
import { cn } from "../../lib/cn";
import { useProjects, useServerConfigs, waitForProject } from "../../state/entities";
import { filesystemEnvironment } from "../../state/filesystem";
import { projectEnvironment } from "../../state/projects";
@@ -123,13 +126,19 @@ function sourceFromParam(value: string | string[] | undefined): AddProjectRemote
function SectionTitle(props: { readonly children: string }) {
return (
<Text className="px-1 text-2xs font-t3-bold tracking-[0.7px] uppercase text-foreground-muted">
<Text
className={
Platform.OS === "android"
? "px-4 text-sm font-t3-medium text-primary"
: "px-1 text-2xs font-t3-bold tracking-[0.7px] uppercase text-foreground-muted"
}
>
{props.children}
</Text>
);
}
function AddProjectShell(props: { readonly children: ReactNode }) {
function AddProjectShell(props: { readonly children: ReactNode; readonly title: string }) {
const insets = useSafeAreaInsets();
return (
@@ -138,25 +147,35 @@ function AddProjectShell(props: { readonly children: ReactNode }) {
// scroll-view frame correction mistakes this full-height wrapper for a
// "header" sibling, coercing the ScrollView to zero height (blank sheet
// as soon as the sheet re-lays-out, e.g. when the keyboard opens).
<View collapsable={false} className="flex-1 bg-sheet">
<SettingsScreen title={props.title}>
<ScrollView
keyboardShouldPersistTaps="handled"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{
paddingHorizontal: 20,
paddingHorizontal: Platform.OS === "android" ? 16 : 20,
paddingTop: 16,
paddingBottom: Math.max(insets.bottom, 18) + 18,
gap: 10,
gap: Platform.OS === "android" ? 16 : 10,
}}
>
{props.children}
</ScrollView>
</View>
</SettingsScreen>
);
}
function ListSection(props: { readonly children: ReactNode }) {
return <View className="overflow-hidden rounded-[24px] bg-card">{props.children}</View>;
return (
<View
className={
Platform.OS === "android"
? "overflow-hidden rounded-[28px] bg-card"
: "overflow-hidden rounded-[24px] bg-card"
}
>
{props.children}
</View>
);
}
function ListRow(props: {
@@ -169,6 +188,20 @@ function ListRow(props: {
readonly right?: ReactNode;
readonly onPress?: () => void;
}) {
if (Platform.OS === "android") {
return (
<MaterialListRow
title={props.title}
subtitle={props.subtitle}
leading={props.icon}
trailing={props.right}
disabled={props.disabled}
onPress={props.onPress}
accessibilityRole={props.selected !== undefined ? "radio" : "button"}
accessibilityState={props.selected !== undefined ? { checked: props.selected } : undefined}
/>
);
}
return (
<Pressable
disabled={props.disabled}
@@ -203,7 +236,7 @@ function ListRow(props: {
<SymbolView
name="chevron.right"
size={13}
tintColorClassName={"accent-chevron"}
tintColorClassName="accent-chevron"
type="monochrome"
/>
) : null}
@@ -218,6 +251,7 @@ function PrimaryActionButton(props: {
readonly loading?: boolean;
readonly onPress: () => void;
}) {
if (Platform.OS === "android") return <MaterialButton {...props} tone="primary" fullWidth />;
return (
<Pressable
disabled={props.disabled}
@@ -435,9 +469,18 @@ function SourceControlRow(props: {
: `Clone ${addProjectRemoteSourceLabel(props.source)} ${props.hint}`;
const icon =
props.source === "url" ? (
<SymbolView name="link" size={17} tintColorClassName={"accent-icon"} type="monochrome" />
<SymbolView
name="link"
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon"
type="monochrome"
/>
) : (
<SourceControlIcon kind={props.source} size={18} colorClassName="accent-icon" />
<SourceControlIcon
kind={props.source}
size={Platform.OS === "android" ? 24 : 18}
colorClassName="accent-icon"
/>
);
if (!props.ready) {
@@ -482,7 +525,7 @@ export function AddProjectSourceScreen() {
);
return (
<AddProjectShell>
<AddProjectShell title="Add project">
{selectedEnvironment === null ? <EmptyEnvironmentState /> : null}
{environmentOptions.length > 1 ? (
@@ -495,7 +538,7 @@ export function AddProjectSourceScreen() {
title={environment.label}
subtitle={
canCreateProjectInEnvironment(environment.connectionState)
? environment.environmentId
? undefined
: connectionStatusText({
phase: environment.connectionState,
error: environment.connectionError,
@@ -505,7 +548,7 @@ export function AddProjectSourceScreen() {
icon={
<EnvironmentMachineSymbol
kind={environment.machine}
size={17}
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon"
/>
}
@@ -516,8 +559,8 @@ export function AddProjectSourceScreen() {
environment.environmentId === selectedEnvironment?.environmentId ? (
<SymbolView
name="checkmark"
size={14}
tintColorClassName={"accent-icon"}
size={Platform.OS === "android" ? 20 : 14}
tintColorClassName="accent-icon"
type="monochrome"
/>
) : null
@@ -538,8 +581,8 @@ export function AddProjectSourceScreen() {
icon={
<SymbolView
name="folder.badge.plus"
size={17}
tintColorClassName={"accent-icon"}
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon"
type="monochrome"
/>
}
@@ -570,7 +613,7 @@ export function AddProjectSourceScreen() {
)}
</ListSection>
{discoveryState.isPending ? (
<ActivityIndicator colorClassName={"accent-icon-muted"} />
<ActivityIndicator colorClassName="accent-icon-muted" />
) : null}
</>
) : null}
@@ -723,7 +766,7 @@ export function AddProjectRepositoryScreen(props: {
}, [environment, isSubmitting, lookupRepositoryQuery, repositoryInput, navigation, source]);
return (
<AddProjectShell>
<AddProjectShell title={source === "url" ? "Git URL" : addProjectRemoteSourceLabel(source)}>
{error ? <ErrorBanner message={error} /> : null}
{environment ? (
<>
@@ -800,7 +843,7 @@ function FolderBrowser(props: {
<ListSection>
{browseState.isPending && browseState.data === null ? (
<View className="items-center py-5">
<ActivityIndicator colorClassName={"accent-icon-muted"} />
<ActivityIndicator colorClassName="accent-icon-muted" />
</View>
) : null}
{browsePath.canBrowseUp ? (
@@ -809,8 +852,8 @@ function FolderBrowser(props: {
icon={
<SymbolView
name="arrow.turn.left.up"
size={17}
tintColorClassName={"accent-icon-muted"}
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
}
@@ -832,8 +875,8 @@ function FolderBrowser(props: {
icon={
<SymbolView
name="folder"
size={17}
tintColorClassName={"accent-icon-muted"}
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
}
@@ -882,7 +925,7 @@ export function AddProjectLocalFolderScreen(props: { readonly environmentId?: st
}, [createProject, environment, isBrowseNavigating, isSubmitting, pathInput]);
return (
<AddProjectShell>
<AddProjectShell title="Local folder">
{error ? <ErrorBanner message={error} /> : null}
{environment ? (
<>
@@ -1025,7 +1068,7 @@ export function AddProjectDestinationScreen(props: {
]);
return (
<AddProjectShell>
<AddProjectShell title="Clone destination">
{error ? <ErrorBanner message={error} /> : null}
{repositoryTitle ? (
<View className="rounded-[24px] bg-card px-4 py-3">
+250 -165
View File
@@ -35,6 +35,8 @@ import { AppText as Text } from "../../components/AppText";
import { SymbolView } from "../../components/AppSymbol";
import { AndroidHeaderIconButton, AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { ControlPillMenu } from "../../components/ControlPill";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { cn } from "../../lib/cn";
import { environmentCatalog } from "../../connection/catalog";
import { useEnvironmentPresentation } from "../../state/presentation";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -54,7 +56,10 @@ import { useSelectedThreadGitState } from "../../state/use-selected-thread-git-s
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
import { useThreadSelection } from "../../state/use-thread-selection";
import { vcsEnvironment } from "../../state/vcs";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import {
AndroidWorkspaceSidebarButton,
WorkspaceSidebarToolbar,
} from "../layout/workspace-sidebar-toolbar";
import { ThreadGitMenu } from "../threads/ThreadGitControls";
import { useReviewCacheForThread } from "./reviewState";
import {
@@ -81,7 +86,12 @@ const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
const ReviewNotice = memo(function ReviewNotice(props: { readonly notice: string }) {
return (
<View className="border-b border-warning-border bg-warning px-4 py-3">
<View
className={cn(
"bg-warning px-4 py-3",
Platform.OS === "android" ? "m-2 rounded-[20px]" : "border-b border-warning-border",
)}
>
<Text className="text-xs font-t3-bold uppercase text-warning-foreground">Partial diff</Text>
<Text className="text-xs leading-normal text-warning-foreground">{props.notice}</Text>
</View>
@@ -103,7 +113,7 @@ function ReviewSelectionActionBar(props: {
<SymbolView
name={props.onOpenComment ? "text.bubble" : "line.3.horizontal.decrease.circle"}
size={16}
tintColorClassName={"accent-primary-foreground"}
tintColorClassName="accent-primary-foreground"
type="monochrome"
/>
<Text className="text-base font-t3-bold text-primary-foreground">{props.title}</Text>
@@ -143,7 +153,7 @@ function ReviewSelectionActionBar(props: {
<SymbolView
name="xmark"
size={16}
tintColorClassName={"accent-primary-foreground"}
tintColorClassName="accent-primary-foreground"
type="monochrome"
/>
</Pressable>
@@ -174,9 +184,14 @@ const ReviewFileNavigatorRow = memo(function ReviewFileNavigatorRow(props: {
accessibilityRole="button"
accessibilityState={{ selected }}
className={
selected
? "mt-1 min-h-12 justify-center rounded-xl bg-subtle-strong px-3 py-2"
: "mt-1 min-h-12 justify-center rounded-xl px-3 py-2 active:bg-subtle"
Platform.OS === "android"
? cn(
"mt-1 min-h-12 justify-center rounded-[20px] px-3 py-2 active:bg-subtle",
selected && "bg-thread-selected",
)
: selected
? "mt-1 min-h-12 justify-center rounded-xl bg-subtle-strong px-3 py-2"
: "mt-1 min-h-12 justify-center rounded-xl px-3 py-2 active:bg-subtle"
}
onPress={handlePress}
>
@@ -323,16 +338,28 @@ function ReviewFileNavigator({
}
return (
<View className="flex-1 border-l border-border bg-sheet">
<View className="border-b border-border" style={{ paddingTop: headerInset }}>
<View className="px-4 py-3">
<Text className="text-sm font-t3-bold text-foreground">Changed files</Text>
<Text className="text-xs text-foreground-muted">
{files.length} {files.length === 1 ? "file" : "files"}
</Text>
<View
className={
Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-l border-border bg-sheet"
}
>
{Platform.OS === "android" ? (
<AndroidScreenHeader
title="Changed files"
subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}
hideBottomBorder
/>
) : (
<View className="border-b border-border" style={{ paddingTop: headerInset }}>
<View className="px-4 py-3">
<Text className="text-sm font-t3-bold text-foreground">Changed files</Text>
<Text className="text-xs text-foreground-muted">
{files.length} {files.length === 1 ? "file" : "files"}
</Text>
</View>
</View>
</View>
{fileList}
)}
<MaterialScreenContent insetHorizontal>{fileList}</MaterialScreenContent>
</View>
);
}
@@ -632,23 +659,21 @@ export function ReviewSheet(props: ReviewSheetProps) {
parsedDiff.kind === "files" &&
NativeReviewDiffView !== null;
useRegisterWorkspaceInspector(showChangedFilesPane ? renderInspector : undefined);
// Raw fallback renders the patch inline with no inspector content, so the
// pane toggle would open an empty column — hide it in exactly that case.
const showChangedFilesToggle =
panes.supportsAuxiliaryPane &&
!(
!showConnectionNotice &&
selectedSection !== null &&
parsedDiff.kind === "files" &&
NativeReviewDiffView === null
);
// A toggle needs registered content; loading, errors and raw patches have no navigator pane.
const showChangedFilesToggle = panes.supportsAuxiliaryPane && showChangedFilesPane;
const listHeader = useMemo(() => {
const children: ReactElement[] = [];
if (error) {
children.push(
<View key="review-error" className="border-b border-border bg-card px-4 py-3">
<View
key="review-error"
className={cn(
"bg-card px-4 py-3",
Platform.OS === "android" ? "m-2 rounded-[20px]" : "border-b border-border",
)}
>
<Text className="text-sm font-t3-bold text-foreground">Review unavailable</Text>
<Text className="text-xs leading-normal text-foreground-muted">{error}</Text>
</View>,
@@ -699,21 +724,35 @@ export function ReviewSheet(props: ReviewSheetProps) {
{isAndroid ? (
<AndroidScreenHeader
title="Review changes"
leading={<AndroidWorkspaceSidebarButton />}
hideBottomBorder
subtitle={androidHeaderSubtitle || "Select a diff"}
onBack={handleReturnToThread}
trailing={
showSectionToolbar ? (
<ControlPillMenu
actions={androidSectionMenuActions}
isAnchoredToRight
onPressAction={handleAndroidSectionMenuAction}
>
<>
{showChangedFilesToggle ? (
<AndroidHeaderIconButton
accessibilityLabel="Select review diff"
icon="ellipsis.circle"
accessibilityLabel={
panes.auxiliaryPaneVisible ? "Hide changed files" : "Show changed files"
}
icon="sidebar.right"
selected={panes.auxiliaryPaneVisible}
onPress={toggleAuxiliaryPane}
/>
</ControlPillMenu>
) : null
) : null}
{showSectionToolbar ? (
<ControlPillMenu
actions={androidSectionMenuActions}
isAnchoredToRight
onPressAction={handleAndroidSectionMenuAction}
>
<AndroidHeaderIconButton
accessibilityLabel="Select review diff"
icon="ellipsis.circle"
/>
</ControlPillMenu>
) : null}
</>
}
/>
) : null}
@@ -805,141 +844,187 @@ export function ReviewSheet(props: ReviewSheetProps) {
</NativeHeaderToolbar>
) : null}
<View className="flex-1 bg-sheet">
{showConnectionNotice ? (
<View className="flex-1" style={{ paddingTop: topContentInset }}>
<EnvironmentConnectionNotice
environmentLabel={environment.presentation?.entry.target.label ?? "Environment"}
connection={
environment.presentation?.connection ?? {
phase: "available",
error: null,
traceId: null,
<MaterialScreenContent>
<View className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}>
{showConnectionNotice ? (
<View className="flex-1" style={{ paddingTop: topContentInset }}>
<EnvironmentConnectionNotice
environmentLabel={environment.presentation?.entry.target.label ?? "Environment"}
connection={
environment.presentation?.connection ?? {
phase: "available",
error: null,
traceId: null,
}
}
}
resourceName="review"
onRetry={handleRetryEnvironment}
/>
</View>
) : selectedSection && parsedDiff.kind === "files" && NativeReviewDiffView ? (
<View
className="flex-1"
style={{
backgroundColor: nativeBridge.theme.background,
}}
>
resourceName="review"
onRetry={handleRetryEnvironment}
/>
</View>
) : selectedSection && parsedDiff.kind === "files" && NativeReviewDiffView ? (
<View
className="min-w-0 flex-1"
style={{ paddingTop: topContentInset + REVIEW_HEADER_SPACING }}
className="flex-1"
style={{
backgroundColor: nativeBridge.theme.background,
}}
>
{listHeader}
<View className="min-w-0 flex-1" collapsable={false}>
<NativeReviewDiffView
collapsable={false}
testID="review-native-diff-view"
refreshing={isPullRefreshing || isSelectedSectionPending || areFilePatchesPending}
onPullToRefresh={() => void handlePullToRefresh()}
style={StyleSheet.absoluteFill}
appearanceScheme={selectedTheme}
collapsedFileIdsJson={nativeBridge.collapsedFileIdsJson}
collapsedCommentIdsJson={nativeBridge.collapsedCommentIdsJson}
contentResetKey={`${reviewCache.threadKey}:${selectedSection.id}`}
contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
nativeViewRef={nativeReviewDiffViewRef}
rowHeight={nativeReviewDiffStyle.rowHeight}
rowsJson={nativeBridge.rowsJson}
selectedRowIdsJson={nativeBridge.selectedRowIdsJson}
styleJson={nativeBridge.styleJson}
themeJson={nativeBridge.themeJson}
tokensPatchJson={nativeBridge.tokensPatchJson}
tokensResetKey={nativeBridge.tokensResetKey}
viewedFileIdsJson={nativeBridge.viewedFileIdsJson}
onDebug={handleNativeDebug}
onPressLine={commentSelection.onPressLine}
onVisibleFileChange={handleVisibleFileChange}
onToggleComment={nativeBridge.onToggleComment}
onToggleFile={handleNativeToggleFile}
onToggleViewedFile={handleNativeToggleViewedFile}
/>
<View
className="min-w-0 flex-1"
style={{ paddingTop: topContentInset + REVIEW_HEADER_SPACING }}
>
{listHeader}
<View className="min-w-0 flex-1" collapsable={false}>
<NativeReviewDiffView
collapsable={false}
testID="review-native-diff-view"
refreshing={
isPullRefreshing || isSelectedSectionPending || areFilePatchesPending
}
onPullToRefresh={() => void handlePullToRefresh()}
style={StyleSheet.absoluteFill}
appearanceScheme={selectedTheme}
collapsedFileIdsJson={nativeBridge.collapsedFileIdsJson}
collapsedCommentIdsJson={nativeBridge.collapsedCommentIdsJson}
contentResetKey={`${reviewCache.threadKey}:${selectedSection.id}`}
contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
nativeViewRef={nativeReviewDiffViewRef}
rowHeight={nativeReviewDiffStyle.rowHeight}
rowsJson={nativeBridge.rowsJson}
selectedRowIdsJson={nativeBridge.selectedRowIdsJson}
styleJson={nativeBridge.styleJson}
themeJson={nativeBridge.themeJson}
tokensPatchJson={nativeBridge.tokensPatchJson}
tokensResetKey={nativeBridge.tokensResetKey}
viewedFileIdsJson={nativeBridge.viewedFileIdsJson}
onDebug={handleNativeDebug}
onPressLine={commentSelection.onPressLine}
onVisibleFileChange={handleVisibleFileChange}
onToggleComment={nativeBridge.onToggleComment}
onToggleFile={handleNativeToggleFile}
onToggleViewedFile={handleNativeToggleViewedFile}
/>
</View>
</View>
</View>
</View>
) : (
<ScrollView
contentInsetAdjustmentBehavior="never"
contentInset={{ top: topContentInset, bottom: Math.max(insets.bottom, 18) + 18 }}
contentOffset={{ x: 0, y: -topContentInset }}
scrollIndicatorInsets={{
top: topContentInset,
bottom: Math.max(insets.bottom, 18) + 18,
}}
showsVerticalScrollIndicator={false}
className="flex-1"
refreshControl={
// The native diff surface owns pull-to-refresh via onPullToRefresh;
// the raw fallback (and empty states) need an explicit control —
// iOS has no other refresh affordance here (the explicit
// "Refresh current diff" menu is Android-only).
<RefreshControl
refreshing={isPullRefreshing || isSelectedSectionPending || areFilePatchesPending}
onRefresh={() => void handlePullToRefresh()}
/>
}
>
{listHeader}
{!selectedSection ? (
<View className="border-b border-border bg-card px-4 py-5">
<Text className="text-sm font-t3-bold text-foreground">No review diffs</Text>
<Text className="text-xs leading-normal text-foreground-muted">
This thread has no ready turn diffs and the worktree diff is empty.
</Text>
</View>
) : selectedSection.isLoading && selectedSection.diff === null ? (
<View className="items-center gap-3 border-b border-border bg-card px-4 py-6">
<ActivityIndicator size="small" />
<Text className="text-xs text-foreground-muted">Loading diff…</Text>
</View>
) : parsedDiff.kind === "empty" ? (
<View className="border-b border-border bg-card px-4 py-5">
<Text className="text-sm font-t3-bold text-foreground">No changes</Text>
<Text className="text-xs leading-normal text-foreground-muted">
{selectedSection.subtitle ?? "This diff is empty."}
</Text>
</View>
) : parsedDiff.kind === "raw" ? (
<View className="gap-3 border-b border-border bg-card px-4 py-4">
<Text className="text-xs leading-normal text-foreground-muted">
{parsedDiff.reason}
</Text>
<ScrollView horizontal showsHorizontalScrollIndicator={false} bounces={false}>
<Text selectable className="font-mono text-xs leading-relaxed text-foreground">
{parsedDiff.text}
) : (
<ScrollView
contentContainerStyle={
Platform.OS === "android" && (parsedDiff.kind === "empty" || !selectedSection)
? { flexGrow: 1, justifyContent: "center" }
: undefined
}
contentInsetAdjustmentBehavior="never"
contentInset={{ top: topContentInset, bottom: Math.max(insets.bottom, 18) + 18 }}
contentOffset={{ x: 0, y: -topContentInset }}
scrollIndicatorInsets={{
top: topContentInset,
bottom: Math.max(insets.bottom, 18) + 18,
}}
showsVerticalScrollIndicator={false}
className="flex-1"
refreshControl={
// The native diff surface owns pull-to-refresh via onPullToRefresh;
// the raw fallback (and empty states) need an explicit control —
// iOS has no other refresh affordance here (the explicit
// "Refresh current diff" menu is Android-only).
<RefreshControl
refreshing={isPullRefreshing || isSelectedSectionPending || areFilePatchesPending}
onRefresh={() => void handlePullToRefresh()}
/>
}
>
{listHeader}
{!selectedSection ? (
<View
className={
Platform.OS === "android"
? "items-center px-6 py-5"
: "border-b border-border bg-card px-4 py-5"
}
>
<Text className="text-sm font-t3-bold text-foreground">No review diffs</Text>
<Text
className={cn(
"text-xs leading-normal text-foreground-muted",
Platform.OS === "android" && "mt-2 text-center",
)}
>
This thread has no ready turn diffs and the worktree diff is empty.
</Text>
</ScrollView>
</View>
) : parsedDiff.kind === "files" ? (
// The native diff surface could not be resolved on this binary;
// degrade to the raw patch instead of crashing the app.
<View className="gap-3 border-b border-border bg-card px-4 py-4">
<Text className="text-xs leading-normal text-foreground-muted">
Native diff view unavailable. Showing the raw patch.
</Text>
<ScrollView horizontal showsHorizontalScrollIndicator={false} bounces={false}>
<Text selectable className="font-mono text-xs leading-relaxed text-foreground">
{selectedSection?.diff ?? ""}
</View>
) : selectedSection.isLoading && selectedSection.diff === null ? (
<View
className={cn(
"items-center gap-3 px-4 py-6",
Platform.OS !== "android" && "border-b border-border bg-card",
)}
>
<ActivityIndicator size="small" />
<Text className="text-xs text-foreground-muted">Loading diff…</Text>
</View>
) : parsedDiff.kind === "empty" ? (
<View
className={
Platform.OS === "android"
? "items-center px-6 py-5"
: "border-b border-border bg-card px-4 py-5"
}
>
<Text className="text-sm font-t3-bold text-foreground">No changes</Text>
<Text
className={cn(
"text-xs leading-normal text-foreground-muted",
Platform.OS === "android" && "mt-2 text-center",
)}
>
{selectedSection.subtitle ?? "This diff is empty."}
</Text>
</ScrollView>
</View>
) : null}
</ScrollView>
)}
<ReviewSelectionActionBar
bottomInset={insets.bottom}
title={commentSelection.selectionAction?.title ?? null}
onOpenComment={commentSelection.selectionAction?.onOpenComment ?? null}
onClear={commentSelection.clearSelection}
/>
</View>
</View>
) : parsedDiff.kind === "raw" ? (
<View
className={cn(
"gap-3 bg-card px-4 py-4",
Platform.OS === "android" ? "m-2 rounded-[20px]" : "border-b border-border",
)}
>
<Text className="text-xs leading-normal text-foreground-muted">
{parsedDiff.reason}
</Text>
<ScrollView horizontal showsHorizontalScrollIndicator={false} bounces={false}>
<Text selectable className="font-mono text-xs leading-relaxed text-foreground">
{parsedDiff.text}
</Text>
</ScrollView>
</View>
) : parsedDiff.kind === "files" ? (
// The native diff surface could not be resolved on this binary;
// degrade to the raw patch instead of crashing the app.
<View
className={cn(
"gap-3 bg-card px-4 py-4",
Platform.OS === "android" ? "m-2 rounded-[20px]" : "border-b border-border",
)}
>
<Text className="text-xs leading-normal text-foreground-muted">
Native diff view unavailable. Showing the raw patch.
</Text>
<ScrollView horizontal showsHorizontalScrollIndicator={false} bounces={false}>
<Text selectable className="font-mono text-xs leading-relaxed text-foreground">
{selectedSection?.diff ?? ""}
</Text>
</ScrollView>
</View>
) : null}
</ScrollView>
)}
<ReviewSelectionActionBar
bottomInset={insets.bottom}
title={commentSelection.selectionAction?.title ?? null}
onOpenComment={commentSelection.selectionAction?.onOpenComment ?? null}
onClear={commentSelection.clearSelection}
/>
</View>
</MaterialScreenContent>
</>
);
}
@@ -255,6 +255,31 @@ describe("createNativeReviewDiffTheme", () => {
}
});
it.each(["light", "dark"] as const)(
"preserves Material You RGBA hex channels and composites alpha in %s",
(appearance) => {
const variables = {
...appTheme("material-you", appearance),
"--color-screen": "#101214FF",
"--color-sheet": "#20222480",
"--color-md-code-text": "#E3E2E6FF",
"--color-foreground-muted": "#C7C5D080",
"--color-border": "#44464F80",
"--color-primary": "#A8C7FAFF",
};
const theme = createNativeReviewDiffTheme(appearance, "material-you", variables);
expect(theme.background).toBe("#181a1c");
expect(theme.headerBackground).toBe(theme.background);
expect(theme.text).toBe("#e3e2e6");
expect(theme.mutedText).toBe("#707076");
expect(theme.border).toBe("#2e3036");
expect(theme.hunkText).toBe("#a8c7fa");
for (const color of Object.values(theme)) {
expect(color).toMatch(/^#[\da-f]{6}$/i);
}
},
);
it("uses the selected app palette for native code surfaces", () => {
const standard = createNativeReviewDiffTheme("dark", "t3-code", appTheme("t3-code", "dark"));
const iris = createNativeReviewDiffTheme("dark", "iris", appTheme("iris", "dark"));
@@ -19,7 +19,7 @@ import type { ReviewInlineComment } from "./reviewCommentSelection";
const NATIVE_REVIEW_MAX_WORD_DIFF_RANGE_COUNT = 4;
const NATIVE_REVIEW_MAX_WORD_DIFF_COVERAGE = 0.45;
const NATIVE_HEX_COLOR = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;
const NATIVE_HEX_COLOR = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i;
const NATIVE_RGBA_COLOR =
/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/;
@@ -44,15 +44,19 @@ export function buildNativeReviewSnippetRows(
function opaqueNativeHexColor(color: string, background: string): string {
const hex = NATIVE_HEX_COLOR.exec(color);
if (hex) return color;
if (hex && !hex[4]) return color;
const rgba = NATIVE_RGBA_COLOR.exec(color);
const backgroundHex = NATIVE_HEX_COLOR.exec(background);
if (!rgba || !backgroundHex) return background;
if ((!hex && !rgba) || !backgroundHex) return background;
const alpha = rgba[4] === undefined ? 1 : Math.min(1, Math.max(0, Number(rgba[4])));
const alpha = hex
? Number.parseInt(hex[4] ?? "ff", 16) / 255
: rgba?.[4] === undefined
? 1
: Math.min(1, Math.max(0, Number(rgba[4])));
const channels = [1, 2, 3].map((index) => {
const foreground = Number(rgba[index]);
const foreground = hex ? Number.parseInt(hex[index] ?? "0", 16) : Number(rgba?.[index]);
const behind = Number.parseInt(backgroundHex[index] ?? "0", 16);
return Math.round(foreground * alpha + behind * (1 - alpha));
});
@@ -169,7 +173,11 @@ export function createNativeReviewDiffTheme(
// Swift expects #RRGGBB/#RRGGBBAA while Android expects #RRGGBB/#AARRGGBB.
// Flatten translucent app tokens onto the code surface so both native
// implementations receive the one unambiguous shared format.
const background = opaqueNativeHexColor(appTheme["--color-sheet"], appTheme["--color-screen"]);
const screen = opaqueNativeHexColor(
appTheme["--color-screen"],
scheme === "dark" ? "#000000" : "#ffffff",
);
const background = opaqueNativeHexColor(appTheme["--color-sheet"], screen);
const nativeColor = (color: string) => opaqueNativeHexColor(color, background);
if (scheme === "dark") {
@@ -1,26 +1,17 @@
import { useNavigation } from "@react-navigation/native";
import { Platform, ScrollView, View } from "react-native";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { SettingsScreen } from "./components/SettingsScreen";
import { CodeAppearanceSection } from "./appearance/sections/CodeAppearanceSection";
import { TerminalAppearanceSection } from "./appearance/sections/TerminalAppearanceSection";
import { TextAppearanceSection } from "./appearance/sections/TextAppearanceSection";
import { ThemeAppearanceSection } from "./appearance/sections/ThemeAppearanceSection";
export function SettingsAppearanceRouteScreen() {
const navigation = useNavigation();
const insets = useSafeAreaInsets();
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="Appearance" onBack={() => navigation.goBack()} />
</>
) : null}
<SettingsScreen title="Appearance">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -35,6 +26,6 @@ export function SettingsAppearanceRouteScreen() {
<TerminalAppearanceSection />
<CodeAppearanceSection />
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,8 +1,9 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { type EnvironmentMachineKind, resolveEnvironmentMachineKind } from "@t3tools/contracts";
import { AsyncResult } from "effect/unstable/reactivity";
import { useMemo } from "react";
import { ActivityIndicator, Alert, Pressable, ScrollView, View } from "react-native";
import { ActivityIndicator, Alert, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/AppText";
@@ -16,6 +17,7 @@ import {
import { useServerConfigs } from "../../state/entities";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { SettingsSection } from "./components/SettingsSection";
import { SettingsScreen } from "./components/SettingsScreen";
export function SettingsClientStorageRouteScreen() {
const insets = useSafeAreaInsets();
@@ -71,7 +73,7 @@ export function SettingsClientStorageRouteScreen() {
};
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SettingsScreen title="Client Storage">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentInset={{ bottom: Math.max(insets.bottom, 18) }}
@@ -85,7 +87,7 @@ export function SettingsClientStorageRouteScreen() {
<SymbolView
name="exclamationmark.triangle"
size={28}
tintColorClassName={"accent-danger-foreground"}
tintColorClassName="accent-danger-foreground"
type="monochrome"
weight="regular"
/>
@@ -123,7 +125,7 @@ export function SettingsClientStorageRouteScreen() {
<SymbolView
name="checkmark.circle"
size={28}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
@@ -146,16 +148,14 @@ export function SettingsClientStorageRouteScreen() {
<SymbolView
name="trash"
size={22}
tintColorClassName={"accent-danger-foreground"}
tintColorClassName="accent-danger-foreground"
type="monochrome"
weight="regular"
/>
<Text className="flex-1 text-lg tabular-nums text-danger-foreground">
{summary ? `Clear ${formatBytes(summary.payloadBytes)}` : "Clear caches"}
</Text>
{isClearing ? (
<ActivityIndicator colorClassName={"accent-danger-foreground"} />
) : null}
{isClearing ? <ActivityIndicator colorClassName="accent-danger-foreground" /> : null}
</Pressable>
</SettingsSection>
<Text className="px-2 text-sm leading-normal text-foreground-muted">
@@ -169,7 +169,7 @@ export function SettingsClientStorageRouteScreen() {
) : null}
</View>
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,13 +1,14 @@
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { NativeHeaderToolbar } from "../../native/StackHeader";
import { useNavigation } from "@react-navigation/native";
import { SymbolView } from "../../components/AppSymbol";
import type { EnvironmentId } from "@t3tools/contracts";
import { useCallback, useState } from "react";
import { Platform, ScrollView, View } from "react-native";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/AppText";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { SettingsScreen } from "./components/SettingsScreen";
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
import { ConnectionEnvironmentRow } from "../connection/ConnectionEnvironmentRow";
import { GitHubRoutingSettings } from "../connection/GitHubRoutingSettings";
@@ -79,28 +80,21 @@ export function SettingsEnvironmentsRouteScreen() {
);
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
{/* Android renders its own in-screen header instead of the native bar. */}
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader
title="Environments"
onBack={() => navigation.goBack()}
actions={[
{
accessibilityLabel: "Add environment",
icon: "plus",
onPress: () =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: "SettingsEnvironmentNew" },
}),
},
]}
/>
</>
) : (
<SettingsScreen
title="Environments"
actions={[
{
accessibilityLabel: "Add environment",
icon: "plus",
onPress: () =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: "SettingsEnvironmentNew" },
}),
},
]}
>
{Platform.OS !== "android" ? (
<NativeHeaderToolbar placement="right">
<NativeHeaderToolbar.Button
icon="plus"
@@ -114,7 +108,7 @@ export function SettingsEnvironmentsRouteScreen() {
tintColor={headerIconColor}
/>
</NativeHeaderToolbar>
)}
) : null}
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -177,6 +171,6 @@ export function SettingsEnvironmentsRouteScreen() {
/>
<GitHubRoutingSettings />
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,3 +1,4 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { LegendList } from "@legendapp/list/react-native";
import { type StaticScreenProps, useNavigation } from "@react-navigation/native";
import {
@@ -8,18 +9,19 @@ import {
type ThirdPartyLicenseEntry,
} from "@t3tools/shared/thirdPartyLicenses";
import { useCallback, useMemo, useState } from "react";
import { Linking, Platform, Pressable, ScrollView, View } from "react-native";
import { Linking, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { SettingsScreen } from "./components/SettingsScreen";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import {
createNativeMailSearchToolbarItem,
NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
} from "../layout/native-mail-search-toolbar";
import { getMobileThirdPartyLicenses } from "./mobileThirdPartyLicenses";
function useMobileThirdPartyLicenses() {
@@ -97,24 +99,18 @@ export function SettingsOpenSourceLicensesRouteScreen() {
if (!manifest) {
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="Open source licenses" onBack={() => navigation.goBack()} />
</>
) : null}
<SettingsScreen title="Open source licenses">
<View className="flex-1 items-center justify-center px-6">
<Text className="text-center text-base text-foreground-muted">
License notices are unavailable in this build.
</Text>
</View>
</View>
</SettingsScreen>
);
}
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SettingsScreen title="Open source licenses">
{Platform.OS === "ios" ? (
<NativeStackScreenOptions
options={{
@@ -148,12 +144,7 @@ export function SettingsOpenSourceLicensesRouteScreen() {
<NativeHeaderToolbar.SearchBarSlot />
</NativeHeaderToolbar>
) : null}
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="Open source licenses" onBack={() => navigation.goBack()} />
</>
) : null}
<LegendList
className="flex-1"
contentContainerStyle={{
@@ -195,14 +186,13 @@ export function SettingsOpenSourceLicensesRouteScreen() {
renderItem={renderItem}
showsVerticalScrollIndicator={false}
/>
</View>
</SettingsScreen>
);
}
type LicenseDetailProps = StaticScreenProps<{ readonly entryKey: string }>;
export function SettingsOpenSourceLicenseRouteScreen({ route }: LicenseDetailProps) {
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const manifest = useMobileThirdPartyLicenses();
const entry = manifest
@@ -212,30 +202,18 @@ export function SettingsOpenSourceLicenseRouteScreen({ route }: LicenseDetailPro
if (!entry) {
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="License notice" onBack={() => navigation.goBack()} />
</>
) : null}
<SettingsScreen title="License notice">
<View className="flex-1 items-center justify-center px-6">
<Text className="text-center text-base text-foreground-muted">
This license notice is unavailable.
</Text>
</View>
</View>
</SettingsScreen>
);
}
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="License notice" onBack={() => navigation.goBack()} />
</>
) : null}
<SettingsScreen title="License notice">
<ScrollView
className="flex-1"
contentInsetAdjustmentBehavior="automatic"
@@ -275,6 +253,6 @@ export function SettingsOpenSourceLicenseRouteScreen({ route }: LicenseDetailPro
</Text>
</View>
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,14 +1,13 @@
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { useNavigation } from "@react-navigation/native";
import type { SidebarProjectGroupingMode } from "@t3tools/contracts";
import { AsyncResult } from "effect/unstable/reactivity";
import { Platform, Pressable, ScrollView, View } from "react-native";
import { Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { AppText as Text } from "../../components/AppText";
import { SymbolView } from "../../components/AppSymbol";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { SettingsScreen } from "./components/SettingsScreen";
import {
mobileProjectGroupingModePatch,
resolveMobileProjectGroupingSettings,
@@ -39,7 +38,6 @@ const GROUPING_OPTIONS: ReadonlyArray<{
];
export function SettingsProjectGroupingRouteScreen() {
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const preferencesResult = useAtomValue(mobilePreferencesAtom);
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
@@ -49,13 +47,7 @@ export function SettingsProjectGroupingRouteScreen() {
: null;
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="Project Grouping" onBack={() => navigation.goBack()} />
</>
) : null}
<SettingsScreen title="Project Grouping">
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
@@ -99,6 +91,6 @@ export function SettingsProjectGroupingRouteScreen() {
))}
</SettingsSection>
</ScrollView>
</View>
</SettingsScreen>
);
}
@@ -1,3 +1,5 @@
import { AutoSettleDaysField } from "./components/AutoSettleDaysField";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { useAuth, useUser } from "@clerk/expo";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import Constants from "expo-constants";
@@ -8,7 +10,7 @@ import { SymbolView } from "../../components/AppSymbol";
import * as Effect from "effect/Effect";
import { AsyncResult } from "effect/unstable/reactivity";
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
import { Alert, Linking, Platform, Pressable, ScrollView, View } from "react-native";
import { Alert, Linking, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import {
@@ -18,8 +20,7 @@ import {
settlePromise,
squashAtomCommandFailure,
} from "@t3tools/client-runtime/state/runtime";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { AppText as Text } from "../../components/AppText";
import { supportsAgentAwarenessPush } from "../agent-awareness/capabilities";
import {
openAndroidLiveUpdateSettings,
@@ -37,15 +38,12 @@ import { hasCloudPublicConfig, resolveRelayClerkTokenOptions } from "../cloud/pu
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import { runtime } from "../../lib/runtime";
import { cn } from "../../lib/cn";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
import { useEnvironments } from "../../state/environments";
import {
DEFAULT_SERVER_SETTINGS,
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
} from "@t3tools/contracts";
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";
import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
import {
@@ -58,6 +56,7 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
import { SettingsRow } from "./components/SettingsRow";
import { SettingsSection } from "./components/SettingsSection";
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
import { SettingsScreen } from "./components/SettingsScreen";
import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic";
import { planAutoSettleSettingsSync, type AutoSettleSettings } from "./autoSettleSettingsSync";
@@ -79,17 +78,16 @@ function useDeviceRegistered(): boolean {
export function SettingsRouteScreen() {
const navigation = useNavigation();
const content = hasCloudPublicConfig() ? (
<ConfiguredSettingsRouteScreen />
) : (
<LocalSettingsRouteScreen />
);
return (
<>
<WorkspaceSidebarToolbar />
{Platform.OS === "android" ? (
<>
{/* Android renders its own in-screen header instead of the native bar. */}
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="Settings" onBack={() => navigation.goBack()} />
</>
) : (
{Platform.OS !== "android" ? (
<NativeStackScreenOptions
options={{
unstable_headerRightItems:
@@ -107,8 +105,12 @@ export function SettingsRouteScreen() {
: undefined,
}}
/>
) : null}
{Platform.OS === "android" ? (
<SettingsScreen title="Settings">{content}</SettingsScreen>
) : (
content
)}
{hasCloudPublicConfig() ? <ConfiguredSettingsRouteScreen /> : <LocalSettingsRouteScreen />}
</>
);
}
@@ -134,6 +136,7 @@ function LocalSettingsRouteScreen() {
icon="desktopcomputer"
label="Environments"
value={`${environmentCount}`}
valuePosition="trailing"
target="SettingsEnvironments"
/>
</SettingsSection>
@@ -516,6 +519,7 @@ function ConfiguredSettingsRouteScreen() {
icon="desktopcomputer"
label="Environments"
value={`${environmentCount}`}
valuePosition="trailing"
target="SettingsEnvironments"
/>
<SettingsSwitchRow
@@ -616,6 +620,7 @@ const AUTO_SETTLE_DEFAULT_DAYS = DEFAULT_SERVER_SETTINGS.sidebarAutoSettleAfterD
*/
function AutoSettleSettingsRows() {
const { environments } = useEnvironments();
const [pendingWrites, setPendingWrites] = useState(0);
const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
label: "server settings update",
reportFailure: true,
@@ -625,16 +630,17 @@ function AutoSettleSettingsRows() {
const reference = syncTargets[0] ?? null;
const referenceSettings = reference?.serverConfig?.settings ?? null;
const [daysDraft, setDaysDraft] = useState<string | null>(null);
if (reference === null || referenceSettings === null) {
return null;
}
const writeToAll = (patch: Partial<AutoSettleSettings>) => {
for (const environment of syncTargets) {
void updateSettings({ environmentId: environment.environmentId, input: { patch } });
}
setPendingWrites((count) => count + 1);
void Promise.allSettled(
syncTargets.map((environment) =>
updateSettings({ environmentId: environment.environmentId, input: { patch } }),
),
).finally(() => setPendingWrites((count) => count - 1));
};
const { patch: autoSettlePatch, mismatches } = planAutoSettleSettingsSync(
@@ -647,21 +653,6 @@ function AutoSettleSettingsRows() {
);
const afterDays = referenceSettings.sidebarAutoSettleAfterDays;
const commitDays = () => {
const draft = (daysDraft ?? "").trim();
setDaysDraft(null);
// Whole-string check so "3.5" and "3days" are rejected instead of
// silently becoming 3 on every eligible sync target.
const parsed = /^\d+$/.test(draft) ? Number(draft) : Number.NaN;
if (
Number.isInteger(parsed) &&
parsed >= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
parsed <= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
parsed !== afterDays
) {
writeToAll({ sidebarAutoSettleAfterDays: parsed });
}
};
return (
<>
@@ -674,28 +665,34 @@ function AutoSettleSettingsRows() {
<SettingsSwitchRow
icon="clock"
label="Auto-settle inactive threads"
subtitle={afterDays === null ? undefined : `After ${afterDays} days without activity`}
value={afterDays !== null}
onValueChange={(value) =>
writeToAll({ sidebarAutoSettleAfterDays: value ? AUTO_SETTLE_DEFAULT_DAYS : null })
}
/>
{afterDays !== null ? (
<View className="flex-row items-center gap-4 border-t border-border-subtle p-4">
<Text className="flex-1 text-lg text-foreground">Days before auto-settle</Text>
<TextInput
className="min-h-10 w-20 rounded-xl px-3 py-2 text-center text-base"
keyboardType="number-pad"
returnKeyType="done"
value={daysDraft ?? String(afterDays)}
onChangeText={setDaysDraft}
onBlur={commitDays}
onSubmitEditing={commitDays}
accessibilityLabel="Days before auto-settle"
<View
className={cn(
"flex-row items-center gap-4 px-4",
Platform.OS === "android" ? "min-h-14 py-3" : "py-4",
)}
>
<View style={{ width: Platform.OS === "android" ? 24 : 22 }} />
<Text
className={cn(
"flex-1 text-foreground",
Platform.OS === "android" ? "text-base" : "text-lg",
)}
>
Inactive days
</Text>
<AutoSettleDaysField
value={afterDays}
onValueChange={(value) => writeToAll({ sidebarAutoSettleAfterDays: value })}
/>
</View>
) : null}
{mismatches.length > 0 ? (
{pendingWrites === 0 && mismatches.length > 0 ? (
<View className="flex-row items-center gap-4 border-t border-border-subtle p-4">
<View className="min-w-0 flex-1">
<Text className="text-lg text-foreground">Auto-settle defaults differ</Text>
@@ -705,14 +702,7 @@ function AutoSettleSettingsRows() {
</View>
<Pressable
accessibilityRole="button"
onPress={() => {
for (const mismatch of mismatches) {
void updateSettings({
environmentId: mismatch.environmentId,
input: { patch: autoSettlePatch },
});
}
}}
onPress={() => writeToAll(autoSettlePatch)}
className="rounded-full bg-subtle px-4 py-2 active:opacity-70"
>
<Text className="text-base font-t3-medium text-foreground">
@@ -831,7 +821,7 @@ function AppSettingsSection() {
<SymbolView
name="info.circle"
size={22}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
@@ -51,9 +51,6 @@ interface AppearancePreferencesContextValue {
readonly themeIds: MobileThemeIds;
readonly themeMode: MobileThemeMode;
readonly themeAppearance: MobileThemeAppearance;
readonly materialYouStyleLayoutEnabled: boolean;
readonly materialYouStyleLayoutActive: boolean;
readonly setMaterialYouStyleLayoutEnabled: (value: boolean) => void;
readonly systemColorsAvailable: boolean;
readonly systemColorsActive: boolean;
readonly themeVariables: MobileThemeVariables;
@@ -97,8 +94,6 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
[resolvedThemeIds.dark, resolvedThemeIds.light],
);
const themeId = themeIds[themeAppearance];
const materialYouStyleLayoutEnabled = storedPreferences?.materialYouStyleLayoutEnabled ?? false;
const materialYouStyleLayoutActive = Platform.OS === "android" && materialYouStyleLayoutEnabled;
const systemColorsActive = themeId === "material-you" && isSystemColorsAvailable;
const [systemColorPalettes, setSystemColorPalettes] = useState(readSystemColorPalettes);
useEffect(() => {
@@ -120,7 +115,7 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
}, []);
const themeVariablesByAppearance = useMemo(() => {
const resolve = (appearance: MobileThemeAppearance) => {
const base = getMobileThemeRuntimeVariables(themeIds[appearance], appearance);
const base = getMobileThemeRuntimeVariables(themeIds[appearance], appearance, Platform.OS);
return themeIds[appearance] === "material-you" && systemColorPalettes
? materialYouPaletteToMobileThemeVariables(
systemColorPalettes[appearance],
@@ -247,13 +242,6 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
[runtimeState, syncThemeRuntime, updateThemePreferences],
);
const setMaterialYouStyleLayoutEnabled = useCallback(
(value: boolean) => {
updatePreferences({ materialYouStyleLayoutEnabled: value });
},
[updatePreferences],
);
const setBaseFontSize = useCallback(
(value: number) => {
const current = appliedRuntimeStateRef.current ?? runtimeState;
@@ -293,9 +281,6 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
themeAppearance,
systemColorsAvailable: isSystemColorsAvailable,
systemColorsActive,
materialYouStyleLayoutEnabled,
materialYouStyleLayoutActive,
setMaterialYouStyleLayoutEnabled,
themeVariables,
themeVariablesByAppearance,
systemColorPalettes,
@@ -315,9 +300,6 @@ export function AppearancePreferencesProvider(props: { readonly children: ReactN
themeMode,
themeAppearance,
systemColorsActive,
materialYouStyleLayoutEnabled,
materialYouStyleLayoutActive,
setMaterialYouStyleLayoutEnabled,
themeVariables,
themeVariablesByAppearance,
systemColorPalettes,
@@ -0,0 +1,81 @@
import { Host, Slider } from "@expo/ui/jetpack-compose";
import { fillMaxWidth } from "@expo/ui/jetpack-compose/modifiers";
import * as Haptics from "expo-haptics";
import { useRef, type ComponentProps } from "react";
import { View } from "react-native";
import { AppText as Text } from "../../../../components/AppText";
import { SymbolView } from "../../../../components/AppSymbol";
import { useAppearancePreferences } from "../AppearancePreferencesProvider";
import type { FontSizeSliderRow as SharedFontSizeSliderRow } from "./FontSizeSliderRow.shared";
export function FontSizeSliderRow(props: ComponentProps<typeof SharedFontSizeSliderRow>) {
const {
themeAppearance,
systemColorsActive,
themeVariables: colors,
} = useAppearancePreferences();
const draft = useRef(props.value);
const commit = (value: number) => {
if (props.disabled) return;
const next = Math.min(
props.max,
Math.max(props.min, props.min + Math.round((value - props.min) / props.step) * props.step),
);
if (next === props.value) return;
void Haptics.selectionAsync().catch(() => undefined);
props.onChange(next);
};
return (
<View className={props.disabled ? "gap-2 p-4 opacity-45" : "gap-2 p-4"}>
<View className="flex-row items-center gap-4">
<SymbolView name={props.icon} size={24} tintColorClassName="accent-icon" />
<Text className="min-w-0 flex-1 text-base">{props.label}</Text>
<Text className="text-sm text-foreground-muted">{props.valueLabel}</Text>
</View>
<View
accessible
accessibilityLabel={props.label}
accessibilityRole="adjustable"
accessibilityState={{ disabled: Boolean(props.disabled) }}
accessibilityValue={{
min: props.min,
max: props.max,
now: props.value,
text: props.valueLabel,
}}
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
onAccessibilityAction={({ nativeEvent }) => {
if (nativeEvent.actionName === "increment") commit(props.value + props.step);
else if (nativeEvent.actionName === "decrement") commit(props.value - props.step);
}}
>
<View importantForAccessibility="no-hide-descendants">
<Host
colorScheme={themeAppearance}
seedColor={systemColorsActive ? undefined : colors["--color-primary"]}
style={{ height: 48, width: "100%" }}
>
<Slider
min={props.min}
max={props.max}
value={props.value}
steps={Math.max(0, Math.round((props.max - props.min) / props.step) - 1)}
enabled={!props.disabled}
modifiers={[fillMaxWidth()]}
colors={{
thumbColor: colors["--color-primary"],
activeTrackColor: colors["--color-primary"],
inactiveTrackColor: colors["--color-secondary"],
}}
onValueChange={(value) => {
draft.current = value;
}}
onValueChangeFinished={() => commit(draft.current)}
/>
</Host>
</View>
</View>
</View>
);
}
@@ -0,0 +1,211 @@
import * as Haptics from "expo-haptics";
import { SymbolView } from "../../../../components/AppSymbol";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { View, type AccessibilityActionEvent } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import Animated, {
runOnJS,
useAnimatedStyle,
useSharedValue,
withTiming,
} from "react-native-reanimated";
import type { ComponentProps } from "react";
import { AppText as Text } from "../../../../components/AppText";
type SymbolName = ComponentProps<typeof SymbolView>["name"];
const THUMB_SIZE = 26;
const TRACK_HEIGHT = 4;
const SNAP_ANIMATION = { duration: 120 } as const;
function clampFraction(value: number): number {
"worklet";
return Math.min(1, Math.max(0, value));
}
export function FontSizeSliderRow(props: {
readonly disabled?: boolean;
readonly icon: SymbolName;
readonly label: string;
readonly valueLabel: string;
readonly min: number;
readonly max: number;
readonly step: number;
readonly value: number;
readonly onChange: (value: number) => void;
}) {
const latest = useRef(props);
latest.current = props;
const { min, max, step, value, disabled } = props;
const fraction = (value - min) / (max - min);
const progress = useSharedValue(clampFraction(fraction));
const trackWidth = useSharedValue(0);
const dragging = useSharedValue(false);
useEffect(() => {
if (!dragging.value) {
progress.value = withTiming(clampFraction(fraction), SNAP_ANIMATION);
}
}, [dragging, fraction, progress]);
const commit = useCallback((next: number) => {
const current = latest.current;
if (current.disabled || next === current.value) {
return;
}
Haptics.selectionAsync().catch(() => undefined);
current.onChange(next);
}, []);
const gesture = useMemo(() => {
const snapValue = (raw: number): number => {
"worklet";
const stepped = Math.round((raw - min) / step) * step + min;
return Math.min(max, Math.max(min, stepped));
};
const fractionAt = (x: number): number => {
"worklet";
const usable = trackWidth.value - THUMB_SIZE;
if (usable <= 0) {
return 0;
}
return clampFraction((x - THUMB_SIZE / 2) / usable);
};
const valueAtFraction = (f: number): number => {
"worklet";
return snapValue(min + f * (max - min));
};
const fractionOfValue = (v: number): number => {
"worklet";
return clampFraction((v - min) / (max - min));
};
const pan = Gesture.Pan()
.enabled(!disabled)
.activeOffsetX([-8, 8])
.failOffsetY([-12, 12])
.onUpdate((event) => {
dragging.value = true;
const f = fractionAt(event.x);
progress.value = f;
})
.onFinalize((_event, success) => {
if (!dragging.value) {
return;
}
dragging.value = false;
if (!success) {
progress.value = withTiming(fractionOfValue(value), SNAP_ANIMATION);
return;
}
const next = valueAtFraction(progress.value);
progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION);
runOnJS(commit)(next);
});
const tap = Gesture.Tap()
.enabled(!disabled)
.onEnd((event) => {
const next = valueAtFraction(fractionAt(event.x));
progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION);
runOnJS(commit)(next);
});
return Gesture.Race(pan, tap);
}, [commit, disabled, dragging, max, min, progress, step, trackWidth, value]);
const fillStyle = useAnimatedStyle(() => ({
width: THUMB_SIZE / 2 + progress.value * Math.max(0, trackWidth.value - THUMB_SIZE),
}));
const thumbStyle = useAnimatedStyle(() => ({
transform: [{ translateX: progress.value * Math.max(0, trackWidth.value - THUMB_SIZE) }],
}));
const handleAccessibilityAction = (event: AccessibilityActionEvent) => {
if (event.nativeEvent.actionName === "increment") {
commit(Math.min(max, value + step));
} else if (event.nativeEvent.actionName === "decrement") {
commit(Math.max(min, value - step));
}
};
return (
<View className={disabled ? "gap-1 p-4 opacity-[0.45]" : "gap-1 p-4"}>
<View className="flex-row items-center gap-4">
<SymbolView
name={props.icon}
size={22}
tintColorClassName={"accent-icon"}
type="monochrome"
weight="regular"
/>
<Text className="flex-1 text-lg text-foreground">{props.label}</Text>
<Text className="text-base font-t3-medium text-foreground-muted">{props.valueLabel}</Text>
</View>
<View className="flex-row items-center gap-3">
<SymbolView
name="textformat.size.smaller"
size={15}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
weight="regular"
/>
<GestureDetector gesture={gesture}>
<View
accessible
accessibilityActions={[
{ name: "increment", label: `Increase ${props.label}` },
{ name: "decrement", label: `Decrease ${props.label}` },
]}
accessibilityLabel={props.label}
accessibilityRole="adjustable"
accessibilityState={{ disabled: Boolean(disabled) }}
accessibilityValue={{ min, max, now: value, text: props.valueLabel }}
className="h-11 flex-1 justify-center"
onAccessibilityAction={handleAccessibilityAction}
onLayout={(event) => {
trackWidth.value = event.nativeEvent.layout.width;
}}
>
<View
className="w-full rounded-full bg-secondary-border"
style={{ height: TRACK_HEIGHT }}
>
<Animated.View
className="absolute inset-y-0 left-0 rounded-full bg-primary"
style={fillStyle}
/>
</View>
<Animated.View
className="absolute left-0 rounded-full border-border bg-primary-foreground"
style={[
{
borderWidth: 1,
height: THUMB_SIZE,
marginTop: -THUMB_SIZE / 2,
shadowColor: "#000000",
shadowOffset: { height: 2, width: 0 },
shadowOpacity: 0.18,
shadowRadius: 3,
top: "50%",
width: THUMB_SIZE,
},
thumbStyle,
]}
/>
</View>
</GestureDetector>
<SymbolView
name="textformat.size.larger"
size={22}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
weight="regular"
/>
</View>
</View>
);
}
@@ -1,210 +1 @@
import * as Haptics from "expo-haptics";
import { SymbolView } from "../../../../components/AppSymbol";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { View, type AccessibilityActionEvent } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import Animated, {
runOnJS,
useAnimatedStyle,
useSharedValue,
withTiming,
} from "react-native-reanimated";
import type { ComponentProps } from "react";
import { AppText as Text } from "../../../../components/AppText";
type SymbolName = ComponentProps<typeof SymbolView>["name"];
const THUMB_SIZE = 26;
const TRACK_HEIGHT = 4;
const SNAP_ANIMATION = { duration: 120 } as const;
function clampFraction(value: number): number {
"worklet";
return Math.min(1, Math.max(0, value));
}
export function FontSizeSliderRow(props: {
readonly disabled?: boolean;
readonly icon: SymbolName;
readonly label: string;
readonly valueLabel: string;
readonly min: number;
readonly max: number;
readonly step: number;
readonly value: number;
readonly onChange: (value: number) => void;
}) {
const latest = useRef(props);
latest.current = props;
const { min, max, step, value, disabled } = props;
const fraction = (value - min) / (max - min);
const progress = useSharedValue(clampFraction(fraction));
const trackWidth = useSharedValue(0);
const dragging = useSharedValue(false);
useEffect(() => {
if (!dragging.value) {
progress.value = withTiming(clampFraction(fraction), SNAP_ANIMATION);
}
}, [dragging, fraction, progress]);
const commit = useCallback((next: number) => {
const current = latest.current;
if (next === current.value) {
return;
}
Haptics.selectionAsync().catch(() => undefined);
current.onChange(next);
}, []);
const gesture = useMemo(() => {
const snapValue = (raw: number): number => {
"worklet";
const stepped = Math.round((raw - min) / step) * step + min;
return Math.min(max, Math.max(min, stepped));
};
const fractionAt = (x: number): number => {
"worklet";
const usable = trackWidth.value - THUMB_SIZE;
if (usable <= 0) {
return 0;
}
return clampFraction((x - THUMB_SIZE / 2) / usable);
};
const valueAtFraction = (f: number): number => {
"worklet";
return snapValue(min + f * (max - min));
};
const fractionOfValue = (v: number): number => {
"worklet";
return clampFraction((v - min) / (max - min));
};
const pan = Gesture.Pan()
.enabled(!disabled)
.activeOffsetX([-8, 8])
.failOffsetY([-12, 12])
.onUpdate((event) => {
dragging.value = true;
const f = fractionAt(event.x);
progress.value = f;
})
.onFinalize((_event, success) => {
if (!dragging.value) {
return;
}
dragging.value = false;
if (!success) {
progress.value = withTiming(fractionOfValue(value), SNAP_ANIMATION);
return;
}
const next = valueAtFraction(progress.value);
progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION);
runOnJS(commit)(next);
});
const tap = Gesture.Tap()
.enabled(!disabled)
.onEnd((event) => {
const next = valueAtFraction(fractionAt(event.x));
progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION);
runOnJS(commit)(next);
});
return Gesture.Race(pan, tap);
}, [commit, disabled, dragging, max, min, progress, step, trackWidth, value]);
const fillStyle = useAnimatedStyle(() => ({
width: THUMB_SIZE / 2 + progress.value * Math.max(0, trackWidth.value - THUMB_SIZE),
}));
const thumbStyle = useAnimatedStyle(() => ({
transform: [{ translateX: progress.value * Math.max(0, trackWidth.value - THUMB_SIZE) }],
}));
const handleAccessibilityAction = (event: AccessibilityActionEvent) => {
if (event.nativeEvent.actionName === "increment") {
commit(Math.min(max, value + step));
} else if (event.nativeEvent.actionName === "decrement") {
commit(Math.max(min, value - step));
}
};
return (
<View className={disabled ? "gap-1 p-4 opacity-[0.45]" : "gap-1 p-4"}>
<View className="flex-row items-center gap-4">
<SymbolView
name={props.icon}
size={22}
tintColorClassName={"accent-icon"}
type="monochrome"
weight="regular"
/>
<Text className="flex-1 text-lg text-foreground">{props.label}</Text>
<Text className="text-base font-t3-medium text-foreground-muted">{props.valueLabel}</Text>
</View>
<View className="flex-row items-center gap-3">
<SymbolView
name="textformat.size.smaller"
size={15}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
weight="regular"
/>
<GestureDetector gesture={gesture}>
<View
accessible
accessibilityActions={[
{ name: "increment", label: `Increase ${props.label}` },
{ name: "decrement", label: `Decrease ${props.label}` },
]}
accessibilityLabel={props.label}
accessibilityRole="adjustable"
accessibilityValue={{ min, max, now: value, text: props.valueLabel }}
className="h-11 flex-1 justify-center"
onAccessibilityAction={handleAccessibilityAction}
onLayout={(event) => {
trackWidth.value = event.nativeEvent.layout.width;
}}
>
<View
className="w-full rounded-full bg-secondary-border"
style={{ height: TRACK_HEIGHT }}
>
<Animated.View
className="absolute inset-y-0 left-0 rounded-full bg-primary"
style={fillStyle}
/>
</View>
<Animated.View
className="absolute left-0 rounded-full border-border bg-primary-foreground"
style={[
{
borderWidth: 1,
height: THUMB_SIZE,
marginTop: -THUMB_SIZE / 2,
shadowColor: "#000000",
shadowOffset: { height: 2, width: 0 },
shadowOpacity: 0.18,
shadowRadius: 3,
top: "50%",
width: THUMB_SIZE,
},
thumbStyle,
]}
/>
</View>
</GestureDetector>
<SymbolView
name="textformat.size.larger"
size={22}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
weight="regular"
/>
</View>
</View>
);
}
export { FontSizeSliderRow } from "./FontSizeSliderRow.shared";
@@ -1,5 +1,5 @@
import { memo, useId } from "react";
import { Platform, Pressable, View } from "react-native";
import { Pressable, View } from "react-native";
import Svg, { Circle, Defs, RadialGradient, Stop } from "react-native-svg";
import { ScopedTheme, ScopedVariables } from "uniwind";
@@ -19,9 +19,6 @@ import { getMobileUniwindThemeName } from "../../../../lib/mobileThemeRuntime";
import { cn } from "../../../../lib/cn";
import { useAppearancePreferences } from "../AppearancePreferencesProvider";
import { SettingsSection } from "../../components/SettingsSection";
import { SettingsSwitchRow } from "../../components/SettingsSwitchRow";
const APPEARANCE_MODES: ReadonlyArray<{
readonly id: MobileThemeMode;
readonly label: string;
@@ -293,25 +290,11 @@ export function ThemeAppearanceSection() {
setThemeMode,
themeIds,
themeMode,
materialYouStyleLayoutEnabled,
setMaterialYouStyleLayoutEnabled,
systemColorsAvailable,
} = useAppearancePreferences();
return (
<View className="gap-6">
{Platform.OS === "android" ? (
<SettingsSection card title="Android">
<SettingsSwitchRow
disabled={!isReady}
icon="square.grid.2x2"
label="Material You Layout"
onValueChange={setMaterialYouStyleLayoutEnabled}
subtitle="Use Material You surfaces, shapes, and component styling."
value={materialYouStyleLayoutEnabled}
/>
</SettingsSection>
) : null}
<View className="gap-2">
<SectionLabel>Color scheme</SectionLabel>
<View accessibilityRole="radiogroup" className="flex-row gap-2">
@@ -0,0 +1,50 @@
import {
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
} from "@t3tools/contracts";
import { View } from "react-native";
import { AppText } from "../../../components/AppText";
import { MaterialIconButton } from "../../../components/MaterialIconButton";
import type { AutoSettleDaysFieldProps } from "./AutoSettleDaysField";
export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
const adjust = (amount: number) => {
const next = Math.max(
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
Math.min(MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS, props.value + amount),
);
if (next !== props.value) props.onValueChange(next);
};
return (
<View className="shrink-0 flex-row items-center">
{/* Match the 32dp switch track while retaining 48dp button touch targets. */}
<View
pointerEvents="none"
className="absolute inset-x-0 rounded-full bg-subtle"
style={{ height: 32 }}
/>
<MaterialIconButton
icon="minus"
accessibilityLabel="Decrease days before auto-settle"
disabled={props.value <= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
onPress={() => adjust(-1)}
/>
<AppText
className="min-w-8 text-center text-base"
style={{ fontVariant: ["tabular-nums"] }}
accessibilityLabel={`${props.value} ${props.value === 1 ? "day" : "days"} before auto-settle`}
accessibilityLiveRegion="polite"
>
{props.value}
</AppText>
<MaterialIconButton
icon="plus"
accessibilityLabel="Increase days before auto-settle"
disabled={props.value >= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
onPress={() => adjust(1)}
/>
</View>
);
}
@@ -0,0 +1,94 @@
import { Button, Host, HStack, Picker, Popover, Text, VStack } from "@expo/ui/swift-ui";
import {
accessibilityLabel,
buttonStyle,
font,
foregroundStyle,
frame,
padding,
pickerStyle,
presentationBackground,
tag,
} from "@expo/ui/swift-ui/modifiers";
import {
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
} from "@t3tools/contracts";
import { useState } from "react";
import { useAppearancePreferences } from "../appearance/AppearancePreferencesProvider";
import type { AutoSettleDaysFieldProps } from "./AutoSettleDaysField";
const days = Array.from(
{ length: MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS - MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS + 1 },
(_, index) => MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS + index,
);
export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
const { themeAppearance, themeVariables: colors, appearance } = useAppearancePreferences();
const [open, setOpen] = useState(false);
const [draft, setDraft] = useState(props.value);
return (
<Host matchContents colorScheme={themeAppearance} seedColor={colors["--color-primary"]}>
<Popover isPresented={open} onIsPresentedChange={setOpen}>
<Popover.Trigger>
<Button
onPress={() => {
setDraft(props.value);
setOpen(true);
}}
modifiers={[
buttonStyle("bordered"),
accessibilityLabel(`Days before auto-settle: ${props.value}`),
frame({ minWidth: 64, minHeight: 44 }),
foregroundStyle(colors["--color-primary"]),
font({ size: appearance.baseFontSize }),
]}
>
<Text>{String(props.value)}</Text>
</Button>
</Popover.Trigger>
<Popover.Content>
<VStack
modifiers={[
padding({ all: 12 }),
frame({ width: 240 }),
presentationBackground(colors["--color-sheet-solid"]),
]}
>
<Picker
label="Days before auto-settle"
selection={draft}
onSelectionChange={setDraft}
modifiers={[pickerStyle("wheel"), frame({ height: 180 })]}
>
{days.map((value) => (
<Text
key={value}
modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
>
{`${value} ${value === 1 ? "day" : "days"}`}
</Text>
))}
</Picker>
<HStack spacing={24}>
<Button
label="Cancel"
onPress={() => setOpen(false)}
modifiers={[foregroundStyle(colors["--color-primary"])]}
/>
<Button
label="Done"
onPress={() => {
setOpen(false);
if (draft !== props.value) props.onValueChange(draft);
}}
modifiers={[foregroundStyle(colors["--color-primary"])]}
/>
</HStack>
</VStack>
</Popover.Content>
</Popover>
</Host>
);
}
@@ -0,0 +1,42 @@
import { useState } from "react";
import {
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
} from "@t3tools/contracts";
import { AppTextInput } from "../../../components/AppText";
export interface AutoSettleDaysFieldProps {
readonly value: number;
readonly onValueChange: (value: number) => void;
}
export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
const [draft, setDraft] = useState<string | null>(null);
const commit = () => {
const text = (draft ?? "").trim();
setDraft(null);
// Validate the whole input; decimals and trailing text must not become whole days.
const parsed = /^\d+$/.test(text) ? Number(text) : Number.NaN;
if (
Number.isInteger(parsed) &&
parsed >= MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
parsed <= MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS &&
parsed !== props.value
) {
props.onValueChange(parsed);
}
};
return (
<AppTextInput
className="min-h-10 w-20 rounded-xl px-3 py-2 text-center text-base"
keyboardType="number-pad"
returnKeyType="done"
value={draft ?? String(props.value)}
onChangeText={setDraft}
onBlur={commit}
onSubmitEditing={commit}
accessibilityLabel="Days before auto-settle"
/>
);
}
@@ -1,11 +1,12 @@
import { MaterialListRow } from "../../../components/MaterialListRow";
import { useNavigation } from "@react-navigation/native";
import type { ComponentProps } from "react";
import { Pressable, View } from "react-native";
import { Platform, Pressable, View } from "react-native";
import { SymbolView } from "../../../components/AppSymbol";
import { AppText as Text } from "../../../components/AppText";
import type { SettingsLegalDocumentTarget, SettingsSheetTarget } from "./settings-sheet-targets";
import { cn } from "../../../lib/cn";
type SymbolName = ComponentProps<typeof SymbolView>["name"];
@@ -14,44 +15,77 @@ export function SettingsRow(props: {
readonly icon: SymbolName;
readonly label: string;
readonly value?: string;
readonly valuePosition?: "below" | "trailing";
readonly target?: SettingsSheetTarget;
readonly fullScreenTarget?: SettingsLegalDocumentTarget;
readonly onPress?: () => void;
}) {
const navigation = useNavigation();
if (Platform.OS === "android") {
return (
<MaterialListRow
title={props.label}
subtitle={props.valuePosition === "trailing" ? undefined : props.value}
accessibilityLabel={[props.label, props.value].filter(Boolean).join(", ")}
trailing={
props.valuePosition === "trailing" && props.value ? (
<View className="flex-row items-center gap-3">
<Text className="text-sm text-foreground-muted">{props.value}</Text>
<SymbolView name="chevron.right" size={16} tintColorClassName="accent-chevron" />
</View>
) : undefined
}
disabled={props.disabled}
leading={
<SymbolView
name={props.icon}
size={24}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
}
onPress={() => {
if (props.target)
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: props.target },
});
else if (props.fullScreenTarget) navigation.navigate(props.fullScreenTarget);
else props.onPress?.();
}}
/>
);
}
const content = (
<View
className={
props.disabled
? "flex-row items-center gap-4 p-4 opacity-[0.45]"
: "flex-row items-center gap-4 p-4"
}
>
<View className={cn("flex-row items-center gap-4 p-4", props.disabled && "opacity-[0.45]")}>
<SymbolView
name={props.icon}
size={22}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
<Text className="shrink-0 text-lg text-foreground" numberOfLines={1}>
{props.label}
</Text>
<View className="min-w-0 flex-1 items-end">
{props.value ? (
<Text
className="max-w-[180px] text-right text-base text-foreground-muted"
ellipsizeMode="middle"
numberOfLines={1}
>
{props.value}
</Text>
) : null}
</View>
<>
<Text className="shrink-0 text-lg text-foreground" numberOfLines={1}>
{props.label}
</Text>
<View className="min-w-0 flex-1 items-end">
{props.value ? (
<Text
className="max-w-[180px] text-right text-base text-foreground-muted"
ellipsizeMode="middle"
numberOfLines={1}
>
{props.value}
</Text>
) : null}
</View>
</>
<SymbolView
name="chevron.right"
size={16}
tintColorClassName={"accent-chevron"}
tintColorClassName="accent-chevron"
type="monochrome"
weight="semibold"
/>
@@ -92,7 +126,12 @@ export function SettingsRow(props: {
}
return (
<Pressable accessibilityRole="button" disabled={props.disabled} onPress={props.onPress}>
<Pressable
accessibilityLabel={props.label}
accessibilityRole="button"
disabled={props.disabled}
onPress={props.onPress}
>
{content}
</Pressable>
);
@@ -0,0 +1,43 @@
import { useNavigation } from "@react-navigation/native";
import type { ComponentProps, ReactNode } from "react";
import { Platform, View } from "react-native";
import { AndroidScreenHeader } from "../../../components/AndroidScreenHeader";
import { MaterialScreenContent as SettingsScreenContent } from "../../../components/MaterialScreenContent";
import { NativeStackScreenOptions } from "../../../native/StackHeader";
import { AndroidWorkspaceSidebarButton } from "../../layout/workspace-sidebar-toolbar";
export { SettingsScreenContent };
export function SettingsScreen(
props: Pick<ComponentProps<typeof AndroidScreenHeader>, "title" | "actions" | "trailing"> & {
readonly children: ReactNode;
/** A native form sheet already owns its rounded outer frame. */
readonly formSheet?: boolean;
},
) {
const navigation = useNavigation();
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader
title={props.title}
leading={props.formSheet ? undefined : <AndroidWorkspaceSidebarButton />}
actions={props.actions}
trailing={props.trailing}
onBack={() => navigation.goBack()}
hideBottomBorder={!props.formSheet}
/>
</>
) : null}
{props.formSheet ? (
props.children
) : (
<SettingsScreenContent>{props.children}</SettingsScreenContent>
)}
</View>
);
}
@@ -1,5 +1,5 @@
import type { ReactNode } from "react";
import { View } from "react-native";
import { Platform, View } from "react-native";
import { AppText as Text } from "../../../components/AppText";
@@ -12,13 +12,23 @@ export function SettingsSection(props: {
return (
<View className="gap-2">
{props.title ? (
<Text className="px-2 text-sm font-t3-medium text-foreground-muted">{props.title}</Text>
<Text
className={
Platform.OS === "android"
? "px-4 text-sm font-t3-medium text-primary"
: "px-2 text-sm font-t3-medium text-foreground-muted"
}
>
{props.title}
</Text>
) : null}
<View
className={
props.card
? "overflow-hidden rounded-[24px] border-continuous bg-card"
: "overflow-hidden rounded-[24px] border-continuous bg-card android:bg-transparent"
Platform.OS === "android"
? "overflow-hidden rounded-[28px] bg-card"
: props.card
? "overflow-hidden rounded-[24px] border-continuous bg-card"
: "overflow-hidden rounded-[24px] border-continuous bg-card android:bg-transparent"
}
>
{props.children}
@@ -1,5 +1,6 @@
import { cn } from "../../../lib/cn";
import type { ComponentProps } from "react";
import { View } from "react-native";
import { Platform, View } from "react-native";
import { SymbolView } from "../../../components/AppSymbol";
import { AppText as Text } from "../../../components/AppText";
@@ -17,21 +18,28 @@ export function SettingsSwitchRow(props: {
}) {
return (
<View
className={
props.disabled
? "flex-row items-center gap-4 p-4 opacity-[0.45]"
: "flex-row items-center gap-4 p-4"
}
className={cn(
"flex-row items-center gap-4",
Platform.OS === "android" ? "min-h-14 px-4 py-3" : "p-4",
Platform.OS === "android" && props.subtitle && "min-h-18",
props.disabled && "opacity-[0.45]",
)}
>
<SymbolView
name={props.icon}
size={22}
tintColorClassName={"accent-icon"}
size={Platform.OS === "android" ? 24 : 22}
tintColorClassName="accent-icon"
type="monochrome"
weight="regular"
/>
<View className="min-w-0 flex-1">
<Text className="text-lg text-foreground">{props.label}</Text>
<View className={cn("min-w-0 flex-1", Platform.OS === "android" && "gap-1")}>
<Text
className={
Platform.OS === "android" ? "text-base text-foreground" : "text-lg text-foreground"
}
>
{props.label}
</Text>
{props.subtitle ? (
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
) : null}
@@ -1,4 +1,3 @@
import { BlurTargetView } from "expo-blur";
import { DEFAULT_TERMINAL_ID, EnvironmentId, ThreadId } from "@t3tools/contracts";
import { type KnownTerminalSession } from "@t3tools/client-runtime/state/terminal";
import type { MenuAction } from "@react-native-menu/menu";
@@ -7,6 +6,7 @@ import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/Stac
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Alert, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/AppText";
import { TerminalContextSheet } from "./TerminalContextSheet";
import { hasNativeTerminalSurface } from "./nativeTerminalModule";
@@ -29,6 +29,9 @@ import { ControlPillMenu } from "../../components/ControlPill";
import { EmptyState } from "../../components/EmptyState";
import { GlassSurface } from "../../components/GlassSurface";
import { LoadingScreen } from "../../components/LoadingScreen";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { MaterialButton } from "../../components/MaterialButton";
import { MaterialIconButton } from "../../components/MaterialIconButton";
import { environmentCatalog } from "../../connection/catalog";
import { useEnvironmentPresentation } from "../../state/presentation";
import { terminalEnvironment } from "../../state/terminal";
@@ -50,6 +53,7 @@ import { useThreadSelection } from "../../state/use-thread-selection";
import { useSelectedThreadDetail } from "../../state/use-thread-detail";
import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { AndroidWorkspaceSidebarButton } from "../layout/workspace-sidebar-toolbar";
import { TerminalSurface } from "./NativeTerminalSurface";
import { getMobileTerminalTheme } from "./terminalTheme";
import { terminalDebugLog } from "./terminalDebugLog";
@@ -158,7 +162,7 @@ type ThreadTerminalRouteScreenProps = StaticScreenProps<{
}>;
export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps) {
const terminalBlurTarget = useRef<View>(null);
const insets = useSafeAreaInsets();
const navigation = useNavigation();
const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
const resizeTerminal = useAtomCommand(terminalEnvironment.resize, "terminal resize");
@@ -190,6 +194,7 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
themeAppearance: appearanceScheme,
themeId,
setTerminalFontSize,
themeVariables,
} = useAppearancePreferences();
const fontSize = appearance.terminalFontSize;
const cachedRouteGridSize =
@@ -515,6 +520,12 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
isVisible: state.isVisible,
}));
const isAccessoryVisible = keyboardState.isVisible && !isAccessoryDismissed;
// Android's terminal owns an EditText; turning off autoFocus also clears its native focus.
const terminalAutoFocus =
Platform.OS === "android"
? !isAccessoryDismissed &&
(!SHOWCASE_ENABLED || keyboardFocusRequest > 0 || keyboardState.isVisible)
: !SHOWCASE_ENABLED;
const terminalBottomInset =
(keyboardState.isVisible ? keyboardState.height : 0) +
(isAccessoryVisible ? TERMINAL_ACCESSORY_HEIGHT : 0);
@@ -1103,6 +1114,7 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
}, []);
const handleShowKeyboard = useCallback(() => {
setIsAccessoryDismissed(false);
setKeyboardFocusRequest((current) => current + 1);
}, []);
const handleRetryEnvironment = useCallback(() => {
@@ -1175,22 +1187,10 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
<AndroidScreenHeader
title="Terminal"
subtitle={headerSubtitle}
leading={<AndroidWorkspaceSidebarButton />}
onBack={handleCloseTerminal}
trailing={
<>
{layout.usesSplitView ? (
<AndroidHeaderIconButton
accessibilityLabel={
panes.primarySidebarVisible ? "Maximize terminal" : "Show threads"
}
icon={
panes.primarySidebarVisible
? "arrow.up.left.and.arrow.down.right"
: "sidebar.left"
}
onPress={togglePrimarySidebar}
/>
) : null}
{isEnvironmentReady ? (
<ControlPillMenu
actions={androidTerminalMenuActions}
@@ -1280,162 +1280,188 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
</NativeHeaderToolbar>
) : null}
<View className="flex-1" style={{ backgroundColor: terminalTheme.background }}>
{!isEnvironmentReady ? (
<EnvironmentConnectionNotice
environmentLabel={
environment.presentation?.entry.target.label ??
selectedEnvironmentConnection?.environmentLabel ??
"Environment"
}
connection={
environment.presentation?.connection ?? {
phase: "available",
error: null,
traceId: null,
<MaterialScreenContent>
<View
className="flex-1"
style={{
backgroundColor:
Platform.OS === "android"
? themeVariables["--color-card-alt"]
: terminalTheme.background,
paddingBottom:
Platform.OS === "android" && !keyboardState.isVisible ? insets.bottom : 0,
}}
>
{!isEnvironmentReady ? (
<EnvironmentConnectionNotice
environmentLabel={
environment.presentation?.entry.target.label ??
selectedEnvironmentConnection?.environmentLabel ??
"Environment"
}
}
resourceName="terminal"
onRetry={handleRetryEnvironment}
/>
) : (
<>
<BlurTargetView
ref={terminalBlurTarget}
style={{
flex: 1,
paddingBottom: terminalBottomInset,
}}
>
connection={
environment.presentation?.connection ?? {
phase: "available",
error: null,
traceId: null,
}
}
resourceName="terminal"
onRetry={handleRetryEnvironment}
/>
) : (
<>
<View
pointerEvents="none"
style={{
position: "absolute",
inset: 0,
backgroundColor: terminalTheme.background,
flex: 1,
paddingBottom: terminalBottomInset,
}}
/>
<TerminalSurface
autoFocus={!SHOWCASE_ENABLED}
buffer={terminalSurfaceBuffer}
fontSize={fontSize}
isRunning={isRunning}
keyboardFocusRequest={keyboardFocusRequest}
captureRequest={captureRequest}
onCapture={(text) => {
if (text.trim()) setCapturedOutput(text);
else Alert.alert("No terminal output", "There is no visible output to attach.");
}}
onInput={handleInput}
onResize={handleResize}
style={{ flex: 1 }}
terminalKey={terminalKey}
theme={terminalTheme}
/>
</BlurTargetView>
{selectedThread && hasNativeTerminalSurface() ? (
<Pressable
accessibilityRole="button"
onPress={() => {
KeyboardController.dismiss();
setCaptureRequest((value) => value + 1);
}}
className="px-4 py-2"
>
<Text style={{ color: terminalTheme.foreground }}>Attach visible output</Text>
</Pressable>
) : null}
{isAccessoryVisible ? (
<KeyboardStickyView
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
offset={{ closed: 0, opened: 0 }}
>
<View
className="border-t"
style={{
backgroundColor: terminalTheme.background,
borderTopColor: terminalTheme.border,
minHeight: TERMINAL_ACCESSORY_HEIGHT,
}}
>
<ComposerToolbarRow paddingBottom={4} paddingHorizontal={8} paddingTop={4}>
<ComposerToolbarScroller
contentPaddingRight={2}
fadeOpaque={terminalTheme.background}
fadeTransparent={`${terminalTheme.background}00`}
>
{terminalToolbarActions.map((action) => {
const active =
action.kind === "modifier" && pendingModifier === action.modifier;
return (
<ComposerToolbarButton
key={action.key}
active={active}
label={action.label}
maxWidth={120}
minWidth={action.label.length > 1 ? 56 : 44}
onPress={() => handleToolbarActionPress(action)}
showChevron={false}
textTransform={
action.kind === "modifier" || action.kind === "clear"
? "uppercase"
: "none"
}
/>
);
})}
</ComposerToolbarScroller>
<ComposerToolbarButton
accessibilityLabel="Dismiss keyboard"
icon={{ ios: "keyboard.chevron.compact.down", android: "keyboard_hide" }}
onPress={handleDismissKeyboard}
showChevron={false}
/>
</ComposerToolbarRow>
</View>
</KeyboardStickyView>
) : !keyboardState.isVisible ? (
<Pressable
accessibilityLabel="Show keyboard"
accessibilityRole="button"
onPress={handleShowKeyboard}
style={({ pressed }) => ({
bottom: 16,
borderRadius: 28,
opacity: pressed ? 0.72 : 1,
position: "absolute",
right: 16,
})}
>
<GlassSurface
chrome="none"
blurTarget={terminalBlurTarget}
fallbackColor={terminalTheme.background}
glassEffectStyle="regular"
tintColor="transparent"
style={{
alignItems: "center",
borderRadius: 24,
height: 48,
justifyContent: "center",
width: 48,
}}
pointerEvents="none"
>
<SymbolView
name={{ ios: "keyboard", android: "keyboard" }}
size={20}
tintColor={terminalTheme.foreground}
type="monochrome"
style={{
position: "absolute",
inset: 0,
backgroundColor: terminalTheme.background,
}}
/>
<TerminalSurface
autoFocus={terminalAutoFocus}
buffer={terminalSurfaceBuffer}
fontSize={fontSize}
isRunning={isRunning}
keyboardFocusRequest={keyboardFocusRequest}
captureRequest={captureRequest}
onCapture={(text) => {
if (text.trim()) setCapturedOutput(text);
else Alert.alert("No terminal output", "There is no visible output to attach.");
}}
onInput={handleInput}
onResize={handleResize}
style={{ flex: 1 }}
terminalKey={terminalKey}
theme={terminalTheme}
/>
</View>
{Platform.OS === "android" && !keyboardState.isVisible ? (
<View className="min-h-14 flex-row items-center gap-2 bg-card-alt px-2">
{selectedThread && hasNativeTerminalSurface() ? (
<MaterialButton
label="Attach output"
tone="text"
onPress={() => setCaptureRequest((value) => value + 1)}
/>
) : null}
<View className="flex-1" />
<MaterialIconButton
accessibilityLabel="Show keyboard"
icon="keyboard"
onPress={handleShowKeyboard}
/>
</GlassSurface>
</Pressable>
) : null}
</>
)}
</View>
</View>
) : Platform.OS !== "android" && selectedThread && hasNativeTerminalSurface() ? (
<Pressable
accessibilityRole="button"
onPress={() => {
KeyboardController.dismiss();
setCaptureRequest((value) => value + 1);
}}
className="px-4 py-2"
>
<Text style={{ color: terminalTheme.foreground }}>Attach visible output</Text>
</Pressable>
) : null}
{isAccessoryVisible ? (
<KeyboardStickyView
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
offset={{ closed: 0, opened: 0 }}
>
<View
className="border-t"
style={{
backgroundColor: terminalTheme.background,
borderTopColor: terminalTheme.border,
minHeight: TERMINAL_ACCESSORY_HEIGHT,
}}
>
<ComposerToolbarRow paddingBottom={4} paddingHorizontal={8} paddingTop={4}>
<ComposerToolbarScroller
contentPaddingRight={2}
fadeOpaque={terminalTheme.background}
fadeTransparent={`${terminalTheme.background}00`}
>
{terminalToolbarActions.map((action) => {
const active =
action.kind === "modifier" && pendingModifier === action.modifier;
return (
<ComposerToolbarButton
key={action.key}
active={active}
label={action.label}
maxWidth={120}
minWidth={action.label.length > 1 ? 56 : 44}
onPress={() => handleToolbarActionPress(action)}
showChevron={false}
textTransform={
action.kind === "modifier" || action.kind === "clear"
? "uppercase"
: "none"
}
/>
);
})}
</ComposerToolbarScroller>
<ComposerToolbarButton
accessibilityLabel="Dismiss keyboard"
icon={{ ios: "keyboard.chevron.compact.down", android: "keyboard_hide" }}
onPress={handleDismissKeyboard}
showChevron={false}
/>
</ComposerToolbarRow>
</View>
</KeyboardStickyView>
) : !keyboardState.isVisible && Platform.OS !== "android" ? (
<Pressable
accessibilityLabel="Show keyboard"
accessibilityRole="button"
onPress={handleShowKeyboard}
style={({ pressed }) => ({
bottom: 16,
borderRadius: 28,
opacity: pressed ? 0.72 : 1,
position: "absolute",
right: 16,
})}
>
<GlassSurface
chrome="none"
fallbackColor={terminalTheme.background}
glassEffectStyle="regular"
tintColor="transparent"
style={{
alignItems: "center",
borderRadius: 24,
height: 48,
justifyContent: "center",
width: 48,
}}
pointerEvents="none"
>
<SymbolView
name={{ ios: "keyboard", android: "keyboard" }}
size={20}
tintColor={terminalTheme.foreground}
type="monochrome"
/>
</GlassSurface>
</Pressable>
) : null}
</>
)}
</View>
</MaterialScreenContent>
</>
);
}
@@ -0,0 +1,287 @@
import { MaterialSegmentedButtons } from "../../components/MaterialSegmentedButtons.android";
import {
BasicAlertDialog,
Button,
Column,
DateTimePicker,
Host,
FilledTonalIconButton,
Row,
Shape,
Surface,
Text,
TextButton,
} from "@expo/ui/jetpack-compose";
import {
padding,
size,
width,
fillMaxWidth,
testID,
verticalScroll,
} from "@expo/ui/jetpack-compose/modifiers";
import {
localSnoozeDate,
localSnoozeTime,
resolveCustomSnooze,
type CustomSnoozeInput,
} from "@t3tools/client-runtime/state/thread-settled";
import { requireNativeModule } from "expo";
import { useEffect, useState } from "react";
import { AppState, useWindowDimensions } from "react-native";
import { OverlayPortal } from "../../components/OverlayPortal";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
import type { CustomSnoozeSheet as SharedCustomSnoozeSheet } from "./CustomSnoozeSheet.shared";
import {
applySnoozePickerDate,
applySnoozePickerTime,
snoozeDateToPickerDate,
} from "./customSnoozeDate";
type Props = Parameters<typeof SharedCustomSnoozeSheet>[0];
const roundedCorner = Shape.RoundedCorner;
const modes = [
{ value: "date", label: "Date and time" },
{ value: "duration", label: "Duration" },
] as const;
const units = [
{ value: "minutes", label: "Minutes" },
{ value: "hours", label: "Hours" },
{ value: "days", label: "Days" },
] as const;
function systemUses24HourClock() {
return requireNativeModule<{ is24HourFormat(): boolean }>("T3NativeControls").is24HourFormat();
}
export function CustomSnoozeSheet(props: Props) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const [is24Hour, setIs24Hour] = useState(systemUses24HourClock);
useEffect(() => {
const subscription = AppState.addEventListener("change", (state) => {
if (state === "active") setIs24Hour(systemUses24HourClock());
});
return () => subscription.remove();
}, []);
const titleTypography = useScaledTextRole("title");
const bodyTypography = useScaledTextRole("footnote");
const { width: windowWidth } = useWindowDimensions();
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
const [picker, setPicker] = useState<"date" | "time">("date");
const [amount, setAmount] = useState(2);
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
const [error, setError] = useState<string | null>(null);
const submit = () => {
const input: CustomSnoozeInput =
mode === "date"
? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
: { mode, amount: String(amount), unit };
const snoozedUntil = resolveCustomSnooze(input, new Date());
if (!snoozedUntil) {
setError(
mode === "date" ? "Choose a date and time in the future." : "Enter a positive duration.",
);
return;
}
props.onSnooze(snoozedUntil);
props.onClose();
};
const pickerColors = {
containerColor: colors["--color-card-alt"],
titleContentColor: colors["--color-foreground-secondary"],
headlineContentColor: colors["--color-foreground"],
weekdayContentColor: colors["--color-foreground-secondary"],
subheadContentColor: colors["--color-foreground"],
navigationContentColor: colors["--color-foreground"],
yearContentColor: colors["--color-foreground"],
dayContentColor: colors["--color-foreground"],
currentYearContentColor: colors["--color-primary"],
selectedYearContainerColor: colors["--color-primary"],
selectedYearContentColor: colors["--color-primary-foreground"],
selectedDayContainerColor: colors["--color-primary"],
selectedDayContentColor: colors["--color-primary-foreground"],
todayContentColor: colors["--color-primary"],
todayDateBorderColor: colors["--color-primary"],
dividerColor: colors["--color-border"],
clockDialColor: colors["--color-secondary"],
clockDialSelectedContentColor: colors["--color-primary-foreground"],
clockDialUnselectedContentColor: colors["--color-secondary-foreground"],
selectorColor: colors["--color-primary"],
periodSelectorSelectedContainerColor: colors["--color-secondary"],
periodSelectorSelectedContentColor: colors["--color-secondary-foreground"],
periodSelectorUnselectedContentColor: colors["--color-foreground"],
timeSelectorSelectedContainerColor: colors["--color-secondary"],
timeSelectorSelectedContentColor: colors["--color-secondary-foreground"],
timeSelectorUnselectedContainerColor: colors["--color-card"],
timeSelectorUnselectedContentColor: colors["--color-foreground"],
};
return (
// Recycled thread rows can detach a zero-sized native dialog host.
<OverlayPortal>
<Host colorScheme={themeAppearance} style={{ height: 0, width: 0 }}>
<BasicAlertDialog
onDismissRequest={props.onClose}
properties={{ usePlatformDefaultWidth: false }}
modifiers={[width(Math.min(360, windowWidth - 32))]}
>
<Surface
color={colors["--color-card-alt"]}
contentColor={colors["--color-foreground"]}
shape={roundedCorner({
cornerRadii: { topStart: 28, topEnd: 28, bottomStart: 28, bottomEnd: 28 },
})}
>
<Column modifiers={[fillMaxWidth(), verticalScroll()]}>
<Column
verticalArrangement={{ spacedBy: 16 }}
modifiers={[fillMaxWidth(), padding(24, 24, 24, 16)]}
>
<Text style={titleTypography}>Custom snooze</Text>
<MaterialSegmentedButtons
options={modes}
selected={mode}
onSelect={(value) => {
setMode(value);
setError(null);
}}
/>
{mode === "date" ? (
<MaterialSegmentedButtons
options={[
{
value: "date",
label: date.toLocaleDateString([], { month: "short", day: "numeric" }),
},
{
value: "time",
label: date.toLocaleTimeString([], {
hour: "numeric",
minute: "2-digit",
hourCycle: is24Hour ? "h23" : "h12",
}),
},
]}
selected={picker}
onSelect={setPicker}
/>
) : null}
</Column>
{mode === "date" ? (
<Column horizontalAlignment="center" modifiers={[fillMaxWidth()]}>
<SnoozeDateTimePicker
key={picker}
date={date}
picker={picker}
is24Hour={is24Hour}
colors={pickerColors}
onChange={(selected) => {
setDate((current) =>
picker === "date"
? applySnoozePickerDate(current, selected)
: applySnoozePickerTime(current, selected),
);
setError(null);
}}
/>
</Column>
) : (
<Column
verticalArrangement={{ spacedBy: 16 }}
modifiers={[fillMaxWidth(), padding(24, 8, 24, 16)]}
>
<Row
horizontalArrangement="spaceEvenly"
verticalAlignment="center"
modifiers={[fillMaxWidth()]}
>
<FilledTonalIconButton
enabled={amount > 1}
onClick={() => setAmount((current) => Math.max(1, current - 1))}
colors={{
containerColor: colors["--color-secondary"],
contentColor: colors["--color-secondary-foreground"],
}}
modifiers={[size(48, 48), testID("snooze-decrease-duration")]}
>
<Text style={titleTypography}>−</Text>
</FilledTonalIconButton>
<Text style={titleTypography} modifiers={[testID("snooze-duration")]}>
{String(amount)}
</Text>
<FilledTonalIconButton
enabled={amount < 99}
onClick={() => setAmount((current) => Math.min(99, current + 1))}
colors={{
containerColor: colors["--color-secondary"],
contentColor: colors["--color-secondary-foreground"],
}}
modifiers={[size(48, 48), testID("snooze-increase-duration")]}
>
<Text style={titleTypography}>+</Text>
</FilledTonalIconButton>
</Row>
<MaterialSegmentedButtons options={units} selected={unit} onSelect={setUnit} />
</Column>
)}
<Column
verticalArrangement={{ spacedBy: 16 }}
modifiers={[fillMaxWidth(), padding(24, 8, 24, 24)]}
>
{error ? (
<Text style={bodyTypography} color={colors["--color-danger-foreground"]}>
{error}
</Text>
) : null}
<Row horizontalArrangement="end" modifiers={[fillMaxWidth()]}>
<TextButton
onClick={props.onClose}
colors={{ contentColor: colors["--color-primary"] }}
>
<Text style={bodyTypography}>Cancel</Text>
</TextButton>
<Button
onClick={submit}
colors={{
containerColor: colors["--color-primary"],
contentColor: colors["--color-primary-foreground"],
}}
>
<Text style={bodyTypography}>Snooze</Text>
</Button>
</Row>
</Column>
</Column>
</Surface>
</BasicAlertDialog>
</Host>
</OverlayPortal>
);
}
function SnoozeDateTimePicker(props: {
readonly date: Date;
readonly picker: "date" | "time";
readonly is24Hour: boolean;
readonly colors: React.ComponentProps<typeof DateTimePicker>["elementColors"];
readonly onChange: (date: Date) => void;
}) {
// Changing initialDate resets Compose's picker state, including its active clock dial.
const [initialDate] = useState(() =>
props.picker === "date" ? snoozeDateToPickerDate(props.date) : props.date.toISOString(),
);
return (
<DateTimePicker
initialDate={initialDate}
displayedComponents={props.picker === "date" ? "date" : "hourAndMinute"}
is24Hour={props.is24Hour}
showVariantToggle={false}
elementColors={props.colors}
onDateSelected={props.onChange}
/>
);
}
@@ -3,7 +3,6 @@ import {
DatePicker,
Host,
HStack,
Menu,
Picker,
Popover,
Spacer,
@@ -11,16 +10,20 @@ import {
VStack,
} from "@expo/ui/swift-ui";
import {
background,
accessibilityAddTraits,
accessibilityHidden,
buttonBorderShape,
buttonStyle,
datePickerStyle,
clipped,
controlSize,
font,
datePickerStyle,
foregroundStyle,
frame,
labelsHidden,
labelStyle,
padding,
pickerStyle,
presentationBackground,
shapes,
tag,
} from "@expo/ui/swift-ui/modifiers";
import {
@@ -30,9 +33,8 @@ import {
type CustomSnoozeInput,
} from "@t3tools/client-runtime/state/thread-settled";
import { useState } from "react";
import { Modal, Pressable, ScrollView, View } from "react-native";
import { AppText } from "../../components/AppText";
import { SegmentedControl } from "../../components/SegmentedControl";
import { useWindowDimensions } from "react-native";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
const durationAmounts = Array.from({ length: 99 }, (_, index) => index + 1);
@@ -50,13 +52,13 @@ export function CustomSnoozeSheet(props: {
readonly onClose: () => void;
readonly onSnooze: (snoozedUntil: string) => void;
}) {
const { width } = useWindowDimensions();
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
const [amount, setAmount] = useState(2);
const [amountOpen, setAmountOpen] = useState(false);
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
const [error, setError] = useState<string | null>(null);
const { themeVariables: colors, themeAppearance, appearance } = useAppearancePreferences();
const { themeVariables: colors, themeAppearance } = useAppearancePreferences();
const updateDate = (value: Date) => {
setDate(value);
setError(null);
@@ -79,190 +81,150 @@ export function CustomSnoozeSheet(props: {
};
return (
<Modal visible transparent animationType="fade" onRequestClose={props.onClose}>
<View className="flex-1 items-center justify-center bg-black/40 px-6">
<ScrollView
className="max-h-[80%] w-full max-w-sm grow-0 rounded-3xl border border-border bg-sheet-solid"
contentContainerStyle={{ padding: 20, gap: 16 }}
>
<View className="flex-row items-center justify-between gap-2">
<Pressable accessibilityRole="button" onPress={props.onClose} hitSlop={10}>
<AppText className="text-base">Cancel</AppText>
</Pressable>
<AppText accessibilityRole="header" className="text-base font-t3-semibold">
Custom snooze
</AppText>
<Pressable accessibilityRole="button" onPress={submit} hitSlop={10}>
<AppText className="text-base text-primary">Snooze</AppText>
</Pressable>
</View>
<SegmentedControl
options={modes}
selected={mode}
onSelect={(value) => {
setMode(value);
setError(null);
}}
role="tab"
/>
<Host
matchContents={{ vertical: true }}
style={{ width: "100%" }}
colorScheme={themeAppearance}
seedColor={colors["--color-primary"]}
>
<HStack
spacing={6}
modifiers={[
frame({ minHeight: 44 }),
foregroundStyle(colors["--color-foreground"]),
font({ size: appearance.baseFontSize }),
]}
>
<Text>{mode === "date" ? "Until" : "Snooze for"}</Text>
<Spacer />
{mode === "date" ? (
<>
<SnoozeDateField date={date} component="date" onChange={updateDate} />
<SnoozeDateField date={date} component="hourAndMinute" onChange={updateDate} />
</>
) : (
<>
<Popover isPresented={amountOpen} onIsPresentedChange={setAmountOpen}>
<Popover.Trigger>
<Button
onPress={() => setAmountOpen(true)}
modifiers={[buttonStyle("plain")]}
>
<FieldLabel label={String(amount)} />
</Button>
</Popover.Trigger>
<Popover.Content>
<VStack
modifiers={[
padding({ all: 12 }),
frame({ width: 180 }),
presentationBackground(colors["--color-sheet-solid"]),
]}
>
<Picker
label="Duration"
selection={amount}
onSelectionChange={(value: number) => {
setAmount(value);
setError(null);
}}
modifiers={[pickerStyle("wheel"), frame({ height: 160 })]}
>
{durationAmounts.map((value) => (
<Text
key={value}
modifiers={[
tag(value),
foregroundStyle(colors["--color-foreground"]),
]}
>
{String(value)}
</Text>
))}
</Picker>
<Button
label="Done"
onPress={() => setAmountOpen(false)}
modifiers={[foregroundStyle(colors["--color-primary"])]}
/>
</VStack>
</Popover.Content>
</Popover>
<Menu
label={
<FieldLabel
label={unit === "minutes" ? "Minutes" : unit === "hours" ? "Hours" : "Days"}
/>
}
>
{units.map((option) => (
<Button
key={option.value}
label={option.label}
onPress={() => {
setUnit(option.value);
setError(null);
}}
/>
))}
</Menu>
</>
)}
</HStack>
</Host>
{error && <AppText className="text-sm text-danger-foreground">{error}</AppText>}
</ScrollView>
</View>
</Modal>
);
}
function FieldLabel(props: { readonly label: string }) {
const { themeVariables: colors } = useAppearancePreferences();
return (
<Text
modifiers={[
padding({ horizontal: 12, vertical: 8 }),
foregroundStyle(colors["--color-foreground"]),
background(colors["--color-card"], shapes.capsule()),
]}
<Host
style={{ position: "absolute", top: 0, right: 0, bottom: 0, left: 0 }}
colorScheme={themeAppearance}
seedColor={colors["--color-primary"]}
>
{props.label}
</Text>
);
}
function SnoozeDateField(props: {
readonly date: Date;
readonly component: "date" | "hourAndMinute";
readonly onChange: (date: Date) => void;
}) {
const [open, setOpen] = useState(false);
const { themeVariables: colors } = useAppearancePreferences();
return (
<Popover isPresented={open} onIsPresentedChange={setOpen}>
<Popover.Trigger>
<Button onPress={() => setOpen(true)} modifiers={[buttonStyle("plain")]}>
<FieldLabel
label={
props.component === "date"
? props.date.toLocaleDateString(undefined, {
month: "short",
day: "numeric",
year: "numeric",
})
: props.date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })
}
/>
</Button>
</Popover.Trigger>
<Popover.Content>
<VStack
modifiers={[
padding({ all: 12 }),
frame({ width: props.component === "date" ? 340 : 300 }),
presentationBackground(colors["--color-sheet-solid"]),
]}
>
<DatePicker
selection={props.date}
displayedComponents={[props.component]}
onDateChange={props.onChange}
modifiers={[datePickerStyle(props.component === "date" ? "graphical" : "wheel")]}
/>
<Button
label="Done"
onPress={() => setOpen(false)}
modifiers={[foregroundStyle(colors["--color-primary"])]}
/>
</VStack>
</Popover.Content>
</Popover>
<Popover
isPresented
onIsPresentedChange={(presented) => {
if (!presented) props.onClose();
}}
>
<Popover.Trigger>
<Spacer
modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity }), accessibilityHidden()]}
/>
</Popover.Trigger>
<Popover.Content>
<VStack
spacing={16}
modifiers={[padding({ all: 16 }), frame({ width: Math.min(360, width - 32) })]}
>
<HStack spacing={12}>
<Button
label="Cancel"
systemImage="xmark"
role="cancel"
onPress={props.onClose}
modifiers={[
labelStyle("iconOnly"),
buttonStyle(NATIVE_LIQUID_GLASS_SUPPORTED ? "glass" : "bordered"),
buttonBorderShape("circle"),
controlSize("large"),
]}
/>
<Text
modifiers={[
font({ textStyle: "headline" }),
frame({ maxWidth: Infinity, alignment: "leading" }),
accessibilityAddTraits(["isHeader"]),
]}
>
Custom snooze
</Text>
<Button
label="Snooze"
onPress={submit}
modifiers={[
buttonStyle(
NATIVE_LIQUID_GLASS_SUPPORTED ? "glassProminent" : "borderedProminent",
),
controlSize("large"),
]}
/>
</HStack>
<Picker
label="Snooze mode"
selection={mode}
onSelectionChange={(value: CustomSnoozeInput["mode"]) => {
setMode(value);
setError(null);
}}
modifiers={[pickerStyle("segmented")]}
>
{modes.map((option) => (
<Text key={option.value} modifiers={[tag(option.value)]}>
{option.label}
</Text>
))}
</Picker>
{mode === "date" ? (
<DatePicker
title="Snooze until"
selection={date}
displayedComponents={["date", "hourAndMinute"]}
onDateChange={updateDate}
modifiers={[
datePickerStyle("wheel"),
labelsHidden(),
frame({ maxWidth: Infinity, height: 180 }),
]}
/>
) : (
<HStack spacing={0}>
<Picker
label="Duration amount"
selection={amount}
onSelectionChange={(value: number) => {
setAmount(value);
setError(null);
}}
modifiers={[
pickerStyle("wheel"),
labelsHidden(),
frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
clipped(),
]}
>
{durationAmounts.map((value) => (
<Text
key={value}
modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
>
{String(value)}
</Text>
))}
</Picker>
<Picker
label="Duration unit"
selection={unit}
onSelectionChange={(value: typeof unit) => {
setUnit(value);
setError(null);
}}
modifiers={[
pickerStyle("wheel"),
labelsHidden(),
frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
clipped(),
]}
>
{units.map((option) => (
<Text
key={option.value}
modifiers={[tag(option.value), foregroundStyle(colors["--color-foreground"])]}
>
{option.label}
</Text>
))}
</Picker>
</HStack>
)}
{error ? (
<Text
modifiers={[
font({ textStyle: "footnote" }),
foregroundStyle(colors["--color-danger-foreground"]),
]}
>
{error}
</Text>
) : null}
</VStack>
</Popover.Content>
</Popover>
</Host>
);
}
@@ -0,0 +1,181 @@
import { DateTimePicker } from "@expo/ui/community/datetime-picker";
import {
localSnoozeDate,
localSnoozeTime,
resolveCustomSnooze,
type CustomSnoozeInput,
} from "@t3tools/client-runtime/state/thread-settled";
import { useState } from "react";
import {
KeyboardAvoidingView,
Modal,
Platform,
Pressable,
ScrollView,
TextInput,
View,
} from "react-native";
import { AppText } from "../../components/AppText";
import { SegmentedControl } from "../../components/SegmentedControl";
export function CustomSnoozeSheet(props: {
readonly onClose: () => void;
readonly onSnooze: (snoozedUntil: string) => void;
}) {
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
const [picker, setPicker] = useState<"date" | "time" | null>(null);
const [amount, setAmount] = useState("2");
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
const [error, setError] = useState<string | null>(null);
return (
<Modal visible transparent animationType="fade" onRequestClose={props.onClose}>
<KeyboardAvoidingView
className="flex-1 items-center justify-center bg-black/40 px-6"
behavior={Platform.OS === "ios" ? "padding" : undefined}
>
<ScrollView
className="max-h-[80%] w-full max-w-md grow-0 rounded-3xl bg-screen"
keyboardShouldPersistTaps="handled"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ padding: 24, paddingBottom: 24, gap: 20 }}
>
<AppText accessibilityRole="header" className="text-xl font-t3-semibold">
Custom snooze
</AppText>
<AppText className="text-base text-foreground-secondary">
Choose when snoozed threads return to your inbox.
</AppText>
<SegmentedControl
options={
[
{ value: "date", label: "Date and time" },
{ value: "duration", label: "Duration" },
] as const
}
selected={mode}
onSelect={(value) => {
setMode(value);
setPicker(null);
setError(null);
}}
role="tab"
/>
{mode === "date" ? (
<View className="gap-3">
{(["date", "time"] as const).map((value) => (
<Pressable
key={value}
accessibilityRole="button"
accessibilityLabel={value === "date" ? "Choose date" : "Choose time"}
className="min-h-12 flex-row items-center justify-between rounded-xl bg-subtle px-3"
onPress={() => setPicker(value)}
>
<AppText>{value === "date" ? "Date" : "Time"}</AppText>
<AppText>
{value === "date"
? date.toLocaleDateString()
: date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}
</AppText>
</Pressable>
))}
{picker && (
<DateTimePicker
value={date}
mode={picker}
display={Platform.OS === "ios" ? "spinner" : "default"}
onDismiss={() => setPicker(null)}
onValueChange={(_, selected) => {
const next = new Date(date);
if (picker === "date")
next.setFullYear(
selected.getFullYear(),
selected.getMonth(),
selected.getDate(),
);
else next.setHours(selected.getHours(), selected.getMinutes(), 0, 0);
setDate(next);
setError(null);
}}
/>
)}
</View>
) : (
<View className="gap-3">
<AppText>Snooze for</AppText>
<TextInput
accessibilityLabel="Duration"
className="min-h-12 rounded-xl bg-subtle px-3 text-base text-foreground"
keyboardType="decimal-pad"
value={amount}
onChangeText={(value) => {
setAmount(value);
setError(null);
}}
/>
<View className="flex-row gap-2">
{(["minutes", "hours", "days"] as const).map((value) => (
<Pressable
key={value}
accessibilityRole="radio"
accessibilityState={{ checked: unit === value }}
className={
unit === value
? "min-h-12 flex-1 items-center justify-center rounded-xl bg-subtle"
: "min-h-12 flex-1 items-center justify-center rounded-xl"
}
onPress={() => {
setUnit(value);
setError(null);
}}
>
<AppText>
{value === "minutes" ? "Minutes" : value === "hours" ? "Hours" : "Days"}
</AppText>
</Pressable>
))}
</View>
</View>
)}
{error && (
<AppText accessibilityRole="alert" className="text-danger-foreground">
{error}
</AppText>
)}
<View className="flex-row justify-end gap-3">
<Pressable
accessibilityRole="button"
className="min-h-12 justify-center px-3"
onPress={props.onClose}
>
<AppText>Cancel</AppText>
</Pressable>
<Pressable
accessibilityRole="button"
className="min-h-12 justify-center rounded-xl bg-primary px-3"
onPress={() => {
const input: CustomSnoozeInput =
mode === "date"
? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
: { mode, amount: amount.replace(",", "."), unit };
const snoozedUntil = resolveCustomSnooze(input, new Date());
if (!snoozedUntil) {
setError(
mode === "date"
? "Choose a date and time in the future."
: "Enter a positive duration.",
);
return;
}
props.onSnooze(snoozedUntil);
props.onClose();
}}
>
<AppText className="text-primary-foreground">Snooze</AppText>
</Pressable>
</View>
</ScrollView>
</KeyboardAvoidingView>
</Modal>
);
}
@@ -1,182 +1 @@
import { DateTimePicker } from "@expo/ui/community/datetime-picker";
import {
localSnoozeDate,
localSnoozeTime,
resolveCustomSnooze,
type CustomSnoozeInput,
} from "@t3tools/client-runtime/state/thread-settled";
import { useState } from "react";
import {
KeyboardAvoidingView,
Modal,
Platform,
Pressable,
ScrollView,
TextInput,
View,
} from "react-native";
import { AppText } from "../../components/AppText";
import { SegmentedControl } from "../../components/SegmentedControl";
export function CustomSnoozeSheet(props: {
readonly onClose: () => void;
readonly onSnooze: (snoozedUntil: string) => void;
}) {
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
const [picker, setPicker] = useState<"date" | "time" | null>(null);
const [amount, setAmount] = useState("2");
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
const [error, setError] = useState<string | null>(null);
return (
<Modal visible transparent animationType="fade" onRequestClose={props.onClose}>
<KeyboardAvoidingView
className="flex-1 items-center justify-center bg-black/40 px-6"
behavior={Platform.OS === "ios" ? "padding" : undefined}
>
<ScrollView
className="max-h-[80%] w-full max-w-md grow-0 rounded-3xl bg-screen"
keyboardShouldPersistTaps="handled"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ padding: 24, paddingBottom: 24, gap: 20 }}
>
<AppText accessibilityRole="header" className="text-xl font-t3-semibold">
Custom snooze
</AppText>
<AppText className="text-base text-foreground-secondary">
Choose when snoozed threads return to your inbox.
</AppText>
<SegmentedControl
options={
[
{ value: "date", label: "Date and time" },
{ value: "duration", label: "Duration" },
] as const
}
selected={mode}
onSelect={(value) => {
setMode(value);
setPicker(null);
setError(null);
}}
role="tab"
/>
{mode === "date" ? (
<View className="gap-3">
{(["date", "time"] as const).map((value) => (
<Pressable
key={value}
accessibilityRole="button"
accessibilityLabel={value === "date" ? "Choose date" : "Choose time"}
className="min-h-12 flex-row items-center justify-between rounded-xl bg-subtle px-3"
onPress={() => setPicker(value)}
>
<AppText>{value === "date" ? "Date" : "Time"}</AppText>
<AppText>
{value === "date"
? date.toLocaleDateString()
: date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}
</AppText>
</Pressable>
))}
{picker && (
<DateTimePicker
value={date}
mode={picker}
display={Platform.OS === "ios" ? "spinner" : "default"}
onDismiss={() => setPicker(null)}
onValueChange={(_, selected) => {
const next = new Date(date);
if (picker === "date")
next.setFullYear(
selected.getFullYear(),
selected.getMonth(),
selected.getDate(),
);
else next.setHours(selected.getHours(), selected.getMinutes(), 0, 0);
setDate(next);
setError(null);
if (Platform.OS === "android") setPicker(null);
}}
/>
)}
</View>
) : (
<View className="gap-3">
<AppText>Snooze for</AppText>
<TextInput
accessibilityLabel="Duration"
className="min-h-12 rounded-xl bg-subtle px-3 text-base text-foreground"
keyboardType="decimal-pad"
value={amount}
onChangeText={(value) => {
setAmount(value);
setError(null);
}}
/>
<View className="flex-row gap-2">
{(["minutes", "hours", "days"] as const).map((value) => (
<Pressable
key={value}
accessibilityRole="radio"
accessibilityState={{ checked: unit === value }}
className={
unit === value
? "min-h-12 flex-1 items-center justify-center rounded-xl bg-subtle"
: "min-h-12 flex-1 items-center justify-center rounded-xl"
}
onPress={() => {
setUnit(value);
setError(null);
}}
>
<AppText>
{value === "minutes" ? "Minutes" : value === "hours" ? "Hours" : "Days"}
</AppText>
</Pressable>
))}
</View>
</View>
)}
{error && (
<AppText accessibilityRole="alert" className="text-danger-foreground">
{error}
</AppText>
)}
<View className="flex-row justify-end gap-3">
<Pressable
accessibilityRole="button"
className="min-h-12 justify-center px-3"
onPress={props.onClose}
>
<AppText>Cancel</AppText>
</Pressable>
<Pressable
accessibilityRole="button"
className="min-h-12 justify-center rounded-xl bg-primary px-3"
onPress={() => {
const input: CustomSnoozeInput =
mode === "date"
? { mode, date: localSnoozeDate(date), time: localSnoozeTime(date) }
: { mode, amount: amount.replace(",", "."), unit };
const snoozedUntil = resolveCustomSnooze(input, new Date());
if (!snoozedUntil) {
setError(
mode === "date"
? "Choose a date and time in the future."
: "Enter a positive duration.",
);
return;
}
props.onSnooze(snoozedUntil);
props.onClose();
}}
>
<AppText className="text-primary-foreground">Snooze</AppText>
</Pressable>
</View>
</ScrollView>
</KeyboardAvoidingView>
</Modal>
);
}
export { CustomSnoozeSheet } from "./CustomSnoozeSheet.shared";
@@ -1,3 +1,4 @@
import { MaterialListRow } from "../../components/MaterialListRow";
import type { VcsRef } from "@t3tools/client-runtime/state/vcs";
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
import { LegendList } from "@legendapp/list/react-native";
@@ -20,6 +21,7 @@ import {
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text } from "../../components/AppText";
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
@@ -46,6 +48,34 @@ function SelectionRow(props: {
readonly subtitle?: string;
readonly title: string;
}) {
if (Platform.OS === "android") {
return (
<MaterialListRow
title={props.title}
subtitle={props.subtitle}
leading={
props.icon === "arrow.triangle.branch" ? (
<SymbolView
name="arrow.triangle.branch"
size={24}
tintColorClassName="accent-icon-muted"
/>
) : (
props.icon
)
}
trailing={
props.selected ? (
<SymbolView name="checkmark" size={20} tintColorClassName="accent-primary" />
) : null
}
accessibilityRole="radio"
accessibilityState={{ checked: props.selected }}
disabled={props.disabled}
onPress={props.onPress}
/>
);
}
return (
<Pressable
accessibilityLabel={[props.title, props.subtitle].filter(Boolean).join(", ")}
@@ -63,7 +93,7 @@ function SelectionRow(props: {
<SymbolView
name="arrow.triangle.branch"
size={17}
tintColorClassName={"accent-icon-muted"}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
) : (
@@ -83,7 +113,7 @@ function SelectionRow(props: {
<SymbolView
name="checkmark"
size={16}
tintColorClassName={"accent-icon"}
tintColorClassName="accent-icon"
type="monochrome"
weight="semibold"
/>
@@ -99,7 +129,13 @@ function ToggleRow(props: {
}) {
return (
<View className="min-h-14 flex-row items-center gap-3 bg-card px-4 py-3">
<Text className="min-w-0 flex-1 text-base font-t3-medium text-foreground" numberOfLines={1}>
<Text
className={cn(
"min-w-0 flex-1 text-base text-foreground",
Platform.OS !== "android" && "font-t3-medium",
)}
numberOfLines={1}
>
{props.title}
</Text>
<ThemedSwitch
@@ -125,8 +161,14 @@ function BranchSelectionRow(props: {
return (
<View
className={cn(
props.isFirst && "overflow-hidden rounded-t-2xl",
props.isLast && "overflow-hidden rounded-b-2xl",
props.isFirst &&
(Platform.OS === "android"
? "overflow-hidden rounded-t-[28px]"
: "overflow-hidden rounded-t-2xl"),
props.isLast &&
(Platform.OS === "android"
? "overflow-hidden rounded-b-[28px]"
: "overflow-hidden rounded-b-2xl"),
)}
>
<SelectionRow
@@ -143,7 +185,17 @@ function BranchSelectionRow(props: {
}
function PickerSurface(props: { readonly children: ReactNode }) {
return <View className="overflow-hidden rounded-2xl bg-card">{props.children}</View>;
return (
<View
className={
Platform.OS === "android"
? "overflow-hidden rounded-[28px] bg-card"
: "overflow-hidden rounded-2xl bg-card"
}
>
{props.children}
</View>
);
}
export function NewTaskEnvironmentPickerRouteScreen() {
@@ -161,42 +213,48 @@ export function NewTaskEnvironmentPickerRouteScreen() {
}}
/>
{Platform.OS === "android" ? (
<AndroidScreenHeader title="Environment" onBack={() => navigation.goBack()} />
<AndroidScreenHeader
title="Environment"
hideBottomBorder
onBack={() => navigation.goBack()}
/>
) : null}
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{
paddingBottom: Math.max(insets.bottom, 16) + 16,
paddingHorizontal: 16,
paddingTop: 16,
}}
showsVerticalScrollIndicator={false}
>
<PickerSurface>
{flow.environments.map((environment, index) => (
<SelectionRow
key={String(environment.environmentId)}
icon={
<EnvironmentMachineSymbol
kind={resolveEnvironmentMachineKind(
serverConfigs.get(environment.environmentId) ?? null,
)}
size={17}
tintColorClassName="accent-icon-muted"
/>
}
isLast={index === flow.environments.length - 1}
onPress={() => {
void Haptics.selectionAsync();
flow.selectEnvironment(environment.environmentId);
navigation.goBack();
}}
selected={flow.selectedEnvironmentId === environment.environmentId}
title={environment.environmentLabel}
/>
))}
</PickerSurface>
</ScrollView>
<MaterialScreenContent>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{
paddingBottom: Math.max(insets.bottom, 16) + 16,
paddingHorizontal: 16,
paddingTop: 16,
}}
showsVerticalScrollIndicator={false}
>
<PickerSurface>
{flow.environments.map((environment, index) => (
<SelectionRow
key={String(environment.environmentId)}
icon={
<EnvironmentMachineSymbol
kind={resolveEnvironmentMachineKind(
serverConfigs.get(environment.environmentId) ?? null,
)}
size={Platform.OS === "android" ? 24 : 17}
tintColorClassName="accent-icon-muted"
/>
}
isLast={index === flow.environments.length - 1}
onPress={() => {
void Haptics.selectionAsync();
flow.selectEnvironment(environment.environmentId);
navigation.goBack();
}}
selected={flow.selectedEnvironmentId === environment.environmentId}
title={environment.environmentLabel}
/>
))}
</PickerSurface>
</ScrollView>
</MaterialScreenContent>
</View>
);
}
@@ -225,7 +283,7 @@ export function NewTaskBranchPickerRouteScreen() {
? 16
: Math.max(insets.bottom, 16) + 16,
paddingHorizontal: 16,
paddingTop: 12,
paddingTop: 16,
}),
[insets.bottom, usesNativeMailSearchToolbar],
);
@@ -327,7 +385,12 @@ export function NewTaskBranchPickerRouteScreen() {
const branchListHeader =
flow.workspaceMode === "worktree" ? (
<View className="mb-3 overflow-hidden rounded-2xl">
<View
className={cn(
"mb-3 overflow-hidden",
Platform.OS === "android" ? "rounded-[28px]" : "rounded-2xl",
)}
>
<ToggleRow
onValueChange={flow.setStartFromOrigin}
title="Start from origin"
@@ -339,9 +402,9 @@ export function NewTaskBranchPickerRouteScreen() {
const branchContent =
flow.filteredBranches.length === 0 ? (
<ScrollView
className="flex-1 bg-sheet"
className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 12 }}
contentContainerStyle={{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 16 }}
scrollEnabled={false}
showsVerticalScrollIndicator={false}
>
@@ -380,7 +443,7 @@ export function NewTaskBranchPickerRouteScreen() {
alwaysBounceVertical={false}
automaticallyAdjustsScrollIndicatorInsets
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
className="flex-1 bg-sheet"
className={Platform.OS === "android" ? "flex-1 bg-sheet-solid" : "flex-1 bg-sheet"}
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={branchListContentStyle}
data={flow.filteredBranches}
@@ -408,19 +471,27 @@ export function NewTaskBranchPickerRouteScreen() {
return (
<View className="flex-1 bg-sheet" collapsable={false}>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title={screenTitle} onBack={() => navigation.goBack()} />
<View className="px-4 pb-2 pt-3">
<AndroidScreenHeader
title={screenTitle}
hideBottomBorder
onBack={() => navigation.goBack()}
/>
<View className="bg-header px-4 pb-3 pt-1">
<TextInput
autoCapitalize="none"
autoCorrect={false}
className="h-11 rounded-xl bg-card px-4 font-sans text-base text-foreground"
accessibilityLabel="Find a branch"
className="h-12 rounded-full border border-input-border bg-input px-4 font-sans text-base text-foreground"
selectionColorClassName="accent-primary/32"
cursorColorClassName="accent-primary"
selectionHandleColorClassName="accent-primary"
onChangeText={flow.setBranchQuery}
placeholder="Find a branch"
placeholderTextColorClassName={"accent-placeholder"}
placeholderTextColorClassName="accent-placeholder"
value={flow.branchQuery}
/>
</View>
{branchContent}
<MaterialScreenContent>{branchContent}</MaterialScreenContent>
</View>
);
}
@@ -27,12 +27,10 @@ import Animated from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { useFontFamily } from "../../lib/useFontFamily";
import {
PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
resolveEnvironmentMachineKind,
type EnvironmentId,
} from "@t3tools/contracts";
import {
@@ -51,6 +49,7 @@ import {
ComposerToolbarRow,
} from "../../components/ComposerToolbar";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { ComposerAttachmentButton } from "../../components/ComposerAttachmentButton";
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
import { composerStripAttachments } from "../../lib/composerImages";
@@ -81,7 +80,6 @@ import {
useThreadSettingsSheetPresentation,
type NavigationWithFinishTransitioning,
} from "./use-thread-settings-sheet-presentation";
import { makeTurnCommandMetadata } from "../../lib/commandMetadata";
import {
convertPastedImagesToAttachments,
@@ -140,7 +138,7 @@ function NewTaskWorkspaceIcon(props: {
<SymbolView
name="folder"
size={16}
tintColorClassName={"accent-icon-muted"}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
);
@@ -151,14 +149,14 @@ function NewTaskWorkspaceIcon(props: {
<SymbolView
name="folder"
size={16}
tintColorClassName={"accent-icon-muted"}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
<View className="absolute -right-1 -bottom-1">
<SymbolView
name="arrow.triangle.branch"
size={9}
tintColorClassName={"accent-icon-muted"}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
</View>
@@ -1322,7 +1320,11 @@ export function NewTaskDraftScreen(props: {
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="New Thread" onBack={() => navigation.goBack()} />
<AndroidScreenHeader
title="New thread"
hideBottomBorder
onBack={() => navigation.goBack()}
/>
</>
) : (
<NativeStackScreenOptions options={{ title: "Loading task" }} />
@@ -1540,7 +1542,12 @@ export function NewTaskDraftScreen(props: {
);
const composerDock = (
<View className="bg-sheet px-[12px] pt-1" style={{ paddingBottom: controlsBottomPadding }}>
<View
className={
Platform.OS === "android" ? "bg-sheet-solid px-[12px] pt-1" : "bg-sheet px-[12px] pt-1"
}
style={{ paddingBottom: controlsBottomPadding }}
>
{!voiceInput.isBusy &&
composerMenu.trigger &&
(composerMenu.items.length > 0 || composerMenu.trigger.kind === "pull-request") ? (
@@ -1754,15 +1761,17 @@ export function NewTaskDraftScreen(props: {
return (
<View className="flex-1 bg-sheet" collapsable={false}>
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader title="New task" onBack={closeNewTask} />
{heroViewport}
<AndroidScreenHeader title="New thread" hideBottomBorder onBack={closeNewTask} />
<MaterialScreenContent>
{heroViewport}
<KeyboardStickyView
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
offset={{ closed: 0, opened: keyboardOpenedOffset }}
>
{composerDock}
</KeyboardStickyView>
<KeyboardStickyView
style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
offset={{ closed: 0, opened: keyboardOpenedOffset }}
>
{composerDock}
</KeyboardStickyView>
</MaterialScreenContent>
</View>
);
}
@@ -1,3 +1,4 @@
import { MaterialListRow } from "../../components/MaterialListRow";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import {
StackActions,
@@ -8,11 +9,13 @@ import {
import { SymbolView } from "../../components/AppSymbol";
import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
import { useEffect, useRef } from "react";
import { ActivityIndicator, Alert, Platform, Pressable, ScrollView, View } from "react-native";
import { ActivityIndicator, Alert, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { cn } from "../../lib/cn";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
import { MaterialButton } from "../../components/MaterialButton";
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
import { AppText as Text } from "../../components/AppText";
import { ProjectFavicon } from "../../components/ProjectFavicon";
import { useProjects } from "../../state/entities";
@@ -183,8 +186,9 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
<NativeStackScreenOptions options={{ headerShown: false }} />
<AndroidScreenHeader
title={screenTitle}
hideBottomBorder
subtitle={incomingShareSubtitle}
onBack={layout.usesSplitView ? () => navigation.goBack() : undefined}
onBack={() => navigation.goBack()}
actions={
catalogState.hasReadyEnvironment
? [
@@ -226,97 +230,156 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
</>
)}
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
className="flex-1"
contentContainerStyle={{
gap: 12,
paddingBottom: Math.max(insets.bottom, 18) + 18,
paddingHorizontal: 20,
paddingTop: 8,
}}
>
{projectScopes.length === 0 ? (
<View collapsable={false} className="items-center gap-3 rounded-[24px] bg-card px-6 py-8">
{projectEmptyState.loading ? (
<ActivityIndicator colorClassName={"accent-icon-muted"} />
) : null}
<Text className="text-center text-lg font-t3-bold text-foreground">
{projectEmptyState.title}
</Text>
<Text className="text-center text-sm leading-normal text-foreground-muted">
{projectEmptyState.detail}
</Text>
{!catalogState.hasReadyEnvironment ? (
<Pressable
className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
onPress={() => navigation.navigate("ConnectionsNew")}
>
<Text className="text-sm font-t3-bold text-primary-foreground">
Add environment
</Text>
</Pressable>
) : (
<Pressable
className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
onPress={() => navigation.dispatch(StackActions.push("AddProject"))}
>
<Text className="text-sm font-t3-bold text-primary-foreground">
Add new project
</Text>
</Pressable>
)}
</View>
) : (
<View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">
{projectScopes.map((scope, scopeIndex) => {
const hasMultipleProjects = scope.projects.length > 1;
const selectionTarget = getProjectScopeSelectionTarget(scope, selectedEnvironmentId);
return (
<View
key={scope.key}
className={cn(scopeIndex > 0 && "border-t border-border-subtle")}
<MaterialScreenContent>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
className="flex-1"
contentContainerStyle={{
gap: Platform.OS === "android" ? 8 : 12,
paddingBottom: Math.max(insets.bottom, 18) + 18,
paddingHorizontal: Platform.OS === "android" ? 16 : 20,
paddingTop: Platform.OS === "android" ? 16 : 8,
...(Platform.OS === "android" && projectScopes.length === 0
? { flexGrow: 1, justifyContent: "center" as const }
: {}),
}}
>
{projectScopes.length === 0 ? (
<View
collapsable={false}
className={cn(
"items-center gap-3 px-6 py-8",
Platform.OS !== "android" && "rounded-[24px] bg-card",
)}
>
{projectEmptyState.loading ? (
<ActivityIndicator colorClassName="accent-icon-muted" />
) : null}
<Text className="text-center text-lg font-t3-bold text-foreground">
{projectEmptyState.title}
</Text>
<Text className="text-center text-sm leading-normal text-foreground-muted">
{projectEmptyState.detail}
</Text>
{Platform.OS === "android" ? (
<MaterialButton
label={catalogState.hasReadyEnvironment ? "Add new project" : "Add environment"}
tone="primary"
onPress={() =>
catalogState.hasReadyEnvironment
? navigation.dispatch(StackActions.push("AddProject"))
: navigation.navigate("ConnectionsNew")
}
/>
) : !catalogState.hasReadyEnvironment ? (
<Pressable
className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
onPress={() => navigation.navigate("ConnectionsNew")}
>
<Pressable
disabled={reservedDestinationProject !== null}
onPress={() => void selectProject(selectionTarget)}
className="flex-row items-center gap-3 bg-card px-4 py-3.5"
>
<View className="h-7 w-7 items-center justify-center">
<ProjectFavicon
environmentId={scope.representative.environmentId}
faviconPath={scope.representative.faviconPath}
size={20}
projectTitle={scope.title}
workspaceRoot={scope.representative.workspaceRoot}
/>
</View>
<View className="min-w-0 flex-1">
<Text className="text-base leading-snug font-t3-bold">{scope.title}</Text>
<Text
className="text-xs leading-snug text-foreground-muted"
ellipsizeMode="middle"
numberOfLines={1}
>
{hasMultipleProjects
<Text className="text-sm font-t3-bold text-primary-foreground">
Add environment
</Text>
</Pressable>
) : (
<Pressable
className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
onPress={() => navigation.dispatch(StackActions.push("AddProject"))}
>
<Text className="text-sm font-t3-bold text-primary-foreground">
Add new project
</Text>
</Pressable>
)}
</View>
) : (
<View
collapsable={false}
className={
Platform.OS === "android"
? "overflow-hidden rounded-[28px] bg-card"
: "overflow-hidden rounded-[24px] bg-card"
}
>
{projectScopes.map((scope, scopeIndex) => {
const hasMultipleProjects = scope.projects.length > 1;
const selectionTarget = getProjectScopeSelectionTarget(
scope,
selectedEnvironmentId,
);
if (Platform.OS === "android") {
return (
<MaterialListRow
key={scope.key}
title={scope.title}
subtitle={
hasMultipleProjects
? `${scope.projects.length} workspaces`
: selectionTarget.workspaceRoot}
</Text>
</View>
<SymbolView
name="chevron.right"
size={14}
tintColorClassName={"accent-chevron"}
type="monochrome"
: selectionTarget.workspaceRoot
}
disabled={reservedDestinationProject !== null}
onPress={() => void selectProject(selectionTarget)}
leading={
<ProjectFavicon
environmentId={scope.representative.environmentId}
faviconPath={scope.representative.faviconPath}
size={24}
projectTitle={scope.title}
workspaceRoot={scope.representative.workspaceRoot}
/>
}
/>
</Pressable>
</View>
);
})}
</View>
)}
</ScrollView>
);
}
return (
<View
key={scope.key}
className={cn(scopeIndex > 0 && "border-t border-border-subtle")}
>
<Pressable
accessibilityRole="button"
accessibilityLabel={scope.title}
disabled={reservedDestinationProject !== null}
onPress={() => void selectProject(selectionTarget)}
className="flex-row items-center gap-3 bg-card px-4 py-3.5"
>
<View className="h-7 w-7 items-center justify-center">
<ProjectFavicon
environmentId={scope.representative.environmentId}
faviconPath={scope.representative.faviconPath}
size={20}
projectTitle={scope.title}
workspaceRoot={scope.representative.workspaceRoot}
/>
</View>
<View className="min-w-0 flex-1">
<Text className={cn("text-base leading-snug", "font-t3-bold")}>
{scope.title}
</Text>
<Text
className="text-xs leading-snug text-foreground-muted"
ellipsizeMode="middle"
numberOfLines={1}
>
{hasMultipleProjects
? `${scope.projects.length} workspaces`
: selectionTarget.workspaceRoot}
</Text>
</View>
<SymbolView
name="chevron.right"
size={14}
tintColorClassName="accent-chevron"
type="monochrome"
/>
</Pressable>
</View>
);
})}
</View>
)}
</ScrollView>
</MaterialScreenContent>
</View>
);
}
@@ -49,6 +49,7 @@ import Animated, {
withTiming,
} from "react-native-reanimated";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { themeColorWithAlpha } from "../../lib/mobileTheme";
import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
import { scopedThreadKey } from "../../lib/scopedEntities";
import {
@@ -208,7 +209,6 @@ export function ComposerSurface(props: {
/** Morphs between the compact and expanded composer layouts. */
readonly animateLayout?: boolean;
}) {
const { materialYouStyleLayoutActive } = useAppearancePreferences();
const colors = useUniwindTheme();
const targetBorderRadius =
typeof props.style.borderRadius === "number" ? props.style.borderRadius : 0;
@@ -232,27 +232,23 @@ export function ComposerSurface(props: {
return (
<Animated.View
className={
materialYouStyleLayoutActive
? undefined
: "shadow-[0_6px_28px] shadow-adaptive-black-a15-a35"
Platform.OS === "android" ? undefined : "shadow-[0_6px_28px] shadow-adaptive-black-a15-a35"
}
layout={layoutTransition}
style={[
animatedShapeStyle,
{
overflow: "hidden",
// Android versions before 9 do not support outset box shadows.
elevation: Platform.OS === "android" && Platform.Version < 28 ? 10 : undefined,
},
]}
>
<AnimatedGlassSurface
chrome="none"
fallbackColor={
materialYouStyleLayoutActive ? colors["--color-composer-surface"] : colors["--color-card"]
Platform.OS === "android" ? colors["--color-composer-surface"] : colors["--color-card"]
}
fallbackClassName={
materialYouStyleLayoutActive ? "border border-composer-border" : "border border-border"
Platform.OS === "android" ? "border border-composer-border" : "border border-border"
}
glassEffectStyle="regular"
// The composer is a passive material containing interactive controls.
@@ -277,8 +273,7 @@ export function ComposerSurface(props: {
export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposerProps) {
const project = useProject(scopeProjectRef(props.environmentId, props.selectedThread.projectId));
const { materialYouStyleLayoutActive, themeVariables: materialTheme } =
useAppearancePreferences();
const { themeVariables: materialTheme } = useAppearancePreferences();
const composerPanel = materialTheme["--color-composer-panel"];
const navigation = useNavigation();
const foregroundColor = useUniwindTheme()["--color-foreground"];
@@ -627,7 +622,8 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
style={{
paddingTop: isExpanded ? 8 : 6,
paddingBottom: (props.bottomInset ?? 0) + (isExpanded ? 8 : 6),
backgroundColor: materialYouStyleLayoutActive ? composerPanel : undefined,
backgroundColor:
Platform.OS === "android" ? themeColorWithAlpha(composerPanel, 1) : undefined,
}}
>
{/* The backdrop gradient lives on a plain View: Reanimated's Animated.View
@@ -635,7 +631,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
strip fully transparent and the feed text legible through the composer. */}
<View
className={
materialYouStyleLayoutActive
Platform.OS === "android"
? "hidden"
: "absolute inset-0 bg-linear-to-b from-screen/0 via-screen/60 to-screen/90"
}
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more