Skip to content

Commit

Permalink
🆕 Add: Example - DebugControls
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Aug 25, 2022
1 parent 19a9763 commit 2e3533d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
44 changes: 44 additions & 0 deletions example/src/examples/DebugControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as React from 'react';

import { useNavigation } from '@react-navigation/native';

import type { SharedExampleProps } from './SharedExampleTypes';

import { ExampleItemCard } from '../components/ExampleItemCard';
import { CardButton } from '../components/Card/CardButton';

import { SHARED_ENV } from '../constants/SharedEnv';


const SCREEN_KEYS = [
'Home',
'Test01'
];


export function DebugControls(props: SharedExampleProps) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const navigation = SHARED_ENV.enableReactNavigation && useNavigation();

const ScreenItems = SCREEN_KEYS.map(key => (
<CardButton
title={`Push: ${key}`}
subtitle={`Navigate to "${key}" screen...'`}
onPress={() => {
// @ts-ignore
navigation.push(key);
}}
/>
));

return (
<ExampleItemCard
style={props.style}
index={props.index}
title={'Debug Controls'}
subtitle={'For testing and stuff'}
>
{ScreenItems}
</ExampleItemCard>
);
};
8 changes: 3 additions & 5 deletions example/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ import PopoverViewExample06 from '../examples/PopoverViewExample06';
import PopoverViewExample07 from '../examples/PopoverViewExample07';
import PopoverViewExample08 from '../examples/PopoverViewExample08';

// TODO:
// import { DebugControls } from '../examples/DebugControls';
// import { SHARED_ENV } from '../constants/SharedEnv';
import { DebugControls } from '../examples/DebugControls';
import { SHARED_ENV } from '../constants/SharedEnv';

type ExampleListItem = {
id: number;
component: React.FC<SharedExampleProps>;
};

const EXAMPLE_COMPONENTS = [
// TODO:
// SHARED_ENV.enableReactNavigation && DebugControls,
SHARED_ENV.enableReactNavigation && DebugControls,
PopoverViewExample01,
PopoverViewExample02,
PopoverViewExample03,
Expand Down

0 comments on commit 2e3533d

Please sign in to comment.