feat(features): auth, accounts, home, repositories, issues, notifications
- auth: welcome/connect screens, shared connect form, connect flow, app lock - accounts: session hook, actions, switcher + add-account screens - home: dashboard (identity, shortcuts, recent repos, assigned issues, review requests, activity, unread badge) - repositories/repository: list+search, overview, files, file viewer, commits, commit detail, branches, tags, repo issues/pulls, issue/pull detail - issues/notifications: cross-repo search, query hooks, inbox with read marking and lifecycle-aware polling - settings: theme/language/biometrics/poll interval/cache/about
This commit is contained in:
1 parent
ad81db07b3
commit
0a889ebfed
36 files changed
+4186
No files matched your search
@@ -0,0 +1,138 @@
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Badge, StatusBadge } from '@/components/ui/badge';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { LabelChip } from '@/components/ui/label-chip';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { usePull } from '@/features/issues/queries';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'PullDetail'>;
|
||||
|
||||
/** Full pull request view: state, branches, reviewers, stats and body. */
|
||||
export function PullDetailScreen({ route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { instance } = useSession();
|
||||
const { owner, name, index } = route.params;
|
||||
|
||||
const query = usePull(owner, name, index);
|
||||
const pull = query.data;
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('pulls.notFound')}
|
||||
body={apiErrorMessage(query.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void query.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (!pull) return null;
|
||||
|
||||
const author = pull.user;
|
||||
const state: 'open' | 'closed' | 'merged' | 'draft' = pull.merged
|
||||
? 'merged'
|
||||
: pull.draft && pull.state === 'open'
|
||||
? 'draft'
|
||||
: pull.state === 'closed'
|
||||
? 'closed'
|
||||
: 'open';
|
||||
const stateLabel = {
|
||||
open: t('pulls.stateOpen'),
|
||||
closed: t('pulls.stateClosed'),
|
||||
merged: t('pulls.stateMerged'),
|
||||
draft: t('pulls.draft'),
|
||||
}[state];
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<View style={styles.titleBlock}>
|
||||
<AppText variant="heading">
|
||||
{pull.title} <AppText variant="heading" tone="tertiary">{`#${pull.number}`}</AppText>
|
||||
</AppText>
|
||||
<View style={styles.stateRow}>
|
||||
<StatusBadge label={stateLabel} state={state} />
|
||||
{pull.head?.label && pull.base?.label ? (
|
||||
<Badge tone="neutral" icon="branch">
|
||||
{t('pulls.into', { head: pull.head.label, base: pull.base.label })}
|
||||
</Badge>
|
||||
) : null}
|
||||
</View>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('pulls.openedBy', { name: author?.login ?? t('common.unknown') })} ·{' '}
|
||||
{formatRelativeTime(pull.created_at, t)}
|
||||
</AppText>
|
||||
</View>
|
||||
|
||||
{pull.labels && pull.labels.length > 0 ? (
|
||||
<View style={styles.labels}>
|
||||
{pull.labels.map((label, labelIndex) => (
|
||||
<LabelChip key={label.id ?? `${label.name}-${labelIndex}`} name={label.name} color={label.color} />
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<Card style={styles.bodyCard}>
|
||||
{pull.body && pull.body.trim().length > 0 ? (
|
||||
<Markdown content={pull.body} baseUrl={instance?.baseUrl} />
|
||||
) : (
|
||||
<AppText variant="secondary" tone="tertiary">
|
||||
{t('pulls.noDescription')}
|
||||
</AppText>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<View style={styles.stats}>
|
||||
<Badge tone="success">{`+${pull.additions ?? 0}`}</Badge>
|
||||
<Badge tone="error">{`−${pull.deletions ?? 0}`}</Badge>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('pulls.changedFiles', { count: pull.changed_files ?? 0 })}
|
||||
</AppText>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('issues.comments', { count: pull.comments ?? 0 })}
|
||||
</AppText>
|
||||
</View>
|
||||
|
||||
{pull.requested_reviewers && pull.requested_reviewers.length > 0 ? (
|
||||
<View style={styles.reviewers}>
|
||||
<AppText variant="label" tone="secondary">
|
||||
{t('pulls.reviewers')}
|
||||
</AppText>
|
||||
<View style={styles.reviewerRow}>
|
||||
{pull.requested_reviewers.map((reviewer) => (
|
||||
<View key={reviewer.id ?? reviewer.login} style={styles.reviewer}>
|
||||
<Avatar url={reviewer.avatar_url} name={reviewer.login} size={24} />
|
||||
<AppText variant="caption" tone="secondary">
|
||||
{reviewer.login}
|
||||
</AppText>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
titleBlock: { gap: spacing.sm },
|
||||
stateRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
|
||||
labels: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
bodyCard: { minHeight: 80 },
|
||||
stats: { flexDirection: 'row', alignItems: 'center', gap: spacing.md, flexWrap: 'wrap' },
|
||||
reviewers: { gap: spacing.sm },
|
||||
reviewerRow: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.lg },
|
||||
reviewer: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
});
|
||||
Reference in new issue
Block a user