Skip to content

Commit 0999c90

Browse files
committed
Set nodeRoles
1 parent fb67897 commit 0999c90

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

demo-react/src/components/HomeScreen.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,64 @@ import * as React from 'react';
22
import { StyleSheet } from 'react-nativescript';
33

44
export function ExampleTabs() {
5+
const [selectedIndex, setSelectedIndex] = React.useState(0);
6+
57
return (
6-
<tabs selectedIndex={1}>
8+
<tabs
9+
selectedIndex={selectedIndex}
10+
onSelectedIndexChanged={(args) => {
11+
console.log('onSelectedIndexChanged', args);
12+
// setSelectedIndex(args.newIndex);
13+
}}
14+
style={{ ...styles.fullSize }}
15+
>
716
{/* The bottomTab UI is created via tabStrip (the container) and tabStripItem (for each tab) */}
8-
<tabStrip>
17+
<tabStrip nodeRole="tabStrip">
918
<tabStripItem>
10-
<label>Home</label>
11-
<image src="font://&#xf015;" className="fas" />
19+
<label nodeRole="label">Home</label>
20+
<image nodeRole="image" src="font://&#xf015;" className="fas" />
1221
</tabStripItem>
1322
<tabStripItem className="special">
14-
<label>Account</label>
15-
<image src="font://&#xf007;" className="fas" />
23+
<label nodeRole="label">Account</label>
24+
<image nodeRole="image" src="font://&#xf007;" className="fas" />
1625
</tabStripItem>
1726
<tabStripItem className="special">
18-
<label>Search</label>
19-
<image src="font://&#xf00e;" className="fas" />
27+
<label nodeRole="label">Search</label>
28+
<image nodeRole="image" src="font://&#xf00e;" className="fas" />
2029
</tabStripItem>
2130
</tabStrip>
2231

2332
{/* The number of tabContentItem components should corespond to the number of TabStripItem components */}
24-
<tabContentItem>
33+
<tabContentItem nodeRole="items">
2534
<gridLayout>
26-
<label className="h2 text-center">Home Page</label>
35+
<label nodeRole="label" className="h2 text-center">
36+
Home Page
37+
</label>
2738
</gridLayout>
2839
</tabContentItem>
29-
<tabContentItem>
40+
<tabContentItem nodeRole="items">
3041
<gridLayout>
31-
<label className="h2 text-center">Account Page</label>
42+
<label nodeRole="label" className="h2 text-center">
43+
Account Page
44+
</label>
3245
</gridLayout>
3346
</tabContentItem>
34-
<tabContentItem>
47+
<tabContentItem nodeRole="items">
3548
<gridLayout>
36-
<label className="h2 text-center">Search Page</label>
49+
<label nodeRole="label" className="h2 text-center">
50+
Search Page
51+
</label>
3752
</gridLayout>
3853
</tabContentItem>
3954
</tabs>
4055
);
4156
}
4257

4358
const styles = StyleSheet.create({
59+
fullSize: {
60+
height: '100%',
61+
width: '100%'
62+
},
4463
container: {
4564
height: '100%',
4665
flexDirection: 'column',

0 commit comments

Comments
 (0)