Skip to content

Commit 7156762

Browse files
committed
init
0 parents  commit 7156762

Some content is hidden

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

46 files changed

+2445
-0
lines changed

.gitignore

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history
38+
39+
40+
.idea

.npmignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.idea
2+
Screenshots
3+
.gif
4+
5+
# OSX
6+
#
7+
.DS_Store
8+
9+
# Xcode
10+
#
11+
build/
12+
*.pbxuser
13+
!default.pbxuser
14+
*.mode1v3
15+
!default.mode1v3
16+
*.mode2v3
17+
!default.mode2v3
18+
*.perspectivev3
19+
!default.perspectivev3
20+
xcuserdata
21+
*.xccheckout
22+
*.moved-aside
23+
DerivedData
24+
*.hmap
25+
*.ipa
26+
*.xcuserstate
27+
28+
# node.js
29+
#
30+
node_modules/
31+
npm-debug.log
32+
examples/

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Jia PengHui
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# react-native-easy-toast
2+
A react native module to show toast like android, it works on iOS and Android.
3+
4+
5+
## Content
6+
7+
- [Installation](#installation)
8+
- [Demo](#demo)
9+
- [Getting started](#getting-started)
10+
- [API](#api)
11+
- [Contribution](#contribution)
12+
13+
## Installation
14+
15+
* 1.Run `npm i react-native-easy-toast --save`
16+
* 2.`import Toast, {DURATION} from 'react-native-toast-easy'`
17+
18+
## Demo
19+
* [Examples](https://github.com/crazycodeboy/react-native-easy-toast/tree/master/examples)
20+
21+
![Screenshots](https://raw.githubusercontent.com/crazycodeboy/react-native-easy-toast/master/examples/Screenshots/react-native-easy-toast-screenshots.gif)
22+
23+
## Getting started
24+
25+
Add `react-native-toast-easy` to your js file.
26+
27+
`import Toast, {DURATION} from 'react-native-toast-easy'`
28+
29+
Inside your component's render method, use Toast:
30+
31+
```javascript
32+
render() {
33+
return (
34+
<View style={styles.container}>
35+
...
36+
<Toast ref="toast"/>
37+
</View>
38+
);
39+
}
40+
```
41+
42+
>Note: Add it in the bottom of the root view.
43+
44+
Then you can use it like this:
45+
46+
```javascript
47+
this.refs.toast.show('hello world!');
48+
```
49+
50+
That's it, you're ready to go!
51+
52+
53+
### Basic usage
54+
55+
```javascript
56+
render() {
57+
return (
58+
<View style={styles.container}>
59+
<TouchableHighlight
60+
style={{padding: 10}}
61+
onPress={()=>{
62+
this.refs.toast.show('hello world!');
63+
}}>
64+
<Text>Press me</Text>
65+
</TouchableHighlight>
66+
<Toast ref="toast"/>
67+
</View>
68+
);
69+
}
70+
```
71+
72+
### Custom Toast
73+
74+
```javascript
75+
render() {
76+
return (
77+
<View style={styles.container}>
78+
<TouchableHighlight
79+
style={{padding: 10}}
80+
onPress={()=>{
81+
this.refs.toast.show('hello world!',DURATION.LENGTH_LONG);
82+
}}>
83+
<Text>Press me</Text>
84+
</TouchableHighlight>
85+
<Toast
86+
ref="toast"
87+
style={{backgroundColor:'red'}}
88+
position='top'
89+
/>
90+
</View>
91+
);
92+
}
93+
```
94+
95+
**More Usage:**
96+
97+
[GitHubPopular](https://github.com/crazycodeboy/GitHubPopular/blob/develop/js/page/SearchPage.js)
98+
99+
100+
101+
## API
102+
103+
104+
Props | Type | Optional | Default | Description
105+
----------------- | -------- | -------- | ----------- | -----------
106+
style | View.propTypes.style | true | {backgroundColor: 'black',opacity: OPACITY,borderRadius: 5,padding: 10,} | Custom style toast
107+
position | PropTypes.oneOf(['top','center','bottom',]) |true | 'bottom' | Custom toast position
108+
109+
110+
111+
Method | Type | Optional | Description
112+
----------------- | -------- | -------- | ----------- | -----------
113+
show(text, duration) | function | false | show a toast
114+
close() | function | true | Close toast early
115+
116+
117+
## Contribution
118+
119+
Issues 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.
120+
121+
Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.
122+
123+
---
124+
125+
**MIT Licensed**

examples/.buckconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

examples/.flowconfig

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*[.]android.js
5+
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
8+
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
11+
12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
14+
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
17+
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
20+
21+
# Ignore duplicate module providers
22+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
.*/Libraries/react-native/ReactNative.js
25+
.*/node_modules/jest-runtime/build/__tests__/.*
26+
27+
[include]
28+
29+
[libs]
30+
node_modules/react-native/Libraries/react-native/react-native-interface.js
31+
node_modules/react-native/flow
32+
flow/
33+
34+
[options]
35+
module.system=haste
36+
37+
esproposal.class_static_fields=enable
38+
esproposal.class_instance_fields=enable
39+
40+
experimental.strict_type_args=true
41+
42+
munge_underscores=true
43+
44+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
45+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
46+
47+
suppress_type=$FlowIssue
48+
suppress_type=$FlowFixMe
49+
suppress_type=$FixMe
50+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
53+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
54+
55+
unsafe.enable_getters_and_setters=true
56+
57+
[version]
58+
^0.30.0

examples/.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IJ
26+
#
27+
*.iml
28+
.idea
29+
.gradle
30+
local.properties
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
android/keystores/debug.keystore

examples/.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Loading

0 commit comments

Comments
 (0)