From 7ebf1ed3710081f27f90eaae125c7315798d56e5 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Oct 2023 19:06:28 +0100 Subject: [PATCH] Initialize screen modules lazily (#1763) * Initialize screen modules lazily * Use getComponent (thanks @ecreeth for the tip) --- src/Navigation.tsx | 85 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 86c097ce..52235ad7 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -92,42 +92,42 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) { <> NotFoundScreen} options={{title: title('Not Found')}} /> ModerationScreen} options={{title: title('Moderation')}} /> ModerationMuteListsScreen} options={{title: title('Mute Lists')}} /> ModerationMutedAccounts} options={{title: title('Muted Accounts')}} /> ModerationBlockedAccounts} options={{title: title('Blocked Accounts')}} /> SettingsScreen} options={{title: title('Settings')}} /> LanguageSettingsScreen} options={{title: title('Language Settings')}} /> ProfileScreen} options={({route}) => ({ title: title(`@${route.params.name}`), animation: 'none', @@ -135,101 +135,101 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) { /> ProfileFollowersScreen} options={({route}) => ({ title: title(`People following @${route.params.name}`), })} /> ProfileFollowsScreen} options={({route}) => ({ title: title(`People followed by @${route.params.name}`), })} /> ProfileListScreen} options={{title: title('Mute List')}} /> PostThreadScreen} options={({route}) => ({title: title(`Post by @${route.params.name}`)})} /> PostLikedByScreen} options={({route}) => ({title: title(`Post by @${route.params.name}`)})} /> PostRepostedByScreen} options={({route}) => ({title: title(`Post by @${route.params.name}`)})} /> CustomFeedScreen} options={{title: title('Feed')}} /> CustomFeedLikedByScreen} options={{title: title('Liked by')}} /> DebugScreen} options={{title: title('Debug')}} /> LogScreen} options={{title: title('Log')}} /> SupportScreen} options={{title: title('Support')}} /> PrivacyPolicyScreen} options={{title: title('Privacy Policy')}} /> TermsOfServiceScreen} options={{title: title('Terms of Service')}} /> CommunityGuidelinesScreen} options={{title: title('Community Guidelines')}} /> CopyrightPolicyScreen} options={{title: title('Copyright Policy')}} /> AppPasswords} options={{title: title('App Passwords')}} /> SavedFeeds} options={{title: title('Edit My Feeds')}} /> PreferencesHomeFeed} options={{title: title('Home Feed Preferences')}} /> PreferencesThreads} options={{title: title('Threads Preferences')}} /> @@ -254,14 +254,17 @@ function TabsNavigator() { backBehavior="initialRoute" screenOptions={{headerShown: false, lazy: true}} tabBar={tabBar}> - - - + HomeTabNavigator} /> + SearchTabNavigator} /> + FeedsTabNavigator} /> NotificationsTabNavigator} + /> + MyProfileTabNavigator} /> - ) } @@ -278,7 +281,7 @@ function HomeTabNavigator() { animationDuration: 250, contentStyle, }}> - + HomeScreen} /> {commonScreens(HomeTab)} ) @@ -295,7 +298,7 @@ function SearchTabNavigator() { animationDuration: 250, contentStyle, }}> - + SearchScreen} /> {commonScreens(SearchTab as typeof HomeTab)} ) @@ -312,7 +315,7 @@ function FeedsTabNavigator() { animationDuration: 250, contentStyle, }}> - + FeedsScreen} /> {commonScreens(FeedsTab as typeof HomeTab)} ) @@ -331,7 +334,7 @@ function NotificationsTabNavigator() { }}> NotificationsScreen} /> {commonScreens(NotificationsTab as typeof HomeTab)} @@ -353,7 +356,7 @@ const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() { ProfileScreen} initialParams={{ name: store.me.did, }} @@ -384,22 +387,22 @@ const FlatNavigator = observer(function FlatNavigatorImpl() { }}> HomeScreen} options={{title: title('Home')}} /> SearchScreen} options={{title: title('Search')}} /> FeedsScreen} options={{title: title('Feeds')}} /> NotificationsScreen} options={{title: title('Notifications')}} /> {commonScreens(Flat as typeof HomeTab, unreadCountLabel)}