Skip to content

Commit e335fe2

Browse files
committed
Revert "Enable TS check on demo files and fix all errors (#2585)"
This reverts commit 1d717e3.
1 parent 755cb40 commit e335fe2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+172
-204
lines changed

demo/src/screens/PlaygroundScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {Component} from 'react';
2-
import {View, Text, Card, TextField, Button} from 'react-native-ui-lib';
2+
import {StyleSheet} from 'react-native';
3+
import {View, Text, Card, TextField, Button} from 'react-native-ui-lib'; //eslint-disable-line
34

45
export default class PlaygroundScreen extends Component {
56
render() {

demo/src/screens/componentScreens/ActionBarScreen.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ import collections from '../../assets/icons/collections.png';
99
import richText from '../../assets/icons/richText.png';
1010

1111
export default class ActionBarScreen extends Component {
12-
state = {
13-
currentPage: 0
14-
};
12+
constructor(props) {
13+
super(props);
14+
15+
this.state = {
16+
currentPage: 0
17+
};
18+
}
1519

1620
render() {
1721
return (

demo/src/screens/componentScreens/AvatarsScreen.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {ScrollView, StyleSheet, Alert} from 'react-native';
4-
import {Avatar, AvatarHelper, View, Text, Colors, Typography, AvatarProps} from 'react-native-ui-lib';
4+
import {Avatar, AvatarHelper, View, Text, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
55

66

77
const star = require('../../assets/icons/star.png');
@@ -25,7 +25,7 @@ const examples = [
2525
'https://lh3.googleusercontent.com/-cw77lUnOvmI/AAAAAAAAAAI/AAAAAAAAAAA/WMNck32dKbc/s181-c/104220521160525129167.jpg'
2626
},
2727
badgeProps: {size: 10, backgroundColor: Colors.$backgroundWarningHeavy},
28-
badgePosition: 'BOTTOM_RIGHT' as AvatarProps['badgePosition']
28+
badgePosition: 'BOTTOM_RIGHT'
2929
},
3030

3131
{
@@ -36,7 +36,7 @@ const examples = [
3636
'https://lh3.googleusercontent.com/-CMM0GmT5tiI/AAAAAAAAAAI/AAAAAAAAAAA/-o9gKbC6FVo/s181-c/111308920004613908895.jpg'
3737
},
3838
badgeProps: {size: 10, backgroundColor: Colors.$backgroundDisabled},
39-
badgePosition: 'BOTTOM_LEFT' as AvatarProps['badgePosition']
39+
badgePosition: 'BOTTOM_LEFT'
4040
},
4141
{
4242
title: 'Image with fade in animation',
@@ -53,7 +53,7 @@ const examples = [
5353
uri: 'https://randomuser.me/api/portraits/women/24.jpg'
5454
},
5555
badgeProps: {size: 14, borderWidth: 0, backgroundColor: onlineColor},
56-
badgePosition: 'TOP_LEFT' as AvatarProps['badgePosition']
56+
badgePosition: 'TOP_LEFT'
5757
},
5858
{
5959
title: 'Icon badge',
@@ -102,7 +102,7 @@ const examples = [
102102
title: 'With custom badge label',
103103
label: 'LD',
104104
backgroundColor: Colors.$backgroundDangerLight,
105-
badgePosition: 'BOTTOM_RIGHT' as AvatarProps['badgePosition'],
105+
badgePosition: 'BOTTOM_RIGHT',
106106
badgeProps: {
107107
label: '+2',
108108
size: 24,
@@ -123,7 +123,7 @@ export default class AvatarsScreen extends Component {
123123
patchedGravatar ? `Patched-uri: ${patchedGravatar}` : ''
124124
}`;
125125
Alert.alert(title, message);
126-
};
126+
}
127127

128128
render() {
129129
return (

demo/src/screens/componentScreens/BasicListScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class BasicListScreen extends Component {
1414
return (
1515
<View>
1616
<ListItem
17+
// @ts-expect-error
1718
activeBackgroundColor={Colors.grey60}
1819
activeOpacity={0.3}
1920
height={77.5}

demo/src/screens/componentScreens/ButtonsScreen.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import {ScrollView, StyleSheet, Alert, Image} from 'react-native';
3-
import {Text, View, Assets, Constants, Button, Colors, Typography, ButtonProps} from 'react-native-ui-lib';
3+
import {Text, View, Assets, Constants, Button, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
44

55
const ButtonSpace = 20;
66
const plusIcon = Assets.getAssetByPath('icons.demo.plus');
@@ -9,12 +9,16 @@ const labelButton = {label: 'Animated'};
99
const iconButton = {round: true};
1010

1111
export default class ButtonsScreen extends Component {
12-
state = {
13-
backgroundColor: Colors.yellow30,
14-
label: 'Button',
15-
// outline: true,
16-
buttonProps: labelButton as ButtonProps
17-
};
12+
constructor(props) {
13+
super(props);
14+
15+
this.state = {
16+
backgroundColor: Colors.yellow30,
17+
label: 'Button',
18+
// outline: true,
19+
buttonProps: labelButton
20+
};
21+
}
1822

1923
changeProps = () => {
2024
if (this.state.buttonProps === labelButton) {
@@ -237,11 +241,9 @@ export default class ButtonsScreen extends Component {
237241
style={{
238242
width: 20,
239243
height: 20,
240-
// @ts-expect-error
241-
backgroundColor: iconStyle[0]?.tintColor,
244+
backgroundColor: iconStyle[0].tintColor,
242245
borderRadius: 10,
243-
// @ts-expect-error
244-
marginRight: iconStyle[0]?.marginRight
246+
marginRight: iconStyle[0].marginRight
245247
}}
246248
/>
247249
)}

demo/src/screens/componentScreens/CarouselScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CarouselScreen extends Component<Props, State> {
117117
pageControlProps={{onPagePress: this.onPagePress, limitShownPages}}
118118
allowAccessibleLayout
119119
>
120-
{_.map([...Array(numberOfPagesShown)], (_item, index) => (
120+
{_.map([...Array(numberOfPagesShown)], (item, index) => (
121121
<Page style={{backgroundColor: BACKGROUND_COLORS[index]}} key={index}>
122122
<Text margin-15>CARD {index}</Text>
123123
</Page>

demo/src/screens/componentScreens/ChipsInputScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component} from 'react';
2-
import {View, Text, Colors, ChipsInput} from 'react-native-ui-lib';
2+
import {View, Text, Card, TextField, Button, Colors, ChipsInput} from 'react-native-ui-lib'; //eslint-disable-line
33
import _ from 'lodash';
44

55
export default class ChipsInputScreen extends Component {

demo/src/screens/componentScreens/ColorPickerScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
77
interface Props {}
88
interface State {
99
color: string;
10-
textColor?: string;
10+
textColor: string;
1111
customColors: string[];
1212
paletteChange: boolean;
1313
backgroundColor: string;

demo/src/screens/componentScreens/DrawerScreen.tsx

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
11
import React, {Component} from 'react';
22
import {StyleSheet, ScrollView, LayoutAnimation} from 'react-native';
3-
import {Assets, Colors, Typography, View, Drawer, Text, Button, Avatar, Badge, DrawerProps} from 'react-native-ui-lib';
3+
import {
4+
Assets,
5+
Colors,
6+
Typography,
7+
View,
8+
Drawer,
9+
Text,
10+
Button,
11+
Avatar,
12+
Badge
13+
} from 'react-native-ui-lib'; //eslint-disable-line
414
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
515
import conversations from '../../data/conversations';
616

7-
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';
17+
import {
18+
renderBooleanOption,
19+
renderSliderOption,
20+
renderColorOption
21+
} from '../ExampleScreenPresenter';
822

923
const ITEMS = {
1024
read: {
1125
icon: require('../../assets/icons/mail.png'),
1226
text: 'Read',
1327
background: Colors.green30,
14-
testID: 'left_item_read'
28+
testID: "left_item_read"
1529
},
1630
archive: {
1731
icon: require('../../assets/icons/archive.png'),
1832
text: 'Archive',
1933
background: Colors.blue30,
20-
testID: 'right_item_archive'
34+
testID: "right_item_archive"
2135
},
2236
delete: {
2337
icon: require('../../assets/icons/delete.png'),
2438
text: 'Delete',
2539
background: Colors.red30,
26-
testID: 'right_item_delete'
40+
testID: "right_item_delete"
2741
}
2842
};
2943

3044
class DrawerScreen extends Component {
31-
state = {
32-
hideItem: false,
33-
showRightItems: true,
34-
fullSwipeRight: true,
35-
showLeftItem: true,
36-
fullSwipeLeft: true,
37-
unread: true,
38-
itemsTintColor: undefined,
39-
bounciness: undefined,
40-
itemsIconSize: undefined
41-
};
45+
constructor(props) {
46+
super(props);
4247

43-
ref: React.Ref<typeof Drawer> = null;
48+
this.state = {
49+
hideItem: false,
50+
showRightItems: true,
51+
fullSwipeRight: true,
52+
showLeftItem: true,
53+
fullSwipeLeft: true,
54+
unread: true
55+
};
56+
}
4457

45-
componentDidUpdate(_prevProps: any, prevState: typeof this.state) {
58+
componentDidUpdate(prevProps, prevState) {
4659
if (this.state.hideItem && prevState.hideItem) {
4760
this.showItem();
4861
}
@@ -69,45 +82,39 @@ class DrawerScreen extends Component {
6982

7083
toggleReadState = () => {
7184
this.setState({unread: !this.state.unread});
72-
};
85+
}
7386

7487
showItem = () => {
7588
this.setState({hideItem: false});
7689
};
7790

7891
openLeftDrawer = () => {
7992
if (this.ref) {
80-
// @ts-expect-error
8193
this.ref.openLeft();
8294
}
8395
};
8496
openLeftDrawerFull = () => {
8597
if (this.ref) {
86-
// @ts-expect-error
8798
this.ref.openLeftFull();
8899
}
89100
};
90101
toggleLeftDrawer = () => {
91102
if (this.ref) {
92-
// @ts-expect-error
93103
this.ref.toggleLeft();
94104
}
95105
};
96106
openRightDrawer = () => {
97107
if (this.ref) {
98-
// @ts-expect-error
99108
this.ref.openRight();
100109
}
101110
};
102111
openRightDrawerFull = () => {
103112
if (this.ref) {
104-
// @ts-expect-error
105113
this.ref.openRightFull();
106114
}
107115
};
108116
closeDrawer = () => {
109117
if (this.ref) {
110-
// @ts-expect-error
111118
this.ref.closeDrawer();
112119
}
113120
};
@@ -142,7 +149,13 @@ class DrawerScreen extends Component {
142149
</View>
143150

144151
<View marginH-20>
145-
<Button onPress={this.closeDrawer} label="Close" style={{margin: 3}} size={'xSmall'} testID="close_btn"/>
152+
<Button
153+
onPress={this.closeDrawer}
154+
label="Close"
155+
style={{margin: 3}}
156+
size={'xSmall'}
157+
testID="close_btn"
158+
/>
146159
</View>
147160

148161
<View>
@@ -179,14 +192,10 @@ class DrawerScreen extends Component {
179192
style={{borderBottomWidth: 1, borderColor: Colors.grey60}}
180193
testID="drawer_item"
181194
>
182-
{this.state.unread && (
183-
<Badge testID="drawer_item_badge" size={6} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>
184-
)}
195+
{this.state.unread && <Badge testID="drawer_item_badge" size={6} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>}
185196
<Avatar source={{uri: data.thumbnail}}/>
186197
<View marginL-20>
187-
<Text text70R={!this.state.unread} text70BO={this.state.unread}>
188-
{data.name}
189-
</Text>
198+
<Text text70R={!this.state.unread} text70BO={this.state.unread}>{data.name}</Text>
190199
<Text text80 marginT-2>
191200
{data.text}
192201
</Text>
@@ -207,12 +216,11 @@ class DrawerScreen extends Component {
207216
hideItem
208217
} = this.state;
209218

210-
const drawerProps: DrawerProps = {
219+
const drawerProps = {
211220
itemsTintColor,
212221
itemsIconSize,
213222
bounciness,
214-
// @ts-expect-error
215-
ref: component => (this.ref = component),
223+
ref: (component) => (this.ref = component),
216224
fullSwipeRight,
217225
onFullSwipeRight: this.deleteItem,
218226
fullSwipeLeft,
@@ -228,7 +236,7 @@ class DrawerScreen extends Component {
228236
drawerProps.leftItem = {
229237
...ITEMS.read,
230238
icon: this.state.unread ? require('../../assets/icons/mail.png') : require('../../assets/icons/refresh.png'),
231-
text: !this.state.unread ? 'Unread' : 'Read',
239+
text: !this.state.unread ? 'Unread' : 'Read',
232240
background: this.state.unread ? Colors.green30 : Colors.orange30,
233241
onPress: this.toggleReadState
234242
};
@@ -257,13 +265,22 @@ class DrawerScreen extends Component {
257265
</>
258266
)}
259267

260-
<ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
268+
<ScrollView
269+
style={styles.container}
270+
contentContainerStyle={styles.contentContainer}
271+
>
261272
<View padding-20>
262273
{this.renderActions()}
263274
{renderBooleanOption.call(this, 'rightItems', 'showRightItems')}
264-
{showRightItems && renderBooleanOption.call(this, 'fullSwipeRight', 'fullSwipeRight')}
275+
{showRightItems &&
276+
renderBooleanOption.call(
277+
this,
278+
'fullSwipeRight',
279+
'fullSwipeRight'
280+
)}
265281
{renderBooleanOption.call(this, 'leftItem', 'showLeftItem')}
266-
{showLeftItem && renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
282+
{showLeftItem &&
283+
renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
267284
{renderColorOption.call(this, 'icon+text color', 'itemsTintColor')}
268285
{renderSliderOption.call(this, 'bounciness', 'bounciness', {
269286
min: 5,

demo/src/screens/componentScreens/GridViewScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import {View, Text, Image, Colors, Constants, Avatar, GridView, Card, GridViewProps} from 'react-native-ui-lib';
2+
import {View, Text, Image, Colors, Constants, Avatar, GridView, Card} from 'react-native-ui-lib';
33
import React, {Component} from 'react';
44
import {Alert, ScrollView} from 'react-native';
55
import conversations from '../../data/conversations';
@@ -30,7 +30,7 @@ class GridViewScreen extends Component {
3030
return <Text text={product.price} style={{alignSelf: 'center', marginTop: 3}}/>;
3131
}
3232
}
33-
})))(products) as GridViewProps['items'],
33+
})))(products),
3434
pairs: _.flow(products => _.take(products, 2),
3535
(products: any[]) =>
3636
_.map(products, product => ({
@@ -102,7 +102,7 @@ class GridViewScreen extends Component {
102102
);
103103
}
104104
}
105-
})))(products) as GridViewProps['items'],
105+
})))(products),
106106

107107
avatars: _.flow(products => _.take(products, 9),
108108
(products: any[]) =>

0 commit comments

Comments
 (0)