Skip to content

Commit 48dc82b

Browse files
authored
TabBar - start deprecation and remove usages (#1545)
1 parent 63ed5ab commit 48dc82b

File tree

11 files changed

+29
-301
lines changed

11 files changed

+29
-301
lines changed

demo/src/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ module.exports = {
118118
get TabControllerScreen() {
119119
return require('./screens/componentScreens/TabControllerScreen').default;
120120
},
121-
get TabBarScreen() {
122-
return require('./screens/componentScreens/TabBarScreen').default;
123-
},
124121
get TextScreen() {
125122
return require('./screens/componentScreens/TextScreen').default;
126123
},

demo/src/screens/MenuStructure.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export const navigationData = {
9595
{title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'},
9696
{title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'},
9797
{title: 'TabController', tags: 'tabbar controller native', screen: 'unicorn.components.TabControllerScreen'},
98-
{title: 'TabBar', tags: 'tab bar', screen: 'unicorn.components.TabBarScreen'},
9998
{
10099
title: 'withScrollEnabler',
101100
tags: 'scroll enabled withScrollEnabler',

demo/src/screens/componentScreens/TabBarScreen.tsx

Lines changed: 0 additions & 257 deletions
This file was deleted.

demo/src/screens/componentScreens/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export function registerScreens(registrar) {
4141
registrar('unicorn.components.SwitchScreen', () => require('./SwitchScreen').default);
4242
registrar('unicorn.components.ToastsScreen', () => require('./ToastsScreen').default);
4343
registrar('unicorn.components.TabControllerScreen', () => require('./TabControllerScreen').default);
44-
registrar('unicorn.components.TabBarScreen', () => require('./TabBarScreen').default);
4544
registrar('unicorn.components.TextScreen', () => require('./TextScreen').default);
4645
registrar('unicorn.components.TextFieldScreen', () => require('./TextFieldScreen').default);
4746
registrar('unicorn.wrappers.TouchableOpacityScreen', () => require('./TouchableOpacityScreen').default);

demo/src/screens/foundationScreens/TypographyScreen.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import _ from 'lodash';
22
import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
44
import {ScrollView} from 'react-native';
5-
import {TabBar, Colors, Typography, View, Text} from 'react-native-ui-lib';
5+
import {TabController, Colors, Typography, View, Text} from 'react-native-ui-lib';
6+
67

78
const WEIGHTS = ['Thin', 'Light', 'Default', 'Regular', 'Medium', 'Bold', 'Heavy', 'Black'];
89

@@ -15,10 +16,6 @@ export default class TypographyScreen extends Component {
1516
color: Colors.grey10
1617
};
1718

18-
state = {
19-
currentPage: 0
20-
};
21-
2219
getWeightSuffix(weight) {
2320
if (weight === 'Default') {
2421
return '';
@@ -30,10 +27,9 @@ export default class TypographyScreen extends Component {
3027
}
3128
}
3229

33-
renderPage() {
30+
renderPage(index = 0) {
3431
const {color} = this.props;
35-
const {currentPage} = this.state;
36-
const weight = WEIGHTS[currentPage];
32+
const weight = WEIGHTS[index];
3733
const weightSuffix = this.getWeightSuffix(weight);
3834
return (
3935
<ScrollView>
@@ -62,19 +58,29 @@ export default class TypographyScreen extends Component {
6258
);
6359
}
6460

65-
render() {
66-
const {currentPage} = this.state;
61+
renderPages() {
6762
return (
6863
<View flex>
69-
<TabBar selectedIndex={currentPage} onChangeIndex={index => this.setState({currentPage: index})}>
70-
{_.map(WEIGHTS, weight => (
71-
<TabBar.Item key={weight} label={weight}/>
72-
))}
73-
</TabBar>
74-
<View flex>
75-
{this.renderPage()}
76-
</View>
64+
{_.map(WEIGHTS, (item, index) => {
65+
return (
66+
<TabController.TabPage key={`${item.title}_page`} index={index}>
67+
{this.renderPage(index)}
68+
</TabController.TabPage>
69+
);
70+
})}
7771
</View>
7872
);
7973
}
74+
75+
render() {
76+
return (
77+
<TabController>
78+
<TabController.TabBar
79+
items={WEIGHTS.map(item => ({label: item, key: item}))}
80+
activeBackgroundColor={Colors.blue70}
81+
/>
82+
{this.renderPages()}
83+
</TabController>
84+
);
85+
}
8086
}

eslint-rules/tests/lib/rules/typography-deprecation.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,21 +692,6 @@ ruleTester.run('typography-deprecation', rule, {
692692
// options: options,
693693
// code: `
694694
// import React, {Component} from 'react';
695-
// import {Typography, TabBar} from 'our-source';
696-
// export default class OurList extends Component {
697-
// render() {
698-
// const titleVal = true;
699-
// return (
700-
// <TabBar labelStyle={{title: titleVal}} selectedLabelStyle={{title: titleVal}}/>
701-
// )
702-
// }
703-
// }`,
704-
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
705-
// },
706-
// {
707-
// options: options,
708-
// code: `
709-
// import React, {Component} from 'react';
710695
// import {Typography, Label} from 'our-source';
711696
// export default class OurList extends Component {
712697
// render() {

markdowns/getting-started/v5.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ Implementation had slightly changed, please see [example screen](https://github.
4545
- `relative` value for `position` prop was removed
4646
- Blur effect is not part of the component
4747

48-
#### TabBar
49-
Implementation had slightly changed, please see [example screen](https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabBarScreen.tsx)
50-
5148
#### ListItem
5249
Component not supporting animation out of the box (animatable wrapper was removed)
5350

src/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default {
134134
get TabController() {
135135
return require('./tabController').default;
136136
},
137-
get TabBar() {
137+
get TabBar() { //TODO: remove on V7
138138
return require('./tabBar').default;
139139
},
140140
get ChipsInput() {

0 commit comments

Comments
 (0)