Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default function TabLayout() {
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
headerShown: false,
tabBarButton: HapticTab,
}}>
}}
>
<Tabs.Screen
name="index"
options={{
Expand Down
27 changes: 13 additions & 14 deletions app/(tabs)/explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@ export default function TabTwoScreen() {
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{' '}
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 file in <ThemedText type="defaultSemiBold">app/(tabs)/_layout.tsx</ThemedText>{' '}
sets up the tab navigator.
The layout file in <ThemedText type="defaultSemiBold">app/(tabs)/_layout.tsx</ThemedText> sets up the tab
navigator.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/router/introduction">
<ThemedText type="link">Learn more</ThemedText>
Expand All @@ -54,8 +55,7 @@ export default function TabTwoScreen() {
<Collapsible title="Images">
<ThemedText>
For static images, you can use the <ThemedText type="defaultSemiBold">@2x</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">@3x</ThemedText> suffixes to provide files for
different screen densities
<ThemedText type="defaultSemiBold">@3x</ThemedText> suffixes to provide files for different screen densities
</ThemedText>
<Image
source={require('@/assets/images/react-logo.png')}
Expand All @@ -68,8 +68,8 @@ export default function TabTwoScreen() {
<Collapsible title="Light and dark mode components">
<ThemedText>
This template has light and dark mode support. The{' '}
<ThemedText type="defaultSemiBold">useColorScheme()</ThemedText> hook lets you inspect
what the user&apos;s current color scheme is, and so you can adjust UI colors accordingly.
<ThemedText type="defaultSemiBold">useColorScheme()</ThemedText> hook lets you inspect what the user&apos;s
current color scheme is, and so you can adjust UI colors accordingly.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/develop/user-interface/color-themes/">
<ThemedText type="link">Learn more</ThemedText>
Expand All @@ -78,8 +78,7 @@ export default function TabTwoScreen() {
<Collapsible title="Animations">
<ThemedText>
This template includes an example of an animated component. The{' '}
<ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses
the powerful{' '}
<ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses the powerful{' '}
<ThemedText type="defaultSemiBold" style={{ fontFamily: Fonts.mono }}>
react-native-reanimated
</ThemedText>{' '}
Expand All @@ -88,8 +87,8 @@ export default function TabTwoScreen() {
{Platform.select({
ios: (
<ThemedText>
The <ThemedText type="defaultSemiBold">components/ParallaxScrollView.tsx</ThemedText>{' '}
component provides a parallax effect for the header image.
The <ThemedText type="defaultSemiBold">components/ParallaxScrollView.tsx</ThemedText> component provides a
parallax effect for the header image.
</ThemedText>
),
})}
Expand Down
28 changes: 6 additions & 22 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ export default function HomeScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }}
headerImage={
<Image
source={require('@/assets/images/partial-react-logo.png')}
style={styles.reactLogo}
/>
}>
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{' '}
Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes. Press{' '}
<ThemedText type="defaultSemiBold">
{Platform.select({
ios: 'cmd + d',
Expand All @@ -44,25 +39,14 @@ export default function HomeScreen() {
<Link.Preview />
<Link.Menu>
<Link.MenuAction title="Action" icon="cube" onPress={() => alert('Action pressed')} />
<Link.MenuAction
title="Share"
icon="square.and.arrow.up"
onPress={() => alert('Share pressed')}
/>
<Link.MenuAction title="Share" icon="square.and.arrow.up" onPress={() => alert('Share pressed')} />
<Link.Menu title="More" icon="ellipsis">
<Link.MenuAction
title="Delete"
icon="trash"
destructive
onPress={() => alert('Delete pressed')}
/>
<Link.MenuAction title="Delete" icon="trash" destructive onPress={() => alert('Delete pressed')} />
</Link.Menu>
</Link.Menu>
</Link>

<ThemedText>
{`Tap the Explore tab to learn more about what's included in this starter app.`}
</ThemedText>
<ThemedText>{`Tap the Explore tab to learn more about what's included in this starter app.`}</ThemedText>
</ThemedView>
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Step 3: Get a fresh start</ThemedText>
Expand Down
3 changes: 2 additions & 1 deletion components/hello-wave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function HelloWave() {
},
animationIterationCount: 4,
animationDuration: '300ms',
}}>
}}
>
πŸ‘‹
</Animated.Text>
);
Expand Down
27 changes: 6 additions & 21 deletions components/parallax-scroll-view.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type { PropsWithChildren, ReactElement } from 'react';
import { StyleSheet } from 'react-native';
import Animated, {
interpolate,
useAnimatedRef,
useAnimatedStyle,
useScrollOffset,
} from 'react-native-reanimated';
import Animated, { interpolate, useAnimatedRef, useAnimatedStyle, useScrollOffset } from 'react-native-reanimated';

import { ThemedView } from '@/components/themed-view';
import { useColorScheme } from '@/hooks/use-color-scheme';
Expand All @@ -18,11 +13,7 @@ type Props = PropsWithChildren<{
headerBackgroundColor: { dark: string; light: string };
}>;

export default function ParallaxScrollView({
children,
headerImage,
headerBackgroundColor,
}: Props) {
export default function ParallaxScrollView({ children, headerImage, headerBackgroundColor }: Props) {
const backgroundColor = useThemeColor({}, 'background');
const colorScheme = useColorScheme() ?? 'light';
const scrollRef = useAnimatedRef<Animated.ScrollView>();
Expand All @@ -34,7 +25,7 @@ export default function ParallaxScrollView({
translateY: interpolate(
scrollOffset.value,
[-HEADER_HEIGHT, 0, HEADER_HEIGHT],
[-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75]
[-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75],
),
},
{
Expand All @@ -45,16 +36,10 @@ export default function ParallaxScrollView({
});

return (
<Animated.ScrollView
ref={scrollRef}
style={{ backgroundColor, flex: 1 }}
scrollEventThrottle={16}>
<Animated.ScrollView ref={scrollRef} style={{ backgroundColor, flex: 1 }} scrollEventThrottle={16}>
<Animated.View
style={[
styles.header,
{ backgroundColor: headerBackgroundColor[colorScheme] },
headerAnimatedStyle,
]}>
style={[styles.header, { backgroundColor: headerBackgroundColor[colorScheme] }, headerAnimatedStyle]}
>
{headerImage}
</Animated.View>
<ThemedView style={styles.content}>{children}</ThemedView>
Expand Down
8 changes: 1 addition & 7 deletions components/themed-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ export type ThemedTextProps = TextProps & {
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
};

export function ThemedText({
style,
lightColor,
darkColor,
type = 'default',
...rest
}: ThemedTextProps) {
export function ThemedText({ style, lightColor, darkColor, type = 'default', ...rest }: ThemedTextProps) {
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');

return (
Expand Down
5 changes: 1 addition & 4 deletions components/ui/collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export function Collapsible({ children, title }: PropsWithChildren & { title: st

return (
<ThemedView>
<TouchableOpacity
style={styles.heading}
onPress={() => setIsOpen((value) => !value)}
activeOpacity={0.8}>
<TouchableOpacity style={styles.heading} onPress={() => setIsOpen((value) => !value)} activeOpacity={0.8}>
<IconSymbol
name="chevron.right"
size={18}
Expand Down
2 changes: 1 addition & 1 deletion hooks/use-theme-color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useColorScheme } from '@/hooks/use-color-scheme';

export function useThemeColor(
props: { light?: string; dark?: string },
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
colorName: keyof typeof Colors.light & keyof typeof Colors.dark,
) {
const theme = useColorScheme() ?? 'light';
const colorFromProps = props[theme];
Expand Down
53 changes: 24 additions & 29 deletions scripts/reset-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* You can remove the `reset-project` script from package.json and safely delete this file after running it.
*/

const fs = require("fs");
const path = require("path");
const readline = require("readline");
const fs = require('fs');
const path = require('path');
const readline = require('readline');

const root = process.cwd();
const oldDirs = ["app", "components", "hooks", "constants", "scripts"];
const exampleDir = "app-example";
const newAppDir = "app";
const oldDirs = ['app', 'components', 'hooks', 'constants', 'scripts'];
const exampleDir = 'app-example';
const newAppDir = 'app';
const exampleDirPath = path.join(root, exampleDir);

const indexContent = `import { Text, View } from "react-native";
Expand Down Expand Up @@ -47,7 +47,7 @@ const rl = readline.createInterface({

const moveDirectories = async (userInput) => {
try {
if (userInput === "y") {
if (userInput === 'y') {
// Create the app-example directory
await fs.promises.mkdir(exampleDirPath, { recursive: true });
console.log(`πŸ“ /${exampleDir} directory created.`);
Expand All @@ -57,7 +57,7 @@ const moveDirectories = async (userInput) => {
for (const dir of oldDirs) {
const oldDirPath = path.join(root, dir);
if (fs.existsSync(oldDirPath)) {
if (userInput === "y") {
if (userInput === 'y') {
const newDirPath = path.join(root, exampleDir, dir);
await fs.promises.rename(oldDirPath, newDirPath);
console.log(`➑️ /${dir} moved to /${exampleDir}/${dir}.`);
Expand All @@ -73,40 +73,35 @@ const moveDirectories = async (userInput) => {
// Create new /app directory
const newAppDirPath = path.join(root, newAppDir);
await fs.promises.mkdir(newAppDirPath, { recursive: true });
console.log("\nπŸ“ New /app directory created.");
console.log('\nπŸ“ New /app directory created.');

// Create index.tsx
const indexPath = path.join(newAppDirPath, "index.tsx");
const indexPath = path.join(newAppDirPath, 'index.tsx');
await fs.promises.writeFile(indexPath, indexContent);
console.log("πŸ“„ app/index.tsx created.");
console.log('πŸ“„ app/index.tsx created.');

// Create _layout.tsx
const layoutPath = path.join(newAppDirPath, "_layout.tsx");
const layoutPath = path.join(newAppDirPath, '_layout.tsx');
await fs.promises.writeFile(layoutPath, layoutContent);
console.log("πŸ“„ app/_layout.tsx created.");
console.log('πŸ“„ app/_layout.tsx created.');

console.log("\nβœ… Project reset complete. Next steps:");
console.log('\nβœ… Project reset complete. Next steps:');
console.log(
`1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${
userInput === "y"
? `\n3. Delete the /${exampleDir} directory when you're done referencing it.`
: ""
}`
userInput === 'y' ? `\n3. Delete the /${exampleDir} directory when you're done referencing it.` : ''
}`,
);
} catch (error) {
console.error(`❌ Error during script execution: ${error.message}`);
}
};

rl.question(
"Do you want to move existing files to /app-example instead of deleting them? (Y/n): ",
(answer) => {
const userInput = answer.trim().toLowerCase() || "y";
if (userInput === "y" || userInput === "n") {
moveDirectories(userInput).finally(() => rl.close());
} else {
console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
rl.close();
}
rl.question('Do you want to move existing files to /app-example instead of deleting them? (Y/n): ', (answer) => {
const userInput = answer.trim().toLowerCase() || 'y';
if (userInput === 'y' || userInput === 'n') {
moveDirectories(userInput).finally(() => rl.close());
} else {
console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
rl.close();
}
);
});
Loading