Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 19 additions & 28 deletions apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useCallback, useState } from "react";
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 { AppText as Text } from "../../components/AppText";
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
import { MaterialButton } from "../../components/MaterialButton";
import { MaterialIconButton } from "../../components/MaterialIconButton";
Expand All @@ -18,6 +18,7 @@ import { cn } from "../../lib/cn";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
import { serverEnvironment } from "../../state/server";
import { ConnectionFormField } from "./ConnectionFormField";
import { ConnectionStatusDot } from "./ConnectionStatusDot";

function connectionStatusLabel(environment: ConnectedEnvironmentSummary): string | null {
Expand Down Expand Up @@ -164,34 +165,24 @@ export function ConnectionEnvironmentRow(props: {
</Text>
) : (
<>
<View className="gap-1.5">
<Text className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
Label
</Text>
<TextInput
autoCapitalize="words"
autoCorrect={false}
placeholder="My MacBook"
value={label}
onChangeText={setLabel}
className="rounded-[14px] border border-input-border bg-input px-4 py-3 text-base text-foreground"
/>
</View>
<ConnectionFormField
label="Label"
autoCapitalize="words"
autoCorrect={false}
placeholder="My MacBook"
value={label}
onChangeText={setLabel}
/>

<View className="gap-1.5">
<Text className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
URL
</Text>
<TextInput
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
placeholder="192.168.1.100:8080"
value={url}
onChangeText={setUrl}
className="rounded-[14px] border border-input-border bg-input px-4 py-3 text-base text-foreground"
/>
</View>
<ConnectionFormField
label="URL"
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
placeholder="192.168.1.100:8080"
value={url}
onChangeText={setUrl}
/>
</>
)}

Expand Down
25 changes: 25 additions & 0 deletions apps/mobile/src/features/connection/ConnectionFormField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { View } from "react-native";

import { AppText, AppTextInput, type AppTextInputProps } from "../../components/AppText";
import { cn } from "../../lib/cn";

type ConnectionFormFieldProps = Omit<AppTextInputProps, "className"> & {
readonly label: string;
readonly className?: string;
};

/** Labeled connection input with a native wrapper retained inside form sheets. */
export function ConnectionFormField({ label, className, ...inputProps }: ConnectionFormFieldProps) {
return (
<View collapsable={false} className={cn("gap-1.5", className)}>
<AppText className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
{label}
</AppText>
<AppTextInput
accessibilityLabel={label}
{...inputProps}
className="rounded-[14px] px-4 py-3.5"
/>
</View>
);
}
47 changes: 19 additions & 28 deletions apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { Alert, Linking, Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
import { AppText as Text } from "../../components/AppText";
import { ErrorBanner } from "../../components/ErrorBanner";
import { ConnectionFormField } from "./ConnectionFormField";
import { ConnectionSheetButton } from "./ConnectionSheetButton";
import { buildPairingUrl, extractPairingUrlFromQrPayload, parsePairingUrl } from "./pairing";
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
Expand Down Expand Up @@ -262,34 +263,24 @@ export function ConnectionsNewRouteScreen({
)
) : (
<View collapsable={false} className="gap-4 rounded-[24px] bg-card p-4">
<View collapsable={false} className="gap-1.5">
<Text className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
Host
</Text>
<TextInput
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
placeholder="192.168.1.100:8080"
value={hostInput}
onChangeText={handleHostChange}
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-base text-foreground"
/>
</View>
<ConnectionFormField
label="Host"
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
placeholder="192.168.1.100:8080"
value={hostInput}
onChangeText={handleHostChange}
/>

<View collapsable={false} className="gap-1.5">
<Text className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
Pairing code
</Text>
<TextInput
autoCapitalize="none"
autoCorrect={false}
placeholder="abc-123-xyz"
value={codeInput}
onChangeText={handleCodeChange}
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-base text-foreground"
/>
</View>
<ConnectionFormField
label="Pairing code"
autoCapitalize="none"
autoCorrect={false}
placeholder="abc-123-xyz"
value={codeInput}
onChangeText={handleCodeChange}
/>

{pairingConnectionError ? <ErrorBanner message={pairingConnectionError} /> : null}

Expand Down
Loading