Merge branch 'master' into backend_nfc

# Conflicts:
#	lib/core/services/DataService.dart
#	lib/views/start_up/start_up_view.dart
#	pubspec.lock
#	pubspec.yaml
backend_nfc
suvaissov 2021-01-18 12:16:36 +06:00
commit f8d7e4717f
12 changed files with 366 additions and 248 deletions

View File

@ -10,78 +10,32 @@ project 'Runner', {
'Release' => :release, 'Release' => :release,
} }
def parse_KV_file(file, separator='=') def flutter_root
file_abs_path = File.expand_path(file) generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
if !File.exists? file_abs_path unless File.exist?(generated_xcode_build_settings_path)
return []; raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"] File.foreach(generated_xcode_build_settings_path) do |line|
File.foreach(file_abs_path) do |line| matches = line.match(/FLUTTER_ROOT\=(.*)/)
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } return matches[1].strip if matches
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end end
generated_key_values
end require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do target 'Runner' do
use_frameworks! use_frameworks!
use_modular_headers! use_modular_headers!
# Flutter Pod flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end end
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
target.build_configurations.each do |config| flutter_additional_ios_build_settings(target)
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end end
end end

View File

@ -14,28 +14,14 @@ PODS:
- MTBBarcodeScanner (5.0.11) - MTBBarcodeScanner (5.0.11)
- path_provider (0.0.1): - path_provider (0.0.1):
- Flutter - Flutter
- path_provider_linux (0.0.1):
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- shared_preferences (0.0.1): - shared_preferences (0.0.1):
- Flutter - Flutter
- shared_preferences_macos (0.0.1): - sqflite (0.0.2):
- Flutter - Flutter
- shared_preferences_web (0.0.1): - FMDB (>= 2.7.5)
- Flutter
- sqflite (0.0.1):
- Flutter
- FMDB (~> 2.7.2)
- SwiftProtobuf (1.9.0) - SwiftProtobuf (1.9.0)
- url_launcher (0.0.1): - url_launcher (0.0.1):
- Flutter - Flutter
- url_launcher_linux (0.0.1):
- Flutter
- url_launcher_macos (0.0.1):
- Flutter
- url_launcher_web (0.0.1):
- Flutter
DEPENDENCIES: DEPENDENCIES:
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
@ -43,16 +29,9 @@ DEPENDENCIES:
- esys_flutter_share (from `.symlinks/plugins/esys_flutter_share/ios`) - esys_flutter_share (from `.symlinks/plugins/esys_flutter_share/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- path_provider (from `.symlinks/plugins/path_provider/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
SPEC REPOS: SPEC REPOS:
trunk: trunk:
@ -71,26 +50,12 @@ EXTERNAL SOURCES:
:path: Flutter :path: Flutter
path_provider: path_provider:
:path: ".symlinks/plugins/path_provider/ios" :path: ".symlinks/plugins/path_provider/ios"
path_provider_linux:
:path: ".symlinks/plugins/path_provider_linux/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
shared_preferences: shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios" :path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_macos:
:path: ".symlinks/plugins/shared_preferences_macos/ios"
shared_preferences_web:
:path: ".symlinks/plugins/shared_preferences_web/ios"
sqflite: sqflite:
:path: ".symlinks/plugins/sqflite/ios" :path: ".symlinks/plugins/sqflite/ios"
url_launcher: url_launcher:
:path: ".symlinks/plugins/url_launcher/ios" :path: ".symlinks/plugins/url_launcher/ios"
url_launcher_linux:
:path: ".symlinks/plugins/url_launcher_linux/ios"
url_launcher_macos:
:path: ".symlinks/plugins/url_launcher_macos/ios"
url_launcher_web:
:path: ".symlinks/plugins/url_launcher_web/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
@ -100,18 +65,11 @@ SPEC CHECKSUMS:
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932 SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.8.4 COCOAPODS: 1.8.4

View File

@ -335,7 +335,6 @@
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = { 249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
@ -417,7 +416,6 @@
}; };
97C147031CF9000F007C117D /* Debug */ = { 97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
@ -473,7 +471,6 @@
}; };
97C147041CF9000F007C117D /* Release */ = { 97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;

View File

@ -3,7 +3,8 @@ class CheckItem {
final num cnt; final num cnt;
final num price; final num price;
final int articul; final int articul;
CheckItem({this.name, this.cnt, this.price, this.articul}); final String excise;
CheckItem({this.name, this.cnt, this.price, this.articul, this.excise});
static CheckItem fromJson(Map<String, dynamic> json) { static CheckItem fromJson(Map<String, dynamic> json) {
return CheckItem( return CheckItem(
@ -11,6 +12,7 @@ class CheckItem {
cnt: json['cnt'], cnt: json['cnt'],
price: json['price'], price: json['price'],
articul: json['articul'], articul: json['articul'],
excise: json['excise'],
); );
} }
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() =>
@ -18,6 +20,7 @@ class CheckItem {
'name': name, 'name': name,
'cnt': cnt, 'cnt': cnt,
'price': price, 'price': price,
'articul': articul 'articul': articul,
'excise' : excise
}; };
} }

