refactor(router): move screen options from layouts into screen files - #157
Open
fernandatoledo wants to merge 1 commit into
Open
refactor(router): move screen options from layouts into screen files#157fernandatoledo wants to merge 1 commit into
fernandatoledo wants to merge 1 commit into
Conversation
💯 Test Coverage
😎 Tests Results
👀 Tests Details • (57%)
|
There was a problem hiding this comment.
🟡 Changes recommended
It introduces user-facing hardcoded strings that violate the repo i18n convention and likely regresses the root stack header behavior for the (app) tabs screen.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors the Expo Router navigation setup by moving per-screen navigation options (titles, headers, tab icons/testIDs, modal presentation) out of layout files and into the screen components that own those options, keeping layouts focused on shared configuration and route guards.
Changes:
- Simplified
(app)tabs layout to sharedscreenOptions, moving each tab’sTabs.Screenoptions into the corresponding tab screen files. - Moved root stack screen options (e.g., onboarding/sign-in header visibility, update-password title, www modal presentation) into the respective screen files.
- Relocated
CreateNewPostLinkfrom the tabs layout into(app)/index.tsxwhere it’s used.
File summaries
| File | Description |
|---|---|
| src/app/www.tsx | Configures modal presentation/title via Stack.Screen inside the screen component. |
| src/app/update-password.tsx | Sets stack title from translations within the screen. |
| src/app/sign-in.tsx | Disables header via Stack.Screen in the screen file. |
| src/app/onboarding.tsx | Disables header via Stack.Screen in the screen file. |
| src/app/(app)/style.tsx | Adds per-tab Tabs.Screen options (title/icon/testID) in the tab screen. |
| src/app/(app)/settings.tsx | Adds per-tab Tabs.Screen options (title/icon/testID) in the tab screen. |
| src/app/(app)/index.tsx | Adds per-tab Tabs.Screen options and moves the “Create” link into the feed tab screen. |
| src/app/(app)/_layout.tsx | Drops explicit Tabs.Screen entries and returns a shared Tabs config. |
| src/app/_layout.tsx | Keeps guarded stack structure while removing per-screen options from guarded entries. |
Review details
Suppressed comments (1)
src/app/(app)/index.tsx:33
- The "Create" label is hardcoded in JSX, which violates the i18n convention (REVIEW.md:36-40). This should be sourced from translations (add a key in src/translations/en.json and use it here).
<Link href="/feed/add-post" asChild>
<Pressable>
<Text className="px-3 text-primary-300">Create</Text>
</Pressable>
</Link>
- Files reviewed: 9/9 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+14
to
+20
| <Tabs.Screen | ||
| options={{ | ||
| title: 'Feed', | ||
| tabBarIcon: ({ color }) => <FeedIcon color={color} />, | ||
| headerRight: () => <CreateNewPostLink />, | ||
| tabBarButtonTestID: 'feed-tab', | ||
| }} |
Comment on lines
+47
to
+53
| <Tabs.Screen | ||
| options={{ | ||
| title: 'Settings', | ||
| tabBarIcon: ({ color }) => <SettingsIcon color={color} />, | ||
| tabBarButtonTestID: 'settings-tab', | ||
| }} | ||
| /> |
Comment on lines
+14
to
+19
| <Tabs.Screen | ||
| options={{ | ||
| title: 'Style', | ||
| tabBarIcon: ({ color }) => <StyleIcon color={color} />, | ||
| tabBarButtonTestID: 'style-tab', | ||
| }} |
Comment on lines
47
to
50
| <Stack.Protected guard={isAuthenticated}> | ||
| <Stack.Screen name="(app)" options={{ headerShown: false }} /> | ||
| <Stack.Screen | ||
| name="update-password" | ||
| options={{ | ||
| title: t('updatePassword.title'), | ||
| }} | ||
| /> | ||
| <Stack.Screen name="(app)" /> | ||
| <Stack.Screen name="update-password" /> | ||
| </Stack.Protected> |
Comment on lines
18
to
22
| if (url === undefined || typeof url !== 'string') { | ||
| return ( | ||
| <View className="flex-1 items-center justify-center bg-white"> | ||
| <Stack.Screen options={screenOptions} /> | ||
| <Text className="text-lg text-red-500"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira board reference:
What does this do?
Moves per-screen navigation options out of the expo-router layout files and into the screens themselves.
src/app/(app)/_layout.tsxdrops its threeTabs.Screendeclarations and returns<Tabs screenOptions={...} />; each tab now declares its own title, icon andtabBarButtonTestIDviaTabs.Screen. In the root stack, the options foronboarding,sign-in,update-passwordandwwwmoved to those screen files.CreateNewPostLinkmoved from the tabs layout to(app)/index.tsx, the only place it is used, andwww.tsxno longer needs auseEffectwithnavigation.setOptionsbecause the modal presentation and title come from a singleStack.Screen.Why did you do this?
Declaring every screen in its layout means each new route has to be registered in two places. With the options living next to the screen they describe, adding a route is just adding a file, and the layout only carries what is genuinely shared.
src/app/feed/already followed this pattern, so this brings the rest of the app in line.Who/what does this impact?
src/app/_layout.tsx,src/app/(app)/_layout.tsx, the three tab screens, andonboarding,sign-in,update-password,www.Tabs.Screenentries in the layout, expo-router orders tabs by filesystem: Feed, Settings, Style — previously Feed, Style, Settings. This is inherent to the pattern; pinning the order would mean putting the declarations back.How did you test this?
Ran
pnpm type-check,pnpm lintandpnpm test:ci— all pass (139 tests). Not yet exercised on a device: tab order, a possible header flash on the screens that setheaderShown: falsefrom the screen file, and thewwwmodal presentation all need a real run.Notes:
Stack.Screenentries insrc/app/_layout.tsxare kept, but stripped of theiroptions. They are the children ofStack.Protectedand removing them would delete the onboarding/auth guards. The ticket predatesStack.Protected, so this is the one part that cannot be applied literally.sign-upandforgot-passworddid not get exampleoptions: they currently have none, and adding atitlewould mean hardcoding a string, whichAGENTS.mdforbids. Happy to add translation keys for them if wanted.Screenshots / Previews