Skip to content

Commit f620190

Browse files
committed
Working demo app
1 parent b4d350a commit f620190

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
import * as React from 'react';
2+
import { ItemEventData } from '@nativescript/core';
23
import { ListView } from 'react-nativescript';
4+
import { Tabs } from './Tabs';
5+
import { BottomNavigation } from './BottomNavigation';
6+
7+
interface MyItem {
8+
text: string;
9+
component: () => JSX.Element;
10+
}
11+
12+
const items: MyItem[] = [
13+
{
14+
text: 'Tabs',
15+
component: Tabs
16+
},
17+
{
18+
text: 'BottomNavigation',
19+
component: BottomNavigation
20+
}
21+
];
22+
23+
const cellFactory = (item: MyItem) => <label text={item.text} style={{ height: 40, paddingLeft: 16 }} />;
324

425
export function AppContainer() {
26+
const [ExampleComponent, setExampleComponent] = React.useState<() => JSX.Element>(null);
27+
const onItemTap = (args: ItemEventData) => {
28+
setExampleComponent(() => items[args.index].component);
29+
};
30+
531
return (
632
<frame>
733
<page>
8-
<label>Hello</label>
34+
<ListView items={items} cellFactory={cellFactory} onItemTap={onItemTap} />
935
</page>
36+
{ExampleComponent ? (
37+
<page onNavigatedFrom={() => setExampleComponent(null)}>
38+
<ExampleComponent />
39+
</page>
40+
) : null}
1041
</frame>
1142
);
1243
}

demo-react/src/components/BottomNavigationScreen.tsx renamed to demo-react/src/components/BottomNavigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
export function ExampleBottomNavigation() {
3+
export function BottomNavigation() {
44
const [selectedIndex, setSelectedIndex] = React.useState(0);
55

66
return (

demo-react/src/components/TabsScreen.tsx renamed to demo-react/src/components/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
export function ExampleTabs() {
3+
export function Tabs() {
44
const [selectedIndex, setSelectedIndex] = React.useState(0);
55

66
return (

0 commit comments

Comments
 (0)