View File

@ -8,8 +8,9 @@ class ProductDao {
num total; num total;
final Good good; final Good good;
final Service service; final Service service;
final String excise;
ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service }); ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service, this.excise });
} }

View File

@ -42,6 +42,11 @@ class DataService extends BaseService {
return list.map((e) => Good.fromMap(e)).toList(); return list.map((e) => Good.fromMap(e)).toList();
} }
Future<List<Good>> getGoodsByBarcode ({ String barcode}) async {
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(Goog_tableName, ' $Goog_columnEan = ?', [barcode]);
return list.map((e) => Good.fromMap(e)).toList();
}
CheckData _transformProductsToCheckData( CheckData _transformProductsToCheckData(
{String paymentType, String tradeType, List<ProductDao> items}) { {String paymentType, String tradeType, List<ProductDao> items}) {
List<CheckItem> itemsList = []; List<CheckItem> itemsList = [];
@ -58,7 +63,9 @@ class DataService extends BaseService {
name: el.name ?? 'Позиция №$iterator', name: el.name ?? 'Позиция №$iterator',
cnt: el.count, cnt: el.count,
price: el.price, price: el.price,
articul: articul)); articul: articul,
excise: el.excise,
));
summ += el.total; summ += el.total;
iterator++; iterator++;
}); });
@ -257,6 +264,7 @@ class DataService extends BaseService {
if (goods.body.isNotEmpty) { if (goods.body.isNotEmpty) {
for (var key in goods.body.keys) { for (var key in goods.body.keys) {
Good row = Good.fromJson(goods.body[key]); Good row = Good.fromJson(goods.body[key]);
//log.i(row.toMap());
await _db.insert(Goog_tableName, row.toMap()); await _db.insert(Goog_tableName, row.toMap());
} }
log.i('Inserted ${goods.body.length} to table $Goog_tableName'); log.i('Inserted ${goods.body.length} to table $Goog_tableName');

View File

@ -5,6 +5,7 @@ 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/dict_dao.dart';
import 'package:aman_kassa_flutter/core/models/product_dao.dart'; import 'package:aman_kassa_flutter/core/models/product_dao.dart';
import 'package:aman_kassa_flutter/core/services/DataService.dart'; import 'package:aman_kassa_flutter/core/services/DataService.dart';
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart'; import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
import 'package:aman_kassa_flutter/redux/state/kassa_state.dart'; import 'package:aman_kassa_flutter/redux/state/kassa_state.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
@ -20,6 +21,7 @@ class SetKassaStateAction {
} }
final DataService _dataService = locator<DataService>(); final DataService _dataService = locator<DataService>();
final DialogService _dialogService = locator<DialogService>();
Future<void> backBottomElement(Store<AppState> store) async { Future<void> backBottomElement(Store<AppState> store) async {
List<DictDao> prevCategories = store.state.kassaState.prevCategories; List<DictDao> prevCategories = store.state.kassaState.prevCategories;
@ -43,15 +45,22 @@ ThunkAction<AppState> addCustomProductToKassaItems(String name, int count, doubl
} }
ThunkAction<AppState> addProductToKassaItems(Good good) { ThunkAction<AppState> addProductToKassaItems(Good good, String excise) {
return (Store<AppState> store) async { return (Store<AppState> store) async {
List<ProductDao> items = store.state.kassaState.kassaItems; List<ProductDao> items = store.state.kassaState.kassaItems;
int index = items.indexWhere((element) => element.good?.id == good.id); int index = items.indexWhere((element) => element.excise == null && element.good?.id == good.id);
if (index > -1) { if(excise !=null) {
int existIndex = items.indexWhere((element) => element.excise != null && element.excise == excise);
if(existIndex > -1) {
_dialogService.showDialog(description: 'Нельзя добавить повторно одинаковые товары');
return;
}
}
if (index > -1 && excise == null) {
store.dispatch(counterProductFromKassaItems(index, 1)); store.dispatch(counterProductFromKassaItems(index, 1));
} else { } else {
items.add(new ProductDao( items.add(new ProductDao(
name: good.name, good: good, count: 1, price: good.price, total: good.price)); name: good.name, good: good, count: 1, price: good.price, total: good.price, excise: excise));
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items))); store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
} }
}; };

11
lib/test/foo.dart Normal file
View File

@ -0,0 +1,11 @@
// Define a function.
void printInteger(int aNumber) {
print('The number is $aNumber.'); // Print to console.
}
// This is where the app starts executing.
void main() {
String dataMatrix = "00000046208262nZ2qnLHODVFWktT";
String numberText = dataMatrix.replaceAll(RegExp("[a-zA-Z]"), '');
print(int.parse(numberText));
}

View File

@ -1,8 +1,11 @@
import 'package:aman_kassa_flutter/core/entity/Goods.dart';
import 'package:aman_kassa_flutter/core/locator.dart'; import 'package:aman_kassa_flutter/core/locator.dart';
import 'package:aman_kassa_flutter/core/models/product_dao.dart'; import 'package:aman_kassa_flutter/core/models/product_dao.dart';
import 'package:aman_kassa_flutter/core/route_names.dart'; import 'package:aman_kassa_flutter/core/route_names.dart';
import 'package:aman_kassa_flutter/core/services/DataService.dart';
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/core/services/navigator_service.dart';
import 'package:aman_kassa_flutter/redux/actions/kassa_actions.dart';
import 'package:aman_kassa_flutter/redux/constants/operation_const.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/constants/setting_const.dart';
import 'package:aman_kassa_flutter/redux/state/kassa_state.dart'; import 'package:aman_kassa_flutter/redux/state/kassa_state.dart';
@ -13,12 +16,19 @@ import 'package:aman_kassa_flutter/views/home/tabs/kassaView/CatalogBottomSheet.
import 'package:aman_kassa_flutter/views/home/tabs/kassaView/ProductAddBottomSheet.dart'; import 'package:aman_kassa_flutter/views/home/tabs/kassaView/ProductAddBottomSheet.dart';
import 'package:aman_kassa_flutter/views/payment/payment_view.dart'; import 'package:aman_kassa_flutter/views/payment/payment_view.dart';
import 'package:aman_kassa_flutter/widgets/components/ProductListItem.dart'; import 'package:aman_kassa_flutter/widgets/components/ProductListItem.dart';
import 'package:barcode_scan/gen/protos/protos.pb.dart';
import 'package:barcode_scan/gen/protos/protos.pbenum.dart';
import 'package:barcode_scan/model/scan_options.dart';
import 'package:barcode_scan/platform_wrapper.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter_redux/flutter_redux.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
class KassaTab extends StatelessWidget { class KassaTab extends StatelessWidget {
final NavigatorService _navigatorService = locator<NavigatorService>(); final NavigatorService _navigatorService = locator<NavigatorService>();
final DialogService _dialogService = locator<DialogService>();
final DataService _dataService = locator<DataService>();
final int index; final int index;
@ -33,8 +43,24 @@ class KassaTab extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Scaffold(
padding: EdgeInsets.all(4), floatingActionButton: Container(
padding: EdgeInsets.only(bottom: 65.0, left: 8.0),
child: Align(
alignment: Alignment.bottomLeft,
child: FloatingActionButton(
elevation: 3.0,
onPressed: scan,
child: Icon(
MdiIcons.barcode,
size: 30,
),
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
body: Padding(
padding: const EdgeInsets.all(4),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Row( Row(
@ -43,13 +69,15 @@ class KassaTab extends StatelessWidget {
child: Padding( child: Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: RaisedButton( child: RaisedButton(
padding: EdgeInsets.all(8), padding: const EdgeInsets.all(8),
color: primaryColor, color: primaryColor,
child: Text( child: Text(
"Добавить", "Добавить",
style: buttonBigTitleTextStyle, style: buttonBigTitleTextStyle,
), ),
onPressed: () { showModalBottomSheetCatalog(context, 'add');}, onPressed: () {
showModalBottomSheetCatalog(context, 'add');
},
), ),
), ),
), ),
@ -63,7 +91,9 @@ class KassaTab extends StatelessWidget {
"Каталог", "Каталог",
style: buttonBigTitleTextStyle, style: buttonBigTitleTextStyle,
), ),
onPressed: () { showModalBottomSheetCatalog(context, 'catalog');}, onPressed: () {
showModalBottomSheetCatalog(context, 'catalog');
},
), ),
), ),
), ),
@ -78,11 +108,10 @@ class KassaTab extends StatelessWidget {
itemCount: vm.kassaItems.length, itemCount: vm.kassaItems.length,
itemBuilder: (BuildContext ctxt, int index) => itemBuilder: (BuildContext ctxt, int index) =>
buildItem(ctxt, index, vm.kassaItems[index])); buildItem(ctxt, index, vm.kassaItems[index]));
} }),
), ),
), ),
), //Divider(),
Divider(),
Container( Container(
margin: const EdgeInsets.symmetric(vertical: 8), margin: const EdgeInsets.symmetric(vertical: 8),
child: Row( child: Row(
@ -91,9 +120,9 @@ class KassaTab extends StatelessWidget {
StoreConnector<AppState, KassaState>( StoreConnector<AppState, KassaState>(
converter: (store) => store.state.kassaState, converter: (store) => store.state.kassaState,
builder: (context, vm) { builder: (context, vm) {
return Text(totalCalc(vm.kassaItems), style: TextStyle(fontSize: 25)); return Text(totalCalc(vm.kassaItems),
} style: TextStyle(fontSize: 25));
), }),
], ],
), ),
), ),
@ -103,30 +132,35 @@ class KassaTab extends StatelessWidget {
child: Padding( child: Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: RaisedButton( child: RaisedButton(
padding: EdgeInsets.all(8), padding: const EdgeInsets.all(8),
color: redColor, color: redColor,
child: Text( child: Text(
"возврат", "возврат",
style: buttonBigTitleTextStyle, style: buttonBigTitleTextStyle,
), ),
onPressed: () { onPressed: () {
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeKassa, operationType: OperationTypeReturn) ); _navigatorService.push(PaymentViewRoute,
} arguments: PaymentModel(
), mode: SettingModeKassa,
operationType: OperationTypeReturn));
}),
), ),
), ),
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: RaisedButton( child: RaisedButton(
padding: EdgeInsets.all(8), padding: const EdgeInsets.all(8),
color: greenColor, color: greenColor,
child: Text( child: Text(
"оплата", "оплата",
style: buttonBigTitleTextStyle, style: buttonBigTitleTextStyle,
), ),
onPressed: () { onPressed: () {
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeKassa, operationType: OperationTypePay) ); _navigatorService.push(PaymentViewRoute,
arguments: PaymentModel(
mode: SettingModeKassa,
operationType: OperationTypePay));
}, },
), ),
), ),
@ -135,6 +169,7 @@ class KassaTab extends StatelessWidget {
) )
], ],
), ),
),
); );
} }
@ -146,6 +181,68 @@ class KassaTab extends StatelessWidget {
return total.toString(); return total.toString();
} }
Future<void> scan() async {
try {
var options = ScanOptions(strings: {
"cancel": 'Отмена',
"flash_on": 'Вкл фонарик',
"flash_off": 'Выкл фонарик',
});
var result = await BarcodeScanner.scan(options: options);
// print(result.type); // The result type (barcode, cancelled, failed)
// print(result.rawContent); // The barcode content
// print(result.format); // The barcode format (as enum)
// print(result.formatNote); // If a unknown format was scanned this field contains a note
// print(result.rawContent); // content
if (result.type == ResultType.Barcode ) {
String barcode;
String dataMatrix;
if(result.format == BarcodeFormat.ean13 || result.format == BarcodeFormat.ean8) {
barcode = result.rawContent;
} else if( result.format == BarcodeFormat.dataMatrix ) {
dataMatrix = result.rawContent;
if(dataMatrix!= null && dataMatrix.length >15) {
try {
String numberText = dataMatrix.substring(0, dataMatrix.length - 15 ).replaceAll(RegExp("[a-zA-Z]"), '');
barcode = int.parse(numberText).toString();
} catch (e) {
}
}
// 00000046208262 nZ2qnLH ODVFWktT
// 00000046208262 tjKDqfu UzVSeFE5
}
if(barcode != null) {
List<Good> goods =
await _dataService.getGoodsByBarcode(barcode: barcode);
if (goods != null && goods.isNotEmpty) {
Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix));
} else {
_dialogService.showDialog(
description: 'Товар не найден: $barcode');
}
} else if (result.type == ResultType.Error) {
_dialogService.showDialog(description: 'Не верный формат QR кода');
}
}
} on PlatformException catch (e) {
var result = ScanResult.create();
result.type = ResultType.Error;
result.format = BarcodeFormat.unknown;
if (e.code == BarcodeScanner.cameraAccessDenied) {
result.rawContent = 'The user did not grant the camera permission!';
_dialogService.showDialog(
description: 'Нет доступа до камеры устройства');
} else {
result.rawContent = 'Unknown error: $e';
_dialogService.showDialog(description: 'Неизвестная ошибка: $e');
}
}
}
void showModalBottomSheetCatalog(BuildContext context, String action) { void showModalBottomSheetCatalog(BuildContext context, String action) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
@ -158,15 +255,16 @@ class KassaTab extends StatelessWidget {
minChildSize: 0.5, minChildSize: 0.5,
builder: (BuildContext context, ScrollController scrollController) { builder: (BuildContext context, ScrollController scrollController) {
if (action == 'add') { if (action == 'add') {
return ProductAddBottomSheet(scrollController: scrollController,); return ProductAddBottomSheet(
scrollController: scrollController,
);
} else { } else {
return CatalogBottomSheet(scrollController: scrollController,); return CatalogBottomSheet(
scrollController: scrollController,
);
} }
}, },
); );
});
} }
);
}
} }

View File

@ -95,7 +95,7 @@ class CatalogBottomSheet extends StatelessWidget {
.dispatch(selectBottomElement(el.id)); .dispatch(selectBottomElement(el.id));
} else if (el is Good) { } else if (el is Good) {
await Redux.store await Redux.store
.dispatch(addProductToKassaItems(el)); .dispatch(addProductToKassaItems(el, null));
Navigator.pop(context); Navigator.pop(context);
} else if (el is Service) { } else if (el is Service) {
await Redux.store await Redux.store

View File

@ -52,17 +52,25 @@ class ProductListItem extends StatelessWidget {
Expanded( Expanded(
flex: 1, flex: 1,
child: Container( child: Container(
//margin: const EdgeInsets.symmetric(horizontal: 4), margin: const EdgeInsets.symmetric(horizontal: 4),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
// buildClipRect(primaryColor, Icons.edit, () {
// editCountForm(context, item.count);
// }),
if(item.excise == null)
buildClipRect(primaryColor, Icons.remove, () { buildClipRect(primaryColor, Icons.remove, () {
Redux.store.dispatch( Redux.store
.dispatch(
counterProductFromKassaItems(index, -1)); counterProductFromKassaItems(index, -1));
}), }),
if(item.excise == null)
buildClipRect(primaryColor, Icons.add, () { buildClipRect(primaryColor, Icons.add, () {
Redux.store Redux.store
.dispatch(counterProductFromKassaItems(index, 1)); .dispatch(
counterProductFromKassaItems(index, 1));
}), }),
Expanded( Expanded(
child: Container(), child: Container(),
), ),
@ -103,4 +111,75 @@ class ProductListItem extends StatelessWidget {
), ),
); );
} }
void editCountForm(BuildContext context, num count) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
actionsPadding: const EdgeInsets.only(right: 15, bottom: 5),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'request.title',
style: TextStyle(fontWeight: FontWeight.bold),
),
//Divider(),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
//Text(request.description),
TextField(
autofocus: true,
decoration: InputDecoration(
labelText: 'request.description',
),
//controller: _controller,
onSubmitted: (value) {
},
keyboardType: TextInputType.phone,
)
],
),
actions: <Widget>[
Row(
children: [
RaisedButton(
color: redColor,
child: Text(
'Отмена',
style: TextStyle(fontSize: 18),
),
onPressed: () {
Navigator.of(context).pop();
},
),
SizedBox(
width: 5,
),
RaisedButton(
color: primaryColor,
child: Text(
'Сохранить',
style: TextStyle(fontSize: 18),
),
onPressed: () {
},
),
],
),
],
);
});
}
} }

View File

@ -152,7 +152,7 @@ packages:
name: flutter_screenutil name: flutter_screenutil
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.2+2" version: "4.0.2+5"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -169,7 +169,7 @@ packages:
name: get_it name: get_it
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.3" version: "5.0.4"
google_fonts: google_fonts:
dependency: "direct main" dependency: "direct main"
description: description:
@ -225,7 +225,7 @@ packages:
name: material_design_icons_flutter name: material_design_icons_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.5755" version: "4.0.5855"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -253,7 +253,7 @@ packages:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.24" version: "1.6.27"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -267,7 +267,7 @@ packages:
name: path_provider_macos name: path_provider_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.4+6" version: "0.0.4+8"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -323,7 +323,7 @@ packages:
name: provider name: provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.3.2+3" version: "4.3.2+4"
qr: qr:
dependency: transitive dependency: transitive
description: description:
@ -433,14 +433,14 @@ packages:
name: sqflite name: sqflite
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.2+1" version: "1.3.2+2"
sqflite_common: sqflite_common:
dependency: transitive dependency: transitive
description: description:
name: sqflite_common name: sqflite_common
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2+1" version: "1.0.3"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description: