Skip to content

Commit 7ad05bb

Browse files
committed
Merge branch 'master' into v6-merge-master
* master: (30 commits) Button - refactor into smaller files (#1168) replace @react-native-community/picker with @react-native-picker/picker (#1063) Update generate types fix: catch undefined StatusBarManager (#1189) prop value shape deprecation lint rule (#1094) Infra/expo app fixes (#1166) Safe require blur-view dependency in Card (#1179) Update our stars count Update expo snack link with only supported platforms Export TabBarProps and fix BadgeScreen typescript errors Disable flipper Avoid passing overlayContent in CardSecion (#1187) Fix Carousel typings updating published version no-direct-import eslint rule - adding `applyAutofix` flag (#1183) Feat/image demo broken (#1173) Remove addItems from screen with fewItems Add vertical scroll to Carousel component (#1175) Fix Carousel gif Update Carousel gifs ... # Conflicts: # demo/src/screens/componentScreens/BadgesScreen.tsx # generatedTypes/components/button/index.d.ts # markdowns/getting-started/setup.md # src/components/button/index.tsx # src/components/card/CardSection.tsx # src/components/card/index.tsx # src/components/loaderScreen/index.js # src/components/modal/index.tsx # typings/components/Toast.d.ts # uilib-docs/src/templates/markdown.scss
2 parents ae188e0 + db258d5 commit 7ad05bb

File tree

96 files changed

+1774
-1040
lines changed

Some content is hidden

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

96 files changed

+1774
-1040
lines changed
Loading

demo/src/configurations.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import {Assets, Typography, Spacings} from 'react-native-ui-lib'; // eslint-disa
22

33
Assets.loadAssetsGroup('icons.demo', {
44
add: require('./assets/icons/add.png'),
5+
camera: require('./assets/icons/cameraSelected.png'),
56
close: require('./assets/icons/close.png'),
67
dashboard: require('./assets/icons/dashboard.png'),
78
image: require('./assets/icons/image.png'),
89
refresh: require('./assets/icons/refresh.png'),
910
search: require('./assets/icons/search.png')
1011
});
1112

13+
Assets.loadAssetsGroup('images.demo', {
14+
brokenImage: require('./assets/images/placeholderMissingImage.png')
15+
});
16+
1217
Typography.loadTypographies({
1318
h1: {...Typography.text40},
1419
h2: {...Typography.text50},

demo/src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ module.exports = {
3434
get CarouselScreen() {
3535
return require('./screens/componentScreens/CarouselScreen').default;
3636
},
37+
get CarouselVerticalScreen() {
38+
return require('./screens/componentScreens/CarouselVerticalScreen').default;
39+
},
3740
get CheckboxScreen() {
3841
return require('./screens/componentScreens/CheckboxScreen').default;
3942
},
43+
get ChipScreen() {
44+
return require('./screens/componentScreens/ChipScreen').default;
45+
},
4046
get ConnectionStatusBarScreen() {
4147
return require('./screens/componentScreens/ConnectionStatusBarScreen').default;
4248
},
@@ -203,6 +209,10 @@ module.exports = {
203209
get ProgressBarScreen() {
204210
return require('./screens/componentScreens/ProgressBarScreen').default;
205211
},
212+
// Incubator
213+
get IncubatorTextFieldScreen() {
214+
return require('./screens/incubatorScreens/IncubatorTextFieldScreen').default;
215+
},
206216
// realExamples
207217
get AppleMusic() {
208218
return require('./screens/realExamples/AppleMusic').default;

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const navigationData = {
8686
title: 'Layouts & Templates',
8787
screens: [
8888
{title: 'Carousel', tags: 'carousel', screen: 'unicorn.components.CarouselScreen'},
89+
{title: 'Carousel (Vertical)', tags: 'carousel', screen: 'unicorn.components.CarouselVerticalScreen'},
8990
{title: 'LoadingScreen', tags: 'loading screen', screen: 'unicorn.screens.LoadingScreen'},
9091
{title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'},
9192
{title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'},

demo/src/screens/componentScreens/BadgesScreen.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ const star = require('../../assets/icons/star.png');
88
const bell = require('../../assets/icons/bell.png');
99

1010
export default class BadgesScreen extends Component {
11-
constructor(props) {
12-
super(props);
11+
state = {
12+
value: 42
13+
};
1314

14-
this.state = {
15-
value: 42
16-
};
17-
}
18-
19-
changeLabelValue(value) {
15+
changeLabelValue(value: number) {
2016
const currValue = this.state.value;
2117
const newValue = currValue + value;
2218
if (newValue >= 1) {
@@ -103,7 +99,6 @@ export default class BadgesScreen extends Component {
10399
<View row>
104100
<View
105101
center
106-
column
107102
style={{justifyContent: 'space-around', alignItems: 'flex-start', width: 140, height: 140}}
108103
>
109104
<Text text80 row>
@@ -115,7 +110,7 @@ export default class BadgesScreen extends Component {
115110
</Text>
116111
</View>
117112

118-
<View center column style={{justifyContent: 'space-around', width: 40, height: 140}}>
113+
<View center style={{justifyContent: 'space-around', width: 40, height: 140}}>
119114
<Badge containerStyle={{marginLeft: BadgesSpace}} backgroundColor={Colors.green30} size={6}/>
120115
<Badge containerStyle={{marginLeft: BadgesSpace}} backgroundColor={Colors.red30} size={10}/>
121116
<Badge containerStyle={{marginLeft: BadgesSpace}} backgroundColor={Colors.blue30} size={14}/>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import {Carousel, Constants, Text, View, Colors} from 'react-native-ui-lib';
2+
import React, {Component} from 'react';
3+
import _ from 'lodash';
4+
import {StyleSheet} from 'react-native';
5+
import {
6+
renderBooleanOption,
7+
renderSliderOption
8+
} from '../ExampleScreenPresenter';
9+
10+
interface Props {}
11+
12+
interface State {
13+
numberOfPagesShown: number;
14+
autoplay: boolean;
15+
}
16+
17+
const BACKGROUND_COLORS = [
18+
Colors.red50,
19+
Colors.yellow20,
20+
Colors.purple50,
21+
Colors.green50,
22+
Colors.cyan50,
23+
Colors.purple20,
24+
Colors.blue60,
25+
Colors.red10,
26+
Colors.green20,
27+
Colors.purple60
28+
];
29+
30+
const pageHeight = Constants.windowHeight / 2;
31+
32+
class CarouselVerticalScreen extends Component<Props, State> {
33+
carousel = React.createRef<typeof Carousel>();
34+
35+
constructor(props: Props) {
36+
super(props);
37+
38+
this.state = {
39+
numberOfPagesShown: 5,
40+
autoplay: false
41+
};
42+
}
43+
44+
render() {
45+
const {numberOfPagesShown, autoplay} = this.state
46+
return (
47+
<View flex paddingT-20>
48+
<View marginH-20 marginB-20>
49+
{renderBooleanOption.call(this, 'autoplay', 'autoplay')}
50+
{renderSliderOption.call(
51+
this,
52+
'Number of pages shown',
53+
'numberOfPagesShown',
54+
{
55+
min: 3,
56+
max: 10,
57+
step: 1,
58+
initial: 5
59+
}
60+
)}
61+
</View>
62+
<Carousel
63+
key={'carousel'}
64+
ref={this.carousel}
65+
autoplay={autoplay}
66+
pageWidth={Constants.windowWidth}
67+
pageHeight={pageHeight}
68+
initialPage={0}
69+
containerStyle={{height: pageHeight}}
70+
allowAccessibleLayout
71+
horizontal={false}
72+
>
73+
{_.map([...Array(numberOfPagesShown)], (_, index) => (
74+
<Page
75+
style={{backgroundColor: BACKGROUND_COLORS[index]}}
76+
key={index}
77+
>
78+
<Text style={styles.pageText}>{index}</Text>
79+
</Page>
80+
))}
81+
</Carousel>
82+
</View>
83+
);
84+
}
85+
}
86+
87+
// @ts-ignore
88+
const Page = ({children, style, ...others}) => {
89+
return (
90+
<View center {...others} style={[styles.page, style]}>
91+
{children}
92+
</View>
93+
);
94+
};
95+
96+
const styles = StyleSheet.create({
97+
container: {},
98+
page: {
99+
flex: 1,
100+
height: pageHeight,
101+
width: Constants.windowWidth
102+
},
103+
pageText: {
104+
fontSize: 40,
105+
color: 'white'
106+
}
107+
});
108+
109+
export default CarouselVerticalScreen

demo/src/screens/componentScreens/ImageScreen.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import React, {Component} from 'react';
2-
import {View, Text, Image, Colors} from 'react-native-ui-lib';
2+
import {View, Text, Image, Colors, Assets} from 'react-native-ui-lib';
33
import {renderBooleanOption, renderRadioGroup, renderSliderOption} from '../ExampleScreenPresenter';
44

5-
import cameraIcon from '../../assets/icons/cameraSelected.png';
65

76
const IMAGE_URL =
87
'https://images.pexels.com/photos/748837/pexels-photo-748837.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260';
9-
8+
const BROKEN_URL = 'file:///Desktop/website/img/cupcake.jpg';
109
const DEFAULT_SIZE = 100;
10+
1111
class ImageScreen extends Component {
1212
state = {
1313
cover: true,
1414
showOverlayContent: false,
1515
overlayType: 'none',
16-
margin: 0
16+
margin: 0,
17+
showErrorImage: false
1718
};
1819

1920
renderOverlayContent() {
@@ -25,7 +26,7 @@ class ImageScreen extends Component {
2526
<View row centerV>
2627
<Image
2728
style={{margin: 5, marginRight: 10}}
28-
source={cameraIcon}
29+
source={Assets.icons.demo.camera}
2930
tintColor={overlayType !== 'none' ? Colors.white : undefined}
3031
/>
3132
<Text text30 white={overlayType !== 'none'}>
@@ -35,19 +36,20 @@ class ImageScreen extends Component {
3536
</View>
3637
);
3738
} else {
38-
return <Image style={{margin: 5}} source={cameraIcon}/>;
39+
return <Image style={{margin: 5}} source={Assets.icons.demo.camera}/>;
3940
}
4041
}
4142
}
4243

4344
render() {
44-
const {cover, overlayType, margin} = this.state;
45+
const {cover, overlayType, margin, showErrorImage} = this.state;
4546

4647
return (
4748
<View flex>
4849
<View centerH height={250}>
4950
<Image
50-
source={{uri: IMAGE_URL}}
51+
source={{uri: showErrorImage ? BROKEN_URL : IMAGE_URL}}
52+
errorSource={Assets.images.demo.brokenImage}
5153
cover={cover}
5254
overlayType={overlayType !== 'none' ? overlayType : undefined}
5355
style={!cover && {width: DEFAULT_SIZE, height: DEFAULT_SIZE}}
@@ -61,6 +63,7 @@ class ImageScreen extends Component {
6163
<View flex>
6264
{renderBooleanOption.call(this, 'Show as Cover Image', 'cover')}
6365
{renderBooleanOption.call(this, 'Show Overlay Content', 'showOverlayContent')}
66+
{renderBooleanOption.call(this, 'Show Error Image', 'showErrorImage')}
6467
{renderRadioGroup.call(this, 'Overlay Type', 'overlayType', {none: 'none', ...Image.overlayTypes})}
6568
{renderSliderOption.call(this, 'Margin(margin-XX)', 'margin', {step: 4, min: 0, max: 40})}
6669
</View>

demo/src/screens/componentScreens/LoadingScreen.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
11
import React, {Component} from 'react';
2-
import {View as AnimatableView} from 'react-native-animatable';
3-
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';//eslint-disable-line
4-
2+
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';
53
export default class LoadingScreen extends Component {
6-
74
state = {
8-
loading: true,
5+
loading: true
96
};
107

118
componentDidMount() {
129
setTimeout(() => {
13-
this.setState({
14-
animationConfig: {
15-
animation: 'fadeOut',
16-
onAnimationEnd: () => this.setState({loading: false}),
17-
},
18-
});
10+
this.setState({loading: false});
1911
}, 2500);
2012
}
2113

2214
render() {
23-
const {loading, animationConfig} = this.state;
15+
const {loading} = this.state;
2416
return (
2517
<View flex bg-orange70 center>
26-
<Text text10>
27-
Content Content Content
28-
</Text>
29-
{loading &&
30-
<AnimatableView {...animationConfig}>
31-
<LoaderScreen
32-
color={Colors.blue30}
33-
message="Loading..."
34-
overlay
35-
/>
36-
</AnimatableView>
37-
}
18+
<Text text10>Content Content Content</Text>
19+
{loading && <LoaderScreen color={Colors.blue30} message="Loading..." overlay/>}
3820
</View>
3921
);
4022
}

demo/src/screens/componentScreens/PickerScreen.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export default class PickerScreen extends Component {
8484
placeholder="Favorite Language"
8585
floatingPlaceholder
8686
value={this.state.language}
87+
enableModalBlur={false}
8788
onChange={item => this.setState({language: item})}
8889
topBarProps={{title: 'Languages'}}
8990
style={{color: Colors.red20}}

demo/src/screens/componentScreens/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function registerScreens(registrar) {
1010
registrar('unicorn.components.CardsScreen', () => require('./CardsScreen').default);
1111
registrar('unicorn.animations.CardScannerScreen', () => require('../componentScreens/CardScannerScreen').default);
1212
registrar('unicorn.components.CarouselScreen', () => require('./CarouselScreen').default);
13+
registrar('unicorn.components.CarouselVerticalScreen', () => require('./CarouselVerticalScreen').default);
1314
registrar('unicorn.components.CheckboxScreen', () => require('./CheckboxScreen').default);
1415
registrar('unicorn.components.ChipScreen', () => require('./ChipScreen').default);
1516
registrar('unicorn.components.ConnectionStatusBar', () => require('./ConnectionStatusBarScreen').default);

eslint-rules/lib/rules/no-direct-import.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ const MAP_SCHEMA = {
22
type: 'object',
33
properties: {
44
origin: {
5-
type: 'string',
5+
type: 'string'
66
},
77
destination: {
8-
type: 'string',
8+
type: 'string'
99
},
10+
applyAutofix: {
11+
type: 'boolean'
12+
}
1013
},
11-
additionalProperties: false,
14+
additionalProperties: false
1215
};
1316

1417
module.exports = {
@@ -19,7 +22,7 @@ module.exports = {
1922
recommended: true,
2023
},
2124
messages: {
22-
uiLib: 'Do not import directly from this source. Please use another import source (autofix available).',
25+
uiLib: 'Do not import directly from this source. Please use another import source (autofix may be available).',
2326
},
2427
fixable: 'code',
2528
schema: [
@@ -31,12 +34,14 @@ module.exports = {
3134
try {
3235
const origin = context.options[0].origin;
3336
const destination = context.options[0].destination;
34-
const message = `Do not import directly from '${origin}'. Please use '${destination}' (autofix available).`;
37+
const applyAutofix = context.options[0].applyAutofix;
38+
const autofixMessage = applyAutofix ? ' (autofix available)' : '';
39+
const message = `Do not import directly from '${origin}'. Please use '${destination}'${autofixMessage}.`;
3540
context.report({
3641
node,
3742
message,
3843
fix(fixer) {
39-
if (node && destination) {
44+
if (node && applyAutofix && destination) {
4045
return fixer.replaceText(node.source, `'${destination}'`);
4146
}
4247
},

0 commit comments

Comments
 (0)