Skip to content

Enable TS check on demo files and fix all errors #2585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions demo/src/screens/PlaygroundScreen.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a manner of taste, but the screen looks a bit broken now with the non centered Button and the grey avatar at the bottom..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed it by mistake. Fixed

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, {Component} from 'react';
import {View, Text, Card, TextField, Button} from 'react-native-ui-lib'; //eslint-disable-line
import {View, Text, Card, Avatar, TextField, Button} from 'react-native-ui-lib'; //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can remove the //eslint-disable-line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


export default class PlaygroundScreen extends Component {
render() {
const badgePos = 'BOTTOM_LEFT';
return (
<View bg-grey80 flex padding-20>
<View marginT-20>
Expand All @@ -12,8 +13,9 @@ export default class PlaygroundScreen extends Component {
<Text text50>Playground Screen</Text>
</Card>
<View flex center>
<Button marginV-20 label="Button"/>
<Button marginV-20 label="Button" style={{alignSelf: 'baseline'}}/>
</View>
<Avatar badgePosition={badgePos} source={1}/>
</View>
);
}
Expand Down
10 changes: 3 additions & 7 deletions demo/src/screens/componentScreens/ActionBarScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import collections from '../../assets/icons/collections.png';
import richText from '../../assets/icons/richText.png';

export default class ActionBarScreen extends Component {
constructor(props) {
super(props);

this.state = {
currentPage: 0
};
}
state = {
currentPage: 0
};

render() {
return (
Expand Down
12 changes: 6 additions & 6 deletions demo/src/screens/componentScreens/AvatarsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import React, {Component} from 'react';
import {ScrollView, StyleSheet, Alert} from 'react-native';
import {Avatar, AvatarHelper, View, Text, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
import {Avatar, AvatarHelper, View, Text, Colors, Typography, AvatarProps} from 'react-native-ui-lib'; //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can remove the //eslint-disable-line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed



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

{
Expand All @@ -36,7 +36,7 @@ const examples = [
'https://lh3.googleusercontent.com/-CMM0GmT5tiI/AAAAAAAAAAI/AAAAAAAAAAA/-o9gKbC6FVo/s181-c/111308920004613908895.jpg'
},
badgeProps: {size: 10, backgroundColor: Colors.$backgroundDisabled},
badgePosition: 'BOTTOM_LEFT'
badgePosition: 'BOTTOM_LEFT' as AvatarProps['badgePosition']
},
{
title: 'Image with fade in animation',
Expand All @@ -53,7 +53,7 @@ const examples = [
uri: 'https://randomuser.me/api/portraits/women/24.jpg'
},
badgeProps: {size: 14, borderWidth: 0, backgroundColor: onlineColor},
badgePosition: 'TOP_LEFT'
badgePosition: 'TOP_LEFT' as AvatarProps['badgePosition']
},
{
title: 'Icon badge',
Expand Down Expand Up @@ -102,7 +102,7 @@ const examples = [
title: 'With custom badge label',
label: 'LD',
backgroundColor: Colors.$backgroundDangerLight,
badgePosition: 'BOTTOM_RIGHT',
badgePosition: 'BOTTOM_RIGHT' as AvatarProps['badgePosition'],
badgeProps: {
label: '+2',
size: 24,
Expand All @@ -123,7 +123,7 @@ export default class AvatarsScreen extends Component {
patchedGravatar ? `Patched-uri: ${patchedGravatar}` : ''
}`;
Alert.alert(title, message);
}
};

render() {
return (
Expand Down
1 change: 0 additions & 1 deletion demo/src/screens/componentScreens/BasicListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class BasicListScreen extends Component {
return (
<View>
<ListItem
// @ts-expect-error
activeBackgroundColor={Colors.grey60}
activeOpacity={0.3}
height={77.5}
Expand Down
24 changes: 11 additions & 13 deletions demo/src/screens/componentScreens/ButtonsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import {ScrollView, StyleSheet, Alert, Image} from 'react-native';
import {Text, View, Assets, Constants, Button, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
import {Text, View, Assets, Constants, Button, Colors, Typography, ButtonProps} from 'react-native-ui-lib'; //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can remove the //eslint-disable-line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


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

export default class ButtonsScreen extends Component {
constructor(props) {
super(props);

this.state = {
backgroundColor: Colors.yellow30,
label: 'Button',
// outline: true,
buttonProps: labelButton
};
}
state = {
backgroundColor: Colors.yellow30,
label: 'Button',
// outline: true,
buttonProps: labelButton as ButtonProps
};

changeProps = () => {
if (this.state.buttonProps === labelButton) {
Expand Down Expand Up @@ -241,9 +237,11 @@ export default class ButtonsScreen extends Component {
style={{
width: 20,
height: 20,
backgroundColor: iconStyle[0].tintColor,
// @ts-expect-error
backgroundColor: iconStyle[0]?.tintColor,
borderRadius: 10,
marginRight: iconStyle[0].marginRight
// @ts-expect-error
marginRight: iconStyle[0]?.marginRight
}}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/CarouselScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CarouselScreen extends Component<Props, State> {
pageControlProps={{onPagePress: this.onPagePress, limitShownPages}}
allowAccessibleLayout
>
{_.map([...Array(numberOfPagesShown)], (item, index) => (
{_.map([...Array(numberOfPagesShown)], (_item, index) => (
<Page style={{backgroundColor: BACKGROUND_COLORS[index]}} key={index}>
<Text margin-15>CARD {index}</Text>
</Page>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/ChipsInputScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {Component} from 'react';
import {View, Text, Card, TextField, Button, Colors, ChipsInput} from 'react-native-ui-lib'; //eslint-disable-line
import {View, Text, Colors, ChipsInput} from 'react-native-ui-lib'; //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can remove the //eslint-disable-line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

import _ from 'lodash';

export default class ChipsInputScreen extends Component {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/ColorPickerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
interface Props {}
interface State {
color: string;
textColor: string;
textColor?: string;
customColors: string[];
paletteChange: boolean;
backgroundColor: string;
Expand Down
95 changes: 39 additions & 56 deletions demo/src/screens/componentScreens/DrawerScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
import React, {Component} from 'react';
import {StyleSheet, ScrollView, LayoutAnimation} from 'react-native';
import {
Assets,
Colors,
Typography,
View,
Drawer,
Text,
Button,
Avatar,
Badge
} from 'react-native-ui-lib'; //eslint-disable-line
import {Assets, Colors, Typography, View, Drawer, Text, Button, Avatar, Badge, DrawerProps} from 'react-native-ui-lib'; //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can remove the //eslint-disable-line

import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
import conversations from '../../data/conversations';

import {
renderBooleanOption,
renderSliderOption,
renderColorOption
} from '../ExampleScreenPresenter';
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';

const ITEMS = {
read: {
icon: require('../../assets/icons/mail.png'),
text: 'Read',
background: Colors.green30,
testID: "left_item_read"
testID: 'left_item_read'
},
archive: {
icon: require('../../assets/icons/archive.png'),
text: 'Archive',
background: Colors.blue30,
testID: "right_item_archive"
testID: 'right_item_archive'
},
delete: {
icon: require('../../assets/icons/delete.png'),
text: 'Delete',
background: Colors.red30,
testID: "right_item_delete"
testID: 'right_item_delete'
}
};

class DrawerScreen extends Component {
constructor(props) {
super(props);
state = {
hideItem: false,
showRightItems: true,
fullSwipeRight: true,
showLeftItem: true,
fullSwipeLeft: true,
unread: true,
itemsTintColor: undefined,
bounciness: undefined,
itemsIconSize: undefined
};

this.state = {
hideItem: false,
showRightItems: true,
fullSwipeRight: true,
showLeftItem: true,
fullSwipeLeft: true,
unread: true
};
}
ref: React.Ref<typeof Drawer> = null;

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

toggleReadState = () => {
this.setState({unread: !this.state.unread});
}
};

showItem = () => {
this.setState({hideItem: false});
};

openLeftDrawer = () => {
if (this.ref) {
// @ts-expect-error
this.ref.openLeft();
}
};
openLeftDrawerFull = () => {
if (this.ref) {
// @ts-expect-error
this.ref.openLeftFull();
}
};
toggleLeftDrawer = () => {
if (this.ref) {
// @ts-expect-error
this.ref.toggleLeft();
}
};
openRightDrawer = () => {
if (this.ref) {
// @ts-expect-error
this.ref.openRight();
}
};
openRightDrawerFull = () => {
if (this.ref) {
// @ts-expect-error
this.ref.openRightFull();
}
};
closeDrawer = () => {
if (this.ref) {
// @ts-expect-error
this.ref.closeDrawer();
}
};
Expand Down Expand Up @@ -149,13 +142,7 @@ class DrawerScreen extends Component {
</View>

<View marginH-20>
<Button
onPress={this.closeDrawer}
label="Close"
style={{margin: 3}}
size={'xSmall'}
testID="close_btn"
/>
<Button onPress={this.closeDrawer} label="Close" style={{margin: 3}} size={'xSmall'} testID="close_btn"/>
</View>

<View>
Expand Down Expand Up @@ -192,10 +179,14 @@ class DrawerScreen extends Component {
style={{borderBottomWidth: 1, borderColor: Colors.grey60}}
testID="drawer_item"
>
{this.state.unread && <Badge testID="drawer_item_badge" size={6} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>}
{this.state.unread && (
<Badge testID="drawer_item_badge" size={6} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>
)}
<Avatar source={{uri: data.thumbnail}}/>
<View marginL-20>
<Text text70R={!this.state.unread} text70BO={this.state.unread}>{data.name}</Text>
<Text text70R={!this.state.unread} text70BO={this.state.unread}>
{data.name}
</Text>
<Text text80 marginT-2>
{data.text}
</Text>
Expand All @@ -216,11 +207,12 @@ class DrawerScreen extends Component {
hideItem
} = this.state;

const drawerProps = {
const drawerProps: DrawerProps = {
itemsTintColor,
itemsIconSize,
bounciness,
ref: (component) => (this.ref = component),
// @ts-expect-error
ref: component => (this.ref = component),
fullSwipeRight,
onFullSwipeRight: this.deleteItem,
fullSwipeLeft,
Expand All @@ -236,7 +228,7 @@ class DrawerScreen extends Component {
drawerProps.leftItem = {
...ITEMS.read,
icon: this.state.unread ? require('../../assets/icons/mail.png') : require('../../assets/icons/refresh.png'),
text: !this.state.unread ? 'Unread' : 'Read',
text: !this.state.unread ? 'Unread' : 'Read',
background: this.state.unread ? Colors.green30 : Colors.orange30,
onPress: this.toggleReadState
};
Expand Down Expand Up @@ -265,22 +257,13 @@ class DrawerScreen extends Component {
</>
)}

<ScrollView
style={styles.container}
contentContainerStyle={styles.contentContainer}
>
<ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
<View padding-20>
{this.renderActions()}
{renderBooleanOption.call(this, 'rightItems', 'showRightItems')}
{showRightItems &&
renderBooleanOption.call(
this,
'fullSwipeRight',
'fullSwipeRight'
)}
{showRightItems && renderBooleanOption.call(this, 'fullSwipeRight', 'fullSwipeRight')}
{renderBooleanOption.call(this, 'leftItem', 'showLeftItem')}
{showLeftItem &&
renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
{showLeftItem && renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
{renderColorOption.call(this, 'icon+text color', 'itemsTintColor')}
{renderSliderOption.call(this, 'bounciness', 'bounciness', {
min: 5,
Expand Down
Loading