@@ -15,6 +15,7 @@ import {
1515 StatusBar ,
1616 ActivityIndicator ,
1717 ScrollView ,
18+ InteractionManager ,
1819 LayoutAnimation
1920} from 'react-native' ;
2021import * as dialogType from '../redux/actions/dialogType' ;
@@ -23,8 +24,7 @@ import * as actionCreators from '../redux/actions/loginActions';
2324import CodePush from 'react-native-code-push' ;
2425import Modal from 'react-native-modalbox' ;
2526import * as CONFIG from '../equipment/ComponentUtil' ;
26- import { ListRow , Toast } from 'teaset' ;
27- import ToastView from '../equipment/ToastUtil' ;
27+ import { ListRow } from 'teaset' ;
2828import PopupDialog from '../modules/PopupDialog' ;
2929import MaskedView from '../modules/MaskedView' ;
3030let components = [ Text , TextInput ] ;
@@ -43,7 +43,7 @@ components.map((item, index) => {
4343 } ;
4444 item . prototype . render = function render ( ) {
4545 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 ] } ;
4747 try {
4848 return TextRender . apply ( this , arguments ) ;
4949 } finally {
@@ -133,36 +133,61 @@ class LoginScreenView extends Component {
133133 this . props . showDialog ( diaOptin ) ;
134134 } ;
135135 onCheckForUpdate = ( ) => {
136- ToastView . showCustom ( '检测更新' ) ;
136+ this . props . showDialog ( dialogType . UPDATE_DIALOG ) ;
137137 CodePush . checkForUpdate ( CONFIG . CODEPUS_KEY )
138138 . then ( update => {
139- ToastView . hideCustom ( ) ;
140139 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+ } ) ;
142146 } 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+ }
158179 }
159- }
160- ] ) ;
180+ ] ) ;
181+ } ) ;
161182 }
162183 } )
163184 . 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+ } ) ;
166191 } ) ;
167192 } ;
168193 render ( ) {
@@ -179,7 +204,6 @@ class LoginScreenView extends Component {
179204 titlePlace = "top"
180205 detailStyle = { [ styles . counterTextRed , this . props . state . theme . styles . navFont ] }
181206 />
182- < ListRow title = "更新进度:" detail = { this . state . per } />
183207 < ListRow title = "isLoggedIn:" detail = { this . props . state . login . isLoggedIn + '' } />
184208 < ListRow title = "status:" detail = { this . props . state . login . status + '' } />
185209 < ListRow
@@ -213,7 +237,7 @@ class LoginScreenView extends Component {
213237 ) ;
214238 } }
215239 title = { 'SyanImagePicker' }
216- bgColor = "#188eee "
240+ bgColor = "#5ACBC8 "
217241 />
218242 </ View >
219243
@@ -261,16 +285,18 @@ const mapStateToProps = state => {
261285 isLoggedIn : state . login . isLoggedIn ,
262286 status : state . login . status ,
263287 state : state ,
264- theme : state . theme
288+ theme : state . theme ,
289+ schedule : state . schedule
265290 } ;
266291} ;
267292const mapDispatchToProps = ( dispatch , ownProps ) => {
268293 return {
269294 actions : bindActionCreators ( actionCreators , dispatch ) ,
270- showDialog : option => dispatch ( option ) ,
295+ showDialog : DIALOG => dispatch ( DIALOG ) ,
271296 hideDialog : ( ) => dispatch ( dialogType . HIDE_DIALOG ) ,
272297 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 } )
274300 } ;
275301} ;
276302export default connect ( mapStateToProps , mapDispatchToProps ) ( LoginScreenView ) ;
0 commit comments