@@ -15,6 +15,7 @@ import {
15
15
StatusBar ,
16
16
ActivityIndicator ,
17
17
ScrollView ,
18
+ InteractionManager ,
18
19
LayoutAnimation
19
20
} from 'react-native' ;
20
21
import * as dialogType from '../redux/actions/dialogType' ;
@@ -23,8 +24,7 @@ import * as actionCreators from '../redux/actions/loginActions';
23
24
import CodePush from 'react-native-code-push' ;
24
25
import Modal from 'react-native-modalbox' ;
25
26
import * as CONFIG from '../equipment/ComponentUtil' ;
26
- import { ListRow , Toast } from 'teaset' ;
27
- import ToastView from '../equipment/ToastUtil' ;
27
+ import { ListRow } from 'teaset' ;
28
28
import PopupDialog from '../modules/PopupDialog' ;
29
29
import MaskedView from '../modules/MaskedView' ;
30
30
let components = [ Text , TextInput ] ;
@@ -43,7 +43,7 @@ components.map((item, index) => {
43
43
} ;
44
44
item . prototype . render = function render ( ) {
45
45
let oldProps = this . props ;
46
- this . props = { ...this . props , ...customProps , style : [ this . props . style ] } ;
46
+ this . props = { ...this . props , ...customProps , style : [ customProps . style , this . props . style ] } ;
47
47
try {
48
48
return TextRender . apply ( this , arguments ) ;
49
49
} finally {
@@ -133,36 +133,61 @@ class LoginScreenView extends Component {
133
133
this . props . showDialog ( diaOptin ) ;
134
134
} ;
135
135
onCheckForUpdate = ( ) => {
136
- ToastView . showCustom ( '检测更新' ) ;
136
+ this . props . showDialog ( dialogType . UPDATE_DIALOG ) ;
137
137
CodePush . checkForUpdate ( CONFIG . CODEPUS_KEY )
138
138
. then ( update => {
139
- ToastView . hideCustom ( ) ;
140
139
if ( ! update ) {
141
- Toast . smile ( '暂无更新' , 1500 ) ;
140
+ InteractionManager . runAfterInteractions ( ( ) => {
141
+ this . props . showDialog ( dialogType . UP_TO_DATE ) ;
142
+ setTimeout ( ( ) => {
143
+ this . props . hideDialog ( ) ;
144
+ } , 1000 ) ;
145
+ } ) ;
142
146
} else {
143
- Alert . alert ( '有可用更新' + update . label , update . description , [
144
- { text : '取消' , onPress : ( ) => console . log ( 'Cancel Pressed' ) , style : 'destructive' } ,
145
- {
146
- text : '更新' ,
147
- onPress : ( ) => {
148
- update
149
- . download ( mess => {
150
- let receivedBytes = ( mess . receivedBytes / 1024 ) . toFixed ( 3 ) ;
151
- let totalBytes = ( mess . totalBytes / 1024 ) . toFixed ( 3 ) ;
152
- let per = parseInt ( receivedBytes / totalBytes * 100 ) ;
153
- this . setState ( { per } ) ;
154
- } )
155
- . then ( LocalPackage => {
156
- LocalPackage . install ( CodePush . InstallMode . IMMEDIATE , 0 ) ;
157
- } ) ;
147
+ //this.props.showDialog(dialogType.AWAITING_USER_ACTION);
148
+ InteractionManager . runAfterInteractions ( ( ) => {
149
+ Alert . alert ( '有可用更新' + update . label , update . description , [
150
+ {
151
+ text : '取消' ,
152
+ onPress : ( ) => {
153
+ this . props . showDialog ( dialogType . UPDATE_IGNORED ) ;
154
+ setTimeout ( ( ) => {
155
+ this . props . hideDialog ( ) ;
156
+ } , 500 ) ;
157
+ }
158
+ } ,
159
+ {
160
+ text : '更新' ,
161
+ onPress : ( ) => {
162
+ update
163
+ . download ( mess => {
164
+ let receivedBytes = ( mess . receivedBytes / 1024 ) . toFixed ( 3 ) ;
165
+ let totalBytes = ( mess . totalBytes / 1024 ) . toFixed ( 3 ) ;
166
+ let per = parseInt ( receivedBytes / totalBytes * 100 ) ;
167
+ this . props . showDialog ( dialogType . DOWNLOADING_PACKAGE ( per ) ) ;
168
+ //this.props.downSchedule(per);
169
+ } )
170
+ . then ( LocalPackage => {
171
+ InteractionManager . runAfterInteractions ( ( ) => {
172
+ this . props . showDialog ( dialogType . UPDATE_INSTALLED ) ;
173
+ setTimeout ( ( ) => {
174
+ LocalPackage . install ( CodePush . InstallMode . IMMEDIATE , 0 ) ;
175
+ } , 500 ) ;
176
+ } ) ;
177
+ } ) ;
178
+ }
158
179
}
159
- }
160
- ] ) ;
180
+ ] ) ;
181
+ } ) ;
161
182
}
162
183
} )
163
184
. catch ( error => {
164
- ToastView . hideCustom ( ) ;
165
- Toast . sad ( '更新失败' , 1500 ) ;
185
+ InteractionManager . runAfterInteractions ( ( ) => {
186
+ this . props . showDialog ( dialogType . UNKNOWN_ERROR ) ;
187
+ setTimeout ( ( ) => {
188
+ this . props . hideDialog ( ) ;
189
+ } , 1000 ) ;
190
+ } ) ;
166
191
} ) ;
167
192
} ;
168
193
render ( ) {
@@ -179,7 +204,6 @@ class LoginScreenView extends Component {
179
204
titlePlace = "top"
180
205
detailStyle = { [ styles . counterTextRed , this . props . state . theme . styles . navFont ] }
181
206
/>
182
- < ListRow title = "更新进度:" detail = { this . state . per } />
183
207
< ListRow title = "isLoggedIn:" detail = { this . props . state . login . isLoggedIn + '' } />
184
208
< ListRow title = "status:" detail = { this . props . state . login . status + '' } />
185
209
< ListRow
@@ -213,7 +237,7 @@ class LoginScreenView extends Component {
213
237
) ;
214
238
} }
215
239
title = { 'SyanImagePicker' }
216
- bgColor = "#188eee "
240
+ bgColor = "#5ACBC8 "
217
241
/>
218
242
</ View >
219
243
@@ -261,16 +285,18 @@ const mapStateToProps = state => {
261
285
isLoggedIn : state . login . isLoggedIn ,
262
286
status : state . login . status ,
263
287
state : state ,
264
- theme : state . theme
288
+ theme : state . theme ,
289
+ schedule : state . schedule
265
290
} ;
266
291
} ;
267
292
const mapDispatchToProps = ( dispatch , ownProps ) => {
268
293
return {
269
294
actions : bindActionCreators ( actionCreators , dispatch ) ,
270
- showDialog : option => dispatch ( option ) ,
295
+ showDialog : DIALOG => dispatch ( DIALOG ) ,
271
296
hideDialog : ( ) => dispatch ( dialogType . HIDE_DIALOG ) ,
272
297
setTheme : ( ) => dispatch ( { type : 'DARK_THEME' } ) ,
273
- setDefaultTheme : ( ) => dispatch ( { type : 'DEFAULT_THEME' } )
298
+ setDefaultTheme : ( ) => dispatch ( { type : 'DEFAULT_THEME' } ) ,
299
+ downSchedule : schedule => dispatch ( { type : 'STARE_DOWNLOADING' , schedule : schedule } )
274
300
} ;
275
301
} ;
276
302
export default connect ( mapStateToProps , mapDispatchToProps ) ( LoginScreenView ) ;
0 commit comments