Skip to content

Commit

Permalink
add more devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbrwstr committed Jun 3, 2024
1 parent 5d65713 commit 43330c9
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 28 deletions.
3 changes: 3 additions & 0 deletions apps/tlon-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"@10play/tentap-editor": "^0.4.55",
"@aws-sdk/client-s3": "^3.190.0",
"@aws-sdk/s3-request-presigner": "^3.190.0",
"@dev-plugins/async-storage": "^0.0.3",
"@dev-plugins/react-navigation": "^0.0.6",
"@dev-plugins/react-query": "^0.0.6",
"@google-cloud/recaptcha-enterprise-react-native": "^18.3.0",
"@gorhom/bottom-sheet": "^4.5.1",
"@op-engineering/op-sqlite": "5.0.5",
Expand Down
35 changes: 33 additions & 2 deletions apps/tlon-mobile/src/App.main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { useAsyncStorageDevTools } from '@dev-plugins/async-storage';
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation';
import { useReactQueryDevTools } from '@dev-plugins/react-query';
import NetInfo from '@react-native-community/netinfo';
import {
DarkTheme,
DefaultTheme,
NavigationContainer,
NavigationContainerRefWithCurrent,
useNavigationContainerRef,
} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { QueryClientProvider, queryClient } from '@tloncorp/shared/dist/api';
import { TamaguiProvider } from '@tloncorp/ui';
import { PostHogProvider } from 'posthog-react-native';
import type { PropsWithChildren } from 'react';
Expand Down Expand Up @@ -197,20 +203,32 @@ function MigrationCheck({ children }: PropsWithChildren) {
export default function ConnectedApp(props: Props) {
const isDarkMode = useIsDarkMode();
const tailwind = useTailwind();
const navigationContainerRef = useNavigationContainerRef();

return (
<TamaguiProvider
defaultTheme={isDarkMode ? 'dark' : 'light'}
config={tamaguiConfig}
>
<ShipProvider>
<NavigationContainer theme={isDarkMode ? DarkTheme : DefaultTheme}>
<NavigationContainer
theme={isDarkMode ? DarkTheme : DefaultTheme}
ref={navigationContainerRef}
>
<BranchProvider>
<PostHogProvider client={posthogAsync} autocapture>
<GestureHandlerRootView style={tailwind('flex-1')}>
<SafeAreaProvider>
<MigrationCheck>
<App {...props} />
<QueryClientProvider client={queryClient}>
<App {...props} />

{__DEV__ && (
<DevTools
navigationContainerRef={navigationContainerRef}
/>
)}
</QueryClientProvider>
</MigrationCheck>
</SafeAreaProvider>
</GestureHandlerRootView>
Expand All @@ -221,3 +239,16 @@ export default function ConnectedApp(props: Props) {
</TamaguiProvider>
);
}

// This is rendered as a component because I didn't have any better ideas
// on calling these hooks conditionally.
const DevTools = ({
navigationContainerRef,
}: {
navigationContainerRef: NavigationContainerRefWithCurrent<any>;
}) => {
useAsyncStorageDevTools();
useReactQueryDevTools(queryClient);
useReactNavigationDevTools(navigationContainerRef);
return null;
};
116 changes: 90 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 43330c9

Please sign in to comment.