Merge branch 'master' of http://gitea.a7.kz/dev/aman-kassa-flutter
commit
c83d055c64
|
|
@ -21,6 +21,7 @@
|
|||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class ApiService extends BaseService {
|
|||
'password': password
|
||||
};
|
||||
String response = await requestFormData('/authenticate', requestBody, statusCheck: statusCheck );
|
||||
|
||||
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
||||
return aman.body;
|
||||
}
|
||||
|
|
@ -38,7 +37,6 @@ class ApiService extends BaseService {
|
|||
'token': token
|
||||
};
|
||||
String response = await requestFormData('/activate_token', requestBody, statusCheck: statusCheck );
|
||||
|
||||
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
||||
return aman.body;
|
||||
}
|
||||
|
|
@ -52,7 +50,6 @@ class ApiService extends BaseService {
|
|||
Future<Response<dynamic>> logout(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/logout', requestBody);
|
||||
print(json.decode(response));
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
|
|
@ -74,19 +71,15 @@ class ApiService extends BaseService {
|
|||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<Response<Smena>> smena(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/smena', requestBody);
|
||||
|
||||
return Response.fromJson(json.decode(response), Smena.fromJson);
|
||||
}
|
||||
|
||||
Future<Response<Smena>> closeSmena(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/close_smena', requestBody);
|
||||
|
||||
return Response.fromJson(json.decode(response), Smena.fromJson);
|
||||
}
|
||||
|
||||
|
|
@ -99,21 +92,18 @@ class ApiService extends BaseService {
|
|||
Future<Response<dynamic>> xReport(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/report_x', requestBody);
|
||||
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
Future<Response<dynamic>> sell(String token, String checkData) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token, 'data': checkData};
|
||||
var response = await requestFormData('/sell', requestBody);
|
||||
print(response);
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
Future<Response<dynamic>> sellReturn(String token, String checkData) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token, 'data': checkData};
|
||||
var response = await requestFormData('/sell_return', requestBody);
|
||||
print(response);
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +118,6 @@ class ApiService extends BaseService {
|
|||
};
|
||||
if(Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
print(androidInfo.model);
|
||||
headers.addAll(<String, String>{
|
||||
HttpHeaders.userAgentHeader: androidInfo.model,
|
||||
});
|
||||
|
|
@ -136,7 +125,6 @@ class ApiService extends BaseService {
|
|||
|
||||
if(Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
print(iosInfo.utsname.machine);
|
||||
headers.addAll(<String, String>{
|
||||
HttpHeaders.userAgentHeader: iosInfo.utsname.machine,
|
||||
});
|
||||
|
|
@ -163,20 +151,17 @@ class ApiService extends BaseService {
|
|||
Future<Response<dynamic>> getGoodsFromServer(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/goods', requestBody);
|
||||
print(response);
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
|
||||
Future<Response<dynamic>> getCategoryFromServer(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/goods_category', requestBody);
|
||||
print(response);
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
Future<Response<dynamic>> getServiceFromServer(String token) async {
|
||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||
var response = await requestFormData('/services', requestBody);
|
||||
print(response);
|
||||
return Response.fromJsonDynamic(json.decode(response));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class AuthenticationService extends BaseService {
|
|||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +42,6 @@ class AuthenticationService extends BaseService {
|
|||
Future<bool> logout(String token) async {
|
||||
Response<Message> session = await _api.logout(token);
|
||||
if ("logout" == session.body.message) {
|
||||
//_session = session;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,4 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:aman_kassa_flutter/core/entity/Category.dart';
|
||||
import 'package:aman_kassa_flutter/core/entity/Goods.dart';
|
||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/dict_dao.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/product_dao.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/services/ApiService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/calc_state.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/kassa_state.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
|
@ -42,9 +27,6 @@ ThunkAction<AppState> onTapAction(String value) {
|
|||
return setEqual(store);
|
||||
}
|
||||
List calcItems = Calculator.action(value: value, items: store.state.calcState.calcItems);
|
||||
calcItems.asMap().forEach((index,element ) {
|
||||
print('#$index: ${element.toString()}');
|
||||
});
|
||||
store.dispatch(SetCalcStateAction(CalcState(calcItems: calcItems, isEqual: false)));
|
||||
};
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ ThunkAction<AppState> counterProductFromKassaItems(int index, int counter) {
|
|||
|
||||
ThunkAction<AppState> selectBottomElement(int parentId) {
|
||||
return (Store<AppState> store) async {
|
||||
store.dispatch(SetKassaStateAction(KassaState(bottomSheetLoading: true)));
|
||||
store.dispatch(SetKassaStateAction(KassaState(bottomSheetLoading: true, bottomSheetElements: [])));
|
||||
try {
|
||||
List<DictDao> prevCategories = store.state.kassaState.prevCategories;
|
||||
if (parentId == 0) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import 'package:redux/redux.dart';
|
|||
import 'package:redux_persist_flutter/redux_persist_flutter.dart';
|
||||
import 'package:redux_thunk/redux_thunk.dart';
|
||||
import 'package:redux_persist/redux_persist.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'actions/calc_actions.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -153,22 +153,31 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
priceController.text.isEmpty) {
|
||||
_showDialog();
|
||||
} else {
|
||||
Redux.store.dispatch(addCustomProductToKassaItems(nameController.text,
|
||||
int.parse(countController.text), double.parse(priceController.text), sum));
|
||||
Redux.store.dispatch(addCustomProductToKassaItems(
|
||||
nameController.text,
|
||||
int.parse(countController.text),
|
||||
double.parse(priceController.text),
|
||||
sum));
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
void calcOnChange(value) {
|
||||
setState(() {
|
||||
sum = 0;
|
||||
});
|
||||
double count = double.parse(countController.text);
|
||||
double price = double.parse(priceController.text);
|
||||
double result = count * price;
|
||||
setState(() {
|
||||
sum = ((result * 100).roundToDouble()) / 100;
|
||||
});
|
||||
try {
|
||||
setState(() {
|
||||
sum = 0;
|
||||
});
|
||||
if (countController.text != '' && priceController.text != '') {
|
||||
double count = double.parse(countController.text);
|
||||
double price = double.parse(priceController.text);
|
||||
double result = count * price;
|
||||
setState(() {
|
||||
sum = ((result * 100).roundToDouble()) / 100;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
void _showDialog() {
|
||||
|
|
@ -178,10 +187,13 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: new Text("Aman Касса"),
|
||||
content: new Text("Введите наименова, количество и цену"),
|
||||
content: new Text("Введите наименование, количество и цену"),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text("ОK", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
"ОK",
|
||||
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
|
|
@ -191,5 +203,4 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,60 +13,70 @@ class ProductListItem extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(item.name ?? 'name', style: productTextStyle,)),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(
|
||||
'${item.price?.toString()} x ${item.count?.toString()} = ${item.total?.toString()}',
|
||||
textAlign: TextAlign.right, style: productTextStyle)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
return Container(
|
||||
color: index % 2 == 1 ? fillColor : whiteColor,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(item.name ?? 'name', style: productTextStyle,)),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
//margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
buildClipRect(primaryColor,Icons.remove, () {
|
||||
Redux.store.dispatch(counterProductFromKassaItems(index, -1));
|
||||
}),
|
||||
buildClipRect(primaryColor,Icons.add, () {
|
||||
Redux.store.dispatch(counterProductFromKassaItems(index, 1));
|
||||
}),
|
||||
Expanded(
|
||||
child: Container(
|
||||
),
|
||||
),
|
||||
buildClipRect(redColor,Icons.close, () {
|
||||
Redux.store.dispatch(removeProductFromKassaItems(index));
|
||||
}),
|
||||
],
|
||||
)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(
|
||||
'${item.price?.toString()} x ${item.count?.toString()} = ${item.total?.toString()}',
|
||||
textAlign: TextAlign.right, style: productTextStyle)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 10.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
//margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
buildClipRect(primaryColor,Icons.remove, () {
|
||||
Redux.store.dispatch(counterProductFromKassaItems(index, -1));
|
||||
}),
|
||||
buildClipRect(primaryColor,Icons.add, () {
|
||||
Redux.store.dispatch(counterProductFromKassaItems(index, 1));
|
||||
}),
|
||||
Expanded(
|
||||
child: Container(
|
||||
),
|
||||
),
|
||||
buildClipRect(redColor,Icons.close, () {
|
||||
Redux.store.dispatch(removeProductFromKassaItems(index));
|
||||
}),
|
||||
],
|
||||
)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Colors.black38,
|
||||
//thickness: 1,
|
||||
indent: 4,
|
||||
endIndent: 4,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,13 +37,15 @@ class NumberDisplay extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
double fontSizeCalc({String value = " "}) {
|
||||
double fontSizeCalc({String value = " ", context}) {
|
||||
const double result = 40.0;
|
||||
try {
|
||||
const double global = 100000.0;
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
double global = width * height / 2;
|
||||
double scale = (global / value.length);
|
||||
final pixelOfLetter = sqrt(scale);
|
||||
final pixelOfLetterP = pixelOfLetter - (pixelOfLetter * 5) / 100;
|
||||
final pixelOfLetterP = pixelOfLetter - (pixelOfLetter * 7) / 100;
|
||||
if (pixelOfLetterP > result) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue