File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
demo-react/src/components Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2+ import { ItemEventData } from '@nativescript/core' ;
23import { 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
425export 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}
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22
3- export function ExampleBottomNavigation ( ) {
3+ export function BottomNavigation ( ) {
44 const [ selectedIndex , setSelectedIndex ] = React . useState ( 0 ) ;
55
66 return (
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22
3- export function ExampleTabs ( ) {
3+ export function Tabs ( ) {
44 const [ selectedIndex , setSelectedIndex ] = React . useState ( 0 ) ;
55
66 return (
You can’t perform that action at this time.
0 commit comments