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:
JustZoe101 committed 2026-10-09 16:41:21 +02:00
1 parent ad81db07b3
commit 0a889ebfed
36 files changed
+4186

No files matched your search

@@ -0,0 +1,69 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { SearchBar } from '@/components/ui/search-bar';
import { Badge } from '@/components/ui/badge';
import { ListItem } from '@/components/ui/list-item';
import { EmptyState } from '@/components/ui/state-views';
import type { Branch } from '@/core/api/types';
import { firstLine, formatRelativeTime, shortSha } from '@/core/utils/format';
import { flattenPages } from '@/core/utils/infinite';
import { useBranches } from '@/features/repository/queries';
import { useRepository } from '@/features/repositories/queries';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Branches'>;
/** Branch list with search; tapping a branch opens its file tree. */
export function BranchesScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const [search, setSearch] = useState('');
const query = useBranches(owner, name, search);
const repo = useRepository(owner, name);
const defaultBranch = repo.data?.default_branch;
const branches: Branch[] = flattenPages(query.data);
return (
<QueryList<Branch>
query={query}
items={branches}
keyExtractor={(branch) => branch.name}
header={
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('branches.searchPlaceholder')}
/>
}
renderItem={(branch) => {
const isDefault = branch.name === defaultBranch;
return (
<ListItem
leadingIcon="branch"
title={branch.name}
subtitle={firstLine(branch.commit?.message)}
meta={[
branch.commit?.id ? shortSha(branch.commit.id) : null,
formatRelativeTime(branch.commit?.timestamp, t),
]
.filter(Boolean)
.join(' · ')}
trailing={
isDefault || branch.protected ? (
<Badge tone={isDefault ? 'primary' : 'warning'} icon={isDefault ? 'star' : 'shield'}>
{isDefault ? t('branches.default') : t('branches.protected')}
</Badge>
) : undefined
}
onPress={() => navigation.navigate('Files', { owner, name, ref: branch.name })}
/>
);
}}
empty={<EmptyState icon="branch" title={t('branches.empty')} />}
/>
);
}
@@ -0,0 +1,187 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { CommitAffectedFile } from '@/core/api/types';
import { useCommit } from '@/features/repository/queries';
import { formatDateTime, shortSha } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { fontFamily, fontSize, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'CommitDetail'>;
/** Single commit: metadata, message, stats and per-file diffs. */
export function CommitDetailScreen({ route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { owner, name, sha } = route.params;
const query = useCommit(owner, name, sha);
const commit = query.data;
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
if (!commit) return null;
const message = commit.commit.message ?? '';
const title = splitCommitTitle(message);
const body = splitCommitBody(message);
const author = commit.author;
const authorName = author?.login ?? commit.commit.author?.name ?? t('common.unknown');
const date = commit.commit.author?.date ?? commit.created;
const files = commit.files ?? [];
return (
<Screen scroll padded>
<View style={styles.titleBlock}>
<AppText variant="heading">{title}</AppText>
{body ? (
<AppText variant="secondary" tone="secondary">
{body}
</AppText>
) : null}
</View>
<View style={styles.metaRow}>
<Avatar url={author?.avatar_url} name={authorName} size={32} />
<View style={styles.metaBody}>
<AppText variant="bodyMedium">{authorName}</AppText>
<AppText variant="caption" tone="tertiary">
{formatDateTime(date)}
</AppText>
</View>
<View style={[styles.shaChip, { backgroundColor: colors.surfaceSecondary }]}>
<AppText variant="monoSmall" tone="tertiary">
{shortSha(commit.sha)}
</AppText>
</View>
</View>
{commit.stats ? (
<View style={styles.stats}>
<Badge tone="success">
{`+${commit.stats.additions ?? 0}`}
</Badge>
<Badge tone="error">{`−${commit.stats.deletions ?? 0}`}</Badge>
<AppText variant="caption" tone="tertiary">
{t('commits.filesChanged', { count: files.length || (commit.stats.total ?? 0) })}
</AppText>
</View>
) : null}
{commit.commit.verification ? (
<Badge tone={commit.commit.verification.verified ? 'success' : 'warning'} icon={commit.commit.verification.verified ? 'verified' : 'unverified'}>
{commit.commit.verification.verified ? t('commits.verified') : t('commits.unverified')}
</Badge>
) : null}
{files.map((file, index) => (
<FileDiff key={`${file.filename ?? index}`} file={file} />
))}
</Screen>
);
}
function FileDiff({ file }: { file: CommitAffectedFile }) {
const { t } = useTranslation();
const { colors } = useTheme();
return (
<Card padded={false} style={styles.diffCard}>
<View style={[styles.diffHeader, { borderBottomColor: colors.border }]}>
<AppText variant="monoSmall" numberOfLines={1} style={styles.diffPath}>
{file.filename ?? ''}
</AppText>
<View style={styles.diffBadges}>
<AppText variant="caption" style={{ color: colors.success }}>
+{file.additions ?? 0}
</AppText>
<AppText variant="caption" style={{ color: colors.error }}>
−{file.deletions ?? 0}
</AppText>
</View>
</View>
{file.patch ? (
<View style={styles.patch}>
{file.patch.split('\n').map((line, lineIndex) => (
<AppText
key={lineIndex}
variant="monoSmall"
selectable
style={[
styles.patchLine,
line.startsWith('+') && !line.startsWith('+++')
? { color: colors.diffAddText }
: line.startsWith('-') && !line.startsWith('---')
? { color: colors.diffDelText }
: line.startsWith('@@')
? { color: colors.textTertiary }
: { color: colors.text },
]}
>
{line || ' '}
</AppText>
))}
</View>
) : (
<AppText variant="caption" tone="tertiary" style={styles.noPatch}>
{t('files.binary')}
</AppText>
)}
</Card>
);
}
function splitCommitTitle(message: string): string {
return message.split('\n', 1)[0]?.trim() || '';
}
function splitCommitBody(message: string): string {
const parts = message.split('\n');
const body = parts.slice(1).join('\n').trim();
return body;
}
const styles = StyleSheet.create({
titleBlock: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
metaBody: { flex: 1, gap: 2 },
shaChip: { paddingHorizontal: spacing.sm, paddingVertical: 2, borderRadius: 6 },
stats: { flexDirection: 'row', alignItems: 'center', gap: spacing.md, flexWrap: 'wrap' },
diffCard: { overflow: 'hidden' },
diffHeader: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: spacing.sm,
paddingHorizontal: spacing.md,
paddingVertical: spacing.sm,
borderBottomWidth: StyleSheet.hairlineWidth,
},
diffPath: { flex: 1 },
diffBadges: { flexDirection: 'row', gap: spacing.sm },
patch: { padding: spacing.md },
patchLine: {
fontFamily: fontFamily.mono,
fontSize: fontSize.xs,
lineHeight: 17,
},
noPatch: { padding: spacing.md },
});
@@ -0,0 +1,53 @@
import { useTranslation } from 'react-i18next';
import { View } from 'react-native';
import { CommitRow } from '@/components/git/commit-row';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { EmptyState } from '@/components/ui/state-views';
import type { Commit } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useCommits } from '@/features/repository/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Commits'>;
/** Commit history for a repository (optionally restricted to a path). */
export function CommitsScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name, sha, path } = route.params;
const query = useCommits(owner, name, { sha, path });
const items: Commit[] = flattenPages(query.data);
return (
<QueryList<Commit>
query={query}
items={items}
keyExtractor={(commit) => commit.sha}
header={
path ? (
<View style={{ paddingHorizontal: spacing.lg, paddingTop: spacing.sm }}>
<AppText variant="caption" tone="tertiary">
{t('commits.fileFilter', { path })}
</AppText>
</View>
) : undefined
}
renderItem={(commit) => (
<CommitRow
commit={commit}
onPress={() => navigation.navigate('CommitDetail', { owner, name, sha: commit.sha })}
/>
)}
empty={
<EmptyState
icon="commit"
title={path ? t('commits.emptyPath') : t('commits.empty')}
/>
}
/>
);
}
@@ -0,0 +1,158 @@
import { Image } from 'expo-image';
import { ScrollView, 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 { Card } from '@/components/ui/card';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useSession } from '@/features/accounts/use-session';
import { decodeBase64, useFile } from '@/features/repository/queries';
import { formatBytes } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { fontFamily, fontSize, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'FileViewer'>;
const IMAGE_EXTENSIONS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg']);
const MARKDOWN_EXTENSIONS = new Set(['md', 'markdown', 'mdown', 'mkd']);
const LARGE_FILE_BYTES = 1_000_000;
function extensionOf(path: string): string {
const last = path.split('/').pop() ?? '';
const dot = last.lastIndexOf('.');
return dot >= 0 ? last.slice(dot + 1).toLowerCase() : '';
}
/** Renders a single file: image preview, markdown, or source text. */
export function FileViewerScreen({ route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { instance, token } = useSession();
const { owner, name, path, ref } = route.params;
const query = useFile(owner, name, path, ref);
const entry = query.data;
const extension = extensionOf(path);
if (query.isPending) return <LoadingView label={t('files.loadingFile')} />;
if (query.isError) {
return (
<ErrorState
title={t('files.rawUnavailable')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
if (!entry) return null;
if (entry.type === 'symlink' || entry.type === 'submodule') {
return (
<Screen padded>
<Card>
<AppText variant="bodyMedium">
{entry.type === 'submodule' ? t('files.submodule') : t('files.symlink', { target: entry.target ?? '' })}
</AppText>
</Card>
</Screen>
);
}
if (IMAGE_EXTENSIONS.has(extension) && entry.download_url) {
const host = instance ? safeHost(instance.baseUrl) : null;
const headers =
token && host && safeHost(entry.download_url) === host
? { Authorization: `token ${token}` }
: undefined;
return (
<Screen padded>
<Card padded={false} style={styles.imageCard}>
<Image
source={{ uri: entry.download_url, headers }}
style={styles.image}
contentFit="contain"
transition={150}
accessibilityLabel={entry.name}
/>
</Card>
<AppText variant="caption" tone="tertiary" style={styles.center}>
{t('files.image')} · {formatBytes(entry.size)}
</AppText>
</Screen>
);
}
const content = entry.content ? decodeBase64(entry.content) : '';
if (!content) {
return (
<Screen padded>
<Card>
<AppText variant="bodyMedium">{t('files.binary')}</AppText>
<AppText variant="caption" tone="tertiary">
{formatBytes(entry.size)}
</AppText>
</Card>
</Screen>
);
}
const lineCount = content.length > 0 ? content.split('\n').length : 0;
return (
<Screen padded={false}>
{entry.size >= LARGE_FILE_BYTES ? (
<AppText variant="caption" tone="warning" style={styles.notice}>
{t('files.large', { size: formatBytes(entry.size) })}
</AppText>
) : null}
{MARKDOWN_EXTENSIONS.has(extension) ? (
<View style={styles.markdownWrap}>
<Markdown content={content} baseUrl={instance?.baseUrl} />
</View>
) : (
<ScrollView horizontal showsHorizontalScrollIndicator contentContainerStyle={styles.codeOuter}>
<ScrollView contentContainerStyle={styles.codeInner}>
<AppText variant="monoSmall" selectable style={[styles.code, { color: colors.text }]}>
{content}
</AppText>
</ScrollView>
</ScrollView>
)}
<AppText variant="caption" tone="tertiary" style={styles.notice}>
{t('files.lines', { count: lineCount })} · {formatBytes(entry.size)}
</AppText>
</Screen>
);
}
function safeHost(url: string): string | null {
try {
return new URL(url).host;
} catch {
return null;
}
}
const styles = StyleSheet.create({
notice: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
markdownWrap: { paddingHorizontal: spacing.lg },
imageCard: { overflow: 'hidden', minHeight: 200 },
image: { width: '100%', height: 320 },
center: { textAlign: 'center' },
codeOuter: {},
codeInner: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
code: {
fontFamily: fontFamily.mono,
fontSize: fontSize.sm,
lineHeight: 19,
},
});
@@ -0,0 +1,103 @@
import { useMemo } from 'react';
import { StyleSheet, View } from 'react-native';
import { FlashList } from '@shopify/flash-list';
import { useTranslation } from 'react-i18next';
import { Breadcrumb, FileRow } from '@/components/git/file-row';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { ErrorState, EmptyState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { ContentsEntry } from '@/core/api/types';
import { useContents } from '@/features/repository/queries';
import { useRepository } from '@/features/repositories/queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Files'>;
/** Directory listing with breadcrumb navigation. */
export function FilesScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { owner, name, ref } = route.params;
const path = route.params.path ?? '';
const repoQuery = useRepository(owner, name);
const effectiveRef = ref ?? repoQuery.data?.default_branch;
const query = useContents(owner, name, path, effectiveRef);
const entries = useMemo(() => {
const list = Array.isArray(query.data) ? (query.data as ContentsEntry[]) : [];
return [...list].sort((a, b) => {
if (a.type === 'dir' && b.type !== 'dir') return -1;
if (a.type !== 'dir' && b.type === 'dir') return 1;
return a.name.localeCompare(b.name);
});
}, [query.data]);
const header = (
<View style={styles.header}>
<Breadcrumb
path={path}
rootLabel={t('files.root')}
onNavigate={(target) => navigation.setParams({ path: target || undefined })}
/>
{effectiveRef ? (
<AppText variant="caption" tone="tertiary" style={styles.ref}>
{t('files.currentRef', { ref: effectiveRef })}
</AppText>
) : null}
</View>
);
const body = () => {
if (query.isPending) return <LoadingView label={t('common.loading')} />;
if (query.isError) {
return (
<ErrorState
title={t('files.pathNotFound')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
return (
<FlashList
data={entries}
keyExtractor={(entry) => entry.path}
renderItem={({ item }) => (
<FileRow
entry={item}
onPress={() =>
item.type === 'dir'
? navigation.setParams({ path: item.path })
: navigation.navigate('FileViewer', { owner, name, path: item.path, ref: effectiveRef })
}
/>
)}
refreshing={query.isRefetching}
onRefresh={() => void query.refetch()}
ListEmptyComponent={<EmptyState icon="folder" title={t('files.empty')} />}
contentContainerStyle={entries.length === 0 ? styles.grow : undefined}
/>
);
};
return (
<Screen padded={false}>
<View style={[styles.refBar, { borderBottomColor: colors.border }]}>{header}</View>
{body()}
</Screen>
);
}
const styles = StyleSheet.create({
header: { gap: spacing.xs, paddingBottom: spacing.xs },
ref: { paddingHorizontal: spacing.lg },
refBar: { borderBottomWidth: StyleSheet.hairlineWidth },
grow: { flexGrow: 1 },
});
@@ -0,0 +1,132 @@
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 { Icon } from '@/components/ui/icon';
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 { useIssue } from '@/features/issues/queries';
import { formatRelativeTime } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'IssueDetail'>;
/** Full issue view: state, author, labels, milestone and rendered body. */
export function IssueDetailScreen({ route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { instance } = useSession();
const { owner, name, index } = route.params;
const query = useIssue(owner, name, index);
const issue = query.data;
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('issues.notFound')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
if (!issue) return null;
const author = issue.user;
const state = issue.state === 'closed' ? 'closed' : 'open';
return (
<Screen scroll padded>
<View style={styles.titleBlock}>
<AppText variant="heading">
{issue.title} <AppText variant="heading" tone="tertiary">{`#${issue.number}`}</AppText>
</AppText>
<View style={styles.stateRow}>
<StatusBadge label={state === 'closed' ? t('issues.closed') : t('issues.open')} state={state} />
{issue.is_locked ? <Badge tone="neutral" icon="lock">{`#${issue.number}`}</Badge> : null}
<AppText variant="caption" tone="tertiary">
{t('issues.openedBy', { name: author?.login ?? t('common.unknown') })} ·{' '}
{formatRelativeTime(issue.created_at, t)}
</AppText>
</View>
</View>
<View style={styles.authorRow}>
<Avatar url={author?.avatar_url} name={author?.login ?? '?'} size={28} />
<AppText variant="bodyMedium" style={styles.authorName}>
{author?.login ?? t('common.unknown')}
</AppText>
</View>
{issue.labels && issue.labels.length > 0 ? (
<View style={styles.labels}>
{issue.labels.map((label, index2) => (
<LabelChip key={label.id ?? `${label.name}-${index2}`} name={label.name} color={label.color} />
))}
</View>
) : null}
<Card style={styles.bodyCard}>
{issue.body && issue.body.trim().length > 0 ? (
<Markdown content={issue.body} baseUrl={instance?.baseUrl} />
) : (
<AppText variant="secondary" tone="tertiary">
{t('issues.noDescription')}
</AppText>
)}
</Card>
<View style={styles.metaGrid}>
{issue.assignees && issue.assignees.length > 0 ? (
<MetaRow
icon="person"
label={t('issues.assignedTo', {
name: issue.assignees.map((a) => a.login).join(', '),
})}
/>
) : null}
{issue.milestone ? <MetaRow icon="tag" label={`${t('issues.milestone')}: ${issue.milestone.title}`} /> : null}
<MetaRow
icon="mail"
label={t('issues.comments', { count: issue.comments ?? 0 })}
color={colors.textSecondary}
/>
</View>
</Screen>
);
}
function MetaRow({ icon, label, color }: { icon: 'person' | 'tag' | 'mail'; label: string; color?: string }) {
const { colors } = useTheme();
return (
<View style={styles.metaRow}>
<Icon name={icon} size={15} color={color ?? colors.textTertiary} />
<AppText variant="caption" tone="secondary">
{label}
</AppText>
</View>
);
}
const styles = StyleSheet.create({
titleBlock: { gap: spacing.sm },
stateRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
authorRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
authorName: { flex: 1 },
labels: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
bodyCard: { minHeight: 80 },
metaGrid: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
});
@@ -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 },
});
@@ -0,0 +1,70 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { IssueRow } from '@/components/git/issue-row';
import { QueryList } from '@/components/layout/query-list';
import { SearchBar } from '@/components/ui/search-bar';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { Issue } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useRepoIssues } from '@/features/issues/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoIssues'>;
type StateKey = 'open' | 'closed' | 'all';
/** Issues scoped to one repository. */
export function RepoIssuesScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const [state, setState] = useState<StateKey>('open');
const [search, setSearch] = useState('');
const query = useRepoIssues(owner, name, state, search);
const issues: Issue[] = flattenPages(query.data);
return (
<QueryList<Issue>
query={query}
items={issues}
keyExtractor={(issue) => String(issue.id)}
header={
<View>
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('issues.searchPlaceholder')}
/>
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('issues.title')}
options={[
{ value: 'open', label: t('issues.stateOpen') },
{ value: 'closed', label: t('issues.stateClosed') },
{ value: 'all', label: t('issues.stateAll') },
]}
/>
</View>
</View>
}
renderItem={(issue) => (
<IssueRow
issue={issue}
onPress={() => navigation.navigate('IssueDetail', { owner, name, index: issue.number })}
/>
)}
empty={<EmptyState icon="issue" title={t('issues.emptySearch', { query: search.trim() })} />}
/>
);
}
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
});
@@ -0,0 +1,302 @@
import { useMemo } from 'react';
import { Linking, 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 { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { LabelChip } from '@/components/ui/label-chip';
import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository, useRepositoryLanguages } from '@/features/repositories/queries';
import { useReadme } from '@/features/repository/queries';
import { useSession } from '@/features/accounts/use-session';
import { useTheme } from '@/theme/theme-provider';
import { radius, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoOverview'>;
/** Repository landing page: metadata, quick navigation, stats, languages, README. */
export function RepoOverviewScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { instance } = useSession();
const { owner, name, ref } = route.params;
const repoQuery = useRepository(owner, name);
const repo = repoQuery.data;
const readmeRef = ref ?? repo?.default_branch;
const readmeQuery = useReadme(owner, name, readmeRef);
const languagesQuery = useRepositoryLanguages(owner, name);
const languages = useMemo(() => {
const entries = Object.entries(languagesQuery.data ?? {});
const total = entries.reduce((sum, [, bytes]) => sum + bytes, 0);
if (total <= 0) return [];
return entries
.map(([language, bytes]) => ({ language, bytes, percent: (bytes / total) * 100 }))
.sort((a, b) => b.bytes - a.bytes)
.slice(0, 6);
}, [languagesQuery.data]);
if (!repo && repoQuery.isPending) return <LoadingView />;
if (!repo && repoQuery.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(repoQuery.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void repoQuery.refetch()}
/>
);
}
if (!repo) return null;
const readmeText = decodeReadme(readmeQuery.data?.content);
return (
<Screen scroll padded={false}>
{/* Header */}
<View style={[styles.header, { borderBottomColor: colors.border }]}>
<View style={styles.titleRow}>
<AppText variant="caption" tone="tertiary">
{owner}/
</AppText>
<AppText variant="title" numberOfLines={2} style={styles.name}>
{name}
</AppText>
</View>
<AppText variant="secondary" tone={repo.description ? 'secondary' : 'tertiary'}>
{repo.description ?? t('repo.noDescription')}
</AppText>
<View style={styles.badges}>
{repo.private ? <Badge tone="neutral" icon="lock">{t('repositories.private')}</Badge> : null}
{repo.fork ? <Badge tone="neutral" icon="fork">{t('repositories.fork')}</Badge> : null}
{repo.archived ? <Badge tone="warning" icon="shield">{t('repositories.archived')}</Badge> : null}
{repo.template ? <Badge tone="info" icon="package">{t('repositories.template')}</Badge> : null}
{repo.mirror ? <Badge tone="info" icon="autoRenew">{t('repositories.mirror')}</Badge> : null}
{repo.default_branch ? (
<Badge tone="primary" icon="branch">{repo.default_branch}</Badge>
) : null}
</View>
{repo.topics && repo.topics.length > 0 ? (
<View style={styles.badges}>
{repo.topics.slice(0, 8).map((topic) => (
<LabelChip key={topic} name={topic} />
))}
</View>
) : null}
{repo.html_url ? (
<Button
label={t('repo.viewOnInstance')}
variant="secondary"
iconLeft="externalLink"
onPress={() => void Linking.openURL(repo.html_url as string).catch(() => undefined)}
/>
) : null}
</View>
{/* Quick navigation */}
<View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}>
{t('repo.browse')}
</AppText>
<Card padded={false} variant="flat" style={styles.card}>
<ListItem
leadingIcon="folder"
title={t('repo.files')}
onPress={() => navigation.navigate('Files', { owner, name, ref: readmeRef })}
/>
<ListItem
leadingIcon="commit"
title={t('repo.commits')}
onPress={() => navigation.navigate('Commits', { owner, name, sha: readmeRef })}
/>
<ListItem
leadingIcon="branch"
title={t('repo.branches')}
onPress={() => navigation.navigate('Branches', { owner, name })}
/>
<ListItem
leadingIcon="tag"
title={t('repo.tags')}
onPress={() => navigation.navigate('Tags', { owner, name })}
/>
{repo.has_issues !== false ? (
<ListItem
leadingIcon="issue"
title={t('repo.issuesTab')}
rightText={repo.open_issues_count ? String(repo.open_issues_count) : undefined}
onPress={() => navigation.navigate('RepoIssues', { owner, name })}
/>
) : null}
{repo.has_pull_requests !== false ? (
<ListItem
leadingIcon="pullRequest"
title={t('repo.pullsTab')}
rightText={repo.open_pr_counter ? String(repo.open_pr_counter) : undefined}
onPress={() => navigation.navigate('RepoPulls', { owner, name })}
divider={false}
/>
) : null}
</Card>
</View>
{/* Statistics */}
<View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}>
{t('repo.statistics')}
</AppText>
<Card style={styles.card}>
<View style={styles.statsGrid}>
<Stat label={t('repo.stars')} value={repo.stars_count} icon="star" />
<Stat label={t('repo.forks')} value={repo.forks_count} icon="fork" />
<Stat label={t('repo.watchers')} value={repo.watchers_count} icon="eye" />
<Stat label={t('repo.openIssues')} value={repo.open_issues_count} icon="issue" />
<Stat label={t('repo.openPulls')} value={repo.open_pr_counter} icon="pullRequest" />
<Stat label={t('repo.releases')} value={repo.release_counter} icon="tag" />
</View>
</Card>
</View>
{/* Languages */}
{languages.length > 0 ? (
<View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}>
{t('repo.languages')}
</AppText>
<Card style={styles.card}>
<View style={[styles.langBar, { backgroundColor: colors.surfaceSecondary }]}>
{languages.map((entry, index) => (
<View
key={entry.language}
style={{
flex: entry.percent,
backgroundColor: languageColor(index, colors.primary),
}}
/>
))}
</View>
<View style={styles.langList}>
{languages.map((entry, index) => (
<View key={entry.language} style={styles.langItem}>
<View
style={[styles.langDot, { backgroundColor: languageColor(index, colors.primary) }]}
/>
<AppText variant="caption" style={styles.langName} numberOfLines={1}>
{entry.language}
</AppText>
<AppText variant="caption" tone="tertiary">
{entry.percent.toFixed(1)}%
</AppText>
</View>
))}
</View>
</Card>
</View>
) : null}
{/* README */}
<View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}>
{t('repo.readme')}
</AppText>
{readmeQuery.isPending ? (
<View style={styles.card}>
<LoadingView />
</View>
) : readmeText ? (
<Card style={styles.card}>
<Markdown content={readmeText} baseUrl={instance?.baseUrl} />
</Card>
) : (
<Card style={styles.card}>
<AppText variant="secondary" tone="tertiary">
{t('repo.noReadme')}
</AppText>
</Card>
)}
</View>
<View style={{ height: spacing.xxl }} />
</Screen>
);
}
function Stat({
label,
value,
icon,
}: {
label: string;
value: number | undefined;
icon: 'star' | 'fork' | 'eye' | 'issue' | 'pullRequest' | 'tag';
}) {
const { colors } = useTheme();
return (
<View style={styles.stat}>
<Icon name={icon} size={16} color={colors.textTertiary} />
<AppText variant="bodyMedium">{value ?? 0}</AppText>
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
{label}
</AppText>
</View>
);
}
const LANGUAGE_COLORS = ['#609926', '#3178c6', '#e34c26', '#f1e05a', '#563d7c', '#89e051'];
function languageColor(index: number, fallback: string): string {
return LANGUAGE_COLORS[index] ?? fallback;
}
function decodeReadme(content: string | undefined): string {
if (!content) return '';
try {
return globalThis.atob(content.replace(/\s/g, ''));
} catch {
return '';
}
}
const styles = StyleSheet.create({
header: {
paddingHorizontal: spacing.lg,
paddingTop: spacing.lg,
paddingBottom: spacing.lg,
gap: spacing.md,
borderBottomWidth: StyleSheet.hairlineWidth,
},
titleRow: { flexDirection: 'row', alignItems: 'baseline', flexWrap: 'wrap' },
name: { flexShrink: 1 },
badges: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm, alignItems: 'center' },
section: { marginTop: spacing.xl, gap: spacing.sm },
sectionTitle: { paddingHorizontal: spacing.lg },
card: { marginHorizontal: spacing.lg },
statsGrid: { flexDirection: 'row', flexWrap: 'wrap' },
stat: { width: '33.33%', alignItems: 'center', gap: 2, paddingVertical: spacing.sm },
langBar: {
flexDirection: 'row',
height: 10,
borderRadius: radius.pill,
overflow: 'hidden',
marginBottom: spacing.md,
},
langList: { gap: spacing.xs },
langItem: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
langDot: { width: 10, height: 10, borderRadius: radius.pill },
langName: { flex: 1 },
});
@@ -0,0 +1,61 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { IssueRow } from '@/components/git/issue-row';
import { QueryList } from '@/components/layout/query-list';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { PullRequest } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useRepoPulls } from '@/features/issues/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoPulls'>;
type StateKey = 'open' | 'closed' | 'all';
/** Pull requests scoped to one repository. */
export function RepoPullsScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const [state, setState] = useState<StateKey>('open');
const query = useRepoPulls(owner, name, state);
const pulls: PullRequest[] = flattenPages(query.data);
return (
<QueryList<PullRequest>
query={query}
items={pulls}
keyExtractor={(pull) => String(pull.id)}
header={
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('pulls.title')}
options={[
{ value: 'open', label: t('pulls.stateOpen') },
{ value: 'closed', label: t('pulls.stateClosed') },
{ value: 'all', label: t('pulls.stateAll') },
]}
/>
</View>
}
renderItem={(pull) => (
<IssueRow
issue={pull}
onPress={() => navigation.navigate('PullDetail', { owner, name, index: pull.number })}
/>
)}
empty={<EmptyState icon="pullRequest" title={t('pulls.emptyCreated')} />}
/>
);
}
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingTop: spacing.sm, paddingBottom: spacing.sm },
});
@@ -0,0 +1,40 @@
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { ListItem } from '@/components/ui/list-item';
import { EmptyState } from '@/components/ui/state-views';
import type { Tag } from '@/core/api/types';
import { firstLine, shortSha } from '@/core/utils/format';
import { flattenPages } from '@/core/utils/infinite';
import { useTags } from '@/features/repository/queries';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Tags'>;
/** Tag list; tapping a tag opens its file tree at that ref. */
export function TagsScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useTags(owner, name);
const tags: Tag[] = flattenPages(query.data);
return (
<QueryList<Tag>
query={query}
items={tags}
keyExtractor={(tag) => tag.name}
renderItem={(tag) => (
<ListItem
leadingIcon="tag"
title={tag.name}
subtitle={firstLine(tag.message)}
meta={tag.commit?.sha ? shortSha(tag.commit.sha) : undefined}
onPress={() => navigation.navigate('Files', { owner, name, ref: tag.name })}
/>
)}
empty={<EmptyState icon="tag" title={t('branches.emptyTags')} />}
/>
);
}