From 2826d56a73415beb52dc71348e6f2bd38909b632 Mon Sep 17 00:00:00 2001 From: Serik Uvaissov Date: Thu, 2 Jul 2020 15:50:34 +0600 Subject: [PATCH] price dot fix --- .../tabs/kassaView/ProductAddBottomSheet.dart | 9 +- lib/views/payment/payment_view.dart | 162 ++++++++++++------ 2 files changed, 114 insertions(+), 57 deletions(-) diff --git a/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart b/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart index e3282e7..cc8134e 100644 --- a/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart +++ b/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart @@ -51,7 +51,7 @@ class _ProductAddBottomSheetState extends State { ), ), body: Padding( - padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10), + padding: const EdgeInsets.only(top: 15, left: 10, right: 15), child: ListView( controller: widget.scrollController, children: [ @@ -74,7 +74,9 @@ class _ProductAddBottomSheetState extends State { labelText: 'Количество', prefixText: ' ', ), - keyboardType: const TextInputType.numberWithOptions(decimal: false,), + keyboardType: const TextInputType.numberWithOptions( + decimal: false, + ), inputFormatters: [ WhitelistingTextInputFormatter.digitsOnly ], @@ -90,7 +92,8 @@ class _ProductAddBottomSheetState extends State { labelText: 'Стоимость', prefixText: ' ', ), - keyboardType: const TextInputType.numberWithOptions(decimal: true), + keyboardType: + const TextInputType.numberWithOptions(decimal: true), inputFormatters: [ WhitelistingTextInputFormatter(RegExp("^[0-9.]*")), ], diff --git a/lib/views/payment/payment_view.dart b/lib/views/payment/payment_view.dart index 069df6b..5cff5fc 100644 --- a/lib/views/payment/payment_view.dart +++ b/lib/views/payment/payment_view.dart @@ -49,24 +49,37 @@ class _PaymentViewState extends State { Widget build(BuildContext context) { return WillPopScope( onWillPop: () { - if (!isBusy) - Navigator.pop(context); + if (!isBusy) Navigator.pop(context); return new Future(() => false); }, child: Scaffold( appBar: AppBar( + brightness: Brightness.light, backgroundColor: whiteColor, elevation: 0, - leading: IconButton(icon: Icon(Icons.arrow_back_ios), color: Colors.black87, onPressed: () => Navigator.pop(context),), - title: Text(dataTitle(), style: TextStyle(color: Colors.black87),), + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + color: Colors.black87, + onPressed: () => Navigator.pop(context), + ), + title: Text( + dataTitle(), + style: TextStyle(color: Colors.black87), + ), ), body: Container( - padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0 ), + padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(dataText() , style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black26, fontSize: 15 ),), - buildStoreConnector(), + Text( + dataText(), + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black26, + fontSize: 15), + ), + buildStoreConnector(), verticalSpaceLarge, _buildBodyContent(), ], @@ -76,96 +89,137 @@ class _PaymentViewState extends State { ); } - String dataTitle() => widget.model.operationType == OperationTypePay ? 'Оплата' : 'Возврат'; + String dataTitle() => + widget.model.operationType == OperationTypePay ? 'Оплата' : 'Возврат'; - String dataText() => widget.model.operationType == OperationTypePay ? 'К оплате' : 'К возврату'; + String dataText() => widget.model.operationType == OperationTypePay + ? 'К оплате' + : 'К возврату'; StoreConnector buildStoreConnector() { - if(widget.model.mode == SettingModeCalc) { + if (widget.model.mode == SettingModeCalc) { return StoreConnector( converter: (store) => store.state.calcState, builder: (_, vm) { - return Text('${totalCalc(vm.calcItems)} тнг', style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black87, - fontSize: 35)); - } - ); + return Text('${totalCalc(vm.calcItems)} тнг', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black87, + fontSize: 35)); + }); } return StoreConnector( - converter: (store) => store.state.kassaState, - builder: (_, vm) { - return Text('${totalKassa(vm.kassaItems)} тнг', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black87, fontSize: 35 )); - } - ); + converter: (store) => store.state.kassaState, + builder: (_, vm) { + return Text('${totalKassa(vm.kassaItems)} тнг', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black87, + fontSize: 35)); + }); } Expanded _buildBodyContent() { return Expanded( - child: Column( + child: Column( + children: [ + Container( + height: 150, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Container( - height: 150, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded(child: BusyButton(title: 'Оплатить картой', onPressed:() { pressPayment('card');}, mainColor: greenColor,)), - horizontalSpaceSmall, - Expanded(child: BusyButton(title: 'Наличными', onPressed:() { pressPayment('cash');}, mainColor: primaryColor,)), - ], - ), - ), - verticalSpaceLarge, - Expanded(child: Container(),), - Container(child: BusyButton(title: 'Отмена', onPressed:() { Navigator.pop(context);} , mainColor: redColor,)), + Expanded( + child: BusyButton( + title: 'Оплатить картой', + onPressed: () { + pressPayment('card'); + }, + mainColor: greenColor, + )), + horizontalSpaceSmall, + Expanded( + child: BusyButton( + title: 'Наличными', + onPressed: () { + pressPayment('cash'); + }, + mainColor: primaryColor, + )), ], ), - ); + ), + verticalSpaceLarge, + Expanded( + child: Container(), + ), + Container( + child: BusyButton( + title: 'Отмена', + onPressed: () { + Navigator.pop(context); + }, + mainColor: redColor, + )), + ], + ), + ); } pressPayment(String type) async { - setState(() { isBusy = true; }); + setState(() { + isBusy = true; + }); Dialogs.showLoadingDialog(context, _keyLoader); try { AppState _state = Redux.store.state; String _token = _state.userState.user.token; String _tradeType = _state.settingState.tradeType; String _mode = _state.settingState.mode; - if(_mode == SettingModeCalc){ + if (_mode == SettingModeCalc) { _tradeType = SettingTradeTypeGood; } List kassaItems = _state.kassaState.kassaItems; List calcItems = _state.calcState.calcItems; - Response response = await _dataService.sellOrReturn(token: _token, kassaItems: kassaItems, paymentType: type, operationType: widget.model.operationType, tradeType: _tradeType, calcItems: calcItems, mode: _mode ); + Response response = await _dataService.sellOrReturn( + token: _token, + kassaItems: kassaItems, + paymentType: type, + operationType: widget.model.operationType, + tradeType: _tradeType, + calcItems: calcItems, + mode: _mode); Navigator.of(context, rootNavigator: true).pop(); - setState(() { isBusy = false; }); - if(response.operation){ + setState(() { + isBusy = false; + }); + if (response.operation) { String message = response.body['message']; String check = response.body['check']; - if(_mode == SettingModeCalc){ + if (_mode == SettingModeCalc) { Redux.store.dispatch(cleanCalcItems); - } else if(_mode == SettingModeKassa) { + } 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) { + _navigatorService.push(ImageShowRoute, + arguments: ImageShowModel(check, message)); + } else if (!response.operation && response.status != 500) { _dialogService.showDialog(description: response.body['message']); } - } catch(e) { + } catch (e) { //Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop(); - setState(() { isBusy = false; }); + setState(() { + isBusy = false; + }); } - - } String totalKassa(List kassaItems) { num total = 0.0; kassaItems.forEach((element) { - total+= element.total == null ? 0.0 : element.total.toDouble(); + total += element.total == null ? 0.0 : element.total.toDouble(); }); return total.toString(); } @@ -173,12 +227,12 @@ class _PaymentViewState extends State { String totalCalc(List items) { num total = 0.0; items.forEach((element) { - if(element.operation == Calculations.MULTIPLY) { + if (element.operation == Calculations.MULTIPLY) { double num1 = element.num1 == null ? 0.0 : double.parse(element.num1); double num2 = element.num2 == null ? 0.0 : double.parse(element.num2); total += num1 * num2; } else { - total+= element.num1 == null ? 0.0 : double.parse(element.num1); + total += element.num1 == null ? 0.0 : double.parse(element.num1); } }); return total.toString(); @@ -189,4 +243,4 @@ class PaymentModel { String operationType; String mode; PaymentModel({this.mode, this.operationType}); -} \ No newline at end of file +}