diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml index 304732f..9a30f5a 100644 --- a/android/app/src/main/res/drawable/launch_background.xml +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -4,9 +4,9 @@ - + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/splash.png b/android/app/src/main/res/mipmap-hdpi/splash.png new file mode 100644 index 0000000..e7f4164 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/splash.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/splash.png b/android/app/src/main/res/mipmap-mdpi/splash.png new file mode 100644 index 0000000..e7f4164 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/splash.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/splash.png b/android/app/src/main/res/mipmap-xhdpi/splash.png new file mode 100644 index 0000000..e7f4164 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/splash.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/splash.png b/android/app/src/main/res/mipmap-xxhdpi/splash.png new file mode 100644 index 0000000..e7f4164 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/splash.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/splash.png b/android/app/src/main/res/mipmap-xxxhdpi/splash.png new file mode 100644 index 0000000..e7f4164 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/splash.png differ diff --git a/lib/core/models/money.dart b/lib/core/models/money.dart new file mode 100644 index 0000000..a9b42b8 --- /dev/null +++ b/lib/core/models/money.dart @@ -0,0 +1,4 @@ +class Money { + final num total; + Money({this.total}); +} \ No newline at end of file diff --git a/lib/core/services/DataService.dart b/lib/core/services/DataService.dart index 6d173a5..4e47198 100644 --- a/lib/core/services/DataService.dart +++ b/lib/core/services/DataService.dart @@ -141,7 +141,22 @@ class DataService extends BaseService { return null; } + Future checkDbFill(User user) async { + int serviceCount = await _db.queryRowCount(Service_tableName); + if( serviceCount ==0) { + int goodCount = await _db.queryRowCount(Goog_tableName); + if(goodCount == 0){ + await getDataFromServer(user); + } else { + log.i('$Goog_tableName is Fill'); + } + } else { + log.i('$Service_tableName is Fill'); + } + } + Future getDataFromServer(User user) async { + log.i('Get Data from server'); try { String token = user.token; Response goods = await _api.getGoodsFromServer(token); diff --git a/lib/redux/actions/user_actions.dart b/lib/redux/actions/user_actions.dart index af8fb01..e6414f2 100644 --- a/lib/redux/actions/user_actions.dart +++ b/lib/redux/actions/user_actions.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:aman_kassa_flutter/core/locator.dart'; import 'package:aman_kassa_flutter/core/models/message.dart'; import 'package:aman_kassa_flutter/core/models/auth_response.dart'; +import 'package:aman_kassa_flutter/core/models/money.dart'; import 'package:aman_kassa_flutter/core/models/response.dart'; import 'package:aman_kassa_flutter/core/models/smena.dart'; import 'package:aman_kassa_flutter/core/models/user.dart'; @@ -77,6 +78,19 @@ Future logoutAction(Store store) async { } } +Future> checkMoney(Store store) async { + try { + Response result = await _api.money(store.state.userState.user.token); + if (result.operation) { + store.dispatch(SetUserStateAction( + UserState(money: Money(total: double.parse(result.body['money']))))); + } + return result; + } catch (error) { + return null; + } +} + ThunkAction authenticateToken(String token) { return (Store store) async { store.dispatch(SetUserStateAction(UserState(isLoading: true))); @@ -139,6 +153,7 @@ Future closeSmena(Store store) async { String token = store.state.userState.user.token; Response result = await _api.closeSmena(token); store.dispatch(SetUserStateAction(UserState(smena: result.body))); + store.dispatch(checkMoney); } Future openSmena(Store store) async { @@ -147,5 +162,6 @@ Future openSmena(Store store) async { store.dispatch(SetUserStateAction(UserState(smena: result.body))); if(result.operation){ store.dispatch(checkSmena); + store.dispatch(checkMoney); } } diff --git a/lib/redux/reducers/user_reducer.dart b/lib/redux/reducers/user_reducer.dart index 46120bf..080c133 100644 --- a/lib/redux/reducers/user_reducer.dart +++ b/lib/redux/reducers/user_reducer.dart @@ -11,5 +11,9 @@ userReducer(UserState prevState, SetUserStateAction action) { isAuthenticated: payload.isAuthenticated, loginFormMessage: payload.loginFormMessage, smena: payload.smena, + money: payload.money, + password: payload.password, + login: payload.login, + authenticateType: payload.authenticateType, ); } \ No newline at end of file diff --git a/lib/redux/state/user_state.dart b/lib/redux/state/user_state.dart index 19401eb..7d4a8e4 100644 --- a/lib/redux/state/user_state.dart +++ b/lib/redux/state/user_state.dart @@ -1,3 +1,4 @@ +import 'package:aman_kassa_flutter/core/models/money.dart'; import 'package:aman_kassa_flutter/core/models/smena.dart'; import 'package:aman_kassa_flutter/core/models/user.dart'; import 'package:meta/meta.dart'; @@ -13,6 +14,7 @@ class UserState { final LoginFormMessage loginFormMessage; final User user; final Smena smena; + final Money money; UserState( {this.isError, @@ -23,7 +25,8 @@ class UserState { this.password, this.user, this.loginFormMessage, - this.smena}); + this.smena, + this.money}); factory UserState.initial(UserState payload) => UserState( isLoading: false, @@ -35,6 +38,7 @@ class UserState { authenticateType: payload?.authenticateType ?? null, login: payload?.login ?? null, password: payload?.password ?? null, + money: Money(), ); UserState copyWith( @@ -47,6 +51,7 @@ class UserState { @required String authenticateType, @required String login, @required String password, + @required Money money, }) { return UserState( isError: isError ?? this.isError, @@ -58,6 +63,7 @@ class UserState { authenticateType: authenticateType ?? this.authenticateType, login: login ?? this.login, password: password ?? this.password, + money: money ?? this.money, ); } diff --git a/lib/views/home/components/popup_menu.dart b/lib/views/home/components/popup_menu.dart index 27b0eec..ab903db 100644 --- a/lib/views/home/components/popup_menu.dart +++ b/lib/views/home/components/popup_menu.dart @@ -4,9 +4,9 @@ import 'package:flutter/material.dart'; const List choices = const [ const Choice(title: 'Обновить номенклатуру', icon: Icons.update, command: 'update'), - const Choice(title: 'Помощь', icon: Icons.help, command: 'help'), - const Choice(title: 'О Программе', icon: Icons.info_outline, command: 'info'), - const Choice(title: 'Язык', icon: Icons.language, command: 'language'), + //const Choice(title: 'Помощь', icon: Icons.help, command: 'help'), + //const Choice(title: 'О Программе', icon: Icons.info_outline, command: 'info'), + //const Choice(title: 'Язык', icon: Icons.language, command: 'language'), const Choice(title: 'Выйти', icon: Icons.exit_to_app, command: 'exit') ]; diff --git a/lib/views/home/home_view.dart b/lib/views/home/home_view.dart index e8411ad..fdae2af 100644 --- a/lib/views/home/home_view.dart +++ b/lib/views/home/home_view.dart @@ -55,6 +55,7 @@ class _HomeViewState extends State { selectedTabIndex = 0; pageController = new PageController(initialPage: selectedTabIndex); Redux.store.dispatch(checkSmena); + _dataService.checkDbFill(Redux.store.state.userState.user); } @override diff --git a/lib/views/home/tabs/AdditionalTab.dart b/lib/views/home/tabs/AdditionalTab.dart index 0863b2f..6d75989 100644 --- a/lib/views/home/tabs/AdditionalTab.dart +++ b/lib/views/home/tabs/AdditionalTab.dart @@ -1,5 +1,6 @@ import 'package:aman_kassa_flutter/core/locator.dart'; import 'package:aman_kassa_flutter/core/models/message.dart'; +import 'package:aman_kassa_flutter/core/models/money.dart'; import 'package:aman_kassa_flutter/core/models/response.dart'; import 'package:aman_kassa_flutter/core/models/dialog_models.dart'; import 'package:aman_kassa_flutter/core/models/smena.dart'; @@ -104,9 +105,10 @@ class _AdditionalTabState extends State { if (response.confirmed) { Response result = await _api.deposit( Redux.store.state.userState.user.token, response.responseText); - //if(result.operation) { _dialog.showDialog(description: result.body['message']); - //} + if(result.operation) { + await Redux.store.dispatch(checkMoney); + } } } catch (e) { print(e); @@ -130,9 +132,10 @@ class _AdditionalTabState extends State { if (response.confirmed) { Response result = await _api.withdrawal( Redux.store.state.userState.user.token, response.responseText); - //if(result.operation) { _dialog.showDialog(description: result.body['message']); - //} + if(result.operation) { + await Redux.store.dispatch(checkMoney); + } } } catch (e) { print(e); @@ -148,16 +151,18 @@ class _AdditionalTabState extends State { isMoneyCheckBusy = true; }); try { - Response result = - await _api.money(Redux.store.state.userState.user.token); + Response result = await Redux.store.dispatch(checkMoney); + //await _api.money(.state.userState.user.token); setState(() { isMoneyCheckBusy = false; }); - if (result.operation) { - _dialog.showDialog( - description: 'Денег в кассе: ${result.body['money']}'); - } else { - _dialog.showDialog(description: '${result.body['message']}'); + if(result != null) { + if (result.operation) { + _dialog.showDialog( + description: 'Денег в кассе: ${result.body['money']}'); + } else { + _dialog.showDialog(description: '${result.body['message']}'); + } } } catch (e) { print(e); @@ -220,12 +225,17 @@ class _AdditionalTabState extends State { 'Денег в кассе:', style: TextStyle(color: primaryColor, fontSize: 15), ), - Text( - '250 024.38 тенге', - style: TextStyle( - color: primaryColor, - fontSize: 25, - fontWeight: FontWeight.bold), + StoreConnector( + converter: (store) => store.state.userState.money, + builder: (_, vm) { + return Text( + vm.total !=null ? '${vm.total} тенге' : 'нет информации', + style: TextStyle( + color: vm.total !=null ? primaryColor : Colors.grey.withOpacity(0.5), + fontSize: 25, + fontWeight: FontWeight.bold), + ); + } ), ], )), diff --git a/lib/views/payment/payment_view.dart b/lib/views/payment/payment_view.dart index 18a994a..069df6b 100644 --- a/lib/views/payment/payment_view.dart +++ b/lib/views/payment/payment_view.dart @@ -8,6 +8,7 @@ import 'package:aman_kassa_flutter/core/services/dialog_service.dart'; import 'package:aman_kassa_flutter/core/services/navigator_service.dart'; import 'package:aman_kassa_flutter/redux/actions/calc_actions.dart'; import 'package:aman_kassa_flutter/redux/actions/kassa_actions.dart'; +import 'package:aman_kassa_flutter/redux/actions/user_actions.dart'; import 'package:aman_kassa_flutter/redux/constants/operation_const.dart'; import 'package:aman_kassa_flutter/redux/constants/setting_const.dart'; import 'package:aman_kassa_flutter/redux/state/calc_state.dart'; @@ -141,12 +142,12 @@ class _PaymentViewState extends State { if(response.operation){ String message = response.body['message']; String check = response.body['check']; - -// if(_mode == SettingModeCalc){ -// Redux.store.dispatch(cleanCalcItems); -// } else if(_mode == SettingModeKassa) { -// Redux.store.dispatch(cleanKassaItems); -// } + if(_mode == SettingModeCalc){ + Redux.store.dispatch(cleanCalcItems); + } else if(_mode == SettingModeKassa) { + Redux.store.dispatch(cleanKassaItems); + } + Redux.store.dispatch(checkMoney); _navigatorService.pop(); _navigatorService.push(ImageShowRoute, arguments: ImageShowModel(check, message)); } else if(!response.operation && response.status !=500) {