Skip to content

Set progress text properly and runs the animation when the default progress is given - #134

Open
mu29 wants to merge 2 commits into
oblador:masterfrom
mu29:master
Open

Set progress text properly and runs the animation when the default progress is given#134
mu29 wants to merge 2 commits into
oblador:masterfrom
mu29:master

Conversation

@mu29

@mu29mu29 commented Nov 22, 2018

Copy link
Copy Markdown

Problem

Since progressValue is set to 0 on constructor, initial progress value didn't works well when combine with animated and showsText props. See code and screenshot below.

importReact,{Component}from'react';importCirclefrom'react-native-progress/Circle'import{Platform,StyleSheet,Button,View}from'react-native';typeExampleState={progress: number;}exportdefaultclassExampleextendsReact.Component<{},ExampleState>{
state ={progress: 0.1,}render(){return(<Viewstyle={styles.container}><Circlecolor="#000000"unfilledColor="#FAFAFA"borderWidth={0}progress={this.state.progress}showsText/><Buttontitle="click!"onPress={()=>this.setState(s=>({progress: s.progress+0.1}))}/></View>)}}conststyles=StyleSheet.create({container: {flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',},});

2018-11-22 3 12 42

Expected behavior

Text shows 10% in the progress circle

Solution

Run progress animation on componentDidMount. This will not only update progress, but also animates progress circle to given default progress.

@mu29mu29 changed the title Set progressValue to the value passed in props on constructorRuns the animation when the default progress is givenNov 22, 2018
@mu29mu29 changed the title Runs the animation when the default progress is givenSet progress text properly and runs the animation when the default progress is givenNov 22, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mu29