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,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 },
|
||||
});
|
||||
Reference in new issue
Block a user