price dot fix
parent
72df9c777c
commit
2826d56a73
|
|
@ -51,7 +51,7 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
),
|
||||
),
|
||||
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: <Widget>[
|
||||
|
|
@ -74,7 +74,9 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
labelText: 'Количество',
|
||||
prefixText: ' ',
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: false,),
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: false,
|
||||
),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
WhitelistingTextInputFormatter.digitsOnly
|
||||
],
|
||||
|
|
@ -90,7 +92,8 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
labelText: 'Стоимость',
|
||||
prefixText: ' ',
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
keyboardType:
|
||||
const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
WhitelistingTextInputFormatter(RegExp("^[0-9.]*")),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -49,23 +49,36 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
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: <Widget>[
|
||||
Text(dataText() , style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black26, fontSize: 15 ),),
|
||||
Text(
|
||||
dataText(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black26,
|
||||
fontSize: 15),
|
||||
),
|
||||
buildStoreConnector(),
|
||||
verticalSpaceLarge,
|
||||
_buildBodyContent(),
|
||||
|
|
@ -76,28 +89,34 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
);
|
||||
}
|
||||
|
||||
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<AppState, CalcState>(
|
||||
converter: (store) => store.state.calcState,
|
||||
builder: (_, vm) {
|
||||
return Text('${totalCalc(vm.calcItems)} тнг', style: TextStyle(
|
||||
return Text('${totalCalc(vm.calcItems)} тнг',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
fontSize: 35));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
return StoreConnector<AppState, KassaState>(
|
||||
converter: (store) => store.state.kassaState,
|
||||
builder: (_, vm) {
|
||||
return Text('${totalKassa(vm.kassaItems)} тнг', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black87, fontSize: 35 ));
|
||||
}
|
||||
);
|
||||
return Text('${totalKassa(vm.kassaItems)} тнг',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
fontSize: 35));
|
||||
});
|
||||
}
|
||||
|
||||
Expanded _buildBodyContent() {
|
||||
|
|
@ -109,63 +128,98 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
Expanded(child: BusyButton(title: 'Оплатить картой', onPressed:() { pressPayment('card');}, mainColor: greenColor,)),
|
||||
Expanded(
|
||||
child: BusyButton(
|
||||
title: 'Оплатить картой',
|
||||
onPressed: () {
|
||||
pressPayment('card');
|
||||
},
|
||||
mainColor: greenColor,
|
||||
)),
|
||||
horizontalSpaceSmall,
|
||||
Expanded(child: BusyButton(title: 'Наличными', onPressed:() { pressPayment('cash');}, mainColor: primaryColor,)),
|
||||
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: 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<ProductDao> kassaItems = _state.kassaState.kassaItems;
|
||||
List<CalcModel> calcItems = _state.calcState.calcItems;
|
||||
Response<dynamic> response = await _dataService.sellOrReturn(token: _token, kassaItems: kassaItems, paymentType: type, operationType: widget.model.operationType, tradeType: _tradeType, calcItems: calcItems, mode: _mode );
|
||||
Response<dynamic> 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<ProductDao> 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<PaymentView> {
|
|||
String totalCalc(List<CalcModel> 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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue