在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:crazycodeboy/react-native-easy-toast开源软件地址:https://github.com/crazycodeboy/react-native-easy-toast开源编程语言:JavaScript 100.0%开源软件介绍:react-native-easy-toastA react native module to show toast like android, it works on iOS and Android. ContentInstallation
DemoGetting startedAdd
Inside your component's render method, use Toast: render() {
return (
<View>
...
<Toast ref={(toast) => this.toast = toast}/>
</View>
);
}
Then you can use it like this: this.toast.show('hello world!'); That's it, you're ready to go! show a toast, and execute callback function when toast close it: this.toast.show('hello world!', 500, () => {
// something you want to do at close
}); Show a toast forever until you manually close it: this.toast.show('hello world!', DURATION.FOREVER); Or pass an element: this.toast.show(<View><Text>hello world!</Text></View>);
// later on:
this.toast.close('hello world!'); Optional you can pass a delay in seconds to the close()-method: this.toast.close('hello world!', 500); Currently, the default delay for close() in FOREVER-mode is set to 250 ms (or this.props.defaultCloseDelay, which you can pass with) <Toast ... defaultCloseDelay={100} /> Basic usagerender() {
return (
<View>
<Button title={'Press me'} onPress={()=>{
this.toast.show('hello world!',2000);
}}/>
<Toast ref={(toast) => this.toast = toast}/>
</View>
);
} Custom Toastrender() {
return (
<View>
<Button title={'Press me'} onPress={()=>{
this.toast.show('hello world!',2000);
}}/>
<Toast
ref={(toast) => this.toast = toast}
style={{backgroundColor:'red'}}
position='top'
positionValue={200}
fadeInDuration={750}
fadeOutDuration={1000}
opacity={0.8}
textStyle={{color:'red'}}
/>
</View>
);
} More Usage: API
ContributionIssues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples. Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first. MIT Licensed |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论