mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
feat(mobile): redesigned Changes tab with file-first rows and swipe to discard (#37214)
Rows lead with the file name and put its folder under it, so names stop truncating. The whole row opens the diff, one quiet button stages or unstages, and discard moves to a left swipe that still asks first. A status line, a Commits row and a conflict banner with Abort sit above Uncommitted and Staged sections that carry Stage all and Unstage all. The rarer git actions move into the header's grouped menu.
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
|
||||
import { ChevronRight, FileText, Minus, Plus, Trash2 } from 'lucide-react-native'
|
||||
import { Gesture, GestureDetector } from 'react-native-gesture-handler'
|
||||
import Animated, {
|
||||
Easing,
|
||||
ReduceMotion,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
withTiming
|
||||
} from 'react-native-reanimated'
|
||||
import { SHEET_CURVE } from '../components/sheet-motion-values'
|
||||
import { useDrawerReducedMotion } from '../components/bottom-drawer-constants'
|
||||
import { Minus, Plus, Undo2 } from 'lucide-react-native'
|
||||
import { colors } from '../theme/mobile-theme'
|
||||
import { SectionHeader } from '../components/list/ListGroup'
|
||||
import { STATUS_LABELS } from '../../../src/shared/git-status-labels'
|
||||
import type { GitConflictKind } from '../../../src/shared/git-status-types'
|
||||
import type { GitConflictKind, GitFileStatus } from '../../../src/shared/git-status-types'
|
||||
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
|
||||
import type { Translate } from '../i18n/mobile-i18n'
|
||||
import { useMobileTranslation } from '../i18n/use-mobile-translation'
|
||||
import { formatMobileBranchEntryMeta } from './mobile-branch-entry-format'
|
||||
import { MobileDiffLineStats } from '../components/MobileDiffReviewFileSummary'
|
||||
import type {
|
||||
MobileBranchEntryView,
|
||||
MobileGitStatusEntryView
|
||||
@@ -17,7 +27,7 @@ import { styles } from './mobile-source-control-styles'
|
||||
import { mobileConflictResolutionLabel } from './mobile-source-control-conflict-actions'
|
||||
import { getUnstageablePaths, statusColor } from './mobile-git-status'
|
||||
|
||||
type RowState = Pick<
|
||||
export type FileRowState = Pick<
|
||||
MobileSourceControlState,
|
||||
'busyAction' | 'openDiffForFile' | 'resolveConflict' | 'runGitAction' | 'setDiscardTarget'
|
||||
>
|
||||
@@ -43,227 +53,288 @@ function conflictKindLabel(kind: GitConflictKind | undefined, t: Translate): str
|
||||
}
|
||||
}
|
||||
|
||||
export function makeRenderFileRow(state: RowState, t: Translate) {
|
||||
const { busyAction, openDiffForFile, resolveConflict, runGitAction, setDiscardTarget } = state
|
||||
return function renderFileRow({ item }: { item: MobileGitStatusEntryView }) {
|
||||
const rowBusy =
|
||||
busyAction === item.stageActionId ||
|
||||
busyAction === item.unstageActionId ||
|
||||
busyAction === item.discardActionId ||
|
||||
busyAction === item.resolveActionId
|
||||
const rowDisabled = !item.canOpen || busyAction !== null
|
||||
const ioBusy = busyAction !== null
|
||||
const hasConflictActions = item.conflictResolutions.length > 0
|
||||
return (
|
||||
// Git paths always use '/'; the name leads so it never truncates behind its folder.
|
||||
function splitGitPath(path: string): { name: string; folder: string } {
|
||||
const slash = path.lastIndexOf('/')
|
||||
return slash === -1
|
||||
? { name: path, folder: '' }
|
||||
: { name: path.slice(slash + 1), folder: path.slice(0, slash) }
|
||||
}
|
||||
|
||||
/** Status letter, file name over its folder, then the row's stats and action. */
|
||||
function FileRowBody({
|
||||
status,
|
||||
path,
|
||||
detail,
|
||||
added,
|
||||
removed,
|
||||
trailing,
|
||||
actions
|
||||
}: {
|
||||
status: GitFileStatus
|
||||
path: string
|
||||
/** Leads the folder line, e.g. a conflict kind or a rename source. */
|
||||
detail?: string
|
||||
added?: number
|
||||
removed?: number
|
||||
trailing?: ReactNode
|
||||
/** Wrapping buttons under the name, e.g. a conflict's resolutions, so the name keeps its width. */
|
||||
actions?: ReactNode
|
||||
}) {
|
||||
useMobileColorScheme()
|
||||
const { name, folder } = splitGitPath(path)
|
||||
const subtitle = detail ? (folder ? `${detail} · ${folder}` : detail) : folder
|
||||
return (
|
||||
<>
|
||||
<View style={styles.statusBadge}>
|
||||
<Text style={[styles.statusBadgeText, { color: statusColor(status) }]}>
|
||||
{STATUS_LABELS[status]}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.fileTextBlock}>
|
||||
<Text
|
||||
style={[styles.fileName, status === 'deleted' && styles.fileNameGone]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{name}
|
||||
</Text>
|
||||
{subtitle ? (
|
||||
<Text style={styles.fileMeta} numberOfLines={1}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
) : null}
|
||||
{actions ? <View style={styles.conflictActions}>{actions}</View> : null}
|
||||
</View>
|
||||
<MobileDiffLineStats added={added} removed={removed} />
|
||||
{trailing}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
// The width the Discard action uncovers; a swipe past half of it settles open.
|
||||
const DISCARD_WIDTH = 84
|
||||
const SWIPE_SETTLE_MS = 250
|
||||
const DRAG_CLICK_WINDOW_MS = 400
|
||||
|
||||
/** Discard sits behind a left swipe and still asks first; it is also on the diff screen. */
|
||||
function SwipeToDiscard({
|
||||
available,
|
||||
enabled,
|
||||
label,
|
||||
accessibilityLabel,
|
||||
onDiscard,
|
||||
children
|
||||
}: {
|
||||
/** Only discardable rows get the swipe; toggling it would remount the row. */
|
||||
available: boolean
|
||||
enabled: boolean
|
||||
label: string
|
||||
accessibilityLabel: string
|
||||
onDiscard: () => void
|
||||
/** Gets a wrapper for the row's press: a tap on a swiped row closes it instead. */
|
||||
children: (guardPress: (onPress: () => void) => () => void) => ReactNode
|
||||
}) {
|
||||
useMobileColorScheme()
|
||||
const reducedMotion = useDrawerReducedMotion()
|
||||
const offset = useSharedValue(0)
|
||||
const start = useSharedValue(0)
|
||||
// When the last drag ended: on the web, releasing a mouse drag also clicks the row.
|
||||
const dragEndedAt = useSharedValue(0)
|
||||
// Built per render: a module-level easing would run before a test's Reanimated mock can serve it.
|
||||
const settle = (to: number) => {
|
||||
'worklet'
|
||||
return withTiming(
|
||||
to,
|
||||
reducedMotion
|
||||
? { duration: 0, reduceMotion: ReduceMotion.Never }
|
||||
: { duration: SWIPE_SETTLE_MS, easing: Easing.bezier(...SHEET_CURVE) }
|
||||
)
|
||||
}
|
||||
// Horizontal only, so the list keeps scrolling under a vertical drag.
|
||||
const pan = Gesture.Pan()
|
||||
.enabled(enabled)
|
||||
.activeOffsetX([-12, 12])
|
||||
.failOffsetY([-10, 10])
|
||||
.onBegin(() => {
|
||||
start.value = offset.value
|
||||
})
|
||||
.onUpdate((event) => {
|
||||
offset.value = Math.min(0, Math.max(-DISCARD_WIDTH, start.value + event.translationX))
|
||||
})
|
||||
.onEnd(() => {
|
||||
// oxlint-disable-next-line react/purity -- runs when the drag ends, never during render.
|
||||
dragEndedAt.value = Date.now()
|
||||
offset.value = settle(offset.value < -DISCARD_WIDTH / 2 ? -DISCARD_WIDTH : 0)
|
||||
})
|
||||
// Web has no worklet plugin; mapper hooks need this explicit dependency list.
|
||||
const rowStyle = useAnimatedStyle(() => ({ transform: [{ translateX: offset.value }] }), [offset])
|
||||
// A tap on an open row closes it rather than opening the diff.
|
||||
const guardPress = (onPress: () => void) => () => {
|
||||
// The click a drag release produces belongs to the drag, not to the row.
|
||||
if (Date.now() - dragEndedAt.value < DRAG_CLICK_WINDOW_MS) {
|
||||
return
|
||||
}
|
||||
if (offset.value !== 0) {
|
||||
offset.value = settle(0)
|
||||
return
|
||||
}
|
||||
onPress()
|
||||
}
|
||||
if (!available) {
|
||||
return children((onPress) => onPress)
|
||||
}
|
||||
return (
|
||||
<View>
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.fileRow,
|
||||
pressed && item.canOpen && styles.fileRowPressed,
|
||||
// Conflict rows cannot open but carry live actions; their buttons dim themselves while busy.
|
||||
rowDisabled && !hasConflictActions && styles.fileRowDisabled,
|
||||
!item.canOpen && !hasConflictActions && styles.fileRowUnavailable
|
||||
]}
|
||||
style={({ pressed }) => [styles.discardAction, pressed && styles.iconButtonPressed]}
|
||||
disabled={!enabled}
|
||||
onPress={() => {
|
||||
if (item.area !== undefined) {
|
||||
openDiffForFile({ kind: 'changes', filePath: item.path, area: item.area })
|
||||
}
|
||||
offset.value = settle(0)
|
||||
onDiscard()
|
||||
}}
|
||||
disabled={rowDisabled}
|
||||
// An accessible row hides nested buttons from iOS VoiceOver; conflict rows cannot open anyway.
|
||||
accessible={!hasConflictActions}
|
||||
accessibilityLabel={t(
|
||||
'sourceControl.fileRows.openChangedFile',
|
||||
'Open changed file {{path}}',
|
||||
{
|
||||
path: item.path
|
||||
}
|
||||
)}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
>
|
||||
<View style={styles.statusBadge}>
|
||||
<Text style={[styles.statusBadgeText, { color: statusColor(item.status) }]}>
|
||||
{STATUS_LABELS[item.status]}
|
||||
</Text>
|
||||
</View>
|
||||
<FileText
|
||||
size={16}
|
||||
color={item.canOpen ? colors.textSecondary : colors.textMuted}
|
||||
strokeWidth={2.1}
|
||||
/>
|
||||
<View style={styles.fileTextBlock}>
|
||||
<Text
|
||||
style={[styles.filePath, !item.canOpen && styles.filePathDisabled]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{item.path}
|
||||
</Text>
|
||||
{item.oldPath ? (
|
||||
<Text style={styles.fileMeta} numberOfLines={1}>
|
||||
{t('sourceControl.fileRows.renamedFrom', 'from {{path}}', { path: item.oldPath })}
|
||||
</Text>
|
||||
) : item.conflictStatus === 'unresolved' ? (
|
||||
<Text style={styles.fileMeta} numberOfLines={1}>
|
||||
{conflictKindLabel(item.conflictKind, t)}
|
||||
</Text>
|
||||
) : null}
|
||||
{!rowBusy && hasConflictActions ? (
|
||||
<View style={styles.conflictActions}>
|
||||
{item.conflictResolutions.map((resolution) => (
|
||||
<Pressable
|
||||
key={resolution}
|
||||
style={({ pressed }) => [
|
||||
styles.conflictActionButton,
|
||||
ioBusy && styles.iconButtonDisabled,
|
||||
pressed && styles.iconButtonPressed
|
||||
]}
|
||||
disabled={ioBusy}
|
||||
onPress={() => void resolveConflict(item, resolution)}
|
||||
hitSlop={4}
|
||||
accessibilityLabel={t(
|
||||
'sourceControl.conflictActions.resolveFile',
|
||||
'{{action}}: {{path}}',
|
||||
{
|
||||
action: mobileConflictResolutionLabel(resolution, t),
|
||||
path: item.path
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Text style={styles.conflictActionText}>
|
||||
{mobileConflictResolutionLabel(resolution, t)}
|
||||
</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{rowBusy ? (
|
||||
<ActivityIndicator size="small" color={colors.textSecondary} />
|
||||
) : item.canUnstage ? (
|
||||
<Undo2 size={17} color={colors.onStatusRed} strokeWidth={2.2} />
|
||||
<Text style={styles.discardActionText}>{label}</Text>
|
||||
</Pressable>
|
||||
{/* pan-y keeps the page scrolling vertically over the row on the web. */}
|
||||
<GestureDetector gesture={pan} touchAction="pan-y">
|
||||
<Animated.View style={rowStyle}>{children(guardPress)}</Animated.View>
|
||||
</GestureDetector>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export function ChangeFileRow({
|
||||
item,
|
||||
state
|
||||
}: {
|
||||
item: MobileGitStatusEntryView
|
||||
state: FileRowState
|
||||
}) {
|
||||
useMobileColorScheme()
|
||||
const t = useMobileTranslation()
|
||||
const { busyAction, openDiffForFile, resolveConflict, runGitAction, setDiscardTarget } = state
|
||||
const rowBusy =
|
||||
busyAction === item.stageActionId ||
|
||||
busyAction === item.unstageActionId ||
|
||||
busyAction === item.discardActionId ||
|
||||
busyAction === item.resolveActionId
|
||||
const ioBusy = busyAction !== null
|
||||
const hasConflictActions = item.conflictResolutions.length > 0
|
||||
const detail = item.oldPath
|
||||
? t('sourceControl.fileRows.renamedFrom', 'from {{path}}', { path: item.oldPath })
|
||||
: item.conflictStatus === 'unresolved'
|
||||
? conflictKindLabel(item.conflictKind, t)
|
||||
: undefined
|
||||
const stage = () => void runGitAction(item.stageActionId, 'git.stage', { filePath: item.path })
|
||||
const unstage = () => {
|
||||
const filePaths = getUnstageablePaths([item])
|
||||
void (filePaths.length > 1
|
||||
? runGitAction(item.unstageActionId, 'git.bulkUnstage', { filePaths })
|
||||
: runGitAction(item.unstageActionId, 'git.unstage', { filePath: item.path }))
|
||||
}
|
||||
// Every press in the row goes through the swipe's guard, so a drag never also presses a button.
|
||||
const conflictActions = (guard: (onPress: () => void) => () => void) =>
|
||||
!rowBusy && hasConflictActions
|
||||
? item.conflictResolutions.map((resolution) => (
|
||||
<Pressable
|
||||
key={resolution}
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
styles.conflictActionButton,
|
||||
ioBusy && styles.iconButtonDisabled,
|
||||
pressed && styles.iconButtonPressed
|
||||
]}
|
||||
disabled={ioBusy}
|
||||
onPress={() => {
|
||||
const filePaths = getUnstageablePaths([item])
|
||||
void (filePaths.length > 1
|
||||
? runGitAction(item.unstageActionId, 'git.bulkUnstage', { filePaths })
|
||||
: runGitAction(item.unstageActionId, 'git.unstage', { filePath: item.path }))
|
||||
}}
|
||||
hitSlop={8}
|
||||
accessibilityLabel={t('sourceControl.fileRows.unstageFile', 'Unstage {{path}}', {
|
||||
path: item.path
|
||||
})}
|
||||
onPress={guard(() => void resolveConflict(item, resolution))}
|
||||
hitSlop={4}
|
||||
accessibilityLabel={t(
|
||||
'sourceControl.conflictActions.resolveFile',
|
||||
'{{action}}: {{path}}',
|
||||
{
|
||||
action: mobileConflictResolutionLabel(resolution, t),
|
||||
path: item.path
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Minus size={16} color={colors.textSecondary} strokeWidth={2.2} />
|
||||
<Text style={styles.conflictActionText}>
|
||||
{mobileConflictResolutionLabel(resolution, t)}
|
||||
</Text>
|
||||
</Pressable>
|
||||
) : item.canStage || item.canDiscard ? (
|
||||
<View style={styles.rowActions}>
|
||||
{item.canStage ? (
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
ioBusy && styles.iconButtonDisabled,
|
||||
pressed && styles.iconButtonPressed
|
||||
]}
|
||||
disabled={ioBusy}
|
||||
onPress={() =>
|
||||
void runGitAction(item.stageActionId, 'git.stage', { filePath: item.path })
|
||||
}
|
||||
hitSlop={8}
|
||||
accessibilityLabel={t('sourceControl.fileRows.stageFile', 'Stage {{path}}', {
|
||||
path: item.path
|
||||
})}
|
||||
>
|
||||
<Plus size={16} color={colors.textSecondary} strokeWidth={2.2} />
|
||||
</Pressable>
|
||||
) : null}
|
||||
{item.canDiscard ? (
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
ioBusy && styles.iconButtonDisabled,
|
||||
pressed && styles.iconButtonPressed
|
||||
]}
|
||||
disabled={ioBusy}
|
||||
onPress={() => setDiscardTarget(item)}
|
||||
hitSlop={8}
|
||||
accessibilityLabel={t('sourceControl.fileRows.discardFile', 'Discard {{path}}', {
|
||||
path: item.path
|
||||
})}
|
||||
>
|
||||
<Trash2 size={16} color={colors.statusRed} strokeWidth={2.1} />
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
{!rowBusy && item.canOpen ? (
|
||||
<ChevronRight size={16} color={colors.textMuted} strokeWidth={2.1} />
|
||||
) : null}
|
||||
))
|
||||
: null
|
||||
const trailing = (guard: (onPress: () => void) => () => void) =>
|
||||
rowBusy ? (
|
||||
<ActivityIndicator size="small" color={colors.textSecondary} />
|
||||
) : !hasConflictActions && (item.canUnstage || item.canStage) ? (
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.iconButton,
|
||||
ioBusy && styles.iconButtonDisabled,
|
||||
pressed && styles.iconButtonPressed
|
||||
]}
|
||||
disabled={ioBusy}
|
||||
onPress={guard(item.canUnstage ? unstage : stage)}
|
||||
hitSlop={8}
|
||||
accessibilityLabel={
|
||||
item.canUnstage
|
||||
? t('sourceControl.fileRows.unstageFile', 'Unstage {{path}}', { path: item.path })
|
||||
: t('sourceControl.fileRows.stageFile', 'Stage {{path}}', { path: item.path })
|
||||
}
|
||||
>
|
||||
{item.canUnstage ? (
|
||||
<Minus size={18} color={colors.textSecondary} strokeWidth={2.2} />
|
||||
) : (
|
||||
<Plus size={18} color={colors.textSecondary} strokeWidth={2.2} />
|
||||
)}
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
type BranchState = Pick<
|
||||
MobileSourceControlState,
|
||||
| 'shouldShowBranchCompareSection'
|
||||
| 'branchCompareSummaryText'
|
||||
| 'branchEntries'
|
||||
| 'branchCompareState'
|
||||
| 'branchCompareResult'
|
||||
| 'busyAction'
|
||||
| 'openDiffForFile'
|
||||
>
|
||||
|
||||
export function BranchCompareHeader({ state }: { state: BranchState }) {
|
||||
useMobileColorScheme()
|
||||
const t = useMobileTranslation()
|
||||
const {
|
||||
shouldShowBranchCompareSection,
|
||||
branchCompareSummaryText,
|
||||
branchEntries,
|
||||
branchCompareState,
|
||||
branchCompareResult
|
||||
} = state
|
||||
if (!shouldShowBranchCompareSection) {
|
||||
return null
|
||||
}
|
||||
|
||||
) : null
|
||||
return (
|
||||
<View style={styles.branchCompareBlock}>
|
||||
<View style={styles.sectionHeaderBleed}>
|
||||
<SectionHeader
|
||||
title={t('sourceControl.fileRows.committedSection', 'Committed on Branch')}
|
||||
trailing={String(branchEntries.length)}
|
||||
/>
|
||||
</View>
|
||||
{branchCompareSummaryText ? (
|
||||
<Text style={styles.branchSectionSubtitle} numberOfLines={1}>
|
||||
{branchCompareSummaryText}
|
||||
</Text>
|
||||
) : null}
|
||||
{branchCompareState.kind === 'loading' ? (
|
||||
<View style={styles.branchStateRow}>
|
||||
<ActivityIndicator size="small" color={colors.textSecondary} />
|
||||
<Text style={styles.branchStateText}>
|
||||
{t('sourceControl.fileRows.loadingCommitted', 'Loading committed changes...')}
|
||||
</Text>
|
||||
</View>
|
||||
) : branchCompareState.kind === 'error' ? (
|
||||
<View style={styles.branchStateRow}>
|
||||
<Text style={styles.branchStateText}>{branchCompareState.message}</Text>
|
||||
</View>
|
||||
) : branchCompareResult && branchCompareResult.summary.status !== 'ready' ? (
|
||||
<View style={styles.branchStateRow}>
|
||||
<Text style={styles.branchStateText}>
|
||||
{branchCompareResult.summary.errorMessage ??
|
||||
t('sourceControl.fileRows.committedUnavailable', 'Committed changes unavailable.')}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
<SwipeToDiscard
|
||||
available={item.canDiscard}
|
||||
enabled={!ioBusy}
|
||||
label={t('sourceControl.fileRows.discard', 'Discard')}
|
||||
accessibilityLabel={t('sourceControl.fileRows.discardFile', 'Discard {{path}}', {
|
||||
path: item.path
|
||||
})}
|
||||
onDiscard={() => setDiscardTarget(item)}
|
||||
>
|
||||
{(guardPress) => (
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.fileRow,
|
||||
pressed && item.canOpen && styles.fileRowPressed,
|
||||
!item.canOpen && !hasConflictActions && styles.fileRowUnavailable
|
||||
]}
|
||||
onPress={guardPress(() => {
|
||||
if (item.area !== undefined) {
|
||||
openDiffForFile({ kind: 'changes', filePath: item.path, area: item.area })
|
||||
}
|
||||
})}
|
||||
disabled={!item.canOpen || ioBusy}
|
||||
// An accessible row hides nested buttons from iOS VoiceOver; conflict rows cannot open anyway.
|
||||
accessible={!hasConflictActions}
|
||||
accessibilityLabel={t(
|
||||
'sourceControl.fileRows.openChangedFile',
|
||||
'Open changed file {{path}}',
|
||||
{
|
||||
path: item.path
|
||||
}
|
||||
)}
|
||||
>
|
||||
<FileRowBody
|
||||
status={item.status}
|
||||
path={item.path}
|
||||
detail={detail}
|
||||
added={item.added}
|
||||
removed={item.removed}
|
||||
trailing={trailing(guardPress)}
|
||||
actions={conflictActions(guardPress)}
|
||||
/>
|
||||
</Pressable>
|
||||
)}
|
||||
</SwipeToDiscard>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -272,55 +343,38 @@ export function BranchFileRow({
|
||||
state
|
||||
}: {
|
||||
entry: MobileBranchEntryView
|
||||
state: BranchState
|
||||
state: Pick<FileRowState, 'busyAction' | 'openDiffForFile'>
|
||||
}) {
|
||||
useMobileColorScheme()
|
||||
const t = useMobileTranslation()
|
||||
const { busyAction, openDiffForFile } = state
|
||||
const rowDisabled = !entry.canOpen || busyAction !== null
|
||||
const meta = formatMobileBranchEntryMeta(entry)
|
||||
return (
|
||||
<Pressable
|
||||
style={({ pressed }) => [
|
||||
styles.fileRow,
|
||||
pressed && entry.canOpen && styles.fileRowPressed,
|
||||
rowDisabled && styles.fileRowDisabled,
|
||||
!entry.canOpen && styles.fileRowUnavailable
|
||||
]}
|
||||
onPress={() => openDiffForFile({ kind: 'changes', filePath: entry.path, area: 'branch' })}
|
||||
disabled={rowDisabled}
|
||||
onPress={() =>
|
||||
state.openDiffForFile({ kind: 'changes', filePath: entry.path, area: 'branch' })
|
||||
}
|
||||
disabled={!entry.canOpen || state.busyAction !== null}
|
||||
accessibilityLabel={t(
|
||||
'sourceControl.fileRows.openCommittedChange',
|
||||
'Open committed change {{path}}',
|
||||
{
|
||||
path: entry.path
|
||||
}
|
||||
{ path: entry.path }
|
||||
)}
|
||||
>
|
||||
<View style={styles.statusBadge}>
|
||||
<Text style={[styles.statusBadgeText, { color: statusColor(entry.status) }]}>
|
||||
{STATUS_LABELS[entry.status]}
|
||||
</Text>
|
||||
</View>
|
||||
<FileText
|
||||
size={16}
|
||||
color={entry.canOpen ? colors.textSecondary : colors.textMuted}
|
||||
strokeWidth={2.1}
|
||||
<FileRowBody
|
||||
status={entry.status}
|
||||
path={entry.path}
|
||||
detail={
|
||||
entry.oldPath
|
||||
? t('sourceControl.fileRows.renamedFrom', 'from {{path}}', { path: entry.oldPath })
|
||||
: undefined
|
||||
}
|
||||
added={entry.added}
|
||||
removed={entry.removed}
|
||||
/>
|
||||
<View style={styles.fileTextBlock}>
|
||||
<Text
|
||||
style={[styles.filePath, !entry.canOpen && styles.filePathDisabled]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{entry.path}
|
||||
</Text>
|
||||
{meta ? (
|
||||
<Text style={styles.fileMeta} numberOfLines={1}>
|
||||
{meta}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{entry.canOpen ? <ChevronRight size={16} color={colors.textMuted} strokeWidth={2.1} /> : null}
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user