Unify mobile new-task and project sheet headers
- Extract shared new-task sheet header - Refresh add-project form spacing and controls - Align project creation screens with the new sheet layout
This commit is contained in:
1 parent
907f4d7501
commit
4db082a2d2
4 files changed
+133
-115
No files matched your search
@@ -8,6 +8,7 @@ import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { ProjectFavicon } from "../../components/ProjectFavicon";
|
||||
import { NewTaskSheetHeader } from "../../features/threads/NewTaskSheetHeader";
|
||||
import { groupProjectsByRepository } from "../../lib/repositoryGroups";
|
||||
import { type RemoteCatalogState, useRemoteCatalog } from "../../state/use-remote-catalog";
|
||||
import { useRemoteEnvironmentState } from "../../state/use-remote-environment-registry";
|
||||
@@ -103,17 +104,7 @@ export default function NewTaskRoute() {
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<Stack.Screen options={{ headerShown: false }} />
|
||||
|
||||
<View style={{ minHeight: 16, paddingTop: 8 }} />
|
||||
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1 }}
|
||||
>
|
||||
New task
|
||||
</Text>
|
||||
<Text className="text-[28px] font-t3-bold">Choose project</Text>
|
||||
</View>
|
||||
<NewTaskSheetHeader title="Choose project" />
|
||||
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
|
||||
@@ -29,7 +29,6 @@ import * as Arr from "effect/Array";
|
||||
import * as Order from "effect/Order";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { ControlPill } from "../../components/ControlPill";
|
||||
import { ErrorBanner } from "../../components/ErrorBanner";
|
||||
import { SourceControlIcon } from "../../components/SourceControlIcon";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
@@ -42,6 +41,7 @@ import {
|
||||
refreshSourceControlDiscoveryForEnvironment,
|
||||
useSourceControlDiscovery,
|
||||
} from "../../state/use-source-control-discovery";
|
||||
import { NewTaskSheetHeader } from "../threads/NewTaskSheetHeader";
|
||||
|
||||
interface EnvironmentOption {
|
||||
readonly environmentId: EnvironmentId;
|
||||
@@ -115,21 +115,21 @@ function AddProjectShell(props: {
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<View className="flex-row items-center justify-between px-5 pb-1 pt-3">
|
||||
<ControlPill
|
||||
icon={props.closeToNew ? "xmark" : "chevron.left"}
|
||||
onPress={() => router.back()}
|
||||
/>
|
||||
<Text className="text-[17px] font-t3-bold">{props.title}</Text>
|
||||
<View className="h-11 w-11" />
|
||||
</View>
|
||||
<NewTaskSheetHeader
|
||||
eyebrow="New project"
|
||||
title={props.title}
|
||||
control={{
|
||||
icon: props.closeToNew ? "xmark" : "chevron.left",
|
||||
onPress: () => router.back(),
|
||||
}}
|
||||
/>
|
||||
|
||||
<ScrollView
|
||||
keyboardShouldPersistTaps="handled"
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 8,
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 16,
|
||||
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
||||
gap: 10,
|
||||
}}
|
||||
@@ -141,7 +141,7 @@ function AddProjectShell(props: {
|
||||
}
|
||||
|
||||
function ListSection(props: { readonly children: ReactNode }) {
|
||||
return <View className="overflow-hidden rounded-2xl bg-card">{props.children}</View>;
|
||||
return <View className="overflow-hidden rounded-[24px] bg-card">{props.children}</View>;
|
||||
}
|
||||
|
||||
function ListRow(props: {
|
||||
@@ -196,6 +196,48 @@ function ListRow(props: {
|
||||
);
|
||||
}
|
||||
|
||||
function PrimaryActionButton(props: {
|
||||
readonly label: string;
|
||||
readonly disabled?: boolean;
|
||||
readonly loading?: boolean;
|
||||
readonly onPress: () => void;
|
||||
}) {
|
||||
const primaryForeground = useThemeColor("--color-primary-foreground");
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
disabled={props.disabled}
|
||||
onPress={props.onPress}
|
||||
className="h-12 items-center justify-center rounded-full bg-primary active:opacity-70 disabled:opacity-45"
|
||||
>
|
||||
{props.loading ? (
|
||||
<ActivityIndicator color={String(primaryForeground)} />
|
||||
) : (
|
||||
<Text className="text-[14px] font-t3-bold text-primary-foreground">{props.label}</Text>
|
||||
)}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectPathInput(props: {
|
||||
readonly value: string;
|
||||
readonly onChangeText: (value: string) => void;
|
||||
readonly onSubmit: () => void;
|
||||
}) {
|
||||
return (
|
||||
<TextInput
|
||||
className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-[15px] leading-[20px]"
|
||||
value={props.value}
|
||||
onChangeText={props.onChangeText}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="~/projects/my-app"
|
||||
returnKeyType="done"
|
||||
onSubmitEditing={props.onSubmit}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function useEnvironmentOptions(): ReadonlyArray<EnvironmentOption> {
|
||||
const { serverConfigByEnvironmentId } = useRemoteCatalog();
|
||||
const { savedConnectionsById } = useRemoteEnvironmentState();
|
||||
@@ -321,7 +363,7 @@ export function AddProjectSourceScreen() {
|
||||
}, [selectedEnvironment]);
|
||||
|
||||
return (
|
||||
<AddProjectShell title="Add project" closeToNew>
|
||||
<AddProjectShell title="Select source" closeToNew>
|
||||
{environmentOptions.length === 0 ? <EmptyEnvironmentState /> : null}
|
||||
|
||||
{environmentOptions.length > 1 ? (
|
||||
@@ -362,7 +404,6 @@ export function AddProjectSourceScreen() {
|
||||
|
||||
{selectedEnvironment ? (
|
||||
<>
|
||||
<SectionTitle>Sources</SectionTitle>
|
||||
<ListSection>
|
||||
<ListRow
|
||||
title="Local folder"
|
||||
@@ -473,7 +514,6 @@ export function AddProjectRepositoryScreen() {
|
||||
const params = useLocalSearchParams<{ environmentId?: string; source?: string }>();
|
||||
const environment = useEnvironmentFromParam();
|
||||
const source = sourceFromParam(params.source);
|
||||
const primaryForeground = useThemeColor("--color-primary-foreground");
|
||||
const [repositoryInput, setRepositoryInput] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -524,7 +564,7 @@ export function AddProjectRepositoryScreen() {
|
||||
<AddProjectShell title={source === "url" ? "Git URL" : addProjectRemoteSourceLabel(source)}>
|
||||
{error ? <ErrorBanner message={error} /> : null}
|
||||
<TextInput
|
||||
className="h-12 min-h-12 rounded-xl px-3 py-0 text-[15px] leading-[20px]"
|
||||
className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-[15px] leading-[20px]"
|
||||
value={repositoryInput}
|
||||
onChangeText={setRepositoryInput}
|
||||
autoCapitalize="none"
|
||||
@@ -537,19 +577,12 @@ export function AddProjectRepositoryScreen() {
|
||||
returnKeyType="next"
|
||||
onSubmitEditing={() => void lookupRepository()}
|
||||
/>
|
||||
<Pressable
|
||||
<PrimaryActionButton
|
||||
label={source === "url" ? "Continue" : "Lookup repository"}
|
||||
disabled={isSubmitting || repositoryInput.trim().length === 0}
|
||||
onPress={() => void lookupRepository()}
|
||||
className="h-11 items-center justify-center rounded-full bg-primary active:opacity-70 disabled:opacity-45"
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<ActivityIndicator color={String(primaryForeground)} />
|
||||
) : (
|
||||
<Text className="text-[14px] font-t3-bold text-primary-foreground">
|
||||
{source === "url" ? "Continue" : "Lookup repository"}
|
||||
</Text>
|
||||
)}
|
||||
</Pressable>
|
||||
loading={isSubmitting}
|
||||
/>
|
||||
</AddProjectShell>
|
||||
);
|
||||
}
|
||||
@@ -643,7 +676,6 @@ function FolderBrowser(props: {
|
||||
export function AddProjectLocalFolderScreen() {
|
||||
const environment = useEnvironmentFromParam();
|
||||
const createProject = useCreateProject(environment);
|
||||
const primaryForeground = useThemeColor("--color-primary-foreground");
|
||||
const [pathInput, setPathInput] = useState(() =>
|
||||
getAddProjectInitialQuery(environment?.baseDirectory),
|
||||
);
|
||||
@@ -683,27 +715,17 @@ export function AddProjectLocalFolderScreen() {
|
||||
{error ? <ErrorBanner message={error} /> : null}
|
||||
{environment ? (
|
||||
<>
|
||||
<TextInput
|
||||
className="h-12 min-h-12 rounded-xl px-3 py-0 text-[15px] leading-[20px]"
|
||||
<ProjectPathInput
|
||||
value={pathInput}
|
||||
onChangeText={setPathInput}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="~/projects/my-app"
|
||||
returnKeyType="done"
|
||||
onSubmitEditing={() => void submitPath()}
|
||||
onSubmit={() => void submitPath()}
|
||||
/>
|
||||
<Pressable
|
||||
<PrimaryActionButton
|
||||
label="Add project"
|
||||
disabled={isSubmitting}
|
||||
onPress={() => void submitPath()}
|
||||
className="h-11 items-center justify-center rounded-full bg-primary active:opacity-70"
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<ActivityIndicator color={String(primaryForeground)} />
|
||||
) : (
|
||||
<Text className="text-[14px] font-t3-bold text-primary-foreground">Add project</Text>
|
||||
)}
|
||||
</Pressable>
|
||||
loading={isSubmitting}
|
||||
/>
|
||||
<FolderBrowser
|
||||
environment={environment}
|
||||
pathInput={pathInput}
|
||||
@@ -725,7 +747,6 @@ export function AddProjectDestinationScreen() {
|
||||
}>();
|
||||
const environment = useEnvironmentFromParam();
|
||||
const createProject = useCreateProject(environment);
|
||||
const primaryForeground = useThemeColor("--color-primary-foreground");
|
||||
const remoteUrl = stringParam(params.remoteUrl);
|
||||
const repositoryTitle = stringParam(params.repositoryTitle);
|
||||
const [pathInput, setPathInput] = useState(() =>
|
||||
@@ -772,7 +793,7 @@ export function AddProjectDestinationScreen() {
|
||||
<AddProjectShell title="Clone destination">
|
||||
{error ? <ErrorBanner message={error} /> : null}
|
||||
{repositoryTitle ? (
|
||||
<View className="rounded-xl bg-card px-3.5 py-2.5">
|
||||
<View className="rounded-[24px] bg-card px-4 py-3">
|
||||
<Text className="text-[14px] font-t3-bold">{repositoryTitle}</Text>
|
||||
<Text className="mt-0.5 text-[12px] text-foreground-muted" numberOfLines={2}>
|
||||
{remoteUrl}
|
||||
@@ -781,29 +802,17 @@ export function AddProjectDestinationScreen() {
|
||||
) : null}
|
||||
{environment ? (
|
||||
<>
|
||||
<TextInput
|
||||
className="h-12 min-h-12 rounded-xl px-3 py-0 text-[15px] leading-[20px]"
|
||||
<ProjectPathInput
|
||||
value={pathInput}
|
||||
onChangeText={setPathInput}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="~/projects/my-app"
|
||||
returnKeyType="done"
|
||||
onSubmitEditing={() => void submitPath()}
|
||||
onSubmit={() => void submitPath()}
|
||||
/>
|
||||
<Pressable
|
||||
<PrimaryActionButton
|
||||
label="Clone project"
|
||||
disabled={isSubmitting || !remoteUrl}
|
||||
onPress={() => void submitPath()}
|
||||
className="h-11 items-center justify-center rounded-full bg-primary active:opacity-70 disabled:opacity-45"
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<ActivityIndicator color={String(primaryForeground)} />
|
||||
) : (
|
||||
<Text className="text-[14px] font-t3-bold text-primary-foreground">
|
||||
Clone project
|
||||
</Text>
|
||||
)}
|
||||
</Pressable>
|
||||
loading={isSubmitting}
|
||||
/>
|
||||
<FolderBrowser
|
||||
environment={environment}
|
||||
pathInput={pathInput}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { MenuView } from "@react-native-menu/menu";
|
||||
import { useRouter } from "expo-router";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { TextInputWrapper } from "expo-paste-input";
|
||||
import { useCallback, useEffect, useMemo } from "react";
|
||||
import { Pressable, View, useColorScheme } from "react-native";
|
||||
import { View, useColorScheme } from "react-native";
|
||||
import { KeyboardStickyView } from "react-native-keyboard-controller";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { EnvironmentId, type ModelSelection } from "@t3tools/contracts";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
|
||||
import { ControlPill } from "../../components/ControlPill";
|
||||
import { ProviderIcon } from "../../components/ProviderIcon";
|
||||
@@ -20,6 +19,7 @@ import { buildThreadRoutePath } from "../../lib/routes";
|
||||
import { useRemoteCatalog } from "../../state/use-remote-catalog";
|
||||
import { useNativePaste } from "../../lib/useNativePaste";
|
||||
import { CLAUDE_AGENT_EFFORT_OPTIONS } from "./claudeEffortOptions";
|
||||
import { NewTaskSheetHeader } from "./NewTaskSheetHeader";
|
||||
import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
|
||||
import { useProjectActions } from "./use-project-actions";
|
||||
|
||||
@@ -50,7 +50,6 @@ export function NewTaskDraftScreen(props: {
|
||||
const controlsBottomPadding = Math.max(insets.bottom, 10);
|
||||
const { logicalProjects, selectedProject, setProject } = flow;
|
||||
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const borderColor = useThemeColor("--color-border");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -394,48 +393,21 @@ export function NewTaskDraftScreen(props: {
|
||||
if (!selectedProject) {
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<View style={{ minHeight: 16, paddingTop: 8 }} />
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1 }}
|
||||
>
|
||||
New task
|
||||
</Text>
|
||||
<Text className="text-[28px] font-t3-bold">Loading task</Text>
|
||||
</View>
|
||||
<NewTaskSheetHeader title="Loading task" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<View style={{ minHeight: 16, paddingTop: 8 }} />
|
||||
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
{flow.logicalProjects.length > 1 ? (
|
||||
<Pressable
|
||||
className="absolute left-3 top-4 h-9 w-9 items-center justify-center rounded-full bg-subtle"
|
||||
style={{ zIndex: 1 }}
|
||||
onPress={() => router.back()}
|
||||
>
|
||||
<SymbolView
|
||||
name="chevron.left"
|
||||
size={16}
|
||||
tintColor={iconColor}
|
||||
type="monochrome"
|
||||
weight="medium"
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1 }}
|
||||
>
|
||||
New task
|
||||
</Text>
|
||||
<Text className="text-[28px] font-t3-bold">{selectedProject.title}</Text>
|
||||
</View>
|
||||
<NewTaskSheetHeader
|
||||
title={selectedProject.title}
|
||||
control={
|
||||
flow.logicalProjects.length > 1
|
||||
? { icon: "chevron.left", onPress: () => router.back() }
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
<View style={{ flex: 1, paddingHorizontal: 20, paddingTop: 8 }}>
|
||||
<TextInputWrapper
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { Pressable, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export function NewTaskSheetHeader(props: {
|
||||
readonly eyebrow?: string;
|
||||
readonly title: string;
|
||||
readonly control?: {
|
||||
readonly icon: "chevron.left" | "xmark";
|
||||
readonly onPress: () => void;
|
||||
};
|
||||
}) {
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
|
||||
return (
|
||||
<>
|
||||
<View style={{ minHeight: 16, paddingTop: 8 }} />
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
{props.control ? (
|
||||
<Pressable
|
||||
className="absolute left-3 top-4 h-9 w-9 items-center justify-center rounded-full bg-subtle"
|
||||
style={{ zIndex: 1 }}
|
||||
onPress={props.control.onPress}
|
||||
>
|
||||
<SymbolView
|
||||
name={props.control.icon}
|
||||
size={16}
|
||||
tintColor={iconColor}
|
||||
type="monochrome"
|
||||
weight="medium"
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1 }}
|
||||
>
|
||||
{props.eyebrow ?? "New task"}
|
||||
</Text>
|
||||
<Text className="text-[28px] font-t3-bold">{props.title}</Text>
|
||||
</View>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user