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
18 changes: 18 additions & 0 deletions apps/mobile/src/components/ConfirmDialog.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export type ConfirmDialogRequest = {
readonly title: string;
readonly message?: string;
readonly cancelText?: string;
readonly confirmText: string;
readonly destructive?: boolean;
readonly onConfirm: () => void;
readonly onCancel?: () => void;
};

export type TextInputDialogRequest = {
readonly title: string;
readonly initialValue: string;
readonly cancelText?: string;
readonly confirmText: string;
readonly onConfirm: (value: string) => void;
readonly onCancel?: () => void;
};
20 changes: 2 additions & 18 deletions apps/mobile/src/components/ConfirmDialogHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,9 @@ import { Platform, Modal, Pressable, TextInput, View } from "react-native";
import { cn } from "../lib/cn";
import { AppText } from "./AppText";
import { MaterialConfirmDialog } from "./MaterialConfirmDialog";
import type { ConfirmDialogRequest, TextInputDialogRequest } from "./ConfirmDialog.types";

export type ConfirmDialogRequest = {
readonly title: string;
readonly message?: string;
readonly cancelText?: string;
readonly confirmText: string;
readonly destructive?: boolean;
readonly onConfirm: () => void;
readonly onCancel?: () => void;
};

export type TextInputDialogRequest = {
readonly title: string;
readonly initialValue: string;
readonly cancelText?: string;
readonly confirmText: string;
readonly onConfirm: (value: string) => void;
readonly onCancel?: () => void;
};
export type { ConfirmDialogRequest, TextInputDialogRequest } from "./ConfirmDialog.types";

type DialogRequest =
| { readonly kind: "confirm"; readonly request: ConfirmDialogRequest }
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/FilePreview.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { requireNativeModule } from "expo";
import { useEffect, useEffectEvent, useId } from "react";
import { Alert } from "react-native";

import type { ResolvedFilePreviewSource } from "./FilePreviewModal";
import type { ResolvedFilePreviewSource } from "./FilePreviewModal.types";

const NativeControls = requireNativeModule<{
presentFile(
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/FilePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Alert, Modal, Pressable, View } from "react-native";
import ImageViewing from "react-native-image-viewing";

import { openAttachmentInViewer } from "../lib/attachmentDownload";
import type { ResolvedFilePreviewSource } from "./FilePreviewModal";
import type { ResolvedFilePreviewSource } from "./FilePreviewModal.types";
import { MediaImagePreview } from "./MediaImagePreview";
import { AppText as Text } from "./AppText";

Expand Down
21 changes: 2 additions & 19 deletions apps/mobile/src/components/FilePreviewModal.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import { useIsFocused } from "@react-navigation/native";
import type { AssetResource, EnvironmentId } from "@t3tools/contracts";
import { useEffect, useEffectEvent, useState } from "react";
import { Alert, Keyboard } from "react-native";

import type { FileBackedComposerAttachment } from "../lib/composerImages";
import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
import type { MediaActionsSource } from "../lib/mediaActions";
import { useRefreshAssetUrl } from "../state/assets";
import { FilePreview } from "./FilePreview";
import type { FilePreviewSource } from "./FilePreviewModal.types";

export interface ResolvedFilePreviewSource {
readonly kind: "image" | "pdf" | "document";
readonly mimeType?: string;
readonly uri: string;
readonly name?: string;
readonly sourceIdentifier?: string;
readonly srcFragment?: string;
readonly actionsSource?: MediaActionsSource;
}

export type FilePreviewSource = Omit<ResolvedFilePreviewSource, "uri"> &
(
| { readonly uri: string }
| { readonly attachment: FileBackedComposerAttachment }
| { readonly environmentId: EnvironmentId; readonly resource: AssetResource }
);
export type { FilePreviewSource, ResolvedFilePreviewSource } from "./FilePreviewModal.types";

function ResolvedFilePreview(props: {
readonly source: FilePreviewSource;
Expand Down
21 changes: 21 additions & 0 deletions apps/mobile/src/components/FilePreviewModal.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { AssetResource, EnvironmentId } from "@t3tools/contracts";

import type { FileBackedComposerAttachment } from "../lib/composerImages";
import type { MediaActionsSource } from "../lib/mediaActions";

export interface ResolvedFilePreviewSource {
readonly kind: "image" | "pdf" | "document";
readonly mimeType?: string;
readonly uri: string;
readonly name?: string;
readonly sourceIdentifier?: string;
readonly srcFragment?: string;
readonly actionsSource?: MediaActionsSource;
}

export type FilePreviewSource = Omit<ResolvedFilePreviewSource, "uri"> &
(
| { readonly uri: string }
| { readonly attachment: FileBackedComposerAttachment }
| { readonly environmentId: EnvironmentId; readonly resource: AssetResource }
);
2 changes: 1 addition & 1 deletion apps/mobile/src/components/MaterialConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ConfirmDialogRequest } from "./ConfirmDialogHost";
import type { ConfirmDialogRequest } from "./ConfirmDialog.types";

export interface MaterialConfirmDialogProps {
readonly request: Pick<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SegmentedButton, SingleChoiceSegmentedButtonRow, Text } from "@expo/ui/
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";
import type { SegmentedControlProps } from "./SegmentedControl.types";

/** Compose content shared by screen controls and native dialogs, inside their existing Host. */
export function MaterialSegmentedButtons<Value extends number | string>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MaterialSegmentedButtons } from "./MaterialSegmentedButtons.android";
import { View } from "react-native";

import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import type { SegmentedControlProps } from "./SegmentedControl";
import type { SegmentedControlProps } from "./SegmentedControl.types";

export function MaterialSegmentedControl<Value extends number | string>(
props: SegmentedControlProps<Value>,
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/MaterialSegmentedControl.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SegmentedControlProps } from "./SegmentedControl";
import type { SegmentedControlProps } from "./SegmentedControl.types";

export function MaterialSegmentedControl<Value extends number | string>(
_props: SegmentedControlProps<Value>,
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/MaterialSwitch.android.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Host, Switch as ComposeSwitch } from "@expo/ui/jetpack-compose";
import { View } from "react-native";
import type { ThemedSwitchProps } from "./ThemedSwitch";
import type { ThemedSwitchProps } from "./MaterialSwitch.types";

import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";

Expand Down
12 changes: 12 additions & 0 deletions apps/mobile/src/components/MaterialSwitch.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { SwitchProps } from "react-native";

export type ThemedSwitchProps = Pick<
SwitchProps,
| "accessibilityHint"
| "accessibilityLabel"
| "disabled"
| "onValueChange"
| "style"
| "testID"
| "value"
>;
2 changes: 1 addition & 1 deletion apps/mobile/src/components/MediaImagePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useMediaActions } from "../lib/mediaActions";
import { AppText } from "./AppText";
import { SymbolView } from "./AppSymbol";
import type { ResolvedFilePreviewSource } from "./FilePreviewModal";
import type { ResolvedFilePreviewSource } from "./FilePreviewModal.types";
import { MediaActionsMenu } from "./MediaActionsMenu";
import { MediaSourceCaption } from "./MediaSourceCaption";

Expand Down
16 changes: 2 additions & 14 deletions apps/mobile/src/components/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@ import Animated, { Easing, LinearTransition, ReduceMotion } from "react-native-r
import { AppText as Text } from "./AppText";
import { cn } from "../lib/cn";
import { MaterialSegmentedControl } from "./MaterialSegmentedControl";
import type { SegmentedControlProps } from "./SegmentedControl.types";

export interface SegmentedControlProps<Value extends number | string> {
readonly options: readonly {
readonly value: Value;
readonly label: string;
readonly accessibilityLabel?: string;
}[];
readonly selected: Value;
readonly onSelect: (value: Value) => void;
/** 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 type { SegmentedControlProps } from "./SegmentedControl.types";

export function SegmentedControl<Value extends number | string>(
props: SegmentedControlProps<Value>,
Expand Down
14 changes: 14 additions & 0 deletions apps/mobile/src/components/SegmentedControl.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface SegmentedControlProps<Value extends number | string> {
readonly options: readonly {
readonly value: Value;
readonly label: string;
readonly accessibilityLabel?: string;
}[];
readonly selected: Value;
readonly onSelect: (value: Value) => void;
/** 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;
}
14 changes: 3 additions & 11 deletions apps/mobile/src/components/ThemedSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { Platform, Switch, type SwitchProps } from "react-native";
import { Platform, Switch } from "react-native";

import { MaterialSwitch } from "./MaterialSwitch";
import type { ThemedSwitchProps } from "./MaterialSwitch.types";

export type ThemedSwitchProps = Pick<
SwitchProps,
| "accessibilityHint"
| "accessibilityLabel"
| "disabled"
| "onValueChange"
| "style"
| "testID"
| "value"
>;
export type { ThemedSwitchProps } from "./MaterialSwitch.types";

export function ThemedSwitch(props: ThemedSwitchProps) {
if (Platform.OS === "android") {
Expand Down
Loading
Loading