Skip to content

Commit 757d64d

Browse files
authored
Progress bar new design (#1549)
* ProgressBar - new component design and API * customElement demo * borderRadius * demo - texts style * fix merge
1 parent c15ae69 commit 757d64d

File tree

9 files changed

+365
-159
lines changed

9 files changed

+365
-159
lines changed

demo/src/screens/componentScreens/ProgressBarScreen.js

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import React, {Component} from 'react';
2+
import {StyleSheet, ScrollView} from 'react-native';
3+
import {View, Text, ProgressBar, Colors, Spacings} from 'react-native-ui-lib';//eslint-disable-line
4+
5+
6+
export default class ProgressBarScreen extends Component {
7+
8+
state = {
9+
progresses: [0, 0, 0, 0]
10+
};
11+
12+
componentDidMount() {
13+
this.startProgress(0, 45);
14+
this.startProgress(1, 25);
15+
this.startProgress(2, 70);
16+
this.startProgress(3, 15);
17+
}
18+
19+
elements = new Array(4);
20+
21+
startProgress(index: number, stepSize: number) {
22+
const {progresses} = this.state;
23+
progresses[index] = Math.min(progresses[index] + stepSize, 100);
24+
this.setState({progresses});
25+
26+
if (progresses[index] < 100) {
27+
setTimeout(() => {
28+
this.startProgress(index, stepSize);
29+
}, 800);
30+
}
31+
}
32+
33+
get customElement() {
34+
return (
35+
<View style={{backgroundColor: Colors.green30, borderWidth: 0.5, borderRadius: 4}}/>
36+
);
37+
}
38+
39+
render() {
40+
const {progresses} = this.state;
41+
42+
return (
43+
<ScrollView>
44+
<View flex bg-grey80 spread paddingV-18>
45+
<View paddingL-18 marginB-18>
46+
<Text text40 grey10>
47+
ProgressBar
48+
</Text>
49+
</View>
50+
51+
<Text text70 style={styles.text}>
52+
Default
53+
</Text>
54+
<ProgressBar
55+
progress={progresses[0]}
56+
style={styles.progressBar}
57+
/>
58+
59+
<Text text70 style={styles.text}>
60+
FullWidth
61+
</Text>
62+
<ProgressBar
63+
progress={progresses[1]}
64+
style={styles.fullWidthProgressBar}
65+
fullWidth
66+
/>
67+
68+
<Text text70 style={styles.text}>
69+
Styled
70+
</Text>
71+
<ProgressBar
72+
progress={progresses[2]}
73+
style={[styles.progressBar, styles.styledProgressBar]}
74+
progressColor={Colors.purple70}
75+
/>
76+
77+
<Text text70 style={styles.text}>
78+
Custom Element
79+
</Text>
80+
<ProgressBar
81+
progress={progresses[0]}
82+
style={styles.progressBar}
83+
customElement={this.customElement}
84+
/>
85+
</View>
86+
</ScrollView>
87+
);
88+
}
89+
}
90+
91+
const styles = StyleSheet.create({
92+
text: {
93+
paddingTop: 20,
94+
paddingBottom: 15,
95+
paddingLeft: 20
96+
},
97+
progressBar: {
98+
marginBottom: 10,
99+
marginHorizontal: Spacings.s4
100+
},
101+
styledProgressBar: {
102+
backgroundColor: Colors.purple40,
103+
height: 30
104+
},
105+
fullWidthProgressBar: {
106+
marginBottom: 10
107+
}
108+
});

generatedTypes/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export {default as ColorPicker, ColorPickerProps} from './src/components/colorPi
4242
export {default as ColorPalette, ColorPaletteProps} from './src/components/colorPicker/ColorPalette';
4343
export {default as ColorSwatch, ColorSwatchProps} from './src/components/colorPicker/ColorSwatch';
4444
export {default as Drawer, DrawerProps, DrawerItemProps} from './src/components/drawer';
45+
export {default as ProgressBar, ProgressBarProps} from './src/components/progressBar';
4546
export {default as FeatureHighlight, FeatureHighlightProps} from './src/components/featureHighlight';
4647
export {default as FloatingButton, FloatingButtonProps} from './src/components/floatingButton';
4748
export {default as GridListItem, GridListItemProps} from './src/components/gridListItem';
@@ -91,7 +92,6 @@ export {
9192
BaseInput,
9293
TextArea,
9394
MaskedInput,
94-
ProgressBar,
9595
ColorSliderGroup,
9696
ChipsInput,
9797
SharedTransition,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React, { PureComponent } from 'react';
2+
import { Animated, StyleProp, ViewStyle, LayoutChangeEvent } from 'react-native';
3+
/**
4+
* @description: Progress bar
5+
* @example:https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ProgressBarScreen.js
6+
*/
7+
interface Props {
8+
/**
9+
* The progress of the bar from 0 to 100
10+
*/
11+
progress?: number;
12+
/**
13+
* FullWidth Ui preset
14+
*/
15+
fullWidth?: boolean;
16+
/**
17+
* Override container style
18+
*/
19+
style?: StyleProp<ViewStyle>;
20+
/**
21+
* Progress color
22+
*/
23+
progressColor?: string;
24+
/**
25+
* Custom element to render on top of the animated progress
26+
*/
27+
customElement?: JSX.Element;
28+
}
29+
export declare type ProgressBarProps = Props;
30+
interface State {
31+
containerWidth?: number;
32+
}
33+
declare class ProgressBar extends PureComponent<Props, State> {
34+
static displayName: string;
35+
static defaultProps: Partial<Props>;
36+
progressAnimation: Animated.Value;
37+
constructor(props: Props);
38+
componentDidUpdate(prevProps: Props): void;
39+
getContainerWidth: (event: LayoutChangeEvent) => void;
40+
animateProgress(toValue?: number): void;
41+
getAccessibilityProps(): {
42+
accessible: boolean;
43+
accessibilityLabel: string;
44+
} | undefined;
45+
getContainerStyle(): {
46+
height: number;
47+
borderRadius?: number | undefined;
48+
};
49+
getProgressStyle(): {
50+
right: number | undefined;
51+
backgroundColor: string;
52+
borderRadius: number;
53+
} | {
54+
right: number | undefined;
55+
backgroundColor: string;
56+
borderBottomRightRadius: number;
57+
borderTopRightRadius: number;
58+
};
59+
renderCustomElement(): React.FunctionComponentElement<any> | undefined;
60+
render(): JSX.Element;
61+
}
62+
export { ProgressBar };
63+
declare const _default: React.ComponentClass<Props & {
64+
useCustomTheme?: boolean | undefined;
65+
}, any> & typeof ProgressBar;
66+
export default _default;

src/components/progressBar/index.js

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

0 commit comments

Comments
 (0)