Skip to content

Commit 529e734

Browse files
authored
Revert "Revert "TabBar refactor (#1040)" (#1074)"
This reverts commit 23cfe8e.
1 parent 23cfe8e commit 529e734

File tree

3 files changed

+355
-349
lines changed

3 files changed

+355
-349
lines changed

demo/src/screens/componentScreens/TabBarScreen.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class TabBarScreen extends Component {
3737
do {
3838
index = Math.floor(Math.random() * this.tabbar.props.children.length);
3939
} while (index === this.state.selectedIndex);
40-
40+
4141
this.setState({selectedIndex: index});
4242
}
4343
};
@@ -82,7 +82,7 @@ export default class TabBarScreen extends Component {
8282
removeTab = () => {
8383
const index = this.state.selectedIndex;
8484
const newTabs = this.state.currentTabs;
85-
85+
8686
if (newTabs.length >= 0) {
8787
newTabs.splice(index, 1);
8888
}
@@ -92,7 +92,7 @@ export default class TabBarScreen extends Component {
9292
/** Actions */
9393
getTabs(showAddTab: boolean) {
9494
const tabs = _.map(this.state.currentTabs, tab => this.renderTabs(tab));
95-
95+
9696
if (showAddTab) {
9797
tabs.push(this.renderAddTabsTab());
9898
} else {
@@ -126,15 +126,20 @@ export default class TabBarScreen extends Component {
126126
<ScrollView style={{overflow: 'visible'}} showsVerticalScrollIndicator={false}>
127127
<View bg-dark80>
128128
<TabBar style={styles.tabbar} selectedIndex={0} enableShadow>
129-
<TabBar.Item
130-
label="single tab"
129+
<TabBar.Item
130+
label="single tab"
131131
labelStyle={{color: Colors.green30, fontWeight: 'bold', textTransform: 'capitalize'}}
132132
/>
133133
</TabBar>
134134

135-
<TabBar style={styles.tabbar} selectedIndex={0} enableShadow>
136-
<TabBar.Item label="Fixed" uppercase style={{backgroundColor: Colors.blue80}}/>
137-
<TabBar.Item label="Tab" badge={{label: '100'}} uppercase style={{backgroundColor: Colors.blue80}}/>
135+
<TabBar
136+
style={styles.tabbar}
137+
selectedIndex={0}
138+
enableShadow
139+
// tabletMargins={{portrait: 0, landscape: 0}}
140+
>
141+
<TabBar.Item label="Fixed" uppercase backgroundColor={Colors.blue80}/>
142+
<TabBar.Item label="Tab" badgeProps={{label: '100'}} uppercase style={{backgroundColor: Colors.blue80}}/>
138143
<TabBar.Item label="Bar" uppercase style={{backgroundColor: Colors.blue80}}/>
139144
</TabBar>
140145

@@ -146,7 +151,7 @@ export default class TabBarScreen extends Component {
146151

147152
<TabBar style={styles.tabbar} selectedIndex={0} ref={r => (this.tabbar = r)} enableShadow>
148153
<TabBar.Item label="Scroll"/>
149-
<TabBar.Item label="View" badge={{size: 'pimpleSmall'}}/>
154+
<TabBar.Item label="View" badgeProps={{size: 'pimpleSmall'}}/>
150155
<TabBar.Item label="tab"/>
151156
<TabBar.Item label="bar"/>
152157
<TabBar.Item label="Container"/>
@@ -169,13 +174,20 @@ export default class TabBarScreen extends Component {
169174
{this.getTabs(true)}
170175
</TabBar>
171176

172-
<Button
173-
size={Button.sizes.small}
174-
margin-20
175-
label={`Change index: ${this.state.selectedIndex}`}
176-
onPress={this.changeIndex}
177-
/>
178-
<TabBar style={styles.tabbar} selectedIndex={this.state.selectedIndex} enableShadow backgroundColor={Colors.green70}>
177+
<View center>
178+
<Button
179+
size={Button.sizes.small}
180+
margin-20
181+
label={`Change index: ${this.state.selectedIndex}`}
182+
onPress={this.changeIndex}
183+
/>
184+
</View>
185+
<TabBar
186+
style={styles.tabbar}
187+
selectedIndex={this.state.selectedIndex}
188+
enableShadow
189+
backgroundColor={Colors.green70}
190+
>
179191
<TabBar.Item label="LONG LABEL"/>
180192
<TabBar.Item label="ACTIVE"/>
181193
<TabBar.Item label="INACTIVE"/>
@@ -187,7 +199,7 @@ export default class TabBarScreen extends Component {
187199
<TabBar.Item label="MODE"/>
188200
</TabBar>
189201

190-
<View row>
202+
<View center row>
191203
<Button size={Button.sizes.small} margin-20 label={`Change Labels`} onPress={this.changeLabels}/>
192204
<Button size={Button.sizes.small} margin-20 label={`Change Color`} onPress={this.changeColors}/>
193205
</View>

0 commit comments

Comments
 (0)