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 1
1
import * as React from 'react' ;
2
+ import { ItemEventData } from '@nativescript/core' ;
2
3
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 } } /> ;
3
24
4
25
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
+
5
31
return (
6
32
< frame >
7
33
< page >
8
- < label > Hello </ label >
34
+ < ListView items = { items } cellFactory = { cellFactory } onItemTap = { onItemTap } / >
9
35
</ page >
36
+ { ExampleComponent ? (
37
+ < page onNavigatedFrom = { ( ) => setExampleComponent ( null ) } >
38
+ < ExampleComponent />
39
+ </ page >
40
+ ) : null }
10
41
</ frame >
11
42
) ;
12
43
}
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
3
- export function ExampleBottomNavigation ( ) {
3
+ export function BottomNavigation ( ) {
4
4
const [ selectedIndex , setSelectedIndex ] = React . useState ( 0 ) ;
5
5
6
6
return (
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
3
- export function ExampleTabs ( ) {
3
+ export function Tabs ( ) {
4
4
const [ selectedIndex , setSelectedIndex ] = React . useState ( 0 ) ;
5
5
6
6
return (
You can’t perform that action at this time.
0 commit comments