1+ /*
2+ * @Author : yinyongqian
3+ * @Description :
4+ * @Date : 2018-11-13 14:45:11
5+ * @LastEditors : yinyongqian
6+ * @LastEditTime : 2019-02-19 10:18:39
7+ */
8+
19/**
210 * Sample React Native App
311 * https://github.com/facebook/react-native
@@ -10,33 +18,47 @@ import {
1018 Text ,
1119 View ,
1220 TouchableOpacity ,
13- Dimensions
21+ Dimensions ,
22+ ScrollView
1423} from 'react-native' ;
15- import { RRCAlert , RRCLoading } from './src' ;
16- import LoadingImage from './src/img/loading.gif' ;
24+ import { RRCAlert , RRCLoading , RRCToast } from './src' ;
25+ import LoadingImage from './src/img/car_list_loading.gif' ;
26+ import AlertImage from './src/img/alert.png' ;
27+ import SuccessImage from './src/img/success.png' ;
28+
1729export default class App extends Component {
1830 constructor ( props ) {
1931 super ( props ) ;
2032 RRCLoading . setLoadingOptions ( {
21- loadingImage : LoadingImage ,
2233 text : 'gogogo' ,
23- loadingBackgroundColor : 'rgba(0,0,0,0.5)' ,
24- loadingViewBackgroundColor : 'rgba(0,0,0,0)'
34+ loadingBackgroundColor : 'rgba(0,0,0,0.0)' ,
35+ loadingImage : LoadingImage ,
36+ loadingViewStyle : { backgroundColor : 'rgba(0,0,0,0.8)' } ,
37+ loadingTextStyle : { }
2538 } )
26- RRCAlert . setAlertOptions ( {
27- alertBackgroundColor : 'rgba(0,0,0,0.3)'
39+ // RRCAlert.setAlertOptions({
40+ // alertBackgroundColor: 'rgba(0,0,0,0.3)',
41+ // titleViewStyle: {},
42+ // titleTextStyle: {},
43+ // contentTextStyle: {}
44+ // })
45+ RRCToast . setToastOptions ( {
46+ toastIcons : [ AlertImage , SuccessImage ] ,
47+ toastBackgroundColor : 'rgba(0,0,0,0)' ,
48+ toastViewStyle : { } ,
49+ toastTextStyle : { } ,
50+ durationTime : 3000
2851 } )
2952 }
3053 render ( ) {
3154 return (
32- < View style = { styles . container } >
55+ < ScrollView style = { { flex : 1 , marginBottom : 44 , marginTop : 34 } } >
3356 < TouchableOpacity onPress = { ( ) => {
34- RRCLoading . show ( '努力加载中 ...' )
57+ RRCLoading . show ( '加载中 ...' )
3558 RRCLoading . setLoadingOptions ( {
36- loadingImage : '' ,
3759 text : 'gogogo' ,
3860 loadingBackgroundColor : 'rgba(0,0,0,0)' ,
39- loadingViewBackgroundColor : 'rgba(0,0,0,0.9)'
61+ loadingViewStyle : { backgroundColor : 'rgba(0,0,0,0.9)' }
4062 } )
4163 setTimeout ( ( ) => {
4264 RRCLoading . hide ( )
@@ -51,7 +73,7 @@ export default class App extends Component {
5173 } } >
5274 < Text style = { styles . welcome } >
5375 Alert normal
54- </ Text >
76+ </ Text >
5577 </ TouchableOpacity >
5678
5779
@@ -62,15 +84,15 @@ export default class App extends Component {
6284 text : 'loading' ,
6385 loadingImage : ''
6486 } )
65- RRCLoading . show ( 'Loading... ' )
87+ RRCLoading . show ( '加载中 ' )
6688 } , 1000 ) ;
6789 setTimeout ( ( ) => {
6890 RRCLoading . hide ( )
6991 } , 3000 ) ;
7092 } } >
7193 < Text style = { styles . welcome } >
7294 Alert normal >> show loading after 1 s >> hide loading after 3 s
73- </ Text >
95+ </ Text >
7496 </ TouchableOpacity >
7597
7698 < TouchableOpacity onPress = { ( ) => {
@@ -81,34 +103,38 @@ export default class App extends Component {
81103 } } >
82104 < Text style = { styles . welcome } >
83105 Alert nothing and show loading
84- </ Text >
106+ </ Text >
85107 </ TouchableOpacity >
86108
87109 < TouchableOpacity onPress = { ( ) => {
88110 RRCAlert . alert ( 'title title' )
89111 } } >
90112 < Text style = { styles . welcome } >
91113 Alert title only
92- </ Text >
114+ </ Text >
93115 </ TouchableOpacity >
94116 < TouchableOpacity onPress = { ( ) => {
95117 RRCAlert . alert ( 'only title && very looooooooooooooooooooooooooooooong' )
96118 } } >
97119 < Text style = { styles . welcome } >
98120 Alert long title only
99- </ Text >
121+ </ Text >
100122 </ TouchableOpacity >
101123 < TouchableOpacity onPress = { ( ) => {
102124 RRCAlert . alert (
103125 null ,
104- 'content content content content content content content content content content ' ,
126+ '这是Alert的内容,如果内容很多会自动折行,行高20 ' ,
105127 [ { text : '确定' } ]
106128 )
129+ // 可以中途修改样式
130+ // RRCAlert.setAlertOptions({
131+ // contentTextStyle: {backgroundColor: 'red'}
132+ // })
107133
108134 } } >
109135 < Text style = { styles . welcome } >
110136 Alert content only
111- </ Text >
137+ </ Text >
112138 </ TouchableOpacity >
113139 < TouchableOpacity onPress = { ( ) => {
114140 RRCAlert . alert (
@@ -122,18 +148,12 @@ export default class App extends Component {
122148 } ] ,
123149 ( index ) => {
124150 console . log ( `index = ${ index } clicked` ) ;
125- } ,
126- {
127- contentTextStyle : {
128- fontSize : 14 ,
129- textAlign : 'left'
130- }
131151 }
132152 )
133153 } } >
134154 < Text style = { styles . welcome } >
135155 Alert mutltiple lines
136- </ Text >
156+ </ Text >
137157 </ TouchableOpacity >
138158
139159
@@ -157,10 +177,45 @@ export default class App extends Component {
157177 } } >
158178 < Text style = { styles . welcome } >
159179 Alert with three buttons >> Alert normal after 2 s
160- </ Text >
180+ </ Text >
181+ </ TouchableOpacity >
182+ < TouchableOpacity onPress = { ( ) => {
183+ RRCAlert . alert ( 'normal' ) ;
184+ RRCToast . show ( '操作成功,可以继续' , 1 , 1000 ) ;
185+ } } >
186+ < Text style = { styles . welcome } >
187+ show toast and alert
188+ </ Text >
161189 </ TouchableOpacity >
162190
163- </ View >
191+ < TouchableOpacity onPress = { ( ) => {
192+ RRCToast . show ( '操作成功' ) ;
193+ } } >
194+ < Text style = { styles . welcome } >
195+ show toast text only (one line)
196+ </ Text >
197+ </ TouchableOpacity >
198+
199+ < TouchableOpacity onPress = { ( ) => {
200+ RRCToast . show ( '操作成功,可以继续,操作成功,可以继续,操作成功,可以继续,操作成功,可以继续,5s后消失' , null , 5000 ) ;
201+ } } >
202+ < Text style = { styles . welcome } >
203+ show toast text only (multiple lines)
204+ </ Text >
205+ </ TouchableOpacity >
206+
207+ < TouchableOpacity onPress = { ( ) => {
208+ RRCLoading . show ( '正在上传图片...' ) ;
209+ setTimeout ( ( ) => {
210+ RRCLoading . hide ( )
211+ RRCToast . show ( '操作成功' , 1 ) ;
212+ } , 2000 ) ;
213+ } } >
214+ < Text style = { styles . welcome } >
215+ loading 2s later hide loading and show toast
216+ </ Text >
217+ </ TouchableOpacity >
218+ </ ScrollView >
164219 ) ;
165220 }
166221}
@@ -170,8 +225,7 @@ const styles = StyleSheet.create({
170225 flex : 1 ,
171226 justifyContent : 'center' ,
172227 alignItems : 'center' ,
173- // backgroundColor: '#fd521d'
174-
228+ backgroundColor : '#ccc'
175229 } ,
176230 welcome : {
177231 fontSize : 20 ,
0 commit comments