Function bodies 50 total
required function · typescript · L9-L15 (7 LOC)app.config.ts
function required(key: string): string {
const value = process.env[key];
if (!value) {
throw new Error(`Missing required env var: ${key} (see .env.example)`);
}
return value;
}optional function · typescript · L17-L19 (3 LOC)app.config.ts
function optional(key: string, fallback = ''): string {
return process.env[key] ?? fallback;
}RootLayout function · typescript · L12-L24 (13 LOC)app/_layout.tsx
export default function RootLayout() {
const colorScheme = useColorScheme();
return (
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
);
}ModalScreen function · typescript · L7-L16 (10 LOC)app/modal.tsx
export default function ModalScreen() {
return (
<ThemedView style={styles.container}>
<ThemedText type="title">This is a modal</ThemedText>
<Link href="/" dismissTo style={styles.link}>
<ThemedText type="link">Go to home screen</ThemedText>
</Link>
</ThemedView>
);
}TabTwoScreen function · typescript · L12-L99 (88 LOC)app/(tabs)/explore.tsx
export default function TabTwoScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#D0D0D0', dark: '#353636' }}
headerImage={
<IconSymbol
size={310}
color="#808080"
name="chevron.left.forwardslash.chevron.right"
style={styles.headerImage}
/>
}>
<ThemedView style={styles.titleContainer}>
<ThemedText
type="title"
style={{
fontFamily: Fonts.rounded,
}}>
Explore
</ThemedText>
</ThemedView>
<ThemedText>This app includes example code to help you get started.</ThemedText>
<Collapsible title="File-based routing">
<ThemedText>
This app has two screens:{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/explore.tsx</ThemedText>
</ThemedText>
<ThemedText>
The layout fiHomeScreen function · typescript · L10-L79 (70 LOC)app/(tabs)/index.tsx
export default function HomeScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }}
headerImage={
<Image
source={require('@/assets/images/partial-react-logo.png')}
style={styles.reactLogo}
/>
}>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Welcome!</ThemedText>
<HelloWave />
</ThemedView>
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Step 1: Try it</ThemedText>
<ThemedText>
Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes.
Press{' '}
<ThemedText type="defaultSemiBold">
{Platform.select({
ios: 'cmd + d',
android: 'cmd + m',
web: 'F12',
})}
</ThemedText>{' '}
to open developer tools.
</ThemedText>
</ThemedView>
<TheTabLayout function · typescript · L9-L35 (27 LOC)app/(tabs)/_layout.tsx
export default function TabLayout() {
const colorScheme = useColorScheme();
return (
<Tabs
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
headerShown: false,
tabBarButton: HapticTab,
}}>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
}}
/>
<Tabs.Screen
name="explore"
options={{
title: 'Explore',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
}}
/>
</Tabs>
);
}Repobility · code-quality intelligence platform · https://repobility.com
ExternalLink function · typescript · L7-L25 (19 LOC)components/external-link.tsx
export function ExternalLink({ href, ...rest }: Props) {
return (
<Link
target="_blank"
{...rest}
href={href}
onPress={async (event) => {
if (process.env.EXPO_OS !== 'web') {
// Prevent the default behavior of linking to the default browser on native.
event.preventDefault();
// Open the link in an in-app browser.
await openBrowserAsync(href, {
presentationStyle: WebBrowserPresentationStyle.AUTOMATIC,
});
}
}}
/>
);
}HapticTab function · typescript · L5-L18 (14 LOC)components/haptic-tab.tsx
export function HapticTab(props: BottomTabBarButtonProps) {
return (
<PlatformPressable
{...props}
onPressIn={(ev) => {
if (process.env.EXPO_OS === 'ios') {
// Add a soft haptic feedback when pressing down on the tabs.
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
}
props.onPressIn?.(ev);
}}
/>
);
}HelloWave function · typescript · L3-L19 (17 LOC)components/hello-wave.tsx
export function HelloWave() {
return (
<Animated.Text
style={{
fontSize: 28,
lineHeight: 32,
marginTop: -6,
animationName: {
'50%': { transform: [{ rotate: '25deg' }] },
},
animationIterationCount: 4,
animationDuration: '300ms',
}}>
👋
</Animated.Text>
);
}ParallaxScrollView function · typescript · L21-L63 (43 LOC)components/parallax-scroll-view.tsx
export default function ParallaxScrollView({
children,
headerImage,
headerBackgroundColor,
}: Props) {
const backgroundColor = useThemeColor({}, 'background');
const colorScheme = useColorScheme() ?? 'light';
const scrollRef = useAnimatedRef<Animated.ScrollView>();
const scrollOffset = useScrollOffset(scrollRef);
const headerAnimatedStyle = useAnimatedStyle(() => {
return {
transform: [
{
translateY: interpolate(
scrollOffset.value,
[-HEADER_HEIGHT, 0, HEADER_HEIGHT],
[-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75]
),
},
{
scale: interpolate(scrollOffset.value, [-HEADER_HEIGHT, 0, HEADER_HEIGHT], [2, 1, 1]),
},
],
};
});
return (
<Animated.ScrollView
ref={scrollRef}
style={{ backgroundColor, flex: 1 }}
scrollEventThrottle={16}>
<Animated.View
style={[
styles.header,
{ backgroundColor: headerBackgThemedText function · typescript · L11-L34 (24 LOC)components/themed-text.tsx
export function ThemedText({
style,
lightColor,
darkColor,
type = 'default',
...rest
}: ThemedTextProps) {
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
return (
<Text
style={[
{ color },
type === 'default' ? styles.default : undefined,
type === 'title' ? styles.title : undefined,
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
type === 'subtitle' ? styles.subtitle : undefined,
type === 'link' ? styles.link : undefined,
style,
]}
{...rest}
/>
);
}ThemedView function · typescript · L10-L14 (5 LOC)components/themed-view.tsx
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
}Collapsible function · typescript · L10-L33 (24 LOC)components/ui/collapsible.tsx
export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
const [isOpen, setIsOpen] = useState(false);
const theme = useColorScheme() ?? 'light';
return (
<ThemedView>
<TouchableOpacity
style={styles.heading}
onPress={() => setIsOpen((value) => !value)}
activeOpacity={0.8}>
<IconSymbol
name="chevron.right"
size={18}
weight="medium"
color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
/>
<ThemedText type="defaultSemiBold">{title}</ThemedText>
</TouchableOpacity>
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
</ThemedView>
);
}IconSymbol function · typescript · L4-L32 (29 LOC)components/ui/icon-symbol.ios.tsx
export function IconSymbol({
name,
size = 24,
color,
style,
weight = 'regular',
}: {
name: SymbolViewProps['name'];
size?: number;
color: string;
style?: StyleProp<ViewStyle>;
weight?: SymbolWeight;
}) {
return (
<SymbolView
weight={weight}
tintColor={color}
resizeMode="scaleAspectFit"
name={name}
style={[
{
width: size,
height: size,
},
style,
]}
/>
);
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
IconSymbol function · typescript · L28-L41 (14 LOC)components/ui/icon-symbol.tsx
export function IconSymbol({
name,
size = 24,
color,
style,
}: {
name: IconSymbolName;
size?: number;
color: string | OpaqueColorValue;
style?: StyleProp<TextStyle>;
weight?: SymbolWeight;
}) {
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
}useColorScheme function · typescript · L7-L21 (15 LOC)hooks/use-color-scheme.web.ts
export function useColorScheme() {
const [hasHydrated, setHasHydrated] = useState(false);
useEffect(() => {
setHasHydrated(true);
}, []);
const colorScheme = useRNColorScheme();
if (hasHydrated) {
return colorScheme;
}
return 'light';
}useThemeColor function · typescript · L9-L21 (13 LOC)hooks/use-theme-color.ts
export function useThemeColor(
props: { light?: string; dark?: string },
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
) {
const theme = useColorScheme() ?? 'light';
const colorFromProps = props[theme];
if (colorFromProps) {
return colorFromProps;
} else {
return Colors[theme][colorName];
}
}Index function · javascript · L21-L33 (13 LOC)scripts/reset-project.js
export default function Index() {
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text>Edit app/index.tsx to edit this screen.</Text>
</View>
);
}RootLayout function · javascript · L38-L40 (3 LOC)scripts/reset-project.js
export default function RootLayout() {
return <Stack />;
}useTranslation function · typescript · L120-L125 (6 LOC)src/core/i18n/i18n.ts
export function useTranslation() {
const lang = useI18nStore((s) => s.lang);
const setLang = useI18nStore((s) => s.setLang);
const t = (key: TranslationKey) => dictionaries[lang][key] ?? baseEn[key] ?? key;
return { t, lang, setLang };
}setLang function · typescript · L127-L129 (3 LOC)src/core/i18n/i18n.ts
export function setLang(lang: Lang) {
useI18nStore.getState().setLang(lang);
}getLang function · typescript · L131-L133 (3 LOC)src/core/i18n/i18n.ts
export function getLang(): Lang {
return useI18nStore.getState().lang;
}Repobility · MCP-ready · https://repobility.com
tAll function · typescript · L135-L138 (4 LOC)src/core/i18n/i18n.ts
export function tAll() {
const lang = useI18nStore.getState().lang;
return { ...baseEn, ...dictionaries[lang] };
}t function · typescript · L140-L143 (4 LOC)src/core/i18n/i18n.ts
export function t(key: TranslationKey) {
const lang = useI18nStore.getState().lang;
return dictionaries[lang][key] ?? baseEn[key] ?? key;
}getExtraValues function · typescript · L18-L22 (5 LOC)src/services/adService.ts
function getExtraValues(): ExtraValues {
const expoConfig = Constants.expoConfig ?? Constants.manifest;
const extra = (expoConfig as any)?.extra ?? {};
return extra as ExtraValues;
}getExtraValue function · typescript · L24-L26 (3 LOC)src/services/adService.ts
function getExtraValue(key: string) {
return getExtraValues()?.[key];
}normalizeToken function · typescript · L28-L30 (3 LOC)src/services/adService.ts
function normalizeToken(value: string): string {
return value.trim().toUpperCase().replace(/-/g, '_');
}parseConsentDebugGeography function · typescript · L32-L51 (20 LOC)src/services/adService.ts
export function parseConsentDebugGeography(value: unknown): AdsConsentDebugGeography | undefined {
if (typeof value !== 'string') return undefined;
const normalized = normalizeToken(value);
if (!normalized) return undefined;
switch (normalized) {
case 'DISABLED':
return AdsConsentDebugGeography.DISABLED;
case 'EEA':
return AdsConsentDebugGeography.EEA;
case 'NOT_EEA':
return AdsConsentDebugGeography.NOT_EEA;
case 'REGULATED_US_STATE':
return AdsConsentDebugGeography.REGULATED_US_STATE;
case 'OTHER':
return AdsConsentDebugGeography.OTHER;
default:
return undefined;
}
}parseConsentTestDeviceIdentifiers function · typescript · L53-L64 (12 LOC)src/services/adService.ts
export function parseConsentTestDeviceIdentifiers(value: unknown): string[] | undefined {
if (typeof value !== 'string') return undefined;
const ids = Array.from(
new Set(
value
.split(',')
.map((item) => item.trim())
.filter(Boolean),
),
);
return ids.length > 0 ? ids : undefined;
}buildAdsConsentInfoOptions function · typescript · L66-L84 (19 LOC)src/services/adService.ts
export function buildAdsConsentInfoOptions(
extraValues: ExtraValues = getExtraValues(),
): AdsConsentInfoOptions {
const options: AdsConsentInfoOptions = {};
const debugGeography = parseConsentDebugGeography(extraValues.ADMOB_CONSENT_DEBUG_GEOGRAPHY);
if (debugGeography !== undefined) {
options.debugGeography = debugGeography;
}
const testDeviceIdentifiers = parseConsentTestDeviceIdentifiers(
extraValues.ADMOB_CONSENT_TEST_DEVICE_IDS,
);
if (testDeviceIdentifiers) {
options.testDeviceIdentifiers = testDeviceIdentifiers;
}
return options;
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
canRequestAdsAfterConsent function · typescript · L86-L102 (17 LOC)src/services/adService.ts
async function canRequestAdsAfterConsent(): Promise<boolean> {
try {
const consentInfo = await AdsConsent.gatherConsent(buildAdsConsentInfoOptions());
if (consentInfo.canRequestAds) return true;
} catch {
// If UMP fails transiently, fall back to last known consent state.
}
try {
const consentInfo = await AdsConsent.getConsentInfo();
if (consentInfo.canRequestAds) return true;
} catch {
// Ignore and fall through.
}
return __DEV__;
}getBannerUnitId function · typescript · L104-L113 (10 LOC)src/services/adService.ts
export function getBannerUnitId(): string | null {
if (!isNative) return null;
if (__DEV__) return TestIds.ADAPTIVE_BANNER;
const key = Platform.OS === 'android' ? 'ADMOB_ANDROID_BANNER_ID' : 'ADMOB_IOS_BANNER_ID';
const value = getExtraValue(key);
if (!value || typeof value !== 'string') return null;
if (!value.trim()) return null;
return value;
}initializeAds function · typescript · L115-L130 (16 LOC)src/services/adService.ts
export async function initializeAds(): Promise<boolean> {
if (!isNative) return false;
if (initialized) return true;
const canRequestAds = await canRequestAdsAfterConsent();
if (!canRequestAds) return false;
mobileAds().setRequestConfiguration({
tagForChildDirectedTreatment: false,
maxAdContentRating: MaxAdContentRating.G,
});
await mobileAds().initialize();
initialized = true;
return true;
}showAdPrivacyOptionsForm function · typescript · L132-L145 (14 LOC)src/services/adService.ts
export async function showAdPrivacyOptionsForm(): Promise<boolean> {
if (!isNative) return false;
const consentInfo = await AdsConsent.getConsentInfo();
if (
consentInfo.privacyOptionsRequirementStatus !==
AdsConsentPrivacyOptionsRequirementStatus.REQUIRED
) {
return false;
}
await AdsConsent.showPrivacyOptionsForm();
return true;
}getExtraValue function · typescript · L9-L13 (5 LOC)src/services/legalService.ts
function getExtraValue(key: string): string {
const expoConfig = Constants.expoConfig ?? Constants.manifest;
const extra = (expoConfig as any)?.extra ?? {};
return (extra?.[key] as string) ?? '';
}getLegalLinks function · typescript · L15-L20 (6 LOC)src/services/legalService.ts
export function getLegalLinks(): LegalLinks {
return {
privacyUrl: getExtraValue('LEGAL_PRIVACY_URL') || 'https://example.com/privacy',
termsUrl: getExtraValue('LEGAL_TERMS_URL') || 'https://example.com/terms',
};
}openExternalLink function · typescript · L22-L27 (6 LOC)src/services/legalService.ts
export async function openExternalLink(url: string): Promise<void> {
const supported = await Linking.canOpenURL(url);
if (supported) {
await Linking.openURL(url);
}
}getExtraValue function · typescript · L36-L40 (5 LOC)src/services/proService.ts
function getExtraValue(key: string) {
const expoConfig = Constants.expoConfig ?? Constants.manifest;
const extra = (expoConfig as any)?.extra ?? {};
return extra?.[key];
}Repobility · code-quality intelligence platform · https://repobility.com
getApiKey function · typescript · L42-L50 (9 LOC)src/services/proService.ts
function getApiKey(): string | null {
if (Platform.OS === 'ios') {
return getExtraValue('REVENUECAT_IOS_API_KEY') ?? null;
}
if (Platform.OS === 'android') {
return getExtraValue('REVENUECAT_ANDROID_API_KEY') ?? null;
}
return null;
}saveState function · typescript · L52-L54 (3 LOC)src/services/proService.ts
async function saveState(state: ProState) {
await SecureStore.setItemAsync(PRO_STATE_KEY, JSON.stringify(state));
}toProState function · typescript · L56-L66 (11 LOC)src/services/proService.ts
function toProState(info: CustomerInfo): ProState {
const isPro = Boolean(info.entitlements.active[ENTITLEMENT_ID]);
return {
isPro,
anonUserId: info.originalAppUserId ?? null,
lastCheckAt: new Date().toISOString(),
planType: null,
expirationDate: null,
managementURL: info.managementURL ?? null,
};
}ensureConfigured function · typescript · L68-L86 (19 LOC)src/services/proService.ts
async function ensureConfigured() {
if (!isNative) return;
if (configured) return;
const apiKey = getApiKey();
if (IAP_DEBUG) {
console.log('[RC] platform=', Platform.OS, 'apiKey exists=', Boolean(apiKey), 'len=', apiKey?.length ?? 0);
}
if (!apiKey) {
throw new Error('RevenueCat API key is missing.');
}
Purchases.setLogLevel(LOG_LEVEL.DEBUG);
await Purchases.configure({ apiKey });
if (IAP_DEBUG) {
console.log('[RC] configured');
}
configured = true;
}getCurrentOffering function · typescript · L88-L103 (16 LOC)src/services/proService.ts
async function getCurrentOffering(): Promise<PurchasesOffering | null> {
await ensureConfigured();
if (!isNative) return null;
const offerings = await Purchases.getOfferings();
if (IAP_DEBUG) {
const currentId = offerings.current?.identifier ?? 'null';
const packages = offerings.current?.availablePackages?.map((p) => ({
id: p.identifier,
type: p.packageType,
productId: p.product.identifier,
}));
console.log('[RC] offerings.current=', currentId);
console.log('[RC] availablePackages=', packages ?? []);
}
return offerings.current ?? null;
}findPackage function · typescript · L105-L108 (4 LOC)src/services/proService.ts
function findPackage(offering: PurchasesOffering | null, plan: PlanType): PurchasesPackage | null {
if (!offering) return null;
return plan === 'monthly' ? offering.monthly : offering.annual;
}toPriceDetail function · typescript · L110-L121 (12 LOC)src/services/proService.ts
function toPriceDetail(product?: PurchasesStoreProduct | null): PriceDetail | null {
if (!product) return null;
return {
title: product.title,
priceString: product.priceString,
price: product.price,
currencyCode: product.currencyCode,
pricePerMonth: product.pricePerMonth ?? null,
pricePerMonthString: product.pricePerMonthString ?? null,
subscriptionPeriod: product.subscriptionPeriod ?? null,
};
}getPriceDetails function · typescript · L123-L130 (8 LOC)src/services/proService.ts
async function getPriceDetails(): Promise<PriceDetails | null> {
const offering = await getCurrentOffering();
if (!offering) return null;
return {
monthly: toPriceDetail(offering.monthly?.product ?? null) ?? undefined,
yearly: toPriceDetail(offering.annual?.product ?? null) ?? undefined,
};
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
loadState function · typescript · L12-L20 (9 LOC)src/services/reviewService.ts
async function loadState(): Promise<ReviewState> {
try {
const raw = await SecureStore.getItemAsync(REVIEW_STATE_KEY);
if (raw) return JSON.parse(raw) as ReviewState;
} catch {
// ignore
}
return { lastPromptedAt: null, promptCount: 0 };
}saveState function · typescript · L22-L24 (3 LOC)src/services/reviewService.ts
async function saveState(state: ReviewState): Promise<void> {
await SecureStore.setItemAsync(REVIEW_STATE_KEY, JSON.stringify(state));
}maybeRequestReview function · typescript · L35-L59 (25 LOC)src/services/reviewService.ts
export async function maybeRequestReview(): Promise<boolean> {
if (Platform.OS === 'web') return false;
const isAvailable = await StoreReview.isAvailableAsync();
if (!isAvailable) return false;
const state = await loadState();
if (state.promptCount >= 3) return false;
if (state.lastPromptedAt) {
const daysSince =
(Date.now() - new Date(state.lastPromptedAt).getTime()) / (1000 * 60 * 60 * 24);
if (daysSince < 90) return false;
}
await StoreReview.requestReview();
await saveState({
lastPromptedAt: new Date().toISOString(),
promptCount: state.promptCount + 1,
});
return true;
}