- UI kit: button, card, field, avatar, badge, list-item, segmented, skeleton, empty/error/loading state views, icon + icon-button, search bar - layout: Screen, SectionHeader, header buttons, QueryList with pull-to-refresh - git components: repo list item, file rows/breadcrumbs, commit row, issue row, native Markdown renderer, notification row with subject-URL parsing
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import {
|
|
ScrollView,
|
|
StyleSheet,
|
|
View,
|
|
type ScrollViewProps,
|
|
type StyleProp,
|
|
type ViewStyle,
|
|
} from 'react-native';
|
|
|
|
import { useTheme } from '@/theme/theme-provider';
|
|
import { spacing } from '@/theme/tokens';
|
|
|
|
export interface ScreenProps {
|
|
children: ReactNode;
|
|
/** Wrap in a ScrollView (default false — lists bring their own). */
|
|
scroll?: boolean;
|
|
/** Apply horizontal screen padding (default true). */
|
|
padded?: boolean;
|
|
/** Optional pull-to-refresh control forwarded to the ScrollView. */
|
|
refreshControl?: ScrollViewProps['refreshControl'];
|
|
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
/** Base screen container: themed background, consistent padding, optional scroll. */
|
|
export function Screen({
|
|
children,
|
|
scroll = false,
|
|
padded = true,
|
|
refreshControl,
|
|
contentContainerStyle,
|
|
style,
|
|
}: ScreenProps) {
|
|
const { colors } = useTheme();
|
|
const padding = padded ? spacing.lg : 0;
|
|
|
|
if (scroll) {
|
|
return (
|
|
<ScrollView
|
|
style={[styles.flex, { backgroundColor: colors.background }]}
|
|
contentContainerStyle={[
|
|
styles.scrollContent,
|
|
{ padding: padding },
|
|
refreshControl ? null : { flexGrow: 1 },
|
|
contentContainerStyle,
|
|
]}
|
|
refreshControl={refreshControl}
|
|
keyboardShouldPersistTaps="handled"
|
|
>
|
|
{children}
|
|
</ScrollView>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<View style={[styles.flex, { backgroundColor: colors.background, padding }, style]}>{children}</View>
|
|
);
|
|
}
|
|
|
|
/** Standard vertical gap between stacked screen sections. */
|
|
export const SECTION_GAP = spacing.lg;
|
|
|
|
const styles = StyleSheet.create({
|
|
flex: { flex: 1 },
|
|
scrollContent: { gap: spacing.lg },
|
|
});
|