Compare commits
17 Commits
backend_nf
...
ns-printer
| Author | SHA1 | Date |
|---|---|---|
|
|
b343d433e9 | |
|
|
7c735834af | |
|
|
0336d6918b | |
|
|
d39baca7c2 | |
|
|
ccd668a5c9 | |
|
|
2f2a4dce3a | |
|
|
d23036ebf0 | |
|
|
005c00071d | |
|
|
95aeb07fc8 | |
|
|
16ea7ead94 | |
|
|
7b06e4c390 | |
|
|
988d6a6c6b | |
|
|
fcbf12f193 | |
|
|
f29d9edb22 | |
|
|
0345a310e5 | |
|
|
97250689c1 | |
|
|
875f930da4 |
|
|
@ -34,7 +34,7 @@ if (keystorePropertiesFile.exists()) {
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 31
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
|
@ -47,7 +47,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "kz.com.aman.kassa"
|
applicationId "kz.com.aman.kassa"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 31
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- android:name="io.flutter.app.FlutterApplication"-->
|
||||||
<application
|
<application
|
||||||
tools:replace="android:label"
|
android:name="${applicationName}"
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:label="Аман Касса"
|
android:label="Аман Касса"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
android:roundIcon="@mipmap/ic_launcher_rounded"
|
android:roundIcon="@mipmap/ic_launcher_rounded"
|
||||||
>
|
>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package kz.com.aman.kassa
|
package kz.com.aman.kassa
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
|
@ -105,17 +106,30 @@ class MainActivity : FlutterActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startOperation(operationType: OperationType, inputJsonData: String?) {
|
private fun startOperation(operationType: OperationType, inputJsonData: String?) {
|
||||||
val intent = Intent()
|
try {
|
||||||
intent.component = ComponentName("ru.m4bank.softpos.halyk", "ru.m4bank.feature.externalapplication.ExternalApplicationActivity")
|
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
||||||
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
val intent = Intent()
|
||||||
intent.putExtra(externalOperationTypeKey, operationType.code)
|
intent.component = ComponentName("ru.m4bank.softpos.halyk", "ru.m4bank.feature.externalapplication.ExternalApplicationActivity")
|
||||||
intent.putExtra(externalInputDataKey, inputJsonData)
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
startActivityForResult(intent, externalApplicationRequestCode)
|
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||||
|
intent.putExtra(externalOperationTypeKey, operationType.code)
|
||||||
|
intent.putExtra(externalInputDataKey, inputJsonData)
|
||||||
|
|
||||||
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
|
startActivityForResult(intent, externalApplicationRequestCode)
|
||||||
|
} else {
|
||||||
|
_result.error("008", "Не удалось найти подходящее приложение", "aaa")
|
||||||
|
}
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
_result.error("008", "Не удалось найти подходящее приложение", "aaa")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
try {
|
||||||
if (requestCode == externalApplicationRequestCode) {
|
if (requestCode == externalApplicationRequestCode) {
|
||||||
println("---------------")
|
println("---------------")
|
||||||
println(requestCode)
|
println(requestCode)
|
||||||
|
|
@ -140,6 +154,9 @@ class MainActivity : FlutterActivity() {
|
||||||
// } else
|
// } else
|
||||||
// _result.success(null)
|
// _result.success(null)
|
||||||
}
|
}
|
||||||
|
} catch (e: IllegalStateException) {
|
||||||
|
print("IllegalStateException")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.61'
|
ext.kotlin_version = '1.6.10'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,6 @@
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>MinimumOSVersion</key>
|
<key>MinimumOSVersion</key>
|
||||||
<string>8.0</string>
|
<string>9.0</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
||||||
|
|
@ -1,98 +1,111 @@
|
||||||
PODS:
|
PODS:
|
||||||
- barcode_scan (0.0.1):
|
- barcode_scan2 (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- MTBBarcodeScanner
|
- MTBBarcodeScanner
|
||||||
- SwiftProtobuf
|
- SwiftProtobuf
|
||||||
|
- bluetooth_print (0.0.1):
|
||||||
|
- Flutter
|
||||||
- charset_converter (0.0.1):
|
- charset_converter (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- device_info (0.0.1):
|
- device_info (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- esys_flutter_share (0.0.1):
|
|
||||||
- Flutter
|
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
- flutter_bluetooth_basic (0.0.1):
|
- flutter_blue (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
- flutter_blue/Protos (= 0.0.1)
|
||||||
|
- flutter_blue/Protos (0.0.1):
|
||||||
|
- Flutter
|
||||||
|
- Protobuf (~> 3.11.4)
|
||||||
- FMDB (2.7.5):
|
- FMDB (2.7.5):
|
||||||
- FMDB/standard (= 2.7.5)
|
- FMDB/standard (= 2.7.5)
|
||||||
- FMDB/standard (2.7.5)
|
- FMDB/standard (2.7.5)
|
||||||
- local_auth (0.0.1):
|
- local_auth (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- MTBBarcodeScanner (5.0.11)
|
- MTBBarcodeScanner (5.0.11)
|
||||||
- path_provider (0.0.1):
|
- path_provider_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- "permission_handler (5.1.0+2)":
|
- "permission_handler (5.1.0+2)":
|
||||||
- Flutter
|
- Flutter
|
||||||
- shared_preferences (0.0.1):
|
- Protobuf (3.11.4)
|
||||||
|
- shared_preferences_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- sqflite (0.0.2):
|
- sqflite (0.0.2):
|
||||||
- Flutter
|
- Flutter
|
||||||
- FMDB (>= 2.7.5)
|
- FMDB (>= 2.7.5)
|
||||||
- SwiftProtobuf (1.9.0)
|
- SwiftProtobuf (1.18.0)
|
||||||
- url_launcher (0.0.1):
|
- url_launcher_ios (0.0.1):
|
||||||
|
- Flutter
|
||||||
|
- vocsy_esys_flutter_share (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
|
- barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`)
|
||||||
|
- bluetooth_print (from `.symlinks/plugins/bluetooth_print/ios`)
|
||||||
- charset_converter (from `.symlinks/plugins/charset_converter/ios`)
|
- charset_converter (from `.symlinks/plugins/charset_converter/ios`)
|
||||||
- device_info (from `.symlinks/plugins/device_info/ios`)
|
- device_info (from `.symlinks/plugins/device_info/ios`)
|
||||||
- esys_flutter_share (from `.symlinks/plugins/esys_flutter_share/ios`)
|
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
- flutter_bluetooth_basic (from `.symlinks/plugins/flutter_bluetooth_basic/ios`)
|
- flutter_blue (from `.symlinks/plugins/flutter_blue/ios`)
|
||||||
- local_auth (from `.symlinks/plugins/local_auth/ios`)
|
- local_auth (from `.symlinks/plugins/local_auth/ios`)
|
||||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
|
||||||
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
|
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
|
||||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
|
||||||
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
- sqflite (from `.symlinks/plugins/sqflite/ios`)
|
||||||
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
|
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||||
|
- vocsy_esys_flutter_share (from `.symlinks/plugins/vocsy_esys_flutter_share/ios`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
trunk:
|
trunk:
|
||||||
- FMDB
|
- FMDB
|
||||||
- MTBBarcodeScanner
|
- MTBBarcodeScanner
|
||||||
|
- Protobuf
|
||||||
- SwiftProtobuf
|
- SwiftProtobuf
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
barcode_scan:
|
barcode_scan2:
|
||||||
:path: ".symlinks/plugins/barcode_scan/ios"
|
:path: ".symlinks/plugins/barcode_scan2/ios"
|
||||||
|
bluetooth_print:
|
||||||
|
:path: ".symlinks/plugins/bluetooth_print/ios"
|
||||||
charset_converter:
|
charset_converter:
|
||||||
:path: ".symlinks/plugins/charset_converter/ios"
|
:path: ".symlinks/plugins/charset_converter/ios"
|
||||||
device_info:
|
device_info:
|
||||||
:path: ".symlinks/plugins/device_info/ios"
|
:path: ".symlinks/plugins/device_info/ios"
|
||||||
esys_flutter_share:
|
|
||||||
:path: ".symlinks/plugins/esys_flutter_share/ios"
|
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
flutter_bluetooth_basic:
|
flutter_blue:
|
||||||
:path: ".symlinks/plugins/flutter_bluetooth_basic/ios"
|
:path: ".symlinks/plugins/flutter_blue/ios"
|
||||||
local_auth:
|
local_auth:
|
||||||
:path: ".symlinks/plugins/local_auth/ios"
|
:path: ".symlinks/plugins/local_auth/ios"
|
||||||
path_provider:
|
path_provider_ios:
|
||||||
:path: ".symlinks/plugins/path_provider/ios"
|
:path: ".symlinks/plugins/path_provider_ios/ios"
|
||||||
permission_handler:
|
permission_handler:
|
||||||
:path: ".symlinks/plugins/permission_handler/ios"
|
:path: ".symlinks/plugins/permission_handler/ios"
|
||||||
shared_preferences:
|
shared_preferences_ios:
|
||||||
:path: ".symlinks/plugins/shared_preferences/ios"
|
:path: ".symlinks/plugins/shared_preferences_ios/ios"
|
||||||
sqflite:
|
sqflite:
|
||||||
:path: ".symlinks/plugins/sqflite/ios"
|
:path: ".symlinks/plugins/sqflite/ios"
|
||||||
url_launcher:
|
url_launcher_ios:
|
||||||
:path: ".symlinks/plugins/url_launcher/ios"
|
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||||
|
vocsy_esys_flutter_share:
|
||||||
|
:path: ".symlinks/plugins/vocsy_esys_flutter_share/ios"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479
|
barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0
|
||||||
|
bluetooth_print: da8f47e8881a0b1f0fd8d73cd6fa84c9bd41ac28
|
||||||
charset_converter: 215c7b04932ec2b9ba43be96a9bc34afed3e5322
|
charset_converter: 215c7b04932ec2b9ba43be96a9bc34afed3e5322
|
||||||
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
|
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
|
||||||
esys_flutter_share: 403498dab005b36ce1f8d7aff377e81f0621b0b4
|
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
|
||||||
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
flutter_blue: eeb381dc4727a0954dede73515f683865494b370
|
||||||
flutter_bluetooth_basic: 0e4e27e22b50b3a25cc1d1e131953feb4af414f4
|
|
||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd
|
local_auth: ef62030a2731330b95df7ef1331bd15f6a64b8a6
|
||||||
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
|
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
|
||||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5
|
||||||
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
|
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
|
||||||
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
|
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
|
||||||
|
shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32
|
||||||
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
|
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
|
||||||
SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932
|
SwiftProtobuf: c3c12645230d9b09c72267e0de89468c5543bd86
|
||||||
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
|
url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af
|
||||||
|
vocsy_esys_flutter_share: 98b79fad467203ababde56a7289ac90da6a4ddf5
|
||||||
|
|
||||||
PODFILE CHECKSUM: 5aafc9b59da66d8d46f05cbbbd21261eb9757176
|
PODFILE CHECKSUM: 5aafc9b59da66d8d46f05cbbbd21261eb9757176
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 46;
|
objectVersion = 50;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
|
@ -166,7 +166,7 @@
|
||||||
97C146E61CF9000F007C117D /* Project object */ = {
|
97C146E61CF9000F007C117D /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 1020;
|
LastUpgradeCheck = 1300;
|
||||||
ORGANIZATIONNAME = "The Chromium Authors";
|
ORGANIZATIONNAME = "The Chromium Authors";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
97C146ED1CF9000F007C117D = {
|
97C146ED1CF9000F007C117D = {
|
||||||
|
|
@ -256,31 +256,35 @@
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
||||||
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
|
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
|
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
|
||||||
|
"${BUILT_PRODUCTS_DIR}/Protobuf/protobuf.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
|
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/barcode_scan/barcode_scan.framework",
|
"${BUILT_PRODUCTS_DIR}/barcode_scan2/barcode_scan2.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/charset_converter/charset_converter.framework",
|
"${BUILT_PRODUCTS_DIR}/charset_converter/charset_converter.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
|
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/esys_flutter_share/esys_flutter_share.framework",
|
"${BUILT_PRODUCTS_DIR}/flutter_blue/flutter_blue.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework",
|
"${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
|
"${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
|
"${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
|
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
|
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
|
||||||
|
"${BUILT_PRODUCTS_DIR}/vocsy_esys_flutter_share/vocsy_esys_flutter_share.framework",
|
||||||
);
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/protobuf.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan2.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/charset_converter.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/charset_converter.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/esys_flutter_share.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_blue.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/vocsy_esys_flutter_share.framework",
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
|
|
@ -376,7 +380,7 @@
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = iphoneos;
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
|
|
@ -401,7 +405,10 @@
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
|
@ -463,7 +470,7 @@
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
|
@ -512,7 +519,7 @@
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = iphoneos;
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
|
|
@ -538,7 +545,10 @@
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
|
@ -570,7 +580,10 @@
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1020"
|
LastUpgradeVersion = "1300"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import 'package:logger/logger.dart';
|
||||||
import '../logger.dart';
|
import '../logger.dart';
|
||||||
|
|
||||||
class BaseService {
|
class BaseService {
|
||||||
Logger log;
|
late Logger log;
|
||||||
|
|
||||||
BaseService({String title}) {
|
BaseService({String? title}) {
|
||||||
this.log = getLogger(
|
this.log = getLogger(
|
||||||
title ?? this.runtimeType.toString(),
|
title ?? this.runtimeType.toString(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ const String Category_columnName = 'name';
|
||||||
const String Category_columnAppCompanyId = 'app_company_id';
|
const String Category_columnAppCompanyId = 'app_company_id';
|
||||||
|
|
||||||
class Category {
|
class Category {
|
||||||
int id;
|
int? id;
|
||||||
int parentIn;
|
int? parentIn;
|
||||||
String name;
|
String name = '';
|
||||||
int appCompanyId;
|
int? appCompanyId;
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
var map = <String, dynamic>{
|
var map = <String, dynamic>{
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,17 @@ const String Goog_columnOkei = 'okei';
|
||||||
const String Goog_columnDiscount = 'discount';
|
const String Goog_columnDiscount = 'discount';
|
||||||
|
|
||||||
class Good {
|
class Good {
|
||||||
int id;
|
int? id;
|
||||||
int articul;
|
int articul = -1;
|
||||||
String name;
|
String name = '';
|
||||||
double price;
|
double price = -1;
|
||||||
int categoryId;
|
int categoryId = -1;
|
||||||
String ean;
|
String? ean;
|
||||||
int appCompanyId;
|
int? appCompanyId;
|
||||||
String description;
|
String? description;
|
||||||
double showPrice;
|
double? showPrice;
|
||||||
int okei;
|
int? okei;
|
||||||
double discount;
|
double? discount;
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
var map = <String, dynamic>{
|
var map = <String, dynamic>{
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,15 @@ const String Service_columnDiscount = 'discount';
|
||||||
|
|
||||||
|
|
||||||
class Service {
|
class Service {
|
||||||
int id;
|
int? id;
|
||||||
int articul;
|
int articul = -1;
|
||||||
String name;
|
String name = '';
|
||||||
double price;
|
double price = -1;
|
||||||
String ean;
|
int? appCompanyId;
|
||||||
int appCompanyId;
|
String? description;
|
||||||
String description;
|
double? showPrice;
|
||||||
double showPrice;
|
String? okei;
|
||||||
String okei;
|
double? discount;
|
||||||
double discount;
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
var map = <String, dynamic>{
|
var map = <String, dynamic>{
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,16 @@ const String VoucherTypeReport = 'report';
|
||||||
const String VoucherTypeCloseDayPosReport = 'closeDayPosReport';
|
const String VoucherTypeCloseDayPosReport = 'closeDayPosReport';
|
||||||
|
|
||||||
class Voucher {
|
class Voucher {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
double total;
|
double? total;
|
||||||
String data;
|
String? data;
|
||||||
String base64Data;
|
String? base64Data;
|
||||||
DateTime dateTime;
|
DateTime? dateTime;
|
||||||
int appCompanyId;
|
int? appCompanyId;
|
||||||
int kassaId;
|
int? kassaId;
|
||||||
String type;
|
String? type;
|
||||||
String url;
|
String? url;
|
||||||
|
|
||||||
Voucher();
|
Voucher();
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Voucher {
|
||||||
Voucher_columnTotal: total,
|
Voucher_columnTotal: total,
|
||||||
Voucher_columnData: data,
|
Voucher_columnData: data,
|
||||||
Voucher_columnBase64Data: base64Data,
|
Voucher_columnBase64Data: base64Data,
|
||||||
Voucher_columnDateTime: dateTime.toIso8601String(),
|
Voucher_columnDateTime: dateTime?.toIso8601String(),
|
||||||
Voucher_columnKassaId: kassaId,
|
Voucher_columnKassaId: kassaId,
|
||||||
Voucher_columnAppCompanyId: appCompanyId,
|
Voucher_columnAppCompanyId: appCompanyId,
|
||||||
Voucher_columnType: type,
|
Voucher_columnType: type,
|
||||||
|
|
@ -48,7 +48,7 @@ class Voucher {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
Voucher.fromMap(Map<String, dynamic> map) {
|
Voucher.fromMap(Map<dynamic, dynamic> map) {
|
||||||
id = map[Voucher_columnId];
|
id = map[Voucher_columnId];
|
||||||
name = map[Voucher_columnName];
|
name = map[Voucher_columnName];
|
||||||
total = map[Voucher_columnTotal]?.toDouble();
|
total = map[Voucher_columnTotal]?.toDouble();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
import 'package:aman_kassa_flutter/core/services/BankService.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/blue_print_service.dart';
|
||||||
|
|
||||||
import '../core/services/DbService.dart';
|
import '../core/services/DbService.dart';
|
||||||
|
|
||||||
|
|
@ -26,6 +27,8 @@ class LocatorInjector {
|
||||||
locator.registerLazySingleton<DialogService>(() => DialogService());
|
locator.registerLazySingleton<DialogService>(() => DialogService());
|
||||||
_log.d('Initializing DbService Service');
|
_log.d('Initializing DbService Service');
|
||||||
locator.registerLazySingleton<DbService>(() => DbService.instance);
|
locator.registerLazySingleton<DbService>(() => DbService.instance);
|
||||||
|
_log.d('Initializing BluePrintService Service');
|
||||||
|
locator.registerLazySingleton<BluePrintService>(() => BluePrintService());
|
||||||
|
|
||||||
|
|
||||||
// depencies
|
// depencies
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ class SimpleLogPrinter extends LogPrinter {
|
||||||
var error = event.error?.toString() ?? '';
|
var error = event.error?.toString() ?? '';
|
||||||
var color = PrettyPrinter.levelColors[level];
|
var color = PrettyPrinter.levelColors[level];
|
||||||
var emoji = PrettyPrinter.levelEmojis[level];
|
var emoji = PrettyPrinter.levelEmojis[level];
|
||||||
String stack;
|
String? stack;
|
||||||
if (event.stackTrace == null) {
|
if (event.stackTrace == null) {
|
||||||
stack = formatStackTrace(StackTrace.current, 2);
|
stack = formatStackTrace(StackTrace.current, 2);
|
||||||
} else {
|
} else {
|
||||||
stack = formatStackTrace(event.stackTrace, 2);
|
stack = formatStackTrace(event.stackTrace!, 1);
|
||||||
}
|
}
|
||||||
print(color(' $emoji $message $error -> $stack '));
|
print(color!(' $emoji $message $error -> $stack '));
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,9 +33,9 @@ class SimpleLogPrinter extends LogPrinter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatStackTrace(StackTrace stackTrace, int methodPosition) {
|
String? formatStackTrace(StackTrace stackTrace, int methodPosition) {
|
||||||
|
|
||||||
var lines = stackTrace.toString()?.split('\n');
|
var lines = stackTrace.toString().split('\n');
|
||||||
var formatted = <String>[];
|
var formatted = <String>[];
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (var line in lines) {
|
for (var line in lines) {
|
||||||
|
|
@ -62,7 +62,7 @@ class SimpleLogPrinter extends LogPrinter {
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return match.group(2).startsWith('package:logger');
|
return match.group(2)!.startsWith('package:logger');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _discardWebStacktraceLine(String line) {
|
bool _discardWebStacktraceLine(String line) {
|
||||||
|
|
@ -70,8 +70,8 @@ class SimpleLogPrinter extends LogPrinter {
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return match.group(1).startsWith('packages/logger') ||
|
return match.group(1)!.startsWith('packages/logger') ||
|
||||||
match.group(1).startsWith('dart-sdk/lib');
|
match.group(1)!.startsWith('dart-sdk/lib');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
class AmanDao<T> {
|
class AmanDao<T> {
|
||||||
final T data;
|
final T? data;
|
||||||
final dynamic rows;
|
final dynamic? rows;
|
||||||
final String msg;
|
final String? msg;
|
||||||
final bool success;
|
final bool? success;
|
||||||
|
|
||||||
AmanDao({this.data, this.success, this.msg, this.rows});
|
AmanDao({this.data, this.success, this.msg, this.rows});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import '../utilsParse.dart';
|
||||||
import 'user.dart';
|
import 'user.dart';
|
||||||
|
|
||||||
class AuthResponse {
|
class AuthResponse {
|
||||||
final AuthBody body;
|
final AuthBody? body;
|
||||||
final int status;
|
final int? status;
|
||||||
final bool operation;
|
final bool? operation;
|
||||||
|
|
||||||
|
|
||||||
AuthResponse( {this.body, this.status, this.operation});
|
AuthResponse( {this.body, this.status, this.operation});
|
||||||
|
|
@ -19,10 +19,10 @@ class AuthResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthBody {
|
class AuthBody {
|
||||||
final List<String> email;
|
final List<String>? email;
|
||||||
final List<String> password;
|
final List<String>? password;
|
||||||
final String message;
|
final String? message;
|
||||||
final User user;
|
final User? user;
|
||||||
AuthBody({this.message, this.user, this.email, this.password});
|
AuthBody({this.message, this.user, this.email, this.password});
|
||||||
factory AuthBody.fromJson(Map<String, dynamic> json) {
|
factory AuthBody.fromJson(Map<String, dynamic> json) {
|
||||||
return AuthBody(
|
return AuthBody(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
class CalcModel {
|
class CalcModel {
|
||||||
String num1;
|
String num1;
|
||||||
String num2;
|
String? num2;
|
||||||
bool closed;
|
bool closed;
|
||||||
String operation;
|
String operation;
|
||||||
CalcModel({this.num1, this.num2, this.operation, this.closed = false});
|
CalcModel({required this.num1, this.num2, required this.operation, this.closed = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
class CardData {
|
class CardData {
|
||||||
final int transactionNumber;
|
final int? transactionNumber;
|
||||||
final int operationDay;
|
final int? operationDay;
|
||||||
final int terminalId;
|
final int? terminalId;
|
||||||
final String cardNumber;
|
final String? cardNumber;
|
||||||
final String cardholderName;
|
final String? cardholderName;
|
||||||
final String authorizationCode;
|
final String? authorizationCode;
|
||||||
final String transactionType;
|
final String? transactionType;
|
||||||
|
|
||||||
CardData({this.transactionNumber, this.operationDay, this.cardNumber, this.cardholderName, this.authorizationCode, this.terminalId, this.transactionType });
|
CardData({this.transactionNumber, this.operationDay, this.cardNumber, this.cardholderName, this.authorizationCode, this.terminalId, this.transactionType });
|
||||||
|
|
||||||
static CardData fromJson(Map<String, dynamic> json) {
|
static CardData? fromJson(Map<String, dynamic>? json) {
|
||||||
return json != null ?
|
return json != null ?
|
||||||
CardData(
|
CardData(
|
||||||
transactionNumber: json['transactionNumber'],
|
transactionNumber: json['transactionNumber'],
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ import 'package:aman_kassa_flutter/core/models/card_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_item.dart';
|
import 'package:aman_kassa_flutter/core/models/check_item.dart';
|
||||||
|
|
||||||
class CheckData {
|
class CheckData {
|
||||||
final String type;
|
final String ?type;
|
||||||
num card;
|
num? card;
|
||||||
final List<CheckItem> items;
|
final List<CheckItem>? items;
|
||||||
CardData cardData;
|
CardData? cardData;
|
||||||
CheckData({this.type, this.card, this.items, this.cardData});
|
CheckData({this.type, this.card, this.items, this.cardData});
|
||||||
|
|
||||||
static CheckData fromJson(Map<String, dynamic> json) {
|
static CheckData fromJson(Map<String, dynamic> json) {
|
||||||
|
|
@ -20,7 +20,7 @@ class CheckData {
|
||||||
{
|
{
|
||||||
'type': type,
|
'type': type,
|
||||||
'card': card,
|
'card': card,
|
||||||
'items': items.map((e) => e.toJson()).toList(),
|
'items': items?.map((e) => e.toJson()).toList(),
|
||||||
'cardData': cardData!=null ? cardData.toJson() : null
|
'cardData': cardData?.toJson()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class CheckImageModal {
|
class CheckImageModal {
|
||||||
final String base64Data;
|
final String? base64Data;
|
||||||
final String textData;
|
final String? textData;
|
||||||
CheckImageModal({this.base64Data, this.textData});
|
CheckImageModal({this.base64Data, this.textData});
|
||||||
|
|
||||||
static CheckImageModal fromJson(Map<String, dynamic> json) {
|
static CheckImageModal fromJson(Map<String, dynamic> json) {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ class CheckItem {
|
||||||
final num cnt;
|
final num cnt;
|
||||||
final num price;
|
final num price;
|
||||||
final int articul;
|
final int articul;
|
||||||
final String excise;
|
final String? excise;
|
||||||
CheckItem({this.name, this.cnt, this.price, this.articul, this.excise});
|
CheckItem({required this.name, required this.cnt, required this.price, required this.articul, this.excise});
|
||||||
|
|
||||||
static CheckItem fromJson(Map<String, dynamic> json) {
|
static CheckItem fromJson(Map<String, dynamic> json) {
|
||||||
return CheckItem(
|
return CheckItem(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class Choice {
|
class Choice {
|
||||||
const Choice({this.title, this.icon, this.command});
|
const Choice({required this.title, required this.icon, required this.command});
|
||||||
final String command;
|
final String command;
|
||||||
final String title;
|
final String title;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@ import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
||||||
import 'halyk/halyk_close_day_dao.dart';
|
import 'halyk/halyk_close_day_dao.dart';
|
||||||
|
|
||||||
class CloseDayData {
|
class CloseDayData {
|
||||||
final String title;
|
final String? title;
|
||||||
final num totalAmount;
|
final num? totalAmount;
|
||||||
final int totalCount;
|
final int? totalCount;
|
||||||
final num paymentAmount;
|
final num? paymentAmount;
|
||||||
final int paymentCount;
|
final int? paymentCount;
|
||||||
final num refundAmount;
|
final num? refundAmount;
|
||||||
final int refundCount;
|
final int? refundCount;
|
||||||
final num cancelAmount;
|
final num? cancelAmount;
|
||||||
final int cancelCount;
|
final int? cancelCount;
|
||||||
|
|
||||||
final List<TransactionBean> items;
|
final List<TransactionBean>? items;
|
||||||
CloseDayData({
|
CloseDayData({
|
||||||
this.title,
|
this.title,
|
||||||
this.items,
|
this.items,
|
||||||
|
|
@ -49,6 +49,6 @@ class CloseDayData {
|
||||||
'refundCount': refundCount,
|
'refundCount': refundCount,
|
||||||
'cancelAmount': cancelAmount,
|
'cancelAmount': cancelAmount,
|
||||||
'cancelCount': cancelCount,
|
'cancelCount': cancelCount,
|
||||||
'items': items.map((e) => e.toJson()).toList(),
|
'items': items?.map((e) => e.toJson()).toList(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -4,13 +4,13 @@ class DialogRequest {
|
||||||
final String title;
|
final String title;
|
||||||
final String description;
|
final String description;
|
||||||
final String buttonTitle;
|
final String buttonTitle;
|
||||||
final String cancelTitle;
|
final String? cancelTitle;
|
||||||
final String formatType;
|
final String? formatType;
|
||||||
|
|
||||||
DialogRequest(
|
DialogRequest(
|
||||||
{@required this.title,
|
{required this.title,
|
||||||
@required this.description,
|
required this.description,
|
||||||
@required this.buttonTitle,
|
required this.buttonTitle,
|
||||||
this.cancelTitle,
|
this.cancelTitle,
|
||||||
this.formatType});
|
this.formatType});
|
||||||
}
|
}
|
||||||
|
|
@ -18,13 +18,13 @@ class DialogRequest {
|
||||||
class DialogResponse {
|
class DialogResponse {
|
||||||
//final String fieldOne;
|
//final String fieldOne;
|
||||||
//final String fieldTwo;
|
//final String fieldTwo;
|
||||||
final String responseText;
|
final String? responseText;
|
||||||
final bool confirmed;
|
final bool confirmed;
|
||||||
|
|
||||||
DialogResponse({
|
DialogResponse({
|
||||||
//this.fieldOne,
|
//this.fieldOne,
|
||||||
//this.fieldTwo,
|
//this.fieldTwo,
|
||||||
this.responseText,
|
this.responseText,
|
||||||
this.confirmed,
|
required this.confirmed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class DictDao {
|
class DictDao {
|
||||||
final int id;
|
final int id;
|
||||||
final String name;
|
final String name;
|
||||||
DictDao({ this.id, this.name});
|
DictDao({ required this.id, required this.name});
|
||||||
}
|
}
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
/// closeDayResults : {"reconciliationResult":[{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]}
|
/// closeDayResults : {"reconciliationResult":[{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]}
|
||||||
|
|
||||||
class HalykCloseDayDao {
|
class HalykCloseDayDao {
|
||||||
ResultBean result;
|
ResultBean? result;
|
||||||
TransactionsBean transactions;
|
TransactionsBean? transactions;
|
||||||
CloseDayResultsBean closeDayResults;
|
CloseDayResultsBean? closeDayResults;
|
||||||
|
|
||||||
HalykCloseDayDao({ this.result, this.closeDayResults, this.transactions});
|
HalykCloseDayDao({ this.result, this.closeDayResults, this.transactions});
|
||||||
|
|
||||||
static HalykCloseDayDao fromMap(Map<String, dynamic> map) {
|
static HalykCloseDayDao? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
HalykCloseDayDao halykCloseDayDaoBean = HalykCloseDayDao();
|
HalykCloseDayDao halykCloseDayDaoBean = HalykCloseDayDao();
|
||||||
halykCloseDayDaoBean.result = ResultBean.fromMap(map['result']);
|
halykCloseDayDaoBean.result = ResultBean.fromMap(map['result']);
|
||||||
|
|
@ -28,13 +28,13 @@ class HalykCloseDayDao {
|
||||||
/// reconciliationResult : [{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]
|
/// reconciliationResult : [{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]
|
||||||
|
|
||||||
class CloseDayResultsBean {
|
class CloseDayResultsBean {
|
||||||
List<ReconciliationResultBean> reconciliationResult;
|
List<ReconciliationResultBean>? reconciliationResult;
|
||||||
|
|
||||||
static CloseDayResultsBean fromMap(Map<String, dynamic> map) {
|
static CloseDayResultsBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
CloseDayResultsBean closeDayResultsBean = CloseDayResultsBean();
|
CloseDayResultsBean closeDayResultsBean = CloseDayResultsBean();
|
||||||
closeDayResultsBean.reconciliationResult = List()..addAll(
|
closeDayResultsBean.reconciliationResult = List.empty()..addAll(
|
||||||
(map['reconciliationResult'] as List ?? []).map((o) => ReconciliationResultBean.fromMap(o))
|
(map['reconciliationResult'] as List).map((o) => ReconciliationResultBean.fromMap(o))
|
||||||
);
|
);
|
||||||
return closeDayResultsBean;
|
return closeDayResultsBean;
|
||||||
}
|
}
|
||||||
|
|
@ -49,12 +49,11 @@ class CloseDayResultsBean {
|
||||||
/// terminalExternalId : "example_terminal_id"
|
/// terminalExternalId : "example_terminal_id"
|
||||||
|
|
||||||
class ReconciliationResultBean {
|
class ReconciliationResultBean {
|
||||||
String hostResultCode;
|
String? hostResultCode;
|
||||||
String hostResultDescription;
|
String? hostResultDescription;
|
||||||
String terminalExternalId;
|
String? terminalExternalId;
|
||||||
|
|
||||||
static ReconciliationResultBean fromMap(Map<String, dynamic> map) {
|
static ReconciliationResultBean fromMap(Map<String, dynamic> map) {
|
||||||
if (map == null) return null;
|
|
||||||
ReconciliationResultBean reconciliationResultBean = ReconciliationResultBean();
|
ReconciliationResultBean reconciliationResultBean = ReconciliationResultBean();
|
||||||
reconciliationResultBean.hostResultCode = map['hostResultCode'];
|
reconciliationResultBean.hostResultCode = map['hostResultCode'];
|
||||||
reconciliationResultBean.hostResultDescription = map['hostResultDescription'];
|
reconciliationResultBean.hostResultDescription = map['hostResultDescription'];
|
||||||
|
|
@ -72,13 +71,13 @@ class ReconciliationResultBean {
|
||||||
/// transaction : [{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]
|
/// transaction : [{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]
|
||||||
|
|
||||||
class TransactionsBean {
|
class TransactionsBean {
|
||||||
List<TransactionBean> transaction;
|
List<TransactionBean>? transaction;
|
||||||
|
|
||||||
static TransactionsBean fromMap(Map<String, dynamic> map) {
|
static TransactionsBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
TransactionsBean transactionsBean = TransactionsBean();
|
TransactionsBean transactionsBean = TransactionsBean();
|
||||||
transactionsBean.transaction = List()..addAll(
|
transactionsBean.transaction = List.empty()..addAll(
|
||||||
(map['transaction'] as List ?? []).map((o) => TransactionBean.fromMap(o))
|
(map['transaction'] as List).map((o) => TransactionBean.fromMap(o))
|
||||||
);
|
);
|
||||||
return transactionsBean;
|
return transactionsBean;
|
||||||
}
|
}
|
||||||
|
|
@ -97,20 +96,19 @@ class TransactionsBean {
|
||||||
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
||||||
|
|
||||||
class TransactionBean {
|
class TransactionBean {
|
||||||
String type;
|
String? type;
|
||||||
String instrument;
|
String? instrument;
|
||||||
num amount;
|
num amount = 0;
|
||||||
int terminalId;
|
int? terminalId;
|
||||||
int operationDay;
|
int? operationDay;
|
||||||
int transactionNumber;
|
int? transactionNumber;
|
||||||
InstrumentSpecificDataBean instrumentSpecificData;
|
InstrumentSpecificDataBean? instrumentSpecificData;
|
||||||
|
|
||||||
static TransactionBean fromMap(Map<String, dynamic> map) {
|
static TransactionBean fromMap(Map<String, dynamic> map) {
|
||||||
if (map == null) return null;
|
|
||||||
TransactionBean transactionBean = TransactionBean();
|
TransactionBean transactionBean = TransactionBean();
|
||||||
transactionBean.type = map['type'];
|
transactionBean.type = map['type'];
|
||||||
transactionBean.instrument = map['instrument'];
|
transactionBean.instrument = map['instrument'];
|
||||||
transactionBean.amount = map['amount'];
|
transactionBean.amount = map['amount'] ?? 0;
|
||||||
transactionBean.terminalId = map['terminalId'];
|
transactionBean.terminalId = map['terminalId'];
|
||||||
transactionBean.operationDay = map['operationDay'];
|
transactionBean.operationDay = map['operationDay'];
|
||||||
transactionBean.transactionNumber = map['transactionNumber'];
|
transactionBean.transactionNumber = map['transactionNumber'];
|
||||||
|
|
@ -135,12 +133,12 @@ class TransactionBean {
|
||||||
/// maskedPan : "123456******7890"
|
/// maskedPan : "123456******7890"
|
||||||
|
|
||||||
class InstrumentSpecificDataBean {
|
class InstrumentSpecificDataBean {
|
||||||
String authorizationCode;
|
String? authorizationCode;
|
||||||
String rrn;
|
String? rrn;
|
||||||
String cardholderName;
|
String? cardholderName;
|
||||||
String maskedPan;
|
String? maskedPan;
|
||||||
|
|
||||||
static InstrumentSpecificDataBean fromMap(Map<String, dynamic> map) {
|
static InstrumentSpecificDataBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
||||||
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
||||||
|
|
@ -162,12 +160,12 @@ class InstrumentSpecificDataBean {
|
||||||
/// description : "Successfully completed"
|
/// description : "Successfully completed"
|
||||||
|
|
||||||
class ResultBean {
|
class ResultBean {
|
||||||
int code;
|
int? code;
|
||||||
String description;
|
String? description;
|
||||||
|
|
||||||
ResultBean({this.code, this.description});
|
ResultBean({this.code, this.description});
|
||||||
|
|
||||||
static ResultBean fromMap(Map<String, dynamic> map) {
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
ResultBean resultBean = ResultBean();
|
ResultBean resultBean = ResultBean();
|
||||||
resultBean.code = map['code'];
|
resultBean.code = map['code'];
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ class HalykPosSession {
|
||||||
this.tokenTimeout,
|
this.tokenTimeout,
|
||||||
this.result});
|
this.result});
|
||||||
|
|
||||||
final String login;
|
final String? login;
|
||||||
final String token;
|
final String? token;
|
||||||
final DateTime serverTime;
|
final DateTime? serverTime;
|
||||||
final int tokenTimeout;
|
final int? tokenTimeout;
|
||||||
final ResultBean result;
|
final ResultBean? result;
|
||||||
|
|
||||||
static HalykPosSession fromJson(Map<String, dynamic> data) => HalykPosSession(
|
static HalykPosSession fromJson(Map<String, dynamic> data) => HalykPosSession(
|
||||||
login: data['login'],
|
login: data['login'],
|
||||||
|
|
@ -30,12 +30,12 @@ class HalykPosSession {
|
||||||
/// Response : {"Code":"040","Description":"Unknown operator login. Check the correctness of the data or contact support."}
|
/// Response : {"Code":"040","Description":"Unknown operator login. Check the correctness of the data or contact support."}
|
||||||
|
|
||||||
class ResultBean {
|
class ResultBean {
|
||||||
String ServerTime;
|
String? ServerTime;
|
||||||
String ResultCode;
|
String? ResultCode;
|
||||||
String ResultStr;
|
String? ResultStr;
|
||||||
ResponseBean Response;
|
ResponseBean? Response;
|
||||||
|
|
||||||
static ResultBean fromMap(Map<String, dynamic> map) {
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
ResultBean resultBean = ResultBean();
|
ResultBean resultBean = ResultBean();
|
||||||
resultBean.ServerTime = map['ServerTime'];
|
resultBean.ServerTime = map['ServerTime'];
|
||||||
|
|
@ -57,10 +57,10 @@ class ResultBean {
|
||||||
/// Description : "Unknown operator login. Check the correctness of the data or contact support."
|
/// Description : "Unknown operator login. Check the correctness of the data or contact support."
|
||||||
|
|
||||||
class ResponseBean {
|
class ResponseBean {
|
||||||
String Code;
|
String? Code;
|
||||||
String Description;
|
String? Description;
|
||||||
|
|
||||||
static ResponseBean fromMap(Map<String, dynamic> map) {
|
static ResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
ResponseBean responseBean = ResponseBean();
|
ResponseBean responseBean = ResponseBean();
|
||||||
responseBean.Code = map['Code'];
|
responseBean.Code = map['Code'];
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
/// transaction : {"terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}}
|
/// transaction : {"terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}}
|
||||||
|
|
||||||
class HalykResponse {
|
class HalykResponse {
|
||||||
ResultBean result;
|
ResultBean? result;
|
||||||
TransactionBean transaction;
|
TransactionBean? transaction;
|
||||||
|
|
||||||
HalykResponse({this.result, this.transaction});
|
HalykResponse({this.result, this.transaction});
|
||||||
|
|
||||||
static HalykResponse fromMap(Map<String, dynamic> map) {
|
static HalykResponse? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
HalykResponse halykResponseBean = HalykResponse();
|
HalykResponse halykResponseBean = HalykResponse();
|
||||||
halykResponseBean.result = ResultBean.fromMap(map['result']);
|
halykResponseBean.result = ResultBean.fromMap(map['result']);
|
||||||
|
|
@ -28,12 +28,12 @@ class HalykResponse {
|
||||||
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
||||||
|
|
||||||
class TransactionBean {
|
class TransactionBean {
|
||||||
int terminalId;
|
int? terminalId;
|
||||||
int operationDay;
|
int? operationDay;
|
||||||
int transactionNumber;
|
int? transactionNumber;
|
||||||
InstrumentSpecificDataBean instrumentSpecificData;
|
InstrumentSpecificDataBean? instrumentSpecificData;
|
||||||
|
|
||||||
static TransactionBean fromMap(Map<String, dynamic> map) {
|
static TransactionBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
TransactionBean transactionBean = TransactionBean();
|
TransactionBean transactionBean = TransactionBean();
|
||||||
transactionBean.terminalId = map['terminalId'];
|
transactionBean.terminalId = map['terminalId'];
|
||||||
|
|
@ -58,12 +58,12 @@ class TransactionBean {
|
||||||
/// maskedPan : "123456******7890"
|
/// maskedPan : "123456******7890"
|
||||||
|
|
||||||
class InstrumentSpecificDataBean {
|
class InstrumentSpecificDataBean {
|
||||||
String authorizationCode;
|
String? authorizationCode;
|
||||||
String rrn;
|
String? rrn;
|
||||||
String cardholderName;
|
String? cardholderName;
|
||||||
String maskedPan;
|
String? maskedPan;
|
||||||
|
|
||||||
static InstrumentSpecificDataBean fromMap(Map<String, dynamic> map) {
|
static InstrumentSpecificDataBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
||||||
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
||||||
|
|
@ -87,14 +87,14 @@ class InstrumentSpecificDataBean {
|
||||||
/// hostResponse : {"code":"0","description":"Successfully completed"}
|
/// hostResponse : {"code":"0","description":"Successfully completed"}
|
||||||
|
|
||||||
class ResultBean {
|
class ResultBean {
|
||||||
int code;
|
int? code;
|
||||||
String description;
|
String? description;
|
||||||
HostResponseBean hostResponse;
|
HostResponseBean? hostResponse;
|
||||||
ErrorResponseBean errorData;
|
ErrorResponseBean? errorData;
|
||||||
|
|
||||||
ResultBean({this.code, this.description});
|
ResultBean({this.code, this.description});
|
||||||
|
|
||||||
static ResultBean fromMap(Map<String, dynamic> map) {
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
ResultBean resultBean = ResultBean();
|
ResultBean resultBean = ResultBean();
|
||||||
resultBean.code = map['code'];
|
resultBean.code = map['code'];
|
||||||
|
|
@ -117,10 +117,10 @@ class ResultBean {
|
||||||
/// description : "Successfully completed"
|
/// description : "Successfully completed"
|
||||||
|
|
||||||
class HostResponseBean {
|
class HostResponseBean {
|
||||||
String code;
|
String? code;
|
||||||
String description;
|
String? description;
|
||||||
|
|
||||||
static HostResponseBean fromMap(Map<String, dynamic> map) {
|
static HostResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
HostResponseBean hostResponseBean = HostResponseBean();
|
HostResponseBean hostResponseBean = HostResponseBean();
|
||||||
hostResponseBean.code = map['code'];
|
hostResponseBean.code = map['code'];
|
||||||
|
|
@ -136,10 +136,10 @@ class HostResponseBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErrorResponseBean {
|
class ErrorResponseBean {
|
||||||
int code;
|
int? code;
|
||||||
String description;
|
String? description;
|
||||||
|
|
||||||
static ErrorResponseBean fromMap(Map<String, dynamic> map) {
|
static ErrorResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) return null;
|
if (map == null) return null;
|
||||||
ErrorResponseBean errorResponseBean = ErrorResponseBean();
|
ErrorResponseBean errorResponseBean = ErrorResponseBean();
|
||||||
errorResponseBean.code = map['code'];
|
errorResponseBean.code = map['code'];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class Message {
|
class Message {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
Message({this.message});
|
Message({required this.message});
|
||||||
|
|
||||||
|
|
||||||
static Message fromJson(Map<String, dynamic> data) => Message(message : data['message']);
|
static Message fromJson(Map<String, dynamic> data) => Message(message : data['message']);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Money {
|
class Money {
|
||||||
final num total;
|
final num? total;
|
||||||
final bool loading;
|
final bool loading;
|
||||||
Money({this.total, this.loading});
|
Money({this.total, required this.loading});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ class ProductDao {
|
||||||
final num price;
|
final num price;
|
||||||
num count;
|
num count;
|
||||||
num total;
|
num total;
|
||||||
final Good good;
|
final Good? good;
|
||||||
final Service service;
|
final Service? service;
|
||||||
final String excise;
|
final String? excise;
|
||||||
|
|
||||||
|
|
||||||
ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service, this.excise });
|
ProductDao( {required this.name, required this.price, required this.count, required this.total, this.good, this.service, this.excise });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
class Response<T> {
|
class Response<T> {
|
||||||
final T body;
|
final T? body;
|
||||||
final int status;
|
final int status;
|
||||||
final bool operation;
|
final bool operation;
|
||||||
|
|
||||||
Response({this.body, this.operation, this.status});
|
Response({this.body, required this.operation, required this.status});
|
||||||
|
|
||||||
factory Response.fromJson(Map<String, dynamic> data, Function parser) {
|
factory Response.fromJson(Map<String, dynamic> data, Function parser) {
|
||||||
return Response(
|
return Response(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class SettingModel {
|
class SettingModel {
|
||||||
const SettingModel({this.name, this.type, this.address});
|
const SettingModel({this.name, this.type, this.address});
|
||||||
final String type;
|
final String? type;
|
||||||
final String name;
|
final String? name;
|
||||||
final String address;
|
final String? address;
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
class Smena {
|
class Smena {
|
||||||
final int id;
|
final int? id;
|
||||||
final DateTime startedAt;
|
final DateTime? startedAt;
|
||||||
final DateTime endedAt;
|
final DateTime? endedAt;
|
||||||
final String message;
|
final String? message;
|
||||||
|
|
||||||
Smena({this.id, this.startedAt, this.endedAt, this.message});
|
Smena({this.id, this.startedAt, this.endedAt, this.message});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
class TransactionItem {
|
class TransactionItem {
|
||||||
final String cardType;
|
final String? cardType;
|
||||||
final String cardExpireDate;
|
final String? cardExpireDate;
|
||||||
final String cardNumber;
|
final String? cardNumber;
|
||||||
final String transactionType;
|
final String? transactionType;
|
||||||
final num amount;
|
final num? amount;
|
||||||
final DateTime date;
|
final DateTime? date;
|
||||||
TransactionItem({this.cardType, this.cardExpireDate, this.cardNumber, this.transactionType, this.amount, this.date});
|
TransactionItem({this.cardType, this.cardExpireDate, this.cardNumber, this.transactionType, this.amount, this.date});
|
||||||
|
|
||||||
static TransactionItem fromJson(Map<String, dynamic> json) {
|
static TransactionItem fromJson(Map<String, dynamic> json) {
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
final String name;
|
final String? name;
|
||||||
final String email;
|
final String? email;
|
||||||
final String fullName;
|
final String? fullName;
|
||||||
final String token;
|
final String? token;
|
||||||
int appCompanyId;
|
int? appCompanyId;
|
||||||
int kassaId;
|
int? kassaId;
|
||||||
|
|
||||||
User({this.email, this.fullName, this.name, this.token, this.appCompanyId, this.kassaId});
|
User({this.email, this.fullName, this.name, this.token, this.appCompanyId, this.kassaId});
|
||||||
|
|
||||||
static User fromJson(Map<String, dynamic> json) {
|
static User? fromJson(Map<String, dynamic> json) {
|
||||||
return json != null
|
return json != null
|
||||||
? User (
|
? User (
|
||||||
name: json['name'],
|
name: json['name'],
|
||||||
email: json['mail'],
|
email: json['mail'],
|
||||||
token: json['api_token'],
|
token: json['api_token'],
|
||||||
fullName: json['fullname'],
|
fullName: json['fullname'],
|
||||||
appCompanyId: json['app_company_id'] as int,
|
appCompanyId: json['app_company_id'] ,
|
||||||
kassaId: json['kassa_id'] as int,
|
kassaId: json['kassa_id'] ,
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,90 +24,88 @@ Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
case LoginViewRoute:
|
case LoginViewRoute:
|
||||||
LoginModel model = settings.arguments as LoginModel;
|
LoginModel model = settings.arguments as LoginModel;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: LoginView(
|
viewToShow: LoginView(loginModel: model,),
|
||||||
loginModel: model,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
case HomeViewRoute:
|
case HomeViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: HomeView(),
|
viewToShow: HomeView(),
|
||||||
);
|
);
|
||||||
case PaymentViewRoute:
|
case PaymentViewRoute:
|
||||||
PaymentModel model = settings.arguments as PaymentModel;
|
PaymentModel model = settings.arguments as PaymentModel;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: PaymentView(model: model),
|
viewToShow: PaymentView(model: model),
|
||||||
);
|
);
|
||||||
case PaymentNfcViewRoute:
|
case PaymentNfcViewRoute:
|
||||||
PaymentModel model = settings.arguments as PaymentModel;
|
PaymentModel model = settings.arguments as PaymentModel;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: PaymentNfcView(model: model),
|
viewToShow: PaymentNfcView(model: model),
|
||||||
);
|
);
|
||||||
case HistoryViewRoute:
|
case HistoryViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: HistoryView(),
|
viewToShow: HistoryView(),
|
||||||
);
|
);
|
||||||
case InfoKkmViewRoute:
|
case InfoKkmViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: InfoKkmView(),
|
viewToShow: InfoKkmView(),
|
||||||
);
|
);
|
||||||
case SettingsViewRoute:
|
case SettingsViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: SettingView(),
|
viewToShow: SettingView(),
|
||||||
);
|
);
|
||||||
case BankViewRoute:
|
case BankViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: BankView(),
|
viewToShow: BankView(),
|
||||||
);
|
);
|
||||||
case BankSettingViewRoute:
|
case BankSettingViewRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: BankSettingView(),
|
viewToShow: BankSettingView(),
|
||||||
);
|
);
|
||||||
case QrViewRoute:
|
case QrViewRoute:
|
||||||
ImageShowModel data = settings.arguments as ImageShowModel;
|
ImageShowModel data = settings.arguments as ImageShowModel;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: QrView(data),
|
viewToShow: QrView(data),
|
||||||
);
|
);
|
||||||
case ImageShowRoute:
|
case ImageShowRoute:
|
||||||
ImageShowModel data = settings.arguments as ImageShowModel;
|
ImageShowModel data = settings.arguments as ImageShowModel;
|
||||||
//return SlideRightRoute(widget: ImageShowContainer(data));
|
//return SlideRightRoute(widget: ImageShowContainer(data));
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: ImageShowContainer(data),
|
viewToShow: ImageShowContainer(data),
|
||||||
);
|
);
|
||||||
case SettingsPrinterRoute:
|
case SettingsPrinterRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: SettingPrinterView(),
|
viewToShow: SettingPrinterView(),
|
||||||
);
|
);
|
||||||
case SettingsPrinterBTRoute:
|
case SettingsPrinterBTRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: PrinterSelectView(),
|
viewToShow: PrinterSelectView(),
|
||||||
);
|
);
|
||||||
case SettingsPrinterEncodingRoute:
|
case SettingsPrinterEncodingRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: PrinterEncodingView(),
|
viewToShow: PrinterEncodingView(),
|
||||||
);
|
);
|
||||||
case SettingsPrinterPaperRoute:
|
case SettingsPrinterPaperRoute:
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: PrinterPaperView(),
|
viewToShow: PrinterPaperView(),
|
||||||
);
|
);
|
||||||
case CloseDayShowRoute:
|
case CloseDayShowRoute:
|
||||||
CloseDayData data = settings.arguments as CloseDayData;
|
CloseDayData data = settings.arguments as CloseDayData;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
routeName: settings.name,
|
routeName: settings.name!,
|
||||||
viewToShow: CloseDayShowContainer(data),
|
viewToShow: CloseDayShowContainer(data),
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
|
|
@ -119,7 +117,7 @@ Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PageRoute _getPageRoute({String routeName, Widget viewToShow}) {
|
PageRoute _getPageRoute({required String routeName, required Widget viewToShow}) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: routeName,
|
name: routeName,
|
||||||
|
|
@ -129,7 +127,7 @@ PageRoute _getPageRoute({String routeName, Widget viewToShow}) {
|
||||||
|
|
||||||
class SlideRightRoute extends PageRouteBuilder {
|
class SlideRightRoute extends PageRouteBuilder {
|
||||||
final Widget widget;
|
final Widget widget;
|
||||||
SlideRightRoute({this.widget})
|
SlideRightRoute({required this.widget})
|
||||||
: super(
|
: super(
|
||||||
pageBuilder: (BuildContext context, Animation<double> animation,
|
pageBuilder: (BuildContext context, Animation<double> animation,
|
||||||
Animation<double> secondaryAnimation) {
|
Animation<double> secondaryAnimation) {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class ApiService extends BaseService {
|
||||||
};
|
};
|
||||||
String response = await requestFormData('/authenticate', requestBody, statusCheck: statusCheck );
|
String response = await requestFormData('/authenticate', requestBody, statusCheck: statusCheck );
|
||||||
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
||||||
return aman.body;
|
return aman.body!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AuthBody> authenticateToken(String token, { bool statusCheck = true}) async {
|
Future<AuthBody> authenticateToken(String token, { bool statusCheck = true}) async {
|
||||||
|
|
@ -52,7 +52,7 @@ class ApiService extends BaseService {
|
||||||
};
|
};
|
||||||
String response = await requestFormData('/activate_token', requestBody, statusCheck: statusCheck );
|
String response = await requestFormData('/activate_token', requestBody, statusCheck: statusCheck );
|
||||||
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
AuthResponse aman = AuthResponse.fromJson(json.decode(response));
|
||||||
return aman.body;
|
return aman.body!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response<Message>> isActive(String token) async {
|
Future<Response<Message>> isActive(String token) async {
|
||||||
|
|
@ -73,8 +73,8 @@ class ApiService extends BaseService {
|
||||||
print(hash);
|
print(hash);
|
||||||
|
|
||||||
Map<String, String> requestBody = <String, String>{'login': login, 'hash': hash};
|
Map<String, String> requestBody = <String, String>{'login': login, 'hash': hash};
|
||||||
//var response = await requestFormData('/halykpos/gettoken', requestBody, bodyEntry: true, posEndPoint: true, statusCheck: false);
|
String pointUrl = test ? '/hb/pos/gettoken' : '/halykpos/gettoken';
|
||||||
var response = await requestFormData('/hb/pos/gettoken', requestBody, bodyEntry: true, posEndPoint: true, statusCheck: false);
|
var response = await requestFormData(pointUrl, requestBody, bodyEntry: true, posEndPoint: true, statusCheck: false);
|
||||||
print(response);
|
print(response);
|
||||||
return HalykPosSession.fromJson(jsonDecode(response));
|
return HalykPosSession.fromJson(jsonDecode(response));
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ class ApiService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<String> requestFormData(String point, Map<String, dynamic> requestBody, { bool statusCheck = true, bool bodyEntry = false, bool posEndPoint= false } ) async {
|
Future<String> requestFormData(String point, Map<String, String> requestBody, { bool statusCheck = true, bool bodyEntry = false, bool posEndPoint= false } ) async {
|
||||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ class ApiService extends BaseService {
|
||||||
|
|
||||||
new Future.delayed(const Duration(milliseconds: 1000), (){
|
new Future.delayed(const Duration(milliseconds: 1000), (){
|
||||||
_dialogService.showDialog(description: 'Необходимо пройти повторную авторизацию');
|
_dialogService.showDialog(description: 'Необходимо пройти повторную авторизацию');
|
||||||
UserState state = Redux.store.state.userState;
|
UserState state = Redux.store!.state.userState!;
|
||||||
_navigatorService.replace(LoginViewRoute, arguments: LoginModel(authType: state.authenticateType, login: state.login, password: state.password ));
|
_navigatorService.replace(LoginViewRoute, arguments: LoginModel(authType: state.authenticateType, login: state.login, password: state.password ));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ class BankService extends BaseService {
|
||||||
result = '0';
|
result = '0';
|
||||||
}
|
}
|
||||||
log.i(result);
|
log.i(result);
|
||||||
return int.parse(result) ?? 0;
|
return int.parse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Ps.HalykPosSession> renewToken({String token, String login, String password}) async {
|
Future<Ps.HalykPosSession?> renewToken({required String token, required String login, required String password}) async {
|
||||||
Ps.HalykPosSession result;
|
Ps.HalykPosSession? result;
|
||||||
try {
|
try {
|
||||||
result = await _api.halykPosToken(token, login, password);
|
result = await _api.halykPosToken(token, login, password);
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
|
|
@ -43,11 +43,11 @@ class BankService extends BaseService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<Cd.HalykCloseDayDao> closeDay({ String token}) async {
|
Future<Cd.HalykCloseDayDao?> closeDay({ required String token}) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("closeDay", <String, dynamic>{'token': token });
|
String response = await _channel.invokeMethod("closeDay", <String, dynamic>{'token': token });
|
||||||
log.i(response);
|
log.i(response);
|
||||||
Cd.HalykCloseDayDao dao = Cd.HalykCloseDayDao.fromMap(json.decode(response));
|
Cd.HalykCloseDayDao dao = Cd.HalykCloseDayDao.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
log.e("BankService", e, stack);
|
log.e("BankService", e, stack);
|
||||||
|
|
@ -55,14 +55,14 @@ class BankService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<HalykResponse> pay({double amount, String token}) async {
|
Future<HalykResponse> pay({required double amount, required String token}) async {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
double total = amount * 100;
|
double total = amount * 100;
|
||||||
log.i('total: $total, ${total.toInt()}');
|
log.i('total: $total, ${total.toInt()}');
|
||||||
String response = await _channel.invokeMethod("pay", <String, dynamic>{'amount': total.toInt(), 'token': token });
|
String response = await _channel.invokeMethod("pay", <String, dynamic>{'amount': total.toInt(), 'token': token });
|
||||||
log.i(response);
|
log.i(response);
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response));
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
log.e("BankService", e, stack);
|
log.e("BankService", e, stack);
|
||||||
|
|
@ -70,12 +70,12 @@ class BankService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<HalykResponse> refund({double amount, String token, int terminalId, int operDay, int transNum }) async {
|
Future<HalykResponse> refund({required double amount, required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("refund", <String, dynamic>{
|
String response = await _channel.invokeMethod("refund", <String, dynamic>{
|
||||||
'amount': amount.toInt(), 'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
'amount': amount.toInt(), 'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
||||||
});
|
});
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response));
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
log.e("BankService", e, stack);
|
log.e("BankService", e, stack);
|
||||||
|
|
@ -83,13 +83,13 @@ class BankService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<HalykResponse> reversal({ String token, int terminalId, int operDay, int transNum }) async {
|
Future<HalykResponse> reversal({ required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("reversal", <String, dynamic>{
|
String response = await _channel.invokeMethod("reversal", <String, dynamic>{
|
||||||
'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
||||||
});
|
});
|
||||||
log.i(response);
|
log.i(response);
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response));
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
log.e("BankService", e, stack);
|
log.e("BankService", e, stack);
|
||||||
|
|
@ -102,7 +102,7 @@ class BankService extends BaseService {
|
||||||
final DateFormat formatter = DateFormat('dd.MM.yyyy');
|
final DateFormat formatter = DateFormat('dd.MM.yyyy');
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
final String formatted = formatter.format(now);
|
final String formatted = formatter.format(now);
|
||||||
List<Cd.TransactionBean> items = transactions.transaction;
|
List<Cd.TransactionBean> items = transactions.transaction!;
|
||||||
num totalAmount = 0;
|
num totalAmount = 0;
|
||||||
int totalCount = 0;
|
int totalCount = 0;
|
||||||
num paymentAmount = 0;
|
num paymentAmount = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||||
import 'package:aman_kassa_flutter/core/entity/Category.dart';
|
import 'package:aman_kassa_flutter/core/entity/Category.dart';
|
||||||
|
|
@ -26,7 +27,8 @@ class DataService extends BaseService {
|
||||||
final ApiService _api = locator<ApiService>();
|
final ApiService _api = locator<ApiService>();
|
||||||
final DbService _db = locator<DbService>();
|
final DbService _db = locator<DbService>();
|
||||||
|
|
||||||
Future<List<Category>> getCategoriesByParentId({int parentId}) async {
|
Future<List<Category>> getCategoriesByParentId(
|
||||||
|
{int? parentId}) async {
|
||||||
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(
|
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(
|
||||||
Category_tableName, '$Category_columnParentIn = ?', [parentId ?? 0]);
|
Category_tableName, '$Category_columnParentIn = ?', [parentId ?? 0]);
|
||||||
return list.map((e) => Category.fromMap(e)).toList();
|
return list.map((e) => Category.fromMap(e)).toList();
|
||||||
|
|
@ -37,35 +39,38 @@ class DataService extends BaseService {
|
||||||
return list.map((e) => Service.fromMap(e)).toList();
|
return list.map((e) => Service.fromMap(e)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Good>> getGoodsByCategoryId({int categoryId}) async {
|
Future<List<Good>> getGoodsByCategoryId({int? categoryId}) async {
|
||||||
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(
|
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(
|
||||||
Goog_tableName, '$Goog_columnCategoryId = ?', [categoryId ?? 0]);
|
Goog_tableName, '$Goog_columnCategoryId = ?', [categoryId ?? 0]);
|
||||||
return list.map((e) => Good.fromMap(e)).toList();
|
return list.map((e) => Good.fromMap(e)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Good>> getGoodsByBarcode ({ String barcode}) async {
|
Future<List<Good>> getGoodsByBarcode({required String barcode}) async {
|
||||||
List<Map<String, dynamic>> list = await _db.queryRowsWithWhere(Goog_tableName, ' $Goog_columnEan = ?', [barcode]);
|
List<Map<String, dynamic>> list = await _db
|
||||||
|
.queryRowsWithWhere(Goog_tableName, ' $Goog_columnEan = ?', [barcode]);
|
||||||
return list.map((e) => Good.fromMap(e)).toList();
|
return list.map((e) => Good.fromMap(e)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckData _transformProductsToCheckData(
|
CheckData _transformProductsToCheckData(
|
||||||
{String paymentType, String tradeType, List<ProductDao> items}) {
|
{String? paymentType,
|
||||||
|
String? tradeType,
|
||||||
|
required List<ProductDao> items}) {
|
||||||
List<CheckItem> itemsList = [];
|
List<CheckItem> itemsList = [];
|
||||||
int iterator = 1;
|
int iterator = 1;
|
||||||
num summ = 0.0;
|
num summ = 0.0;
|
||||||
items.forEach((el) {
|
items.forEach((el) {
|
||||||
int articul = iterator;
|
int articul = iterator;
|
||||||
if (el.service != null) {
|
if (el.service != null) {
|
||||||
articul = el.service.articul;
|
articul = el.service!.articul;
|
||||||
} else if (el.good != null) {
|
} else if (el.good != null) {
|
||||||
articul = el.good.articul;
|
articul = el.good!.articul;
|
||||||
}
|
}
|
||||||
itemsList.add(CheckItem(
|
itemsList.add(CheckItem(
|
||||||
name: el.name ?? 'Позиция №$iterator',
|
name: el.name,
|
||||||
cnt: el.count,
|
cnt: el.count,
|
||||||
price: el.price,
|
price: el.price,
|
||||||
articul: articul,
|
articul: articul,
|
||||||
excise: el.excise,
|
excise: el.excise,
|
||||||
));
|
));
|
||||||
summ += el.total;
|
summ += el.total;
|
||||||
iterator++;
|
iterator++;
|
||||||
|
|
@ -78,7 +83,9 @@ class DataService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckData _transformCalcModelToCheckData(
|
CheckData _transformCalcModelToCheckData(
|
||||||
{String paymentType, String tradeType, List<CalcModel> items}) {
|
{String? paymentType,
|
||||||
|
String? tradeType,
|
||||||
|
required List<CalcModel> items}) {
|
||||||
List<CheckItem> itemsList = [];
|
List<CheckItem> itemsList = [];
|
||||||
int iterator = 1;
|
int iterator = 1;
|
||||||
num summ = 0.0;
|
num summ = 0.0;
|
||||||
|
|
@ -86,7 +93,7 @@ class DataService extends BaseService {
|
||||||
int articul = iterator;
|
int articul = iterator;
|
||||||
CheckItem item = CheckItem(
|
CheckItem item = CheckItem(
|
||||||
name: 'Позиция $iterator',
|
name: 'Позиция $iterator',
|
||||||
cnt: el.num2 != null ? double.parse(el.num2) : 1.0,
|
cnt: el.num2 != null ? double.parse(el.num2!) : 1.0,
|
||||||
price: double.parse(el.num1),
|
price: double.parse(el.num1),
|
||||||
articul: articul);
|
articul: articul);
|
||||||
|
|
||||||
|
|
@ -112,13 +119,13 @@ class DataService extends BaseService {
|
||||||
* type
|
* type
|
||||||
*/
|
*/
|
||||||
Future<void> insertVoucher(
|
Future<void> insertVoucher(
|
||||||
{@required User user,
|
{required User user,
|
||||||
String data,
|
String? data,
|
||||||
String base64Data,
|
String? base64Data,
|
||||||
@required String name,
|
required String name,
|
||||||
double total = 0.0,
|
double total = 0.0,
|
||||||
String type = VoucherTypePayment,
|
String type = VoucherTypePayment,
|
||||||
String url}) {
|
String? url}) async {
|
||||||
assert(user != null);
|
assert(user != null);
|
||||||
assert(name != null);
|
assert(name != null);
|
||||||
Voucher voucher = Voucher()
|
Voucher voucher = Voucher()
|
||||||
|
|
@ -134,14 +141,13 @@ class DataService extends BaseService {
|
||||||
log.i(
|
log.i(
|
||||||
'save to db appCompanyId: ${user.appCompanyId}, kassaId: ${user.kassaId}');
|
'save to db appCompanyId: ${user.appCompanyId}, kassaId: ${user.kassaId}');
|
||||||
_db.insert(Voucher_tableName, voucher.toMap());
|
_db.insert(Voucher_tableName, voucher.toMap());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response<dynamic>> refundM4Bank(
|
Future<Response<dynamic>?> refundM4Bank(
|
||||||
{
|
{
|
||||||
String token,
|
required String token,
|
||||||
CheckData checkData,
|
required CheckData checkData,
|
||||||
CardData cardData}) async {
|
required CardData cardData}) async {
|
||||||
try {
|
try {
|
||||||
var json = cardData.toJson();
|
var json = cardData.toJson();
|
||||||
json['transactionType'] = VoucherTypeReturnPay;
|
json['transactionType'] = VoucherTypeReturnPay;
|
||||||
|
|
@ -154,10 +160,10 @@ class DataService extends BaseService {
|
||||||
log.i('response status: ${response.status}');
|
log.i('response status: ${response.status}');
|
||||||
log.i('response operation: ${response.operation}');
|
log.i('response operation: ${response.operation}');
|
||||||
if (response.status == 200 && response.operation == true) {
|
if (response.status == 200 && response.operation == true) {
|
||||||
User user = Redux.store.state.userState.user;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
String check = response?.body['check'];
|
String check = response.body['check'];
|
||||||
dynamic journal = response?.body['journal'];
|
dynamic journal = response.body['journal'];
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
int checkNum = journal['check_num'];
|
int checkNum = journal['check_num'];
|
||||||
var summ = journal['summ'];
|
var summ = journal['summ'];
|
||||||
double total = summ != null ? double.parse(summ.toString()) : 0.0;
|
double total = summ != null ? double.parse(summ.toString()) : 0.0;
|
||||||
|
|
@ -177,17 +183,17 @@ class DataService extends BaseService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response<dynamic>> sellOrReturn(
|
Future<Response<dynamic>?> sellOrReturn(
|
||||||
{String paymentType,
|
{String? paymentType,
|
||||||
String tradeType,
|
String? tradeType,
|
||||||
String token,
|
required String token,
|
||||||
List<ProductDao> kassaItems,
|
required List<ProductDao> kassaItems,
|
||||||
List<CalcModel> calcItems,
|
required List<CalcModel> calcItems,
|
||||||
String operationType,
|
required String operationType,
|
||||||
String mode,
|
required String mode,
|
||||||
CardData cardData}) async {
|
required CardData? cardData}) async {
|
||||||
try {
|
try {
|
||||||
String data;
|
String data = "";
|
||||||
if (mode == SettingModeKassa) {
|
if (mode == SettingModeKassa) {
|
||||||
CheckData checkData = _transformProductsToCheckData(
|
CheckData checkData = _transformProductsToCheckData(
|
||||||
paymentType: paymentType, tradeType: tradeType, items: kassaItems);
|
paymentType: paymentType, tradeType: tradeType, items: kassaItems);
|
||||||
|
|
@ -208,18 +214,20 @@ class DataService extends BaseService {
|
||||||
// log.i('response status: ${response.status}');
|
// log.i('response status: ${response.status}');
|
||||||
// log.i('response operation: ${response.operation}');
|
// log.i('response operation: ${response.operation}');
|
||||||
if (response.status == 200 && response.operation == true) {
|
if (response.status == 200 && response.operation == true) {
|
||||||
User user = Redux.store.state.userState.user;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
//check compare
|
//check compare
|
||||||
|
|
||||||
String check = response?.body['check'];
|
String check = response.body['check'];
|
||||||
var checkText = response?.body['check_text'];
|
var checkText = response.body['check_text'];
|
||||||
CheckImageModal imageModal = new CheckImageModal( base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null );
|
CheckImageModal imageModal = new CheckImageModal(
|
||||||
|
base64Data: check,
|
||||||
|
textData: checkText != null ? jsonEncode(checkText) : null);
|
||||||
// journal analyze
|
// journal analyze
|
||||||
dynamic journal = response?.body['journal'];
|
dynamic journal = response.body['journal'];
|
||||||
int checkNum = journal['check_num'];
|
int checkNum = journal['check_num'];
|
||||||
var summ = journal['summ'];
|
var summ = journal['summ'];
|
||||||
// short url
|
// short url
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
// total
|
// total
|
||||||
double total = summ != null ? double.parse(summ.toString()) : 0.0;
|
double total = summ != null ? double.parse(summ.toString()) : 0.0;
|
||||||
|
|
||||||
|
|
@ -243,9 +251,9 @@ class DataService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkDbFill(User user) async {
|
Future<void> checkDbFill(User user) async {
|
||||||
int serviceCount = await _db.queryRowCount(Service_tableName);
|
int serviceCount = await _db.queryRowCount(Service_tableName) ?? 0;
|
||||||
if (serviceCount == 0) {
|
if (serviceCount == 0) {
|
||||||
int goodCount = await _db.queryRowCount(Goog_tableName);
|
int goodCount = await _db.queryRowCount(Goog_tableName) ?? 0;
|
||||||
if (goodCount == 0) {
|
if (goodCount == 0) {
|
||||||
await getDataFromServer(user);
|
await getDataFromServer(user);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -259,9 +267,10 @@ class DataService extends BaseService {
|
||||||
Future<bool> getDataFromServer(User user) async {
|
Future<bool> getDataFromServer(User user) async {
|
||||||
log.i('Get Data from server');
|
log.i('Get Data from server');
|
||||||
try {
|
try {
|
||||||
String token = user.token;
|
String token = user.token!;
|
||||||
Response<dynamic> goods = await _api.getGoodsFromServer(token);
|
Response<dynamic> goods = await _api.getGoodsFromServer(token);
|
||||||
if(goods.operation==false && [401,402,403,412].contains(goods.status)){
|
if (goods.operation == false &&
|
||||||
|
[401, 402, 403, 412].contains(goods.status)) {
|
||||||
log.i('session is closed');
|
log.i('session is closed');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +281,6 @@ class DataService extends BaseService {
|
||||||
await _db.deleteAll(Service_tableName);
|
await _db.deleteAll(Service_tableName);
|
||||||
log.i('All tables cleaned');
|
log.i('All tables cleaned');
|
||||||
|
|
||||||
|
|
||||||
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]);
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ class DbService extends BaseService {
|
||||||
static final DbService instance = DbService._privateConstructor();
|
static final DbService instance = DbService._privateConstructor();
|
||||||
|
|
||||||
// only have a single app-wide reference to the database
|
// only have a single app-wide reference to the database
|
||||||
static Database _database;
|
static Database? _database;
|
||||||
|
|
||||||
Future<Database> get database async {
|
Future<Database> get database async {
|
||||||
if (_database != null) return _database;
|
if (_database != null) return _database!;
|
||||||
// lazily instantiate the db the first time it is accessed
|
// lazily instantiate the db the first time it is accessed
|
||||||
_database = await _initDatabase();
|
_database = await _initDatabase();
|
||||||
return _database;
|
return _database!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this opens the database (and creates it if it doesn't exist)
|
// this opens the database (and creates it if it doesn't exist)
|
||||||
|
|
@ -136,7 +136,7 @@ class DbService extends BaseService {
|
||||||
|
|
||||||
// All of the methods (insert, query, update, delete) can also be done using
|
// All of the methods (insert, query, update, delete) can also be done using
|
||||||
// raw SQL commands. This method uses a raw query to give the row count.
|
// raw SQL commands. This method uses a raw query to give the row count.
|
||||||
Future<int> queryRowCount(String table) async {
|
Future<int?> queryRowCount(String table) async {
|
||||||
Database db = await instance.database;
|
Database db = await instance.database;
|
||||||
return Sqflite.firstIntValue(
|
return Sqflite.firstIntValue(
|
||||||
await db.rawQuery('SELECT COUNT(*) FROM $table'));
|
await db.rawQuery('SELECT COUNT(*) FROM $table'));
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,18 @@ import 'ApiService.dart';
|
||||||
class AuthenticationService extends BaseService {
|
class AuthenticationService extends BaseService {
|
||||||
final ApiService _api;
|
final ApiService _api;
|
||||||
|
|
||||||
AuthenticationService({ApiService api}) : _api = api;
|
AuthenticationService({required ApiService api}) : _api = api;
|
||||||
|
|
||||||
User _currentUser;
|
User? _currentUser;
|
||||||
User get currentUser => _currentUser;
|
User? get currentUser => _currentUser;
|
||||||
|
|
||||||
Future<AuthBody> loginWithEmail({
|
Future<AuthBody?> loginWithEmail({
|
||||||
@required String email,
|
required String email,
|
||||||
@required String password,
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
AuthBody result = await _api.authenticate(email, password);
|
AuthBody? result = await _api.authenticate(email, password);
|
||||||
if (result.user != null) {
|
if (result!=null && result.user != null) {
|
||||||
_currentUser = result.user;
|
_currentUser = result.user;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -32,7 +32,7 @@ class AuthenticationService extends BaseService {
|
||||||
|
|
||||||
Future<bool> isUserLoggedIn(String token) async {
|
Future<bool> isUserLoggedIn(String token) async {
|
||||||
Response<Message> session = await _api.isActive(token);
|
Response<Message> session = await _api.isActive(token);
|
||||||
if ("OK" == session.body.message) {
|
if ("OK" == session.body?.message) {
|
||||||
//_session = session;
|
//_session = session;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ class AuthenticationService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> logout(String token) async {
|
Future<bool> logout(String token) async {
|
||||||
Response<Message> session = await _api.logout(token);
|
Response<dynamic> session = await _api.logout(token);
|
||||||
if ("logout" == session.body.message) {
|
if ("logout" == session.body.message) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||||
|
import 'package:bluetooth_print/bluetooth_print.dart';
|
||||||
|
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||||
|
import 'package:flutter_blue/flutter_blue.dart' as flutter_blue;
|
||||||
|
import 'package:flutter_blue/gen/flutterblue.pb.dart' as proto;
|
||||||
|
|
||||||
|
class BluePrintService extends BaseService {
|
||||||
|
final BluetoothPrint _bluetoothAndr = BluetoothPrint.instance;
|
||||||
|
flutter_blue.BluetoothDevice? _bluetoothDeviceIOS;
|
||||||
|
final flutter_blue.FlutterBlue _bluetoothIOS =
|
||||||
|
flutter_blue.FlutterBlue.instance;
|
||||||
|
|
||||||
|
final bool isAndroid = Platform.isAndroid;
|
||||||
|
final bool isIos = Platform.isIOS;
|
||||||
|
// final bool isAndroid = false;
|
||||||
|
// final bool isIos = true;
|
||||||
|
|
||||||
|
BluetoothDevice? _device;
|
||||||
|
|
||||||
|
Future<void> scan() async {
|
||||||
|
if (isAndroid) {
|
||||||
|
await _bluetoothAndr.startScan(timeout: Duration(seconds: 4));
|
||||||
|
} else if (isIos) {
|
||||||
|
await _bluetoothIOS.startScan(timeout: const Duration(seconds: 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> stopScan() async {
|
||||||
|
if (isAndroid) {
|
||||||
|
await _bluetoothAndr.stopScan();
|
||||||
|
} else if (isIos) {
|
||||||
|
await _bluetoothIOS.stopScan();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<List<BluetoothDevice>> get scanResult {
|
||||||
|
if (isAndroid)
|
||||||
|
return _bluetoothAndr.scanResults;
|
||||||
|
else
|
||||||
|
return _bluetoothIOS.scanResults.asyncMap<List<BluetoothDevice>>(
|
||||||
|
(event) =>
|
||||||
|
Future.wait(event.toList().map((e) async => BluetoothDevice()
|
||||||
|
..name = e.device.name
|
||||||
|
..type = e.device.type.index
|
||||||
|
..address = e.device.id.id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<bool> get isScanning =>
|
||||||
|
isAndroid ? _bluetoothAndr.isScanning : _bluetoothIOS.isScanning;
|
||||||
|
|
||||||
|
Stream<int> get state => isAndroid
|
||||||
|
? _bluetoothAndr.state
|
||||||
|
: _bluetoothIOS.state.asyncMap<int>((event) => event.index);
|
||||||
|
|
||||||
|
set device(BluetoothDevice device) => _device = device;
|
||||||
|
|
||||||
|
Future<bool> connect() async {
|
||||||
|
bool response = false;
|
||||||
|
if (_device == null) {
|
||||||
|
response = false;
|
||||||
|
} else {
|
||||||
|
// try {
|
||||||
|
// await _bluetoothAndr.connect(_device!);
|
||||||
|
// await Future.delayed(Duration(seconds: 5));
|
||||||
|
// response = true;
|
||||||
|
// } catch (e) {
|
||||||
|
// print('Error connect $e');
|
||||||
|
// response = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isAndroid) {
|
||||||
|
await _bluetoothAndr.connect(_device!);
|
||||||
|
} else if (isIos) {
|
||||||
|
_bluetoothDeviceIOS = flutter_blue.BluetoothDevice.fromProto(
|
||||||
|
proto.BluetoothDevice(
|
||||||
|
name: _device?.name ?? '',
|
||||||
|
remoteId: _device?.address ?? '',
|
||||||
|
type: proto.BluetoothDevice_Type.valueOf(_device?.type ?? 0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final List<flutter_blue.BluetoothDevice> connectedDevices =
|
||||||
|
await _bluetoothIOS.connectedDevices;
|
||||||
|
final int deviceConnectedIndex = connectedDevices
|
||||||
|
.indexWhere((flutter_blue.BluetoothDevice bluetoothDevice) {
|
||||||
|
return bluetoothDevice.id == _bluetoothDeviceIOS?.id;
|
||||||
|
});
|
||||||
|
if (deviceConnectedIndex < 0) {
|
||||||
|
await _bluetoothDeviceIOS?.connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response = true;
|
||||||
|
_device?.connected = true;
|
||||||
|
return Future<bool>.value(response);
|
||||||
|
} on Exception catch (error) {
|
||||||
|
print('$runtimeType - Error $error');
|
||||||
|
response = false;
|
||||||
|
_device?.connected = false;
|
||||||
|
return Future<bool>.value(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> disconnect() async {
|
||||||
|
bool response = false;
|
||||||
|
try {
|
||||||
|
if (isAndroid) {
|
||||||
|
await _bluetoothAndr.disconnect();
|
||||||
|
} else if (isIos) {
|
||||||
|
await _bluetoothDeviceIOS?.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
print('disconnected');
|
||||||
|
response = true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Error $e');
|
||||||
|
response = false;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> printBytes(Uint8List bytes,
|
||||||
|
{int chunkSizeBytes = 20, int queueSleepTimeMs = 20}) async {
|
||||||
|
Map<String, dynamic> config = Map();
|
||||||
|
final len = bytes.length;
|
||||||
|
List<List<int>> chunks = [];
|
||||||
|
for (var i = 0; i < len; i += chunkSizeBytes) {
|
||||||
|
var end = (i + chunkSizeBytes < len) ? i + chunkSizeBytes : len;
|
||||||
|
chunks.add(bytes.sublist(i, end));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < chunks.length; i += 1) {
|
||||||
|
if (isAndroid) {
|
||||||
|
await _printAndroid(chunks[i], config);
|
||||||
|
} else if (isIos) {
|
||||||
|
await _printIos(Uint8List.fromList(chunks[i]), config);
|
||||||
|
}
|
||||||
|
|
||||||
|
await Future.delayed(Duration(milliseconds: queueSleepTimeMs));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _printIos(Uint8List bytes,Map<String, dynamic> config) async {
|
||||||
|
final List<flutter_blue.BluetoothService> bluetoothServices =
|
||||||
|
await _bluetoothDeviceIOS?.discoverServices() ??
|
||||||
|
<flutter_blue.BluetoothService>[];
|
||||||
|
final flutter_blue.BluetoothService bluetoothService =
|
||||||
|
bluetoothServices.firstWhere(
|
||||||
|
(flutter_blue.BluetoothService service) => service.isPrimary,
|
||||||
|
);
|
||||||
|
final flutter_blue.BluetoothCharacteristic characteristic =
|
||||||
|
bluetoothService.characteristics.firstWhere(
|
||||||
|
(flutter_blue.BluetoothCharacteristic bluetoothCharacteristic) =>
|
||||||
|
bluetoothCharacteristic.properties.write,
|
||||||
|
);
|
||||||
|
await characteristic.write(bytes, withoutResponse: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _printAndroid(List<int> chunk ,Map<String, dynamic> config) async {
|
||||||
|
|
||||||
|
|
||||||
|
await _bluetoothAndr.rawBytes(config, chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,11 +5,11 @@ import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
class DialogService {
|
class DialogService {
|
||||||
GlobalKey<NavigatorState> _dialogNavigationKey = GlobalKey<NavigatorState>();
|
GlobalKey<NavigatorState> _dialogNavigationKey = GlobalKey<NavigatorState>();
|
||||||
Function(DialogRequest) _showDialogListener;
|
Function(DialogRequest)? _showDialogListener;
|
||||||
Function(DialogRequest) _showDialogInputListener;
|
Function(DialogRequest)? _showDialogInputListener;
|
||||||
Completer<DialogResponse> _dialogCompleter;
|
Completer<DialogResponse>? _dialogCompleter;
|
||||||
|
|
||||||
Completer<DialogResponse> get completer => this._dialogCompleter;
|
Completer<DialogResponse>? get completer => this._dialogCompleter;
|
||||||
|
|
||||||
GlobalKey<NavigatorState> get dialogNavigationKey => _dialogNavigationKey;
|
GlobalKey<NavigatorState> get dialogNavigationKey => _dialogNavigationKey;
|
||||||
|
|
||||||
|
|
@ -23,53 +23,53 @@ class DialogService {
|
||||||
/// Calls the dialog listener and returns a Future that will wait for dialogComplete.
|
/// Calls the dialog listener and returns a Future that will wait for dialogComplete.
|
||||||
Future<DialogResponse> showDialog({
|
Future<DialogResponse> showDialog({
|
||||||
String title = 'Aman Касса',
|
String title = 'Aman Касса',
|
||||||
String description,
|
required String description,
|
||||||
String buttonTitle = 'Ok',
|
String buttonTitle = 'Ok',
|
||||||
}) {
|
}) {
|
||||||
_dialogCompleter = Completer<DialogResponse>();
|
_dialogCompleter = Completer<DialogResponse>();
|
||||||
_showDialogListener(DialogRequest(
|
_showDialogListener!(DialogRequest(
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
buttonTitle: buttonTitle,
|
buttonTitle: buttonTitle,
|
||||||
));
|
));
|
||||||
return _dialogCompleter.future;
|
return _dialogCompleter!.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows a confirmation dialog
|
/// Shows a confirmation dialog
|
||||||
Future<DialogResponse> showConfirmationDialog(
|
Future<DialogResponse> showConfirmationDialog(
|
||||||
{String title,
|
{required String title,
|
||||||
String description,
|
required String description,
|
||||||
String confirmationTitle = 'Ok',
|
String confirmationTitle = 'Ok',
|
||||||
String cancelTitle = 'Cancel'}) {
|
String cancelTitle = 'Cancel'}) {
|
||||||
_dialogCompleter = Completer<DialogResponse>();
|
_dialogCompleter = Completer<DialogResponse>();
|
||||||
_showDialogListener(DialogRequest(
|
_showDialogListener!(DialogRequest(
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
buttonTitle: confirmationTitle,
|
buttonTitle: confirmationTitle,
|
||||||
cancelTitle: cancelTitle));
|
cancelTitle: cancelTitle));
|
||||||
return _dialogCompleter.future;
|
return _dialogCompleter!.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DialogResponse> showConfirmationDialogInput(
|
Future<DialogResponse> showConfirmationDialogInput(
|
||||||
{String title = ' Aman Касса',
|
{String title = ' Aman Касса',
|
||||||
String description,
|
required String description,
|
||||||
String confirmationTitle = 'Ok',
|
String confirmationTitle = 'Ok',
|
||||||
String cancelTitle = 'Cancel',
|
String cancelTitle = 'Cancel',
|
||||||
String formatType}) {
|
String? formatType}) {
|
||||||
_dialogCompleter = Completer<DialogResponse>();
|
_dialogCompleter = Completer<DialogResponse>();
|
||||||
_showDialogInputListener(DialogRequest(
|
_showDialogInputListener!(DialogRequest(
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
buttonTitle: confirmationTitle,
|
buttonTitle: confirmationTitle,
|
||||||
cancelTitle: cancelTitle,
|
cancelTitle: cancelTitle,
|
||||||
formatType: formatType));
|
formatType: formatType));
|
||||||
return _dialogCompleter.future;
|
return _dialogCompleter!.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Completes the _dialogCompleter to resume the Future's execution call
|
/// Completes the _dialogCompleter to resume the Future's execution call
|
||||||
void dialogComplete(DialogResponse response) {
|
void dialogComplete(DialogResponse response) {
|
||||||
_dialogNavigationKey.currentState.pop();
|
_dialogNavigationKey.currentState!.pop();
|
||||||
_dialogCompleter.complete(response);
|
_dialogCompleter!.complete(response);
|
||||||
_dialogCompleter = null;
|
_dialogCompleter = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,27 @@ class NavigatorService extends BaseService {
|
||||||
|
|
||||||
Future<dynamic> push(String routeName, {dynamic arguments}) {
|
Future<dynamic> push(String routeName, {dynamic arguments}) {
|
||||||
log.i('routeName: $routeName');
|
log.i('routeName: $routeName');
|
||||||
return navigatorKey.currentState
|
return navigatorKey.currentState!
|
||||||
.pushNamed(routeName, arguments: arguments);
|
.pushNamed(routeName, arguments: arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> replace(String routeName, {dynamic arguments}) {
|
Future<dynamic> replace(String routeName, {dynamic arguments}) {
|
||||||
log.i('routeName: $routeName');
|
log.i('routeName: $routeName');
|
||||||
return navigatorKey.currentState
|
return navigatorKey.currentState!
|
||||||
.pushNamedAndRemoveUntil(routeName, (Route<dynamic> route) => false, arguments: arguments);
|
.pushNamedAndRemoveUntil(routeName, (Route<dynamic> route) => false, arguments: arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<T> navigateToPage<T>(MaterialPageRoute<T> pageRoute) async {
|
Future<T?> navigateToPage<T>(MaterialPageRoute<T> pageRoute) async {
|
||||||
log.i('navigateToPage: pageRoute: ${pageRoute.settings.name}');
|
log.i('navigateToPage: pageRoute: ${pageRoute.settings.name}');
|
||||||
if (navigatorKey.currentState == null) {
|
if (navigatorKey.currentState == null) {
|
||||||
log.e('navigateToPage: Navigator State is null');
|
log.e('navigateToPage: Navigator State is null');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return navigatorKey.currentState.push(pageRoute);
|
return navigatorKey.currentState!.push(pageRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T> navigateToPageWithReplacement<T>(
|
Future<T?> navigateToPageWithReplacement<T>(
|
||||||
MaterialPageRoute<T> pageRoute) async {
|
MaterialPageRoute<T> pageRoute) async {
|
||||||
log.i('navigateToPageWithReplacement: '
|
log.i('navigateToPageWithReplacement: '
|
||||||
'pageRoute: ${pageRoute.settings.name}');
|
'pageRoute: ${pageRoute.settings.name}');
|
||||||
|
|
@ -34,15 +34,15 @@ class NavigatorService extends BaseService {
|
||||||
log.e('navigateToPageWithReplacement: Navigator State is null');
|
log.e('navigateToPageWithReplacement: Navigator State is null');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return navigatorKey.currentState.pushReplacement(pageRoute);
|
return navigatorKey.currentState!.pushReplacement(pageRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop<T>([T result]) {
|
void pop<T>([T? result]) {
|
||||||
log.i('goBack:');
|
log.i('goBack:');
|
||||||
if (navigatorKey.currentState == null) {
|
if (navigatorKey.currentState == null) {
|
||||||
log.e('goBack: Navigator State is null');
|
log.e('goBack: Navigator State is null');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigatorKey.currentState.pop(result);
|
navigatorKey.currentState!.pop(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
List<String> parseListString(json){
|
List<String>? parseListString(json){
|
||||||
if(json==null) return null;
|
if(json==null) return null;
|
||||||
return new List<String>.from(json);
|
return new List<String>.from(json);
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:flutter_screenutil/screenutil_init.dart';
|
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
//service & tools
|
//service & tools
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'core/locator.dart';
|
import 'core/locator.dart';
|
||||||
|
|
@ -16,10 +16,10 @@ import 'core/router.dart';
|
||||||
import 'core/services/navigator_service.dart';
|
import 'core/services/navigator_service.dart';
|
||||||
import 'core/services/dialog_service.dart';
|
import 'core/services/dialog_service.dart';
|
||||||
import './widgets/dialog_manager.dart';
|
import './widgets/dialog_manager.dart';
|
||||||
|
|
||||||
//pages
|
//pages
|
||||||
import 'views/start_up/start_up_view.dart';
|
import 'views/start_up/start_up_view.dart';
|
||||||
|
|
||||||
|
|
||||||
//main start
|
//main start
|
||||||
void main() async {
|
void main() async {
|
||||||
HttpOverrides.global = MyHttpOverrides();
|
HttpOverrides.global = MyHttpOverrides();
|
||||||
|
|
@ -38,25 +38,35 @@ void main() async {
|
||||||
runApp(MainApplication());
|
runApp(MainApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainApplication extends StatelessWidget {
|
class MyHttpOverrides extends HttpOverrides {
|
||||||
|
@override
|
||||||
|
HttpClient createHttpClient(SecurityContext? context) {
|
||||||
|
return super.createHttpClient(context)
|
||||||
|
..badCertificateCallback =
|
||||||
|
(X509Certificate cert, String host, int port) => true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainApplication extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return StoreProvider<AppState>(
|
return StoreProvider<AppState>(
|
||||||
store: Redux.store,
|
store: Redux.store!,
|
||||||
child: ScreenUtilInit(
|
child: ScreenUtilInit(
|
||||||
designSize: Size(411.43, 683.43),
|
designSize: const Size(
|
||||||
allowFontScaling: false,
|
411.43,
|
||||||
|
683.43,
|
||||||
|
),
|
||||||
builder: () => MaterialApp(
|
builder: () => MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
primaryColor: primaryColor,
|
primaryColor: primaryColor,
|
||||||
accentColor: yellowColor,
|
accentColor: yellowColor,
|
||||||
scaffoldBackgroundColor: Colors.white,
|
scaffoldBackgroundColor: Colors.white,
|
||||||
textTheme: GoogleFonts.latoTextTheme(
|
// textTheme: GoogleFonts.latoTextTheme(
|
||||||
Theme.of(context).textTheme,
|
// Theme.of(context).textTheme,
|
||||||
)
|
// )
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
builder: (context, child) => Navigator(
|
builder: (context, child) => Navigator(
|
||||||
|
|
@ -65,18 +75,10 @@ class MainApplication extends StatelessWidget {
|
||||||
builder: (context) => DialogManager(child: child)),
|
builder: (context) => DialogManager(child: child)),
|
||||||
),
|
),
|
||||||
navigatorKey: locator<NavigatorService>().navigatorKey,
|
navigatorKey: locator<NavigatorService>().navigatorKey,
|
||||||
home: StartUpView(), // first page
|
home: StartUpView(),
|
||||||
|
// first page
|
||||||
onGenerateRoute: generateRoute,
|
onGenerateRoute: generateRoute,
|
||||||
),
|
),
|
||||||
),
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHttpOverrides extends HttpOverrides{
|
|
||||||
@override
|
|
||||||
HttpClient createHttpClient(SecurityContext context){
|
|
||||||
return super.createHttpClient(context)
|
|
||||||
..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:aman_kassa_flutter/core/models/calc_model.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/state/calc_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/calc_state.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
@ -26,7 +27,7 @@ ThunkAction<AppState> onTapAction(String value) {
|
||||||
if(value == Calculations.EQUAL){
|
if(value == Calculations.EQUAL){
|
||||||
return setEqual(store);
|
return setEqual(store);
|
||||||
}
|
}
|
||||||
List calcItems = Calculator.action(value: value, items: store.state.calcState.calcItems);
|
List<CalcModel> calcItems = Calculator.action(value: value, items: store.state.calcState!.calcItems!);
|
||||||
store.dispatch(SetCalcStateAction(CalcState(calcItems: calcItems, isEqual: false)));
|
store.dispatch(SetCalcStateAction(CalcState(calcItems: calcItems, isEqual: false)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -24,8 +24,8 @@ final DataService _dataService = locator<DataService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
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;
|
||||||
DictDao last = prevCategories.removeLast();
|
DictDao? last = prevCategories?.removeLast() ;
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
store.dispatch(SetKassaStateAction(KassaState(prevCategories: prevCategories)));
|
store.dispatch(SetKassaStateAction(KassaState(prevCategories: prevCategories)));
|
||||||
store.dispatch(selectBottomElement(last.id));
|
store.dispatch(selectBottomElement(last.id));
|
||||||
|
|
@ -36,18 +36,18 @@ Future<void> cleanKassaItems(Store<AppState> store) async {
|
||||||
store.dispatch(SetKassaStateAction(KassaState(kassaItems: [])));
|
store.dispatch(SetKassaStateAction(KassaState(kassaItems: [])));
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkAction<AppState> addCustomProductToKassaItems(String name, int count, double price, double total) {
|
ThunkAction<AppState> addCustomProductToKassaItems(String name, double count, double price, double total) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = store.state.kassaState.kassaItems;
|
List<ProductDao> items = store.state.kassaState!.kassaItems!;
|
||||||
items.add(new ProductDao(name: name, count: count, price: price, total: total));
|
items.add(new ProductDao(name: name, count: count, price: price, total: total));
|
||||||
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
|
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ThunkAction<AppState> addProductToKassaItems(Good good, String excise) {
|
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.excise == null && element.good?.id == good.id);
|
int index = items.indexWhere((element) => element.excise == null && element.good?.id == good.id);
|
||||||
if(excise !=null) {
|
if(excise !=null) {
|
||||||
int existIndex = items.indexWhere((element) => element.excise != null && element.excise == excise);
|
int existIndex = items.indexWhere((element) => element.excise != null && element.excise == excise);
|
||||||
|
|
@ -68,7 +68,7 @@ ThunkAction<AppState> addProductToKassaItems(Good good, String excise) {
|
||||||
|
|
||||||
ThunkAction<AppState> addServiceToKassaItems(Service service) {
|
ThunkAction<AppState> addServiceToKassaItems(Service service) {
|
||||||
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 == service.id);
|
int index = items.indexWhere((element) => element.good?.id == service.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
store.dispatch(counterProductFromKassaItems(index, 1));
|
store.dispatch(counterProductFromKassaItems(index, 1));
|
||||||
|
|
@ -82,7 +82,7 @@ ThunkAction<AppState> addServiceToKassaItems(Service service) {
|
||||||
|
|
||||||
ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = List.from(store.state.kassaState.kassaItems);
|
List<ProductDao> items = List.from(store.state.kassaState!.kassaItems!);
|
||||||
items.removeAt(index);
|
items.removeAt(index);
|
||||||
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
|
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
|
||||||
};
|
};
|
||||||
|
|
@ -90,7 +90,7 @@ ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
||||||
|
|
||||||
ThunkAction<AppState> counterProductFromKassaItems(int index, int counter) {
|
ThunkAction<AppState> counterProductFromKassaItems(int index, int counter) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = store.state.kassaState.kassaItems;
|
List<ProductDao> items = store.state.kassaState!.kassaItems!;
|
||||||
ProductDao product = items.elementAt(index);
|
ProductDao product = items.elementAt(index);
|
||||||
if (product.count == 1 && counter < 0) {
|
if (product.count == 1 && counter < 0) {
|
||||||
//if count to zero need delete element
|
//if count to zero need delete element
|
||||||
|
|
@ -107,24 +107,24 @@ ThunkAction<AppState> selectBottomElement(int parentId) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
store.dispatch(SetKassaStateAction(KassaState(bottomSheetLoading: true, bottomSheetElements: [])));
|
store.dispatch(SetKassaStateAction(KassaState(bottomSheetLoading: true, bottomSheetElements: [])));
|
||||||
try {
|
try {
|
||||||
List<DictDao> prevCategories = store.state.kassaState.prevCategories;
|
List<DictDao> prevCategories = store.state.kassaState!.prevCategories!;
|
||||||
if (parentId == 0) {
|
if (parentId == 0) {
|
||||||
prevCategories = [];
|
prevCategories = [];
|
||||||
}
|
}
|
||||||
store.state.kassaState.bottomSheetElements.forEach((element) {
|
store.state.kassaState!.bottomSheetElements!.forEach((element) {
|
||||||
if (element is Category && element.id == parentId) {
|
if (element is Category && element.id == parentId) {
|
||||||
prevCategories.add(DictDao(id: element.parentIn, name: element.name));
|
prevCategories.add(DictDao(id: element.parentIn!, name: element.name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
List _bottomSheetElements = [];
|
List _bottomSheetElements = [];
|
||||||
|
|
||||||
|
|
||||||
if(store.state.settingState.tradeType == SettingTradeTypeGood) {
|
if(store.state.settingState!.tradeType == SettingTradeTypeGood) {
|
||||||
List<Category> categories = await _dataService.getCategoriesByParentId(parentId: parentId);
|
List<Category> categories = await _dataService.getCategoriesByParentId(parentId: parentId);
|
||||||
_bottomSheetElements.addAll(categories);
|
_bottomSheetElements.addAll(categories);
|
||||||
List<Good> goods = await _dataService.getGoodsByCategoryId(categoryId: parentId);
|
List<Good> goods = await _dataService.getGoodsByCategoryId(categoryId: parentId);
|
||||||
_bottomSheetElements.addAll(goods);
|
_bottomSheetElements.addAll(goods);
|
||||||
} else if(store.state.settingState.tradeType == SettingTradeTypeService) {
|
} else if(store.state.settingState!.tradeType == SettingTradeTypeService) {
|
||||||
List<Service> services = await _dataService.getServices();
|
List<Service> services = await _dataService.getServices();
|
||||||
_bottomSheetElements.addAll(services);
|
_bottomSheetElements.addAll(services);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
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/setting_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||||
|
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:redux_thunk/redux_thunk.dart';
|
import 'package:redux_thunk/redux_thunk.dart';
|
||||||
import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart';
|
|
||||||
import '../store.dart';
|
import '../store.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
|
|
|
||||||
|
|
@ -30,17 +30,17 @@ final DialogService _dialogService = locator<DialogService>();
|
||||||
Future<void> checkUserAction(Store<AppState> store) async {
|
Future<void> checkUserAction(Store<AppState> store) async {
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
||||||
try {
|
try {
|
||||||
User user = store.state.userState.user;
|
User? user = store.state.userState?.user;
|
||||||
String token = user?.token;
|
String? token = user?.token;
|
||||||
bool isAuthenticated = false;
|
bool isAuthenticated = false;
|
||||||
if (token != null) {
|
if (token != null && user !=null) {
|
||||||
if(user.email!=null && user.email.toLowerCase().trim().startsWith('test')){
|
if(user.email!=null && user.email!.toLowerCase().trim().startsWith('test')){
|
||||||
_api.test = true;
|
_api.test = true;
|
||||||
} else {
|
} else {
|
||||||
_api.test = false;
|
_api.test = false;
|
||||||
}
|
}
|
||||||
Response<Message> session = await _api.isActive(token);
|
Response<Message> session = await _api.isActive(token);
|
||||||
isAuthenticated = "OK" == session.body.message;
|
isAuthenticated = "OK" == session.body?.message;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await Future.delayed(Duration(milliseconds: 2000));
|
await Future.delayed(Duration(milliseconds: 2000));
|
||||||
|
|
@ -82,11 +82,11 @@ Future<void> logoutAction(Store<AppState> store) async {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response<dynamic>> checkMoney(Store<AppState> store) async {
|
Future<Response<dynamic>?> checkMoney(Store<AppState> store) async {
|
||||||
store.dispatch(SetUserStateAction(UserState(money: Money(loading: true))));
|
store.dispatch(SetUserStateAction(UserState(money: Money(loading: true))));
|
||||||
try {
|
try {
|
||||||
Response<dynamic> result =
|
Response<dynamic> result =
|
||||||
await _api.money(store.state.userState.user.token);
|
await _api.money(store.state.userState!.user!.token!);
|
||||||
if (result.operation) {
|
if (result.operation) {
|
||||||
store.dispatch(SetUserStateAction(UserState(
|
store.dispatch(SetUserStateAction(UserState(
|
||||||
money: Money(
|
money: Money(
|
||||||
|
|
@ -165,20 +165,20 @@ ThunkAction<AppState> authenticate(String email, String password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkSmena(Store<AppState> store) async {
|
Future<void> checkSmena(Store<AppState> store) async {
|
||||||
String token = store.state.userState.user.token;
|
String token = store.state.userState!.user!.token!;
|
||||||
Response<Smena> result = await _api.smena(token);
|
Response<Smena> result = await _api.smena(token);
|
||||||
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> closeSmena(Store<AppState> store) async {
|
Future<void> closeSmena(Store<AppState> store) async {
|
||||||
String token = store.state.userState.user.token;
|
String token = store.state.userState!.user!.token!;
|
||||||
Response<Smena> result = await _api.closeSmena(token);
|
Response<Smena> result = await _api.closeSmena(token);
|
||||||
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
||||||
store.dispatch(checkMoney);
|
store.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> openSmena(Store<AppState> store) async {
|
Future<void> openSmena(Store<AppState> store) async {
|
||||||
String token = store.state.userState.user.token;
|
String token = store.state.userState!.user!.token!;
|
||||||
Response<Smena> result = await _api.openSmena(token);
|
Response<Smena> result = await _api.openSmena(token);
|
||||||
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
||||||
if (result.operation) {
|
if (result.operation) {
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,20 @@ import 'package:meta/meta.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class BankState {
|
class BankState {
|
||||||
final String login;
|
final String? login;
|
||||||
final String password;
|
final String? password;
|
||||||
final HalykPosSession session;
|
final HalykPosSession? session;
|
||||||
|
final bool? loading;
|
||||||
|
|
||||||
BankState({this.login, this.password, this.session,});
|
BankState({this.login, this.password, this.session,this.loading});
|
||||||
|
|
||||||
//read hive
|
//read hive
|
||||||
factory BankState.initial(BankState payload) {
|
factory BankState.initial(BankState? payload) {
|
||||||
return BankState(
|
return BankState(
|
||||||
login: payload?.login,
|
login: payload?.login,
|
||||||
password: payload?.password,
|
password: payload?.password,
|
||||||
session: payload?.session
|
session: payload?.session,
|
||||||
|
loading: payload?.loading
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,15 +27,17 @@ class BankState {
|
||||||
@required login,
|
@required login,
|
||||||
@required password,
|
@required password,
|
||||||
@required session,
|
@required session,
|
||||||
|
@required loading,
|
||||||
}) {
|
}) {
|
||||||
return BankState(
|
return BankState(
|
||||||
login: login ?? this.login,
|
login: login ?? this.login,
|
||||||
password: password ?? this.password,
|
password: password ?? this.password,
|
||||||
session: session ?? this.session
|
session: session ?? this.session,
|
||||||
|
loading: loading ?? this.loading
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BankState fromJson(dynamic json) {
|
static BankState? fromJson(dynamic json) {
|
||||||
return json != null
|
return json != null
|
||||||
? BankState(
|
? BankState(
|
||||||
password: json['password'],
|
password: json['password'],
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import 'package:meta/meta.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class CalcState {
|
class CalcState {
|
||||||
final List<CalcModel> calcItems;
|
final List<CalcModel>? calcItems;
|
||||||
final bool isEqual;
|
final bool? isEqual;
|
||||||
|
|
||||||
CalcState({this.calcItems, this.isEqual});
|
CalcState({this.calcItems, this.isEqual});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import 'package:meta/meta.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class KassaState {
|
class KassaState {
|
||||||
final List bottomSheetElements;
|
final List? bottomSheetElements;
|
||||||
final bool bottomSheetLoading;
|
final bool? bottomSheetLoading;
|
||||||
final List<DictDao> prevCategories;
|
final List<DictDao>? prevCategories;
|
||||||
final List<ProductDao> kassaItems;
|
final List<ProductDao>? kassaItems;
|
||||||
|
|
||||||
|
|
||||||
KassaState(
|
KassaState(
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||||
|
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart';
|
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class SettingState {
|
class SettingState {
|
||||||
final String mode;
|
final String? mode;
|
||||||
final String tradeType;
|
final String? tradeType;
|
||||||
final String pinCode;
|
final String? pinCode;
|
||||||
final bool pinLocked;
|
final bool? pinLocked;
|
||||||
final bool pinSkip;
|
final bool? pinSkip;
|
||||||
final BluetoothDevice printerBT;
|
final BluetoothDevice? printerBT;
|
||||||
final String printerEncoding;
|
final String? printerEncoding;
|
||||||
final String printerPaperSize;
|
final String? printerPaperSize;
|
||||||
|
|
||||||
|
|
||||||
SettingState({this.mode, this.tradeType, this.pinCode, this.pinLocked, this.pinSkip, this.printerBT,
|
SettingState({this.mode, this.tradeType, this.pinCode, this.pinLocked, this.pinSkip, this.printerBT,
|
||||||
|
|
@ -19,7 +19,7 @@ class SettingState {
|
||||||
this.printerPaperSize});
|
this.printerPaperSize});
|
||||||
|
|
||||||
//read hive
|
//read hive
|
||||||
factory SettingState.initial(SettingState payload) {
|
factory SettingState.initial(SettingState? payload) {
|
||||||
return SettingState(
|
return SettingState(
|
||||||
mode: payload?.mode ?? SettingModeKassa,
|
mode: payload?.mode ?? SettingModeKassa,
|
||||||
tradeType: payload?.tradeType ?? SettingTradeTypeGood,
|
tradeType: payload?.tradeType ?? SettingTradeTypeGood,
|
||||||
|
|
@ -56,7 +56,7 @@ class SettingState {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SettingState fromJson(dynamic json) {
|
static SettingState? fromJson(dynamic json) {
|
||||||
return json != null
|
return json != null
|
||||||
? SettingState(
|
? SettingState(
|
||||||
tradeType: json['tradeType'],
|
tradeType: json['tradeType'],
|
||||||
|
|
@ -80,7 +80,7 @@ class SettingState {
|
||||||
"pinCode": pinCode,
|
"pinCode": pinCode,
|
||||||
"pinLocked" : pinLocked,
|
"pinLocked" : pinLocked,
|
||||||
"pinSkip" : pinSkip,
|
"pinSkip" : pinSkip,
|
||||||
"printerBT": printerBT != null ? printerBT.toJson() : null,
|
"printerBT": printerBT != null ? printerBT!.toJson() : null,
|
||||||
"printerEncoding": printerEncoding,
|
"printerEncoding": printerEncoding,
|
||||||
"printerPaperSize": printerPaperSize,
|
"printerPaperSize": printerPaperSize,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,16 @@ import 'package:meta/meta.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class UserState {
|
class UserState {
|
||||||
final bool isError;
|
final bool? isError;
|
||||||
final bool isLoading;
|
final bool? isLoading;
|
||||||
final bool isAuthenticated;
|
final bool? isAuthenticated;
|
||||||
final String authenticateType;
|
final String? authenticateType;
|
||||||
final String login;
|
final String? login;
|
||||||
final String password;
|
final String? password;
|
||||||
final LoginFormMessage loginFormMessage;
|
final LoginFormMessage? loginFormMessage;
|
||||||
final User user;
|
final User? user;
|
||||||
final Smena smena;
|
final Smena? smena;
|
||||||
final Money money;
|
final Money? money;
|
||||||
|
|
||||||
|
|
||||||
UserState(
|
UserState(
|
||||||
|
|
@ -30,7 +30,7 @@ class UserState {
|
||||||
this.money,
|
this.money,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory UserState.initial(UserState payload) => UserState(
|
factory UserState.initial(UserState? payload) => UserState(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isError: false,
|
isError: false,
|
||||||
isAuthenticated: false,
|
isAuthenticated: false,
|
||||||
|
|
@ -44,16 +44,16 @@ class UserState {
|
||||||
);
|
);
|
||||||
|
|
||||||
UserState copyWith({
|
UserState copyWith({
|
||||||
@required bool isError,
|
@required bool? isError,
|
||||||
@required bool isLoading,
|
@required bool? isLoading,
|
||||||
@required User user,
|
@required User? user,
|
||||||
@required bool isAuthenticated,
|
@required bool? isAuthenticated,
|
||||||
@required LoginFormMessage loginFormMessage,
|
@required LoginFormMessage? loginFormMessage,
|
||||||
@required Smena smena,
|
@required Smena? smena,
|
||||||
@required String authenticateType,
|
@required String? authenticateType,
|
||||||
@required String login,
|
@required String? login,
|
||||||
@required String password,
|
@required String? password,
|
||||||
@required Money money,
|
@required Money? money,
|
||||||
}) {
|
}) {
|
||||||
return UserState(
|
return UserState(
|
||||||
isError: isError ?? this.isError,
|
isError: isError ?? this.isError,
|
||||||
|
|
@ -69,7 +69,7 @@ class UserState {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UserState fromJson(dynamic json) {
|
static UserState? fromJson(dynamic json) {
|
||||||
return json != null
|
return json != null
|
||||||
? UserState(
|
? UserState(
|
||||||
user: User.fromJson(json['user']),
|
user: User.fromJson(json['user']),
|
||||||
|
|
@ -82,7 +82,7 @@ class UserState {
|
||||||
|
|
||||||
dynamic toJson() {
|
dynamic toJson() {
|
||||||
return {
|
return {
|
||||||
"user": user != null ? user.toJson() : null,
|
"user": user != null ? user!.toJson() : null,
|
||||||
"authenticateType": authenticateType,
|
"authenticateType": authenticateType,
|
||||||
"login": login,
|
"login": login,
|
||||||
"password": password,
|
"password": password,
|
||||||
|
|
@ -91,9 +91,9 @@ class UserState {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginFormMessage {
|
class LoginFormMessage {
|
||||||
final String email;
|
final String? email;
|
||||||
final String password;
|
final String? password;
|
||||||
final String message;
|
final String? message;
|
||||||
|
|
||||||
LoginFormMessage({this.email, this.password, this.message});
|
LoginFormMessage({this.email, this.password, this.message});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ 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/kassa_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
||||||
|
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:redux_persist_flutter/redux_persist_flutter.dart';
|
import 'package:redux_persist_flutter/redux_persist_flutter.dart';
|
||||||
|
|
@ -24,23 +25,23 @@ import 'actions/calc_actions.dart';
|
||||||
AppState appReducer(AppState state, dynamic action) {
|
AppState appReducer(AppState state, dynamic action) {
|
||||||
if (action is SetUserStateAction) {
|
if (action is SetUserStateAction) {
|
||||||
/** UserAction **/
|
/** UserAction **/
|
||||||
final nextUserState = userReducer(state.userState, action);
|
final nextUserState = userReducer(state.userState!, action);
|
||||||
return state.copyWith(userState: nextUserState);
|
return state.copyWith(userState: nextUserState);
|
||||||
} else if (action is SetKassaStateAction) {
|
} else if (action is SetKassaStateAction) {
|
||||||
/** KassaAction **/
|
/** KassaAction **/
|
||||||
final nextMainState = mainReducer(state.kassaState, action);
|
final nextMainState = mainReducer(state.kassaState!, action);
|
||||||
return state.copyWith(kassaState: nextMainState);
|
return state.copyWith(kassaState: nextMainState);
|
||||||
} else if (action is SetSettingStateAction) {
|
} else if (action is SetSettingStateAction) {
|
||||||
/** SettingAction **/
|
/** SettingAction **/
|
||||||
final nextSettingState = settingReducer(state.settingState, action);
|
final nextSettingState = settingReducer(state.settingState!, action);
|
||||||
return state.copyWith(settingState: nextSettingState);
|
return state.copyWith(settingState: nextSettingState);
|
||||||
} else if (action is SetCalcStateAction) {
|
} else if (action is SetCalcStateAction) {
|
||||||
/** CalcAction **/
|
/** CalcAction **/
|
||||||
final nextCalcState = calcReducer(state.calcState, action);
|
final nextCalcState = calcReducer(state.calcState!, action);
|
||||||
return state.copyWith(calcState: nextCalcState);
|
return state.copyWith(calcState: nextCalcState);
|
||||||
} else if (action is SetBankStateAction) {
|
} else if (action is SetBankStateAction) {
|
||||||
/** BankAction **/
|
/** BankAction **/
|
||||||
final nextBankState = bankReducer(state.bankState, action);
|
final nextBankState = bankReducer(state.bankState!, action);
|
||||||
return state.copyWith(bankState: nextBankState);
|
return state.copyWith(bankState: nextBankState);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|
@ -49,11 +50,11 @@ AppState appReducer(AppState state, dynamic action) {
|
||||||
//Main State
|
//Main State
|
||||||
@immutable
|
@immutable
|
||||||
class AppState {
|
class AppState {
|
||||||
final UserState userState;
|
final UserState? userState;
|
||||||
final KassaState kassaState;
|
final KassaState? kassaState;
|
||||||
final SettingState settingState;
|
final SettingState? settingState;
|
||||||
final CalcState calcState;
|
final CalcState? calcState;
|
||||||
final BankState bankState;
|
final BankState? bankState;
|
||||||
|
|
||||||
AppState({
|
AppState({
|
||||||
this.userState,
|
this.userState,
|
||||||
|
|
@ -65,11 +66,11 @@ class AppState {
|
||||||
|
|
||||||
//stable work
|
//stable work
|
||||||
AppState copyWith({
|
AppState copyWith({
|
||||||
UserState userState,
|
UserState? userState,
|
||||||
KassaState kassaState,
|
KassaState? kassaState,
|
||||||
SettingState settingState,
|
SettingState? settingState,
|
||||||
CalcState calcState,
|
CalcState? calcState,
|
||||||
BankState bankState,
|
BankState? bankState,
|
||||||
}) {
|
}) {
|
||||||
return AppState(
|
return AppState(
|
||||||
userState: userState ?? this.userState,
|
userState: userState ?? this.userState,
|
||||||
|
|
@ -80,8 +81,8 @@ class AppState {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AppState fromJson(dynamic json) {
|
static AppState? fromJson(dynamic json){
|
||||||
return json != null
|
return json !=null
|
||||||
? AppState(
|
? AppState(
|
||||||
settingState: SettingState.fromJson(json['settingState']),
|
settingState: SettingState.fromJson(json['settingState']),
|
||||||
userState: UserState.fromJson(json['userState']),
|
userState: UserState.fromJson(json['userState']),
|
||||||
|
|
@ -92,17 +93,17 @@ class AppState {
|
||||||
|
|
||||||
dynamic toJson() {
|
dynamic toJson() {
|
||||||
return {
|
return {
|
||||||
"settingState": settingState.toJson(),
|
"settingState": settingState?.toJson(),
|
||||||
"userState": userState.toJson(),
|
"userState": userState?.toJson(),
|
||||||
"bankState": bankState.toJson(),
|
"bankState": bankState?.toJson(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Redux {
|
class Redux {
|
||||||
static Store<AppState> _store;
|
static Store<AppState>? _store;
|
||||||
|
|
||||||
static Store<AppState> get store {
|
static Store<AppState>? get store {
|
||||||
if (_store == null) {
|
if (_store == null) {
|
||||||
throw Exception("store is not initialized");
|
throw Exception("store is not initialized");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -119,7 +120,12 @@ class Redux {
|
||||||
AppState.fromJson), // Or use other serializers
|
AppState.fromJson), // Or use other serializers
|
||||||
);
|
);
|
||||||
|
|
||||||
final initialState = await persist.load();
|
AppState? initialState;
|
||||||
|
try {
|
||||||
|
initialState = await persist.load();
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e('message', e, stack);
|
||||||
|
}
|
||||||
|
|
||||||
final userStateInitial = UserState.initial(initialState?.userState);
|
final userStateInitial = UserState.initial(initialState?.userState);
|
||||||
final kassaStateInitial = KassaState.initial();
|
final kassaStateInitial = KassaState.initial();
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,15 @@ class BankSettingView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BankSettingViewState extends State<BankSettingView> {
|
class _BankSettingViewState extends State<BankSettingView> {
|
||||||
TextEditingController _emailController;
|
late TextEditingController _emailController;
|
||||||
TextEditingController _passwordController;
|
late TextEditingController _passwordController;
|
||||||
final BankService _bankService = locator<BankService>();
|
final BankService _bankService = locator<BankService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
BankState state = Redux.store.state.bankState;
|
BankState state = Redux.store!.state.bankState!;
|
||||||
_emailController = new TextEditingController(text: state.login);
|
_emailController = new TextEditingController(text: state.login);
|
||||||
_passwordController = new TextEditingController(text: state.password);
|
_passwordController = new TextEditingController(text: state.password);
|
||||||
//permissions();
|
//permissions();
|
||||||
|
|
@ -52,7 +52,7 @@ class _BankSettingViewState extends State<BankSettingView> {
|
||||||
|
|
||||||
void _saveData(BuildContext _context) async {
|
void _saveData(BuildContext _context) async {
|
||||||
FocusScope.of(_context).unfocus();
|
FocusScope.of(_context).unfocus();
|
||||||
await Redux.store.dispatch(saveData(_emailController.text, _passwordController.text));
|
await Redux.store!.dispatch(saveData(_emailController.text, _passwordController.text));
|
||||||
_dialogService.showDialog(description: 'Данные сохранены');
|
_dialogService.showDialog(description: 'Данные сохранены');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,17 @@ class _BankViewState extends State<BankView> {
|
||||||
MethodChannel('channel:com.amanKassa/bank');
|
MethodChannel('channel:com.amanKassa/bank');
|
||||||
static const MethodChannel _activity =
|
static const MethodChannel _activity =
|
||||||
MethodChannel('channel:com.amanKassa/activity');
|
MethodChannel('channel:com.amanKassa/activity');
|
||||||
String initValue;
|
String? initValue;
|
||||||
String connectionValue;
|
String? connectionValue;
|
||||||
String authValue;
|
String? authValue;
|
||||||
String payValue;
|
String? payValue;
|
||||||
String cancelValue;
|
String? cancelValue;
|
||||||
String shutdownValue;
|
String? shutdownValue;
|
||||||
String versionValue;
|
String? versionValue;
|
||||||
String transactionValue;
|
String? transactionValue;
|
||||||
String closeDayValue;
|
String? closeDayValue;
|
||||||
String getValue;
|
String? getValue;
|
||||||
String errorValue;
|
String? errorValue;
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -40,21 +40,21 @@ class _BankViewState extends State<BankView> {
|
||||||
'serverUrl': 'http://195.200.74.83:5000',
|
'serverUrl': 'http://195.200.74.83:5000',
|
||||||
});
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
initValue = result ?? 'none';
|
initValue = result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
version() async {
|
version() async {
|
||||||
String result = await _channel.invokeMethod('version');
|
String result = await _channel.invokeMethod('version');
|
||||||
setState(() {
|
setState(() {
|
||||||
versionValue = result ?? 'none';
|
versionValue = result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction() async {
|
transaction() async {
|
||||||
String result = await _channel.invokeMethod('transaction');
|
String result = await _channel.invokeMethod('transaction');
|
||||||
setState(() {
|
setState(() {
|
||||||
transactionValue = result ?? 'none';
|
transactionValue = result ;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
|
import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_data.dart';
|
import 'package:aman_kassa_flutter/core/models/check_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
||||||
|
|
@ -11,6 +12,7 @@ import 'package:aman_kassa_flutter/core/models/response.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/BankService.dart';
|
import 'package:aman_kassa_flutter/core/services/BankService.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/blue_print_service.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/dialog_service.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/setting_actions.dart';
|
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||||
|
|
@ -24,13 +26,12 @@ import 'package:aman_kassa_flutter/views/settings/printer/PrinterTest.dart';
|
||||||
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart';
|
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
||||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
|
||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
import 'package:esys_flutter_share/esys_flutter_share.dart';
|
import 'package:vocsy_esys_flutter_share/vocsy_esys_flutter_share.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../core/models/aman_dao.dart';
|
import '../../core/models/aman_dao.dart';
|
||||||
|
|
@ -45,19 +46,18 @@ class ImageShowContainer extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ImageShowContainerState extends State<ImageShowContainer> {
|
class _ImageShowContainerState extends State<ImageShowContainer> {
|
||||||
final PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
final BluePrintService printerManager = locator<BluePrintService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
final BluetoothDevice? printerBtDevice =
|
||||||
final BluetoothDevice printerBtDevice = Redux.store.state.settingState.printerBT;
|
Redux.store!.state.settingState!.printerBT;
|
||||||
final BluetoothManager bluetoothManager = BluetoothManager.instance;
|
|
||||||
|
|
||||||
bool _printing = false;
|
bool _printing = false;
|
||||||
|
|
||||||
void _preparePrint() async {
|
void _preparePrint() async {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
await _print();
|
_print();
|
||||||
} else {
|
} else {
|
||||||
bluetoothManager.state.listen((val) {
|
printerManager.state.listen((val) {
|
||||||
print("state = $val");
|
print("state = $val");
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (val == 12) {
|
if (val == 12) {
|
||||||
|
|
@ -65,17 +65,31 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
||||||
_print();
|
_print();
|
||||||
} else if (val == 10) {
|
} else if (val == 10) {
|
||||||
print('off');
|
print('off');
|
||||||
_dialogService.showDialog(description: 'Отсутвует соеденение Bluetooth или он отключен', title: 'Bluetooth');
|
_dialogService.showDialog(
|
||||||
|
description: 'Отсутвует соеденение Bluetooth или он отключен',
|
||||||
|
title: 'Bluetooth');
|
||||||
}
|
}
|
||||||
print('state is $val');
|
print('state is $val');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
disconnect();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void disconnect() async {
|
||||||
|
await printerManager.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
void _print() async {
|
void _print() async {
|
||||||
final SettingState state = Redux.store.state.settingState;
|
final SettingState state = Redux.store!.state.settingState!;
|
||||||
if (state.printerBT == null) {
|
if (state.printerBT == null) {
|
||||||
_dialogService.showDialog(description: 'Укажите в настройках принтер для печати чеков');
|
_dialogService.showDialog(
|
||||||
|
description: 'Укажите в настройках принтер для печати чеков');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,29 +106,32 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
||||||
_printing = true;
|
_printing = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
printerManager.selectPrinter(PrinterBluetooth(state.printerBT));
|
printerManager.device = state.printerBT!;
|
||||||
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80 ? PaperSize.mm80 : PaperSize.mm58;
|
await printerManager.connect();
|
||||||
|
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80
|
||||||
|
? PaperSize.mm80
|
||||||
|
: PaperSize.mm58;
|
||||||
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
||||||
final PosPrintResult res = await printerManager.printTicket(
|
final bool res = await printerManager.printBytes(
|
||||||
await printImageCheck(paper, widget.showModel.data.base64Data),
|
Uint8List.fromList(await printImageCheck(paper, widget.showModel.data!.base64Data!)));
|
||||||
chunkSizeBytes: chunkSizeBytes,
|
if (!res) {
|
||||||
queueSleepTimeMs: queueSleepTimeMs);
|
_dialogService.showDialog(description: 'Ошибка при печати');
|
||||||
if (res.value != 1) {
|
|
||||||
_dialogService.showDialog(description: res.msg);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final PosPrintResult res = await printerManager.printTicket(
|
final bool res = await printerManager.printBytes(
|
||||||
await printTextCheck(paper, state.printerEncoding, jsonDecode(widget.showModel.data.textData)),
|
Uint8List.fromList(await printTextCheck(paper, state.printerEncoding!,
|
||||||
chunkSizeBytes: chunkSizeBytes,
|
jsonDecode(widget.showModel.data!.textData!)))
|
||||||
queueSleepTimeMs: queueSleepTimeMs);
|
);
|
||||||
if (res.value != 1) {
|
if (!res) {
|
||||||
_dialogService.showDialog(description: res.msg);
|
_dialogService.showDialog(description: 'Ошибка при печати');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
await Future.delayed(Duration(seconds: 7));
|
await Future.delayed(Duration(seconds: 15));
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_printing = false;
|
_printing = false;
|
||||||
});
|
});
|
||||||
|
|
@ -145,7 +162,9 @@ class _ImageShowContainerState extends State<ImageShowContainer> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[imageFromBase64String(widget.showModel.data.base64Data)],
|
children: <Widget>[
|
||||||
|
imageFromBase64String(widget.showModel.data!.base64Data!)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: MyFloatingActionButton(widget.showModel),
|
floatingActionButton: MyFloatingActionButton(widget.showModel),
|
||||||
);
|
);
|
||||||
|
|
@ -160,13 +179,13 @@ Padding imageFromBase64String(String base64String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageShowModel {
|
class ImageShowModel {
|
||||||
final CheckImageModal data;
|
final CheckImageModal? data;
|
||||||
final String title;
|
final String title;
|
||||||
final String url;
|
final String? url;
|
||||||
final CardData cardData;
|
final CardData? cardData;
|
||||||
final Voucher voucher;
|
final Voucher? voucher;
|
||||||
|
|
||||||
ImageShowModel({this.data, this.title, this.url, this.cardData, this.voucher});
|
ImageShowModel({this.data, required this.title, this.url, this.cardData, this.voucher});
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyFloatingActionButton extends StatefulWidget {
|
class MyFloatingActionButton extends StatefulWidget {
|
||||||
|
|
@ -196,7 +215,7 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (widget.data.cardData != null && widget.data.cardData.transactionType == "payment")
|
if (widget.data.cardData?.transactionType == "payment")
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
backgroundColor: redColor,
|
backgroundColor: redColor,
|
||||||
tooltip: 'Отмена',
|
tooltip: 'Отмена',
|
||||||
|
|
@ -207,23 +226,21 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var today = new DateTime.now();
|
var today = new DateTime.now();
|
||||||
var yesterday = today.subtract(new Duration(days: 1));
|
var yesterday = today.subtract(new Duration(days: 1));
|
||||||
if( Redux.store.state.userState == null
|
if(Redux.store?.state.userState?.smena?.startedAt == null
|
||||||
|| Redux.store.state.userState.smena == null
|
|| yesterday.isAfter(Redux.store!.state.userState!.smena!.startedAt!)) {
|
||||||
|| Redux.store.state.userState.smena.startedAt == null
|
|
||||||
|| yesterday.isAfter(Redux.store.state.userState.smena.startedAt)) {
|
|
||||||
_dialog.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
_dialog.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
AmanDao<CardData> response = await reversalHalykPos(widget.data.cardData, widget.data.voucher.total);
|
AmanDao<CardData> response = await reversalHalykPos(widget.data.cardData!, widget.data.voucher!.total!);
|
||||||
if (response.success) {
|
if (response.success == true) {
|
||||||
pressRefund();
|
pressRefund();
|
||||||
} else {
|
} else {
|
||||||
_dialog.showDialog(description: response.msg);
|
_dialog.showDialog(description: response.msg!);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
}
|
}
|
||||||
_navigatorService.replace(HomeViewRoute);
|
_navigatorService.replace(HomeViewRoute);
|
||||||
},
|
},
|
||||||
|
|
@ -236,7 +253,7 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
if (widget.data.cardData != null && widget.data.cardData.transactionType == "payment")
|
if (widget.data.cardData != null && widget.data.cardData?.transactionType == "payment")
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
backgroundColor: redColor,
|
backgroundColor: redColor,
|
||||||
tooltip: 'Возврат',
|
tooltip: 'Возврат',
|
||||||
|
|
@ -247,24 +264,24 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var today = new DateTime.now();
|
var today = new DateTime.now();
|
||||||
var yesterday = today.subtract(new Duration(days: 1));
|
var yesterday = today.subtract(new Duration(days: 1));
|
||||||
if( Redux.store.state.userState == null
|
if( Redux.store!.state.userState == null
|
||||||
|| Redux.store.state.userState.smena == null
|
|| Redux.store!.state.userState?.smena == null
|
||||||
|| Redux.store.state.userState.smena.startedAt == null
|
|| Redux.store!.state.userState?.smena?.startedAt == null
|
||||||
|| yesterday.isAfter(Redux.store.state.userState.smena.startedAt)) {
|
|| yesterday.isAfter(Redux.store!.state.userState!.smena!.startedAt!)) {
|
||||||
_dialog.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
_dialog.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
AmanDao<CardData> response = await refundHalykPos(widget.data.cardData, widget.data.voucher.total);
|
AmanDao<CardData> response = await refundHalykPos(widget.data.cardData!, widget.data.voucher!.total!);
|
||||||
if (response.success) {
|
if (response.success == true) {
|
||||||
pressRefund();
|
pressRefund();
|
||||||
} else {
|
} else {
|
||||||
_dialog.showDialog(description: response.msg);
|
_dialog.showDialog(description: response.msg!);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
heroTag: null,
|
heroTag: null,
|
||||||
|
|
@ -286,7 +303,7 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(15)),
|
borderRadius: BorderRadius.all(Radius.circular(15)),
|
||||||
boxShadow: [BoxShadow(blurRadius: 10, color: Colors.grey[300], spreadRadius: 5)]),
|
boxShadow: [BoxShadow(blurRadius: 10, color: Colors.grey[300]!, spreadRadius: 5)]),
|
||||||
height: 260,
|
height: 260,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
@ -331,22 +348,22 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
pressRefund() async {
|
pressRefund() async {
|
||||||
Dialogs.showLoadingDialog(context, _keyLoader);
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
try {
|
try {
|
||||||
AppState _state = Redux.store.state;
|
AppState _state = Redux.store!.state;
|
||||||
String _token = _state.userState.user.token;
|
String _token = _state.userState!.user!.token!;
|
||||||
CardData _cardData = widget.data.cardData;
|
CardData _cardData = widget.data.cardData!;
|
||||||
CheckData _checkData = CheckData.fromJson(json.decode(widget.data.voucher.data));
|
CheckData _checkData = CheckData.fromJson(json.decode(widget.data.voucher!.data!));
|
||||||
Response<dynamic> response =
|
Response<dynamic>? response =
|
||||||
await _dataService.refundM4Bank(token: _token, cardData: _cardData, checkData: _checkData);
|
await _dataService.refundM4Bank(token: _token, cardData: _cardData, checkData: _checkData);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
if (response.operation) {
|
if (response.operation) {
|
||||||
String message = response.body['message'];
|
String message = response.body['message'];
|
||||||
String check = response.body['check'];
|
String check = response.body['check'];
|
||||||
var checkText = response.body['check_text'];
|
var checkText = response.body['check_text'];
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
print('url : $url');
|
print('url : $url');
|
||||||
Redux.store.dispatch(checkMoney);
|
Redux.store!.dispatch(checkMoney);
|
||||||
Redux.store.dispatch(openSmenaPseudo);
|
Redux.store!.dispatch(openSmenaPseudo);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_navigatorService.replace(HomeViewRoute);
|
_navigatorService.replace(HomeViewRoute);
|
||||||
_navigatorService.push(ImageShowRoute,
|
_navigatorService.push(ImageShowRoute,
|
||||||
arguments: ImageShowModel(
|
arguments: ImageShowModel(
|
||||||
|
|
@ -355,23 +372,23 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
title: message,
|
title: message,
|
||||||
url: url));
|
url: url));
|
||||||
} else if (!response.operation && ![401, 402, 403, 412, 500].contains(response.status)) {
|
} else if (!response.operation && ![401, 402, 403, 412, 500].contains(response.status)) {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_dialog.showDialog(description: response.body['message']);
|
_dialog.showDialog(description: response.body['message']);
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void shareFile() async {
|
void shareFile() async {
|
||||||
try {
|
try {
|
||||||
await Share.file('Aman Kassa', 'aman_kassa_check.png', base64Decode(widget.data.data.base64Data), 'image/png');
|
await Share.file('Aman Kassa', 'aman_kassa_check.png', base64Decode(widget.data.data!.base64Data!), 'image/png');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('error: $e');
|
print('error: $e');
|
||||||
}
|
}
|
||||||
|
|
@ -385,15 +402,15 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
||||||
DialogResponse response = await _dialog.showConfirmationDialogInput(
|
DialogResponse response = await _dialog.showConfirmationDialogInput(
|
||||||
description: 'Номер телефона', cancelTitle: 'Отмена', confirmationTitle: 'Отправить', formatType: 'phone');
|
description: 'Номер телефона', cancelTitle: 'Отмена', confirmationTitle: 'Отправить', formatType: 'phone');
|
||||||
if (response.confirmed) {
|
if (response.confirmed) {
|
||||||
String phoneNumber = response.responseText;
|
String phoneNumber = response.responseText!;
|
||||||
String msg = "Спасибо за покупку! \r\n ${widget.data.url} ";
|
String msg = "Спасибо за покупку! \r\n ${widget.data.url} ";
|
||||||
launchWhatsApp(phone: phoneNumber, message: msg);
|
launchWhatsApp(phone: phoneNumber, message: msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchWhatsApp({
|
void launchWhatsApp({
|
||||||
@required String phone,
|
required String phone,
|
||||||
@required String message,
|
required String message,
|
||||||
}) async {
|
}) async {
|
||||||
String url() {
|
String url() {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
|
|
|
||||||
|
|
@ -55,19 +55,19 @@ class CloseDayShowContainer extends StatelessWidget {
|
||||||
Divider(),
|
Divider(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
itemCount: data.items.length,
|
itemCount: data.items?.length ?? 0,
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
return Divider();
|
return Divider();
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
TransactionBean item = data.items.elementAt(index);
|
TransactionBean item = data.items!.elementAt(index);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(item.instrumentSpecificData.maskedPan),
|
title: Text(item.instrumentSpecificData?.maskedPan ?? ''),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if(item.instrumentSpecificData.cardholderName!=null)
|
if(item.instrumentSpecificData!.cardholderName!=null)
|
||||||
Text(item.instrumentSpecificData.cardholderName),
|
Text(item.instrumentSpecificData!.cardholderName!),
|
||||||
Text('Операционный день № ${item.operationDay?.toString()}'),
|
Text('Операционный день № ${item.operationDay?.toString()}'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -68,16 +68,16 @@ class _HistoryViewState extends State<HistoryView> {
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
Voucher voucher = data[index];
|
Voucher voucher = data[index];
|
||||||
CardData cardData;
|
CardData? cardData;
|
||||||
CloseDayData closeDayData;
|
CloseDayData? closeDayData;
|
||||||
if( voucher.type == VoucherTypeCloseDayPosReport ) {
|
if( voucher.type == VoucherTypeCloseDayPosReport ) {
|
||||||
closeDayData = CloseDayData.fromJson(json.decode(voucher.data));
|
closeDayData = CloseDayData.fromJson(json.decode(voucher.data!));
|
||||||
} else if( voucher.data !=null ) {
|
} else if( voucher.data !=null ) {
|
||||||
CheckData checkData = CheckData.fromJson(json.decode(voucher.data));
|
CheckData checkData = CheckData.fromJson(json.decode(voucher.data!));
|
||||||
cardData = checkData.cardData;
|
cardData = checkData.cardData;
|
||||||
}
|
}
|
||||||
|
|
||||||
String base64Data = voucher.base64Data;
|
String? base64Data = voucher.base64Data;
|
||||||
CheckImageModal checkImageData;
|
CheckImageModal checkImageData;
|
||||||
if(base64Data !=null && base64Data.startsWith('{')){
|
if(base64Data !=null && base64Data.startsWith('{')){
|
||||||
checkImageData = CheckImageModal.fromJson(jsonDecode(base64Data));
|
checkImageData = CheckImageModal.fromJson(jsonDecode(base64Data));
|
||||||
|
|
@ -94,7 +94,7 @@ class _HistoryViewState extends State<HistoryView> {
|
||||||
_navigatorService.push(ImageShowRoute,
|
_navigatorService.push(ImageShowRoute,
|
||||||
arguments: ImageShowModel(
|
arguments: ImageShowModel(
|
||||||
data: checkImageData,
|
data: checkImageData,
|
||||||
title: voucher.name,
|
title: voucher.name ?? '',
|
||||||
url: voucher.url,
|
url: voucher.url,
|
||||||
cardData: cardData,
|
cardData: cardData,
|
||||||
voucher: voucher,
|
voucher: voucher,
|
||||||
|
|
@ -105,7 +105,7 @@ class _HistoryViewState extends State<HistoryView> {
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(dateFormat.format(voucher.dateTime)),
|
Text(dateFormat.format(voucher.dateTime!)),
|
||||||
cardData != null ? Text('№ ${cardData.cardNumber} holder: ${cardData.cardholderName}') : Text(''),
|
cardData != null ? Text('№ ${cardData.cardNumber} holder: ${cardData.cardholderName}') : Text(''),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -138,7 +138,7 @@ class _HistoryViewState extends State<HistoryView> {
|
||||||
Text buildText(Voucher voucher) {
|
Text buildText(Voucher voucher) {
|
||||||
if (voucher.type == VoucherTypePayment || voucher.type == VoucherTypeReturnPay) {
|
if (voucher.type == VoucherTypePayment || voucher.type == VoucherTypeReturnPay) {
|
||||||
return Text(
|
return Text(
|
||||||
'${voucher.name} на сумму: ${voucher.total.toStringAsFixed(2)}');
|
'${voucher.name} на сумму: ${voucher.total?.toStringAsFixed(2)}');
|
||||||
}
|
}
|
||||||
return Text('${voucher.name}');
|
return Text('${voucher.name}');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,20 @@ class BottomBar extends StatelessWidget {
|
||||||
final int selectedTabIndex;
|
final int selectedTabIndex;
|
||||||
|
|
||||||
BottomBar({
|
BottomBar({
|
||||||
this.pageController,
|
required this.pageController,
|
||||||
this.selectedTabIndex,
|
required this.selectedTabIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreConnector<AppState, SettingState>(
|
return StoreConnector<AppState, SettingState>(
|
||||||
converter: (store) => store.state.settingState,
|
converter: (store) => store.state.settingState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return BottomNavigationBar(
|
return BottomNavigationBar(
|
||||||
currentIndex: selectedTabIndex,
|
currentIndex: selectedTabIndex,
|
||||||
|
showUnselectedLabels: true,
|
||||||
backgroundColor: menuColor,
|
backgroundColor: menuColor,
|
||||||
type: BottomNavigationBarType.shifting,
|
type: BottomNavigationBarType.shifting,
|
||||||
showUnselectedLabels: true,
|
|
||||||
items: [
|
items: [
|
||||||
vm.mode == SettingModeKassa
|
vm.mode == SettingModeKassa
|
||||||
? BottomNavigationBarItem(
|
? BottomNavigationBarItem(
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class HeaderTitle extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreConnector<AppState, UserState>(
|
return StoreConnector<AppState, UserState>(
|
||||||
converter: (store) => store.state.userState,
|
converter: (store) => store.state.userState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
@ -30,7 +30,7 @@ class HeaderTitle extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
'Пользователь: ${vm.user.email}',
|
'Пользователь: ${vm.user?.email}',
|
||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
|
|
@ -39,10 +39,10 @@ class HeaderTitle extends StatelessWidget {
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
vm.smena.message != null
|
vm.smena?.message != null
|
||||||
? Text(vm.smena.message,
|
? Text(vm.smena!.message!,
|
||||||
style: TextStyle(fontSize: 13, color: redColor))
|
style: TextStyle(fontSize: 13, color: redColor))
|
||||||
: vm.smena.startedAt != null
|
: vm.smena!.startedAt != null
|
||||||
? Text(
|
? Text(
|
||||||
'Смена открыта',
|
'Смена открыта',
|
||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class PopupMenu extends StatefulWidget {
|
||||||
|
|
||||||
final void Function(Choice value) onSelectChoice;
|
final void Function(Choice value) onSelectChoice;
|
||||||
|
|
||||||
PopupMenu({this.onSelectChoice});
|
PopupMenu({required this.onSelectChoice});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PopupMenuState createState() => _PopupMenuState();
|
_PopupMenuState createState() => _PopupMenuState();
|
||||||
|
|
@ -17,7 +17,7 @@ class PopupMenu extends StatefulWidget {
|
||||||
|
|
||||||
class _PopupMenuState extends State<PopupMenu> {
|
class _PopupMenuState extends State<PopupMenu> {
|
||||||
BankService _bankService = locator<BankService>();
|
BankService _bankService = locator<BankService>();
|
||||||
List<Choice> choices;
|
List<Choice> choices = <Choice>[];
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO: implement initState
|
// TODO: implement initState
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ class HomeView extends StatefulWidget {
|
||||||
|
|
||||||
class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
Logger log = getLogger('HomeView');
|
Logger log = getLogger('HomeView');
|
||||||
PageController pageController;
|
late PageController pageController;
|
||||||
int selectedTabIndex;
|
late int selectedTabIndex;
|
||||||
DataService _dataService = locator<DataService>();
|
DataService _dataService = locator<DataService>();
|
||||||
ApiService _api = locator<ApiService>();
|
ApiService _api = locator<ApiService>();
|
||||||
NavigatorService _navigatorService = locator<NavigatorService>();
|
NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
|
|
@ -55,8 +55,8 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
final prevState = sp.getInt(lastKnownStateKey);
|
final prevState = sp.getInt(lastKnownStateKey);
|
||||||
final prevStateIsNotPaused = prevState != null &&
|
final prevStateIsNotPaused = prevState != null &&
|
||||||
AppLifecycleState.values[prevState] != AppLifecycleState.paused;
|
AppLifecycleState.values[prevState] != AppLifecycleState.paused;
|
||||||
final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty;
|
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null && Redux.store!.state.settingState!.pinCode!.length > 3;
|
||||||
final bool pinSkipped = Redux.store.state.settingState.pinSkip;
|
final bool pinSkipped = Redux.store!.state.settingState?.pinSkip == true;
|
||||||
print('prevStateIsNotPaused=$prevStateIsNotPaused, pinIsExist=$pinIsExist, pinSkipped=$pinSkipped');
|
print('prevStateIsNotPaused=$prevStateIsNotPaused, pinIsExist=$pinIsExist, pinSkipped=$pinSkipped');
|
||||||
if(prevStateIsNotPaused && pinSkipped == false && pinIsExist == true) {
|
if(prevStateIsNotPaused && pinSkipped == false && pinIsExist == true) {
|
||||||
// save App backgrounded time to Shared preferences
|
// save App backgrounded time to Shared preferences
|
||||||
|
|
@ -72,7 +72,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
final allowedBackgroundTime = bgTime + pinLockMillis;
|
final allowedBackgroundTime = bgTime + pinLockMillis;
|
||||||
final shouldShowPIN = DateTime.now().millisecondsSinceEpoch > allowedBackgroundTime;
|
final shouldShowPIN = DateTime.now().millisecondsSinceEpoch > allowedBackgroundTime;
|
||||||
if(shouldShowPIN && bgTime > 0) {
|
if(shouldShowPIN && bgTime > 0) {
|
||||||
await Redux.store.dispatch(changePinLockedFromSetting(true));
|
await Redux.store!.dispatch(changePinLockedFromSetting(true));
|
||||||
pushToLockScreen();
|
pushToLockScreen();
|
||||||
}
|
}
|
||||||
sp.remove(backgroundedTimeKey); // clean
|
sp.remove(backgroundedTimeKey); // clean
|
||||||
|
|
@ -92,8 +92,8 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkLockPin () async {
|
_checkLockPin () async {
|
||||||
final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty;
|
final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null && Redux.store!.state.settingState!.pinCode!.length > 3;
|
||||||
final bool pinLocked = Redux.store.state.settingState?.pinLocked;
|
final bool pinLocked = Redux.store!.state.settingState?.pinLocked == true;
|
||||||
final sp = await SharedPreferences.getInstance();
|
final sp = await SharedPreferences.getInstance();
|
||||||
sp.remove(backgroundedTimeKey);
|
sp.remove(backgroundedTimeKey);
|
||||||
sp.setInt(lastKnownStateKey, AppLifecycleState.resumed.index);// previous state
|
sp.setInt(lastKnownStateKey, AppLifecycleState.resumed.index);// previous state
|
||||||
|
|
@ -106,11 +106,11 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance!.addObserver(this);
|
||||||
selectedTabIndex = 0;
|
selectedTabIndex = 0;
|
||||||
pageController = new PageController(initialPage: selectedTabIndex);
|
pageController = new PageController(initialPage: selectedTabIndex);
|
||||||
Redux.store.dispatch(checkSmena);
|
Redux.store!.dispatch(checkSmena);
|
||||||
_dataService.checkDbFill(Redux.store.state.userState.user);
|
_dataService.checkDbFill(Redux.store!.state.userState!.user!);
|
||||||
_checkLockPin();
|
_checkLockPin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance!.removeObserver(this);
|
||||||
pageController.dispose();
|
pageController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
@ -143,12 +143,11 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
void _onSelectChoice(Choice choice) async {
|
void _onSelectChoice(Choice choice) async {
|
||||||
if (choice.command == 'exit') {
|
if (choice.command == 'exit') {
|
||||||
Dialogs.showLoadingDialog(context, _keyLoader);
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
Response<dynamic> result =
|
Response<dynamic> result = await _api.logout(Redux.store!.state.userState!.user!.token!);
|
||||||
await _api.logout(Redux.store.state.userState.user.token);
|
if(result.operation && result.status == 200) {
|
||||||
if (result.operation && result.status == 200) {
|
Redux.store!.dispatch(logoutAction);
|
||||||
Redux.store.dispatch(logoutAction);
|
|
||||||
}
|
}
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
} else if (choice.command == 'infokkm') {
|
} else if (choice.command == 'infokkm') {
|
||||||
_navigatorService.push(InfoKkmViewRoute);
|
_navigatorService.push(InfoKkmViewRoute);
|
||||||
} else if (choice.command == 'settings') {
|
} else if (choice.command == 'settings') {
|
||||||
|
|
@ -176,22 +175,24 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
],
|
],
|
||||||
backgroundColor: fillColor,
|
backgroundColor: fillColor,
|
||||||
),
|
),
|
||||||
body: StoreConnector<AppState, SettingState>(
|
body:StoreConnector<AppState, SettingState>(
|
||||||
converter: (store) => store.state.settingState,
|
converter: (store) => store.state.settingState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return PageView(
|
return PageView(
|
||||||
onPageChanged: (index) {
|
pageSnapping: true,
|
||||||
setState(() {
|
onPageChanged: (index) {
|
||||||
selectedTabIndex = index;
|
setState(() {
|
||||||
});
|
selectedTabIndex = index;
|
||||||
},
|
});
|
||||||
controller: pageController,
|
},
|
||||||
children: <Widget>[
|
controller: pageController,
|
||||||
vm.mode == SettingModeKassa ? KassaTab(0) : CalculatorTab(0),
|
children: <Widget>[
|
||||||
AdditionalTab(1),
|
vm.mode == SettingModeKassa ? KassaTab(0) : CalculatorTab(0),
|
||||||
],
|
AdditionalTab(1),
|
||||||
);
|
],
|
||||||
}),
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
bottomNavigationBar: BottomBar(
|
bottomNavigationBar: BottomBar(
|
||||||
pageController: pageController,
|
pageController: pageController,
|
||||||
selectedTabIndex: selectedTabIndex,
|
selectedTabIndex: selectedTabIndex,
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,14 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
DataService _dataService = locator<DataService>();
|
DataService _dataService = locator<DataService>();
|
||||||
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
|
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
|
||||||
|
|
||||||
bool isMoneyCheckBusy;
|
late bool isMoneyCheckBusy;
|
||||||
bool isClosePosBusy;
|
late bool closeSmenaBusy;
|
||||||
bool closeSmenaBusy;
|
late bool openSmenaBusy;
|
||||||
bool openSmenaBusy;
|
late bool depositBusy;
|
||||||
bool depositBusy;
|
late bool withdrawalBusy;
|
||||||
bool withdrawalBusy;
|
late bool xReportBusy;
|
||||||
bool xReportBusy;
|
late bool updateCatalog;
|
||||||
bool updateCatalog;
|
late bool isClosePosBusy;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -76,7 +76,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
closeSmenaBusy = true;
|
closeSmenaBusy = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(closeSmena);
|
await Redux.store!.dispatch(closeSmena);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -91,7 +91,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
openSmenaBusy = true;
|
openSmenaBusy = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(openSmena);
|
await Redux.store!.dispatch(openSmena);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -106,15 +106,15 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
xReportBusy = true;
|
xReportBusy = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
User user = Redux.store.state.userState.user;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
Response response = await _api.xReport(user.token);
|
Response response = await _api.xReport(user.token!);
|
||||||
if (response.operation) {
|
if (response.operation) {
|
||||||
String check = response.body['check'];
|
String check = response.body['check'];
|
||||||
var checkText = response.body['check_text'];
|
var checkText = response.body['check_text'];
|
||||||
_navigator.push(ImageShowRoute,
|
_navigator.push(ImageShowRoute,
|
||||||
arguments:
|
arguments:
|
||||||
ImageShowModel(data: CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: 'X Отчет'));
|
ImageShowModel(data: CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: 'X Отчет'));
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
_dataService.insertVoucher(
|
_dataService.insertVoucher(
|
||||||
user: user,
|
user: user,
|
||||||
name: 'X Отчет',
|
name: 'X Отчет',
|
||||||
|
|
@ -139,8 +139,8 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
Dialogs.showLoadingDialog(context, _keyLoader);
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
await _dataService.getDataFromServer(Redux.store.state.userState.user);
|
await _dataService.getDataFromServer(Redux.store!.state.userState!.user!);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -162,10 +162,10 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
);
|
);
|
||||||
if (response.confirmed) {
|
if (response.confirmed) {
|
||||||
Response<dynamic> result = await _api.deposit(
|
Response<dynamic> result = await _api.deposit(
|
||||||
Redux.store.state.userState.user.token, response.responseText);
|
Redux.store!.state.userState!.user!.token!, response.responseText!);
|
||||||
_dialog.showDialog(description: result.body['message']);
|
_dialog.showDialog(description: result.body['message']);
|
||||||
if (result.operation) {
|
if (result.operation) {
|
||||||
await Redux.store.dispatch(checkMoney);
|
await Redux.store!.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -189,10 +189,10 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
);
|
);
|
||||||
if (response.confirmed) {
|
if (response.confirmed) {
|
||||||
Response<dynamic> result = await _api.withdrawal(
|
Response<dynamic> result = await _api.withdrawal(
|
||||||
Redux.store.state.userState.user.token, response.responseText);
|
Redux.store!.state.userState!.user!.token!, response.responseText!);
|
||||||
_dialog.showDialog(description: result.body['message']);
|
_dialog.showDialog(description: result.body['message']);
|
||||||
if (result.operation) {
|
if (result.operation) {
|
||||||
await Redux.store.dispatch(checkMoney);
|
await Redux.store!.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -209,7 +209,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
isMoneyCheckBusy = true;
|
isMoneyCheckBusy = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(checkMoney);
|
await Redux.store!.dispatch(checkMoney);
|
||||||
setState(() {
|
setState(() {
|
||||||
isMoneyCheckBusy = false;
|
isMoneyCheckBusy = false;
|
||||||
});
|
});
|
||||||
|
|
@ -236,13 +236,13 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
HalykCloseDayDao closeDayDao = await closeDayHalykPos();
|
HalykCloseDayDao? closeDayDao = await closeDayHalykPos();
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
log.i(closeDayDao.toJson());
|
log.i(closeDayDao?.toJson());
|
||||||
if (closeDayDao.result.code != 0) {
|
if (closeDayDao?.result?.code != 0) {
|
||||||
if (closeDayDao.result.description != null) {
|
if (closeDayDao!.result?.description != null) {
|
||||||
_dialog.showDialog(description: closeDayDao.result.description);
|
_dialog.showDialog(description: closeDayDao.result!.description!);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
isClosePosBusy = false;
|
isClosePosBusy = false;
|
||||||
|
|
@ -251,14 +251,14 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CloseDayData closeDayData = _bankService.closeDayDataConvert(closeDayDao.transactions);
|
CloseDayData closeDayData = _bankService.closeDayDataConvert(closeDayDao!.transactions!);
|
||||||
|
|
||||||
User user = Redux.store.state.userState.user;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
_dataService.insertVoucher(
|
_dataService.insertVoucher(
|
||||||
user: user,
|
user: user,
|
||||||
name: closeDayData.title,
|
name: closeDayData.title!,
|
||||||
data: jsonEncode(closeDayData.toJson()),
|
data: jsonEncode(closeDayData.toJson()),
|
||||||
total: closeDayData.totalAmount.toDouble(),
|
total: closeDayData.totalAmount!.toDouble(),
|
||||||
type: VoucherTypeCloseDayPosReport);
|
type: VoucherTypeCloseDayPosReport);
|
||||||
|
|
||||||
// _dialog.showDialog(description: 'Закрытие дня: операция прошла успешно!');
|
// _dialog.showDialog(description: 'Закрытие дня: операция прошла успешно!');
|
||||||
|
|
@ -282,7 +282,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
right: 20.0,
|
right: 20.0,
|
||||||
),
|
),
|
||||||
child: StoreConnector<AppState, SettingState>(
|
child: StoreConnector<AppState, SettingState>(
|
||||||
converter: (store) => store.state.settingState,
|
converter: (store) => store.state.settingState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
|
@ -336,7 +336,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
height: 50,
|
height: 50,
|
||||||
// width: double.infinity,
|
// width: double.infinity,
|
||||||
child: StoreConnector<AppState, Money>(
|
child: StoreConnector<AppState, Money>(
|
||||||
converter: (store) => store.state.userState.money,
|
converter: (store) => store.state.userState!.money!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
if (vm.loading == true) {
|
if (vm.loading == true) {
|
||||||
return Center(
|
return Center(
|
||||||
|
|
@ -478,6 +478,6 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeMode(el) {
|
void changeMode(el) {
|
||||||
Redux.store.dispatch(changeModeFromSetting(el));
|
Redux.store!.dispatch(changeModeFromSetting(el));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ class CalculatorTab extends StatelessWidget {
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
StoreConnector<AppState, CalcState>(
|
StoreConnector<AppState, CalcState>(
|
||||||
converter: (store) => store.state.calcState,
|
converter: (store) => store.state.calcState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return NumberDisplay(
|
return NumberDisplay(
|
||||||
value: Calculator.parseItems(vm.calcItems, vm.isEqual));
|
value: Calculator.parseItems(vm.calcItems!, vm.isEqual!));
|
||||||
}),
|
}),
|
||||||
CalculatorButtons(onTap: _onPress),
|
CalculatorButtons(onTap: _onPress),
|
||||||
Row(
|
Row(
|
||||||
|
|
@ -74,7 +74,7 @@ class CalculatorTab extends StatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPress({String buttonText}) {
|
void _onPress({required String buttonText}) {
|
||||||
Redux.store.dispatch(onTapAction(buttonText));
|
Redux.store!.dispatch(onTapAction(buttonText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ 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_scan2/gen/protos/protos.pb.dart';
|
||||||
import 'package:barcode_scan/gen/protos/protos.pbenum.dart';
|
import 'package:barcode_scan2/gen/protos/protos.pbenum.dart';
|
||||||
import 'package:barcode_scan/model/scan_options.dart';
|
import 'package:barcode_scan2/model/scan_options.dart';
|
||||||
import 'package:barcode_scan/platform_wrapper.dart';
|
import 'package:barcode_scan2/platform_wrapper.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
@ -103,12 +103,12 @@ class KassaTab extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
child: StoreConnector<AppState, KassaState>(
|
child: StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
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]));
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -119,9 +119,9 @@ class KassaTab extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
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),
|
return Text(totalCalc(vm.kassaItems!),
|
||||||
style: TextStyle(fontSize: 25));
|
style: TextStyle(fontSize: 25));
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
@ -184,7 +184,7 @@ class KassaTab extends StatelessWidget {
|
||||||
|
|
||||||
Future<void> scan() async {
|
Future<void> scan() async {
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
var options = ScanOptions(strings: {
|
var options = ScanOptions(strings: {
|
||||||
"cancel": 'Отмена',
|
"cancel": 'Отмена',
|
||||||
"flash_on": 'Вкл фонарик',
|
"flash_on": 'Вкл фонарик',
|
||||||
|
|
@ -197,8 +197,8 @@ class KassaTab extends StatelessWidget {
|
||||||
// print(result.formatNote); // If a unknown format was scanned this field contains a note
|
// print(result.formatNote); // If a unknown format was scanned this field contains a note
|
||||||
// print(result.rawContent); // content
|
// print(result.rawContent); // content
|
||||||
if (result.type == ResultType.Barcode ) {
|
if (result.type == ResultType.Barcode ) {
|
||||||
String barcode;
|
String? barcode;
|
||||||
String dataMatrix;
|
String? dataMatrix;
|
||||||
if(result.format == BarcodeFormat.ean13 || result.format == BarcodeFormat.ean8) {
|
if(result.format == BarcodeFormat.ean13 || result.format == BarcodeFormat.ean8) {
|
||||||
barcode = result.rawContent;
|
barcode = result.rawContent;
|
||||||
} else if( result.format == BarcodeFormat.dataMatrix ) {
|
} else if( result.format == BarcodeFormat.dataMatrix ) {
|
||||||
|
|
@ -219,7 +219,7 @@ class KassaTab extends StatelessWidget {
|
||||||
List<Good> goods =
|
List<Good> goods =
|
||||||
await _dataService.getGoodsByBarcode(barcode: barcode);
|
await _dataService.getGoodsByBarcode(barcode: barcode);
|
||||||
if (goods != null && goods.isNotEmpty) {
|
if (goods != null && goods.isNotEmpty) {
|
||||||
await Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix));
|
await Redux.store!.dispatch(addProductToKassaItems(goods.first, dataMatrix));
|
||||||
} else {
|
} else {
|
||||||
_dialogService.showDialog(
|
_dialogService.showDialog(
|
||||||
description: 'Товар не найден: $barcode');
|
description: 'Товар не найден: $barcode');
|
||||||
|
|
@ -241,7 +241,7 @@ class KassaTab extends StatelessWidget {
|
||||||
_dialogService.showDialog(description: 'Неизвестная ошибка: $e');
|
_dialogService.showDialog(description: 'Неизвестная ошибка: $e');
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,20 +15,20 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
||||||
class CatalogBottomSheet extends StatelessWidget {
|
class CatalogBottomSheet extends StatelessWidget {
|
||||||
final ScrollController scrollController;
|
final ScrollController? scrollController;
|
||||||
|
|
||||||
CatalogBottomSheet({this.scrollController});
|
CatalogBottomSheet({this.scrollController});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreConnector<AppState, KassaState>(
|
return StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
onInit: (store) => Redux.store.dispatch(selectBottomElement(0)),
|
onInit: (store) => Redux.store!.dispatch(selectBottomElement(0)),
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
if (vm.prevCategories.length > 0) {
|
if (vm.prevCategories!.length > 0) {
|
||||||
Redux.store.dispatch(backBottomElement);
|
Redux.store!.dispatch(backBottomElement);
|
||||||
} else
|
} else
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
return new Future(() => false);
|
return new Future(() => false);
|
||||||
|
|
@ -36,8 +36,8 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
vm.prevCategories.isNotEmpty
|
vm.prevCategories!.isNotEmpty
|
||||||
? vm.prevCategories?.last?.name
|
? vm.prevCategories!.last.name
|
||||||
: '',
|
: '',
|
||||||
style: TextStyle(color: Colors.black45),
|
style: TextStyle(color: Colors.black45),
|
||||||
),
|
),
|
||||||
|
|
@ -45,12 +45,12 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
backgroundColor: whiteColor,
|
backgroundColor: whiteColor,
|
||||||
elevation: 1,
|
elevation: 1,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(vm.prevCategories.length > 0
|
icon: Icon(vm.prevCategories!.length > 0
|
||||||
? Icons.arrow_back
|
? Icons.arrow_back
|
||||||
: Icons.close),
|
: Icons.close),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (vm.prevCategories.length > 0) {
|
if (vm.prevCategories!.length > 0) {
|
||||||
Redux.store.dispatch(backBottomElement);
|
Redux.store!.dispatch(backBottomElement);
|
||||||
} else
|
} else
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
|
|
@ -63,11 +63,11 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemCount: vm.bottomSheetElements.length,
|
itemCount: vm.bottomSheetElements!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var el = vm.bottomSheetElements[index];
|
var el = vm.bottomSheetElements![index];
|
||||||
String name;
|
String? name;
|
||||||
String price;
|
String? price;
|
||||||
if (el is Category) {
|
if (el is Category) {
|
||||||
Category category = el;
|
Category category = el;
|
||||||
name = category.name;
|
name = category.name;
|
||||||
|
|
@ -86,19 +86,19 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
? Icon(Icons.layers, size: 25)
|
? Icon(Icons.layers, size: 25)
|
||||||
: null,
|
: null,
|
||||||
title: Text(
|
title: Text(
|
||||||
name,
|
name ?? '',
|
||||||
style: TextStyle(fontSize: 15),
|
style: TextStyle(fontSize: 15),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (el is Category) {
|
if (el is Category) {
|
||||||
Redux.store
|
Redux.store!
|
||||||
.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, null));
|
.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!
|
||||||
.dispatch(addServiceToKassaItems(el));
|
.dispatch(addServiceToKassaItems(el));
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
trailing: el is Category
|
trailing: el is Category
|
||||||
? Icon(Icons.chevron_right)
|
? Icon(Icons.chevron_right)
|
||||||
: Text(
|
: Text(
|
||||||
price,
|
price ?? '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15, color: Colors.black54),
|
fontSize: 15, color: Colors.black54),
|
||||||
),
|
),
|
||||||
|
|
@ -135,12 +135,12 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0),
|
margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0),
|
||||||
child: StoreConnector<AppState, KassaState>(
|
child: StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
builder: (_, mainState) {
|
builder: (_, mainState) {
|
||||||
return StoreConnector<AppState, SettingState>(
|
return StoreConnector<AppState, SettingState>(
|
||||||
converter: (store) => store.state.settingState,
|
converter: (store) => store.state.settingState!,
|
||||||
builder: (_, settingState) {
|
builder: (_, settingState) {
|
||||||
if (mainState.kassaItems.isNotEmpty) {
|
if (mainState.kassaItems!.isNotEmpty) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
locator<DialogService>().showDialog(
|
locator<DialogService>().showDialog(
|
||||||
|
|
@ -169,8 +169,8 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
underline: Container(
|
underline: Container(
|
||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
onChanged: (String newValue) {
|
onChanged: (String? newValue) {
|
||||||
onChangeTradeType(newValue, settingState.tradeType);
|
onChangeTradeType(newValue!, settingState.tradeType!);
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
|
|
@ -190,8 +190,8 @@ class CatalogBottomSheet extends StatelessWidget {
|
||||||
|
|
||||||
void onChangeTradeType(String newValue, String oldValue) async {
|
void onChangeTradeType(String newValue, String oldValue) async {
|
||||||
if (oldValue != newValue) {
|
if (oldValue != newValue) {
|
||||||
await Redux.store.dispatch(changeTradeTypeFromSetting(newValue));
|
await Redux.store!.dispatch(changeTradeTypeFromSetting(newValue));
|
||||||
await Redux.store.dispatch(selectBottomElement(0));
|
await Redux.store!.dispatch(selectBottomElement(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class ProductAddBottomSheet extends StatefulWidget {
|
class ProductAddBottomSheet extends StatefulWidget {
|
||||||
final ScrollController scrollController;
|
final ScrollController? scrollController;
|
||||||
|
|
||||||
ProductAddBottomSheet({this.scrollController});
|
ProductAddBottomSheet({this.scrollController});
|
||||||
|
|
||||||
|
|
@ -15,9 +15,9 @@ class ProductAddBottomSheet extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
||||||
TextEditingController nameController;
|
late TextEditingController nameController;
|
||||||
TextEditingController countController;
|
late TextEditingController countController;
|
||||||
TextEditingController priceController;
|
late TextEditingController priceController;
|
||||||
double sum = 0.0;
|
double sum = 0.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -75,11 +75,12 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
||||||
prefixText: ' ',
|
prefixText: ' ',
|
||||||
),
|
),
|
||||||
keyboardType: const TextInputType.numberWithOptions(
|
keyboardType: const TextInputType.numberWithOptions(
|
||||||
decimal: false,
|
decimal: true,
|
||||||
),
|
),
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
// WhitelistingTextInputFormatter.digitsOnly
|
// WhitelistingTextInputFormatter.digitsOnly
|
||||||
FilteringTextInputFormatter.digitsOnly
|
// FilteringTextInputFormatter.digitsOnly
|
||||||
|
FilteringTextInputFormatter.allow(RegExp("^[0-9.]*")),
|
||||||
],
|
],
|
||||||
controller: countController,
|
controller: countController,
|
||||||
onChanged: calcOnChange,
|
onChanged: calcOnChange,
|
||||||
|
|
@ -157,9 +158,9 @@ class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
||||||
priceController.text.isEmpty) {
|
priceController.text.isEmpty) {
|
||||||
_showDialog();
|
_showDialog();
|
||||||
} else {
|
} else {
|
||||||
Redux.store.dispatch(addCustomProductToKassaItems(
|
Redux.store!.dispatch(addCustomProductToKassaItems(
|
||||||
nameController.text,
|
nameController.text,
|
||||||
int.parse(countController.text),
|
double.parse(countController.text),
|
||||||
double.parse(priceController.text),
|
double.parse(priceController.text),
|
||||||
sum));
|
sum));
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ class _InfoKkmViewState extends State<InfoKkmView> {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = true;
|
||||||
});
|
});
|
||||||
User user = Redux.store.state.userState.user;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
Response<dynamic> response = await _apiService.infoKkm(user.token);
|
Response<dynamic> response = await _apiService.infoKkm(user.token!);
|
||||||
if (response.operation) {
|
if (response.operation) {
|
||||||
List<dynamic> list = [];
|
List<dynamic> list = [];
|
||||||
for (var key in response.body.keys) {
|
for (var key in response.body.keys) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||||
|
|
||||||
class PassCodeScreen extends StatefulWidget {
|
class PassCodeScreen extends StatefulWidget {
|
||||||
PassCodeScreen({Key key, this.title}) : super(key: key);
|
PassCodeScreen({Key? key, required this.title}) : super(key: key);
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ class _PassCodeScreenState extends State<PassCodeScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var myPass = [];
|
var myPass = [];
|
||||||
String _pinCode = Redux.store.state.settingState.pinCode;
|
String _pinCode = Redux.store!.state.settingState!.pinCode!;
|
||||||
for (var i = 0; i < _pinCode.length; i++) {
|
for (var i = 0; i < _pinCode.length; i++) {
|
||||||
myPass.add(int.parse(_pinCode[i]));
|
myPass.add(int.parse(_pinCode[i]));
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@ class _PassCodeScreenState extends State<PassCodeScreen> {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onSuccess: () {
|
onSuccess: () {
|
||||||
Redux.store.dispatch(changePinLockedFromSetting(false));
|
Redux.store!.dispatch(changePinLockedFromSetting(false));
|
||||||
_navigatorService.replace(HomeViewRoute);
|
_navigatorService.replace(HomeViewRoute);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,18 @@ import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/input_field.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/input_field.dart';
|
||||||
import 'package:barcode_scan/gen/protos/protos.pb.dart';
|
import 'package:barcode_scan2/gen/protos/protos.pb.dart';
|
||||||
import 'package:barcode_scan/gen/protos/protos.pbenum.dart';
|
import 'package:barcode_scan2/gen/protos/protos.pbenum.dart';
|
||||||
import 'package:barcode_scan/model/scan_options.dart';
|
import 'package:barcode_scan2/model/scan_options.dart';
|
||||||
import 'package:barcode_scan/platform_wrapper.dart';
|
import 'package:barcode_scan2/platform_wrapper.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
|
|
||||||
class LoginView extends StatefulWidget {
|
class LoginView extends StatefulWidget {
|
||||||
final LoginModel loginModel;
|
final LoginModel? loginModel;
|
||||||
|
|
||||||
LoginView({this.loginModel});
|
LoginView({this.loginModel});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -29,9 +30,9 @@ class LoginView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LoginViewState extends State<LoginView> {
|
class _LoginViewState extends State<LoginView> {
|
||||||
TextEditingController emailController;
|
late TextEditingController emailController;
|
||||||
|
|
||||||
TextEditingController passwordController;
|
late TextEditingController passwordController;
|
||||||
|
|
||||||
final FocusNode passwordNode = new FocusNode();
|
final FocusNode passwordNode = new FocusNode();
|
||||||
|
|
||||||
|
|
@ -45,10 +46,10 @@ class _LoginViewState extends State<LoginView> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.loginModel != null &&
|
if (widget.loginModel != null &&
|
||||||
widget.loginModel.authType == AuthenticateTypeLogin) {
|
widget.loginModel?.authType == AuthenticateTypeLogin) {
|
||||||
emailController = TextEditingController(text: widget.loginModel.login);
|
emailController = TextEditingController(text: widget.loginModel?.login);
|
||||||
passwordController =
|
passwordController =
|
||||||
TextEditingController(text: widget.loginModel.password);
|
TextEditingController(text: widget.loginModel?.password);
|
||||||
} else {
|
} else {
|
||||||
emailController = TextEditingController();
|
emailController = TextEditingController();
|
||||||
passwordController = TextEditingController();
|
passwordController = TextEditingController();
|
||||||
|
|
@ -65,86 +66,87 @@ class _LoginViewState extends State<LoginView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreConnector<AppState, UserState>(
|
return StoreConnector<AppState, UserState>(
|
||||||
converter: (store) => store.state.userState,
|
converter: (store) => store.state.userState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
backgroundColor: fillColor,
|
backgroundColor: fillColor,
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
physics: BouncingScrollPhysics(),
|
physics: BouncingScrollPhysics(),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
verticalSpaceLarge,
|
verticalSpaceLarge,
|
||||||
Stack(
|
Stack(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 150,
|
height: 150,
|
||||||
child: Image.asset('assets/images/logo.png'),
|
child: Image.asset('assets/images/logo.png'),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
child: Text(
|
||||||
|
'онлайн касса',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Positioned(
|
bottom: 23.0,
|
||||||
child: Text(
|
left: 25.0,
|
||||||
'онлайн касса',
|
),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
],
|
||||||
),
|
),
|
||||||
bottom: 23.0,
|
|
||||||
left: 25.0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
InputField(
|
InputField(
|
||||||
placeholder: 'Электронная почта',
|
placeholder: 'Электронная почта',
|
||||||
controller: emailController,
|
controller: emailController,
|
||||||
textInputType: TextInputType.emailAddress,
|
textInputType: TextInputType.emailAddress,
|
||||||
nextFocusNode: passwordNode,
|
nextFocusNode: passwordNode,
|
||||||
additionalNote: vm.loginFormMessage.email,
|
additionalNote: vm.loginFormMessage?.email,
|
||||||
),
|
),
|
||||||
verticalSpaceSmall,
|
verticalSpaceSmall,
|
||||||
InputField(
|
InputField(
|
||||||
placeholder: 'Пароль',
|
placeholder: 'Пароль',
|
||||||
password: true,
|
password: true,
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
fieldFocusNode: passwordNode,
|
fieldFocusNode: passwordNode,
|
||||||
additionalNote: vm.loginFormMessage.password,
|
additionalNote: vm.loginFormMessage?.password,
|
||||||
enterPressed: _pressBtnEnter,
|
enterPressed: _pressBtnEnter,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
),
|
),
|
||||||
verticalSpaceMedium,
|
verticalSpaceMedium,
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
child: BusyButton(
|
child: BusyButton(
|
||||||
title: 'Войти',
|
title: 'Войти',
|
||||||
busy: vm.isLoading,
|
busy: vm.isLoading ?? false,
|
||||||
onPressed: _pressBtnEnter,
|
onPressed: _pressBtnEnter,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
verticalSpaceLarge,
|
verticalSpaceLarge,
|
||||||
// TextLink(
|
// TextLink(
|
||||||
// 'Регистрация',
|
// 'Регистрация',
|
||||||
// onPressed: () {},
|
// onPressed: () {},
|
||||||
// ),
|
// ),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(MdiIcons.qrcodeScan),
|
icon: Icon(MdiIcons.qrcodeScan),
|
||||||
iconSize: 40,
|
iconSize: 40,
|
||||||
tooltip: "Scan",
|
tooltip: "Scan",
|
||||||
onPressed: scan,
|
onPressed: scan,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +157,7 @@ class _LoginViewState extends State<LoginView> {
|
||||||
} else {
|
} else {
|
||||||
_apiService.test = false;
|
_apiService.test = false;
|
||||||
}
|
}
|
||||||
Redux.store
|
Redux.store!
|
||||||
.dispatch(authenticate(emailController.text, passwordController.text));
|
.dispatch(authenticate(emailController.text, passwordController.text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,14 +174,13 @@ class _LoginViewState extends State<LoginView> {
|
||||||
// print(result.format); // The barcode format (as enum)
|
// print(result.format); // The barcode format (as enum)
|
||||||
// print(result
|
// print(result
|
||||||
// .formatNote); // If a unknown format was scanned this field contains a note
|
// .formatNote); // If a unknown format was scanned this field contains a note
|
||||||
if (result.type == ResultType.Barcode &&
|
if (result.type == ResultType.Barcode && result.rawContent.length == 60) {
|
||||||
result.rawContent?.length == 60) {
|
|
||||||
if (result.rawContent.toLowerCase().trim().startsWith('test')) {
|
if (result.rawContent.toLowerCase().trim().startsWith('test')) {
|
||||||
_apiService.test = true;
|
_apiService.test = true;
|
||||||
} else {
|
} else {
|
||||||
_apiService.test = false;
|
_apiService.test = false;
|
||||||
}
|
}
|
||||||
Redux.store.dispatch(authenticateToken(result.rawContent));
|
Redux.store!.dispatch(authenticateToken(result.rawContent));
|
||||||
} else if (result.type == ResultType.Error) {
|
} else if (result.type == ResultType.Error) {
|
||||||
_dialogService.showDialog(description: 'Не верный формат QR кода');
|
_dialogService.showDialog(description: 'Не верный формат QR кода');
|
||||||
}
|
}
|
||||||
|
|
@ -200,8 +201,9 @@ class _LoginViewState extends State<LoginView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginModel {
|
class LoginModel {
|
||||||
final String authType;
|
final String? authType;
|
||||||
final String login;
|
final String? login;
|
||||||
final String password;
|
final String? password;
|
||||||
|
|
||||||
LoginModel({this.authType, this.login, this.password});
|
LoginModel({this.authType, this.login, this.password});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,43 +22,43 @@ Logger log = getLogger('PaymentNfcView');
|
||||||
|
|
||||||
Future<AmanDao<CardData>> paymentHalykPos(double total) async {
|
Future<AmanDao<CardData>> paymentHalykPos(double total) async {
|
||||||
//Авторизация
|
//Авторизация
|
||||||
String token = Redux.store.state.userState.user.token;
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
BankState bankState = Redux.store.state.bankState;
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
//права доступа
|
//права доступа
|
||||||
HalykPosSession session = await _bankService.renewToken(
|
HalykPosSession? session = await _bankService.renewToken(
|
||||||
token: token, login: bankState.login, password: bankState.password);
|
token: token, login: bankState.login!, password: bankState.password!);
|
||||||
if (session.token == null) {
|
if (session == null || session.token == null) {
|
||||||
return sessionDeclineDao(session);
|
return sessionDeclineDao(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Инициализация
|
//Инициализация
|
||||||
HalykResponse response =
|
HalykResponse response =
|
||||||
await _bankService.pay(token: session.token, amount: total);
|
await _bankService.pay(token: session.token!, amount: total);
|
||||||
if (response.result.code == 0) {
|
if (response.result?.code == 0) {
|
||||||
CardData cardData = new CardData(
|
CardData cardData = new CardData(
|
||||||
authorizationCode:
|
authorizationCode:
|
||||||
response.transaction.instrumentSpecificData.authorizationCode,
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
cardholderName:
|
cardholderName:
|
||||||
response.transaction.instrumentSpecificData.cardholderName,
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
cardNumber: response.transaction.instrumentSpecificData.maskedPan,
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
operationDay: response.transaction.operationDay,
|
operationDay: response.transaction?.operationDay,
|
||||||
transactionNumber: response.transaction.transactionNumber,
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
terminalId: response.transaction.terminalId,
|
terminalId: response.transaction?.terminalId,
|
||||||
transactionType: 'payment');
|
transactionType: 'payment');
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.description, success: true, data: cardData);
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
}
|
}
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.errorData != null
|
msg: response.result?.errorData != null
|
||||||
? response.result.errorData.description
|
? response.result!.errorData!.description
|
||||||
: response.result.description,
|
: response.result!.description,
|
||||||
success: false);
|
success: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
AmanDao<CardData> sessionDeclineDao(HalykPosSession session) {
|
AmanDao<CardData> sessionDeclineDao(HalykPosSession? session) {
|
||||||
String msg = 'Отказано в доступе к API банка';
|
String msg = 'Отказано в доступе к API банка';
|
||||||
if(session.result?.Response?.Description != null) {
|
if(session!=null && session.result?.Response?.Description != null) {
|
||||||
msg = '${session.result.Response.Description} (${session.result.Response.Code}) ';
|
msg = '${session.result?.Response?.Description} (${session.result?.Response?.Code}) ';
|
||||||
}
|
}
|
||||||
return AmanDao<CardData>(success: false, msg: msg);
|
return AmanDao<CardData>(success: false, msg: msg);
|
||||||
}
|
}
|
||||||
|
|
@ -66,93 +66,93 @@ AmanDao<CardData> sessionDeclineDao(HalykPosSession session) {
|
||||||
Future<AmanDao<CardData>> refundHalykPos(
|
Future<AmanDao<CardData>> refundHalykPos(
|
||||||
CardData refundData, double total) async {
|
CardData refundData, double total) async {
|
||||||
//Авторизация
|
//Авторизация
|
||||||
String token = Redux.store.state.userState.user.token;
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
BankState bankState = Redux.store.state.bankState;
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
//права доступа
|
//права доступа
|
||||||
HalykPosSession session = await _bankService.renewToken(
|
HalykPosSession? session = await _bankService.renewToken(
|
||||||
token: token, login: bankState.login, password: bankState.password);
|
token: token, login: bankState.login!, password: bankState.password!);
|
||||||
if (session.token == null) {
|
if (session == null || session.token == null) {
|
||||||
return sessionDeclineDao(session);
|
return sessionDeclineDao(session);
|
||||||
}
|
}
|
||||||
HalykResponse response = await _bankService.refund(
|
HalykResponse response = await _bankService.refund(
|
||||||
token: session.token,
|
token: session.token!,
|
||||||
amount: total,
|
amount: total,
|
||||||
operDay: refundData.operationDay,
|
operDay: refundData.operationDay!,
|
||||||
terminalId: refundData.terminalId,
|
terminalId: refundData.terminalId!,
|
||||||
transNum: refundData.transactionNumber);
|
transNum: refundData.transactionNumber!);
|
||||||
if (response.result.code == 0) {
|
if (response.result?.code == 0) {
|
||||||
CardData cardData = new CardData(
|
CardData cardData = new CardData(
|
||||||
authorizationCode:
|
authorizationCode:
|
||||||
response.transaction.instrumentSpecificData.authorizationCode,
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
cardholderName:
|
cardholderName:
|
||||||
response.transaction.instrumentSpecificData.cardholderName,
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
cardNumber: response.transaction.instrumentSpecificData.maskedPan,
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
operationDay: response.transaction.operationDay,
|
operationDay: response.transaction?.operationDay,
|
||||||
transactionNumber: response.transaction.transactionNumber,
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
terminalId: response.transaction.terminalId,
|
terminalId: response.transaction?.terminalId,
|
||||||
transactionType: 'refund');
|
transactionType: 'refund');
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.description, success: true, data: cardData);
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
}
|
}
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.errorData != null
|
msg: response.result?.errorData != null
|
||||||
? response.result.errorData.description
|
? response.result!.errorData!.description
|
||||||
: response.result.description,
|
: response.result!.description,
|
||||||
success: false);
|
success: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AmanDao<CardData>> reversalHalykPos(
|
Future<AmanDao<CardData>> reversalHalykPos(
|
||||||
CardData refundData, double total) async {
|
CardData refundData, double total) async {
|
||||||
//Авторизация
|
//Авторизация
|
||||||
String token = Redux.store.state.userState.user.token;
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
BankState bankState = Redux.store.state.bankState;
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
//права доступа
|
//права доступа
|
||||||
HalykPosSession session = await _bankService.renewToken(
|
HalykPosSession? session = await _bankService.renewToken(
|
||||||
token: token, login: bankState.login, password: bankState.password);
|
token: token, login: bankState.login ?? '', password: bankState.password ?? '');
|
||||||
if (session.token == null) {
|
if (session == null || session.token == null) {
|
||||||
return sessionDeclineDao(session);
|
return sessionDeclineDao(session);
|
||||||
}
|
}
|
||||||
log.i(refundData.toJson());
|
log.i(refundData.toJson());
|
||||||
HalykResponse response = await _bankService.reversal(
|
HalykResponse response = await _bankService.reversal(
|
||||||
token: session.token,
|
token: session.token!,
|
||||||
operDay: refundData.operationDay,
|
operDay: refundData.operationDay!,
|
||||||
terminalId: refundData.terminalId,
|
terminalId: refundData.terminalId!,
|
||||||
transNum: refundData.transactionNumber);
|
transNum: refundData.transactionNumber!);
|
||||||
if (response.result.code == 0) {
|
if (response.result?.code == 0) {
|
||||||
CardData cardData = new CardData(
|
CardData cardData = new CardData(
|
||||||
authorizationCode:
|
authorizationCode:
|
||||||
response.transaction.instrumentSpecificData.authorizationCode,
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
cardholderName:
|
cardholderName:
|
||||||
response.transaction.instrumentSpecificData.cardholderName,
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
cardNumber: response.transaction.instrumentSpecificData.maskedPan,
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
operationDay: response.transaction.operationDay,
|
operationDay: response.transaction?.operationDay,
|
||||||
transactionNumber: response.transaction.transactionNumber,
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
terminalId: response.transaction.terminalId,
|
terminalId: response.transaction?.terminalId,
|
||||||
transactionType: 'reversal');
|
transactionType: 'reversal');
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.description, success: true, data: cardData);
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
}
|
}
|
||||||
return AmanDao<CardData>(
|
return AmanDao<CardData>(
|
||||||
msg: response.result.errorData != null
|
msg: response.result?.errorData != null
|
||||||
? response.result.errorData.description
|
? response.result!.errorData!.description
|
||||||
: response.result.description,
|
: response.result!.description,
|
||||||
success: false);
|
success: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Cd.HalykCloseDayDao> closeDayHalykPos() async {
|
Future<Cd.HalykCloseDayDao?> closeDayHalykPos() async {
|
||||||
//Авторизация
|
//Авторизация
|
||||||
String token = Redux.store.state.userState.user.token;
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
BankState bankState = Redux.store.state.bankState;
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
//права доступа
|
//права доступа
|
||||||
HalykPosSession session = await _bankService.renewToken(
|
HalykPosSession? session = await _bankService.renewToken(
|
||||||
token: token, login: bankState.login, password: bankState.password);
|
token: token, login: bankState.login ?? '', password: bankState.password ?? '');
|
||||||
if (session.token == null) {
|
if (session== null || session.token == null) {
|
||||||
return new Cd.HalykCloseDayDao(
|
return new Cd.HalykCloseDayDao(
|
||||||
result: Cd.ResultBean(
|
result: Cd.ResultBean(
|
||||||
description: 'Отказано в доступе к API банка', code: -1));
|
description: 'Отказано в доступе к API банка', code: -1));
|
||||||
}
|
}
|
||||||
//Инициализация
|
//Инициализация
|
||||||
Cd.HalykCloseDayDao response =
|
Cd.HalykCloseDayDao? response =
|
||||||
await _bankService.closeDay(token: session.token);
|
await _bankService.closeDay(token: session.token!);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import '../../core/models/card_data.dart';
|
||||||
class PaymentView extends StatefulWidget {
|
class PaymentView extends StatefulWidget {
|
||||||
final PaymentModel model;
|
final PaymentModel model;
|
||||||
|
|
||||||
const PaymentView({Key key, this.model}) : super(key: key);
|
const PaymentView({Key? key, required this.model}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PaymentViewState createState() => _PaymentViewState();
|
_PaymentViewState createState() => _PaymentViewState();
|
||||||
|
|
@ -52,8 +52,8 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
BankService _bankService = locator<BankService>();
|
BankService _bankService = locator<BankService>();
|
||||||
final NavigatorService _navigatorService = locator<NavigatorService>();
|
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
bool isBusy;
|
late bool isBusy;
|
||||||
bool isBankApiAccess;
|
late bool isBankApiAccess;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -127,9 +127,9 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
StoreConnector buildStoreConnector() {
|
StoreConnector buildStoreConnector() {
|
||||||
if (widget.model.mode == SettingModeCalc) {
|
if (widget.model.mode == SettingModeCalc) {
|
||||||
return StoreConnector<AppState, CalcState>(
|
return StoreConnector<AppState, CalcState>(
|
||||||
converter: (store) => store.state.calcState,
|
converter: (store) => store.state.calcState!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
return Text('${totalCalc(vm.calcItems)} тнг',
|
return Text('${totalCalc(vm.calcItems!)} тнг',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
|
|
@ -137,9 +137,9 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return StoreConnector<AppState, KassaState>(
|
return StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
return Text('${totalKassa(vm.kassaItems)} тнг',
|
return Text('${totalKassa(vm.kassaItems!)} тнг',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
|
|
@ -202,42 +202,49 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
return StoreConnector<AppState, AppState>(
|
return StoreConnector<AppState, AppState>(
|
||||||
converter: (store) => store.state,
|
converter: (store) => store.state,
|
||||||
builder: (_, _state) {
|
builder: (_, _state) {
|
||||||
BankState state = _state.bankState;
|
BankState state = _state.bankState!;
|
||||||
double _total;
|
double _total;
|
||||||
if (widget.model.mode == SettingModeCalc) {
|
if (widget.model.mode == SettingModeCalc) {
|
||||||
String value = totalCalc(_state.calcState.calcItems);
|
String value = totalCalc(_state.calcState!.calcItems!);
|
||||||
_total = double.parse(value);
|
_total = double.parse(value);
|
||||||
} else {
|
} else {
|
||||||
String value = totalKassa(_state.kassaState.kassaItems);
|
String value = totalKassa(_state.kassaState!.kassaItems!);
|
||||||
_total = double.parse(value);
|
_total = double.parse(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.password == null || state.login == null || state.password.length < 1 || state.login.length < 1) {
|
if (state.password == null || state.login == null || state.password!.length < 1 || state.login!.length < 1) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: isBusy ? null : () async {
|
||||||
|
|
||||||
|
|
||||||
var today = new DateTime.now();
|
var today = new DateTime.now();
|
||||||
var yesterday = today.subtract(new Duration(days: 1));
|
var yesterday = today.subtract(new Duration(days: 1));
|
||||||
if( Redux.store.state.userState == null
|
if( Redux.store!.state.userState == null
|
||||||
|| Redux.store.state.userState.smena == null
|
|| Redux.store!.state.userState!.smena == null
|
||||||
|| Redux.store.state.userState.smena.startedAt == null
|
|| Redux.store!.state.userState!.smena!.startedAt == null
|
||||||
|| yesterday.isAfter(Redux.store.state.userState.smena.startedAt)) {
|
|| yesterday.isAfter(Redux.store!.state.userState!.smena!.startedAt!)) {
|
||||||
_dialogService.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
_dialogService.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setState(() {
|
||||||
|
isBusy = true;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
AmanDao<CardData> data = await paymentHalykPos(_total);
|
AmanDao<CardData> data = await paymentHalykPos(_total);
|
||||||
if (data.success) {
|
if (data.success == true) {
|
||||||
pressPayment(widget.model.operationType, data.data);
|
pressPayment('card', data.data);
|
||||||
} else {
|
} else {
|
||||||
_dialogService.showDialog(description: data.msg);
|
_dialogService.showDialog(description: data.msg ?? '');
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await Redux.store.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
|
setState(() {
|
||||||
|
isBusy = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
splashColor: halykColor.withOpacity(0.4),
|
splashColor: halykColor.withOpacity(0.4),
|
||||||
|
|
@ -290,22 +297,22 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pressPayment(String type, CardData cardData) async {
|
pressPayment(String type, CardData? cardData) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
isBusy = true;
|
isBusy = true;
|
||||||
});
|
});
|
||||||
Dialogs.showLoadingDialog(context, _keyLoader);
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
try {
|
try {
|
||||||
AppState _state = Redux.store.state;
|
AppState _state = Redux.store!.state;
|
||||||
String _token = _state.userState.user.token;
|
String _token = _state.userState!.user!.token!;
|
||||||
String _tradeType = _state.settingState.tradeType;
|
String _tradeType = _state.settingState!.tradeType!;
|
||||||
String _mode = _state.settingState.mode;
|
String _mode = _state.settingState!.mode!;
|
||||||
if (_mode == SettingModeCalc) {
|
if (_mode == SettingModeCalc) {
|
||||||
_tradeType = SettingTradeTypeGood;
|
_tradeType = SettingTradeTypeGood;
|
||||||
}
|
}
|
||||||
List<ProductDao> kassaItems = _state.kassaState.kassaItems;
|
List<ProductDao> kassaItems = _state.kassaState!.kassaItems!;
|
||||||
List<CalcModel> calcItems = _state.calcState.calcItems;
|
List<CalcModel> calcItems = _state.calcState!.calcItems!;
|
||||||
Response<dynamic> response = await _dataService.sellOrReturn(
|
Response<dynamic>? response = await _dataService.sellOrReturn(
|
||||||
token: _token,
|
token: _token,
|
||||||
kassaItems: kassaItems,
|
kassaItems: kassaItems,
|
||||||
paymentType: type,
|
paymentType: type,
|
||||||
|
|
@ -323,16 +330,16 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
String message = response.body['message'];
|
String message = response.body['message'];
|
||||||
String check = response.body['check'];
|
String check = response.body['check'];
|
||||||
var checkText = response.body['check_text'];
|
var checkText = response.body['check_text'];
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
print('url : $url');
|
print('url : $url');
|
||||||
if (_mode == SettingModeCalc) {
|
if (_mode == SettingModeCalc) {
|
||||||
Redux.store.dispatch(cleanCalcItems);
|
Redux.store!.dispatch(cleanCalcItems);
|
||||||
} else if (_mode == SettingModeKassa) {
|
} else if (_mode == SettingModeKassa) {
|
||||||
Redux.store.dispatch(cleanKassaItems);
|
Redux.store!.dispatch(cleanKassaItems);
|
||||||
}
|
}
|
||||||
Redux.store.dispatch(checkMoney);
|
Redux.store!.dispatch(checkMoney);
|
||||||
Redux.store.dispatch(openSmenaPseudo);
|
Redux.store!.dispatch(openSmenaPseudo);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_navigatorService.pop();
|
_navigatorService.pop();
|
||||||
_navigatorService.push(ImageShowRoute,
|
_navigatorService.push(ImageShowRoute,
|
||||||
arguments: ImageShowModel(data: new CheckImageModal(
|
arguments: ImageShowModel(data: new CheckImageModal(
|
||||||
|
|
@ -340,20 +347,20 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
title: message,
|
title: message,
|
||||||
url: url));
|
url: url));
|
||||||
} else if (!response.operation && ![401, 402, 403, 412, 500].contains(response.status)) {
|
} else if (!response.operation && ![401, 402, 403, 412, 500].contains(response.status)) {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_dialogService.showDialog(description: response.body['message']);
|
_dialogService.showDialog(description: response.body['message']);
|
||||||
} else if (!response.operation && response.body['message'] != null) {
|
} else if (!response.operation && response.body['message'] != null) {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_dialogService.showDialog(description: response.body['message']);
|
_dialogService.showDialog(description: response.body['message']);
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
} finally {
|
} finally {
|
||||||
//Navigator.of(context, rootNavigator: true).pop();
|
//Navigator.of(context, rootNavigator: true).pop();
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -375,7 +382,7 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
items.forEach((element) {
|
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 num1 = element.num1 == null ? 0.0 : double.parse(element.num1);
|
||||||
double num2 = element.num2 == null ? 0.0 : double.parse(element.num2);
|
double num2 = element.num2 == null ? 0.0 : double.parse(element.num2!);
|
||||||
total += num1 * num2;
|
total += num1 * num2;
|
||||||
} else {
|
} else {
|
||||||
total += element.num1 == null ? 0.0 : double.parse(element.num1);
|
total += element.num1 == null ? 0.0 : double.parse(element.num1);
|
||||||
|
|
@ -388,8 +395,8 @@ class _PaymentViewState extends State<PaymentView> {
|
||||||
class PaymentModel {
|
class PaymentModel {
|
||||||
String operationType;
|
String operationType;
|
||||||
String mode;
|
String mode;
|
||||||
Voucher voucher;
|
Voucher? voucher;
|
||||||
CardData cardData;
|
CardData? cardData;
|
||||||
|
|
||||||
PaymentModel({this.mode, this.operationType, this.voucher, this.cardData});
|
PaymentModel({required this.mode, required this.operationType, this.voucher, this.cardData});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import 'package:logger/logger.dart';
|
||||||
|
|
||||||
class PaymentNfcView extends StatefulWidget {
|
class PaymentNfcView extends StatefulWidget {
|
||||||
final PaymentModel model;
|
final PaymentModel model;
|
||||||
const PaymentNfcView({Key key, this.model}) : super(key: key);
|
const PaymentNfcView({Key? key, required this.model}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PaymentNfcViewState createState() => _PaymentNfcViewState();
|
_PaymentNfcViewState createState() => _PaymentNfcViewState();
|
||||||
|
|
@ -57,9 +57,9 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
final DataService _dataService = locator<DataService>();
|
final DataService _dataService = locator<DataService>();
|
||||||
final NavigatorService _navigatorService = locator<NavigatorService>();
|
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
Logger log = getLogger('PaymentNfcView');
|
Logger log = getLogger('PaymentNfcView');
|
||||||
bool isBusy;
|
late bool isBusy;
|
||||||
bool isPhoneScaled;
|
late bool isPhoneScaled;
|
||||||
int status;
|
late int status;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -73,12 +73,12 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
void start() async {
|
void start() async {
|
||||||
|
|
||||||
//Авторизация
|
//Авторизация
|
||||||
String token = Redux.store.state.userState.user.token;
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
BankState bankState = Redux.store.state.bankState;
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
//права доступа
|
//права доступа
|
||||||
HalykPosSession session = await _bankService.renewToken(token: token, login: bankState.login, password: bankState.password);
|
HalykPosSession? session = await _bankService.renewToken(token: token, login: bankState.login!, password: bankState.password!);
|
||||||
log.i(session);
|
log.i(session);
|
||||||
if (session.token ==null) {
|
if (session == null || session.token ==null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
status = 4;
|
status = 4;
|
||||||
});
|
});
|
||||||
|
|
@ -100,10 +100,10 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
|
|
||||||
var today = new DateTime.now();
|
var today = new DateTime.now();
|
||||||
var yesterday = today.subtract(new Duration(days: 1));
|
var yesterday = today.subtract(new Duration(days: 1));
|
||||||
if( Redux.store.state.userState == null
|
if( Redux.store!.state.userState == null
|
||||||
|| Redux.store.state.userState.smena == null
|
|| Redux.store!.state.userState!.smena == null
|
||||||
|| Redux.store.state.userState.smena.startedAt == null
|
|| Redux.store!.state.userState!.smena!.startedAt == null
|
||||||
|| yesterday.isAfter(Redux.store.state.userState.smena.startedAt)) {
|
|| yesterday.isAfter(Redux.store!.state.userState!.smena!.startedAt!)) {
|
||||||
_dialogService.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
_dialogService.showDialog(description: 'Текущая смена открыта более 24 ч. Необходимо закрыть смену и открыть ее заново.');
|
||||||
_navigatorService.pop();
|
_navigatorService.pop();
|
||||||
return;
|
return;
|
||||||
|
|
@ -163,7 +163,7 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
refund() async {
|
refund() async {
|
||||||
CardData _cardData = widget.model.cardData;
|
//CardData _cardData = widget.model.cardData;
|
||||||
// AmanDao findTransaction = await _bankService.findTransaction(transactionNumber: _cardData.transactionNumber, authorizationCode: _cardData.authorizationCode);
|
// AmanDao findTransaction = await _bankService.findTransaction(transactionNumber: _cardData.transactionNumber, authorizationCode: _cardData.authorizationCode);
|
||||||
// if(!findTransaction.success){
|
// if(!findTransaction.success){
|
||||||
// _dialogService.showDialog(description: findTransaction.msg);
|
// _dialogService.showDialog(description: findTransaction.msg);
|
||||||
|
|
@ -264,18 +264,18 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
});
|
});
|
||||||
Dialogs.showLoadingDialog(context, _keyLoader);
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
try {
|
try {
|
||||||
AppState _state = Redux.store.state;
|
AppState _state = Redux.store!.state;
|
||||||
String _token = _state.userState.user.token;
|
String _token = _state.userState!.user!.token!;
|
||||||
String _tradeType = _state.settingState.tradeType;
|
String _tradeType = _state.settingState!.tradeType!;
|
||||||
String _mode = _state.settingState.mode;
|
String _mode = _state.settingState!.mode!;
|
||||||
if (_mode == SettingModeCalc) {
|
if (_mode == SettingModeCalc) {
|
||||||
_tradeType = SettingTradeTypeGood;
|
_tradeType = SettingTradeTypeGood;
|
||||||
}
|
}
|
||||||
CardData cardData = cardDataDynamic != null ? CardData.fromJson(cardDataDynamic) : null;
|
CardData? cardData = cardDataDynamic != null ? CardData.fromJson(cardDataDynamic) : null;
|
||||||
|
|
||||||
List<ProductDao> kassaItems = _state.kassaState.kassaItems;
|
List<ProductDao> kassaItems = _state.kassaState!.kassaItems!;
|
||||||
List<CalcModel> calcItems = _state.calcState.calcItems;
|
List<CalcModel> calcItems = _state.calcState!.calcItems!;
|
||||||
Response<dynamic> response = await _dataService.sellOrReturn(
|
Response<dynamic>? response = await _dataService.sellOrReturn(
|
||||||
token: _token,
|
token: _token,
|
||||||
kassaItems: kassaItems,
|
kassaItems: kassaItems,
|
||||||
paymentType: type,
|
paymentType: type,
|
||||||
|
|
@ -293,31 +293,31 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
String message = response.body['message'];
|
String message = response.body['message'];
|
||||||
String check = response.body['check'];
|
String check = response.body['check'];
|
||||||
var checkText = response.body['check_text'];
|
var checkText = response.body['check_text'];
|
||||||
String url = response?.body['link'];
|
String url = response.body['link'];
|
||||||
if (_mode == SettingModeCalc) {
|
if (_mode == SettingModeCalc) {
|
||||||
Redux.store.dispatch(cleanCalcItems);
|
Redux.store!.dispatch(cleanCalcItems);
|
||||||
} else if (_mode == SettingModeKassa) {
|
} else if (_mode == SettingModeKassa) {
|
||||||
Redux.store.dispatch(cleanKassaItems);
|
Redux.store!.dispatch(cleanKassaItems);
|
||||||
}
|
}
|
||||||
Redux.store.dispatch(checkMoney);
|
Redux.store!.dispatch(checkMoney);
|
||||||
Redux.store.dispatch(openSmenaPseudo);
|
Redux.store!.dispatch(openSmenaPseudo);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_navigatorService.replace(HomeViewRoute);
|
_navigatorService.replace(HomeViewRoute);
|
||||||
_navigatorService.push(ImageShowRoute,
|
_navigatorService.push(ImageShowRoute,
|
||||||
arguments: ImageShowModel(data: new CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: message, url: url));
|
arguments: ImageShowModel(data: new CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: message, url: url));
|
||||||
} else if (!response.operation &&
|
} else if (!response.operation &&
|
||||||
![401, 402, 403, 412, 500].contains(response.status)) {
|
![401, 402, 403, 412, 500].contains(response.status)) {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
_dialogService.showDialog(description: response.body['message']);
|
_dialogService.showDialog(description: response.body['message']);
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop();
|
||||||
} finally {
|
} finally {
|
||||||
//Navigator.of(context, rootNavigator: true).pop();
|
//Navigator.of(context, rootNavigator: true).pop();
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -470,9 +470,9 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
StoreConnector buildStoreConnector() {
|
StoreConnector buildStoreConnector() {
|
||||||
if (widget.model.mode == SettingModeCalc) {
|
if (widget.model.mode == SettingModeCalc) {
|
||||||
return StoreConnector<AppState, CalcState>(
|
return StoreConnector<AppState, CalcState>(
|
||||||
converter: (store) => store.state.calcState,
|
converter: (store) => store.state.calcState!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
return Text('${totalCalc(vm.calcItems)} тнг',
|
return Text('${totalCalc(vm.calcItems!)} тнг',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: whiteColor,
|
color: whiteColor,
|
||||||
|
|
@ -481,9 +481,9 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
}
|
}
|
||||||
if(widget.model.voucher !=null) {
|
if(widget.model.voucher !=null) {
|
||||||
return StoreConnector<AppState, KassaState>(
|
return StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
return Text('${widget.model.voucher.total} тнг',
|
return Text('${widget.model.voucher?.total} тнг',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: whiteColor,
|
color: whiteColor,
|
||||||
|
|
@ -491,9 +491,9 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return StoreConnector<AppState, KassaState>(
|
return StoreConnector<AppState, KassaState>(
|
||||||
converter: (store) => store.state.kassaState,
|
converter: (store) => store.state.kassaState!,
|
||||||
builder: (_, vm) {
|
builder: (_, vm) {
|
||||||
return Text('${totalKassa(vm.kassaItems)} тнг',
|
return Text('${totalKassa(vm.kassaItems!)} тнг',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: whiteColor,
|
color: whiteColor,
|
||||||
|
|
@ -514,7 +514,7 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
|
||||||
items.forEach((element) {
|
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 num1 = element.num1 == null ? 0.0 : double.parse(element.num1);
|
||||||
double num2 = element.num2 == null ? 0.0 : double.parse(element.num2);
|
double num2 = element.num2 == null ? 0.0 : double.parse(element.num2!);
|
||||||
total += num1 * num2;
|
total += num1 * num2;
|
||||||
} else {
|
} else {
|
||||||
total += element.num1 == null ? 0.0 : double.parse(element.num1);
|
total += element.num1 == null ? 0.0 : double.parse(element.num1);
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
|
||||||
class ActionView extends StatelessWidget {
|
class ActionView extends StatelessWidget {
|
||||||
final String acceptText;
|
final String? acceptText;
|
||||||
final String declineText;
|
final String? declineText;
|
||||||
final void Function() acceptCallback;
|
final void Function()? acceptCallback;
|
||||||
final void Function() declineCallback;
|
final void Function()? declineCallback;
|
||||||
final bool show;
|
final bool show;
|
||||||
|
|
||||||
const ActionView(
|
const ActionView(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.acceptText,
|
this.acceptText,
|
||||||
this.declineText,
|
this.declineText,
|
||||||
this.acceptCallback,
|
this.acceptCallback,
|
||||||
|
|
@ -39,10 +39,10 @@ class ActionView extends StatelessWidget {
|
||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (acceptCallback !=null && acceptText !=null)
|
if (acceptCallback !=null && acceptText !=null)
|
||||||
Expanded(child: BusyButton(title: acceptText, onPressed: acceptCallback)),
|
Expanded(child: BusyButton(title: acceptText!, onPressed: acceptCallback!)),
|
||||||
SizedBox(width: 5.0,),
|
SizedBox(width: 5.0,),
|
||||||
if (declineCallback !=null && declineText !=null)
|
if (declineCallback !=null && declineText !=null)
|
||||||
BusyButton(title: declineText, onPressed: declineCallback, mainColor: redColor,)
|
BusyButton(title: declineText!, onPressed: declineCallback!, mainColor: redColor,)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
||||||
|
|
||||||
class PhoneView extends StatefulWidget {
|
class PhoneView extends StatefulWidget {
|
||||||
final bool scaled;
|
final bool scaled;
|
||||||
final int status;
|
final int? status;
|
||||||
|
|
||||||
const PhoneView({this.scaled = false, this.status });
|
const PhoneView({this.scaled = false, this.status });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
|
||||||
class TextStateView extends StatelessWidget {
|
class TextStateView extends StatelessWidget {
|
||||||
final int status;
|
final int? status;
|
||||||
final String text;
|
final String text;
|
||||||
|
|
||||||
const TextStateView({Key key, this.status, this.text = ''}) : super(key: key);
|
const TextStateView({Key? key, this.status, this.text = ''}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class _QrViewState extends State<QrView> {
|
||||||
body: Container(
|
body: Container(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: QrImage(
|
child: QrImage(
|
||||||
data: widget.data.url,
|
data: widget.data.url!,
|
||||||
version: QrVersions.auto,
|
version: QrVersions.auto,
|
||||||
size: 220.0,
|
size: 220.0,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SettingItem extends StatefulWidget {
|
class SettingItem extends StatefulWidget {
|
||||||
|
|
||||||
final String name;
|
final String? name;
|
||||||
final String value;
|
final String? value;
|
||||||
final String title;
|
final String title;
|
||||||
final Function onTap;
|
final Function onTap;
|
||||||
|
|
||||||
SettingItem({Key key, this.name, this.value, this.onTap, this.title }) : super(key: key);
|
SettingItem({Key? key, this.name, this.value, required this.onTap, required this.title }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SettingItemState createState() => _SettingItemState();
|
_SettingItemState createState() => _SettingItemState();
|
||||||
|
|
@ -21,16 +21,16 @@ class _SettingItemState extends State<SettingItem> {
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
subtitle: Text.rich(
|
subtitle: Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: widget.name,
|
text: widget.name ?? '',
|
||||||
style: TextStyle(fontWeight: FontWeight.w500),
|
style: TextStyle(fontWeight: FontWeight.w500),
|
||||||
children: <TextSpan>[
|
children: <TextSpan>[
|
||||||
if(widget.value !=null)
|
if(widget.value != null)
|
||||||
TextSpan(text: ' ${widget.value}', style: TextStyle(fontStyle: FontStyle.italic)),
|
TextSpan(text: ' ${widget.value}', style: TextStyle(fontStyle: FontStyle.italic)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
trailing: Icon(Icons.chevron_right),
|
trailing: Icon(Icons.chevron_right),
|
||||||
onTap: widget.onTap,
|
onTap: () => widget.onTap(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,65 +10,26 @@ import 'package:image/image.dart' as Im;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|
||||||
Future<Ticket> testTicket(PaperSize paper) async {
|
Future<List<int>> testTicket(PaperSize paper) async {
|
||||||
final Ticket ticket = Ticket(paper);
|
|
||||||
|
|
||||||
//Uint8List encTxt11 = await CharsetConverter.encode("cp866", "Russian: Привет Мир!");
|
final profile = await CapabilityProfile.load();
|
||||||
//ticket.textEncoded(encTxt11, styles: PosStyles(codeTable: PosCodeTable.pc866_2));
|
final ticket = Generator(PaperSize.mm80, profile);
|
||||||
//ticket.textEncoded(encTxt11);
|
List<int> bytes = [];
|
||||||
|
bytes += ticket.text(
|
||||||
// ticket.text('Special 1: àÀ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //А
|
|
||||||
// ticket.text('Special 1: á'.toUpperCase(), styles: PosStyles(codeTable: PosCodeTable.westEur));// Б
|
|
||||||
// ticket.text('Special 1: â', styles: PosStyles(codeTable: PosCodeTable.westEur)); //В
|
|
||||||
// ticket.text('Special 1: ã', styles: PosStyles(codeTable: PosCodeTable.westEur));// Г
|
|
||||||
// ticket.text('Special 1: äÄ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Д
|
|
||||||
// ticket.text('Special 1: å', styles: PosStyles(codeTable: PosCodeTable.westEur));// Е
|
|
||||||
// ticket.text('Special 1: æÆ', styles: PosStyles(codeTable: PosCodeTable.westEur));// Ж
|
|
||||||
// ticket.text('Special 1: ç', styles: PosStyles(codeTable: PosCodeTable.westEur));//З
|
|
||||||
// ticket.text('Special 1: èÈ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // И
|
|
||||||
// ticket.text('Special 1: éÉ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Й
|
|
||||||
// ticket.text('Special 1: ê', styles: PosStyles(codeTable: PosCodeTable.westEur));//К
|
|
||||||
// ticket.text('Special 1: ëË', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Л
|
|
||||||
// ticket.text('Special 1: ìÌ', styles: PosStyles(codeTable: PosCodeTable.westEur));// M
|
|
||||||
// ticket.text('Special 1: íÍ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Н
|
|
||||||
// ticket.text('Special 1: î', styles: PosStyles(codeTable: PosCodeTable.westEur));// О
|
|
||||||
// ticket.text('Special 1: ï', styles: PosStyles(codeTable: PosCodeTable.westEur)); // П
|
|
||||||
// ticket.text('Special 1: ð', styles: PosStyles(codeTable: PosCodeTable.westEur));// Р
|
|
||||||
// ticket.text('Special 1: ñ', styles: PosStyles(codeTable: PosCodeTable.westEur));// С
|
|
||||||
// ticket.text('Special 1: ò', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Т
|
|
||||||
// ticket.text('Special 1: óÓ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //У
|
|
||||||
// ticket.text('Special 1: ô', styles: PosStyles(codeTable: PosCodeTable.westEur));// Ф
|
|
||||||
// ticket.text('Special 1: õÕ', styles: PosStyles(codeTable: PosCodeTable.westEur));// Х
|
|
||||||
// ticket.text('Special 1: ö', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ц
|
|
||||||
// ticket.text('Special 1: ÷', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ч
|
|
||||||
// ticket.text('Special 1: ø', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ш
|
|
||||||
// ticket.text('Special 1: ù', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Щ
|
|
||||||
// ticket.text('Special 1: ú', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ъ
|
|
||||||
// ticket.text('Special 1: û', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ы
|
|
||||||
// ticket.text('Special 1: üÜ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ь
|
|
||||||
// ticket.text('Special 1: ý', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Э
|
|
||||||
// ticket.text('Special 1: þ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // ю
|
|
||||||
// ticket.text('Special 1: ÿß', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Я
|
|
||||||
|
|
||||||
// Uint8List encTxt11 = await CharsetConverter.encode("cp866", "Russian: Привет Мир!");
|
|
||||||
// //ticket.textEncoded(encTxt11, styles: PosStyles(codeTable: PosCodeTable.pc866_2));
|
|
||||||
// ticket.textEncoded(encTxt11);
|
|
||||||
|
|
||||||
ticket.text(
|
|
||||||
'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
|
'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
|
||||||
//ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ', styles: PosStyles(codeTable: PosCodeTable.westEur));
|
//ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ', styles: PosStyles(codeTable: PosCodeTable.westEur));
|
||||||
//ticket.text('Special 2: blåbærgrød', styles: PosStyles(codeTable: PosCodeTable.westEur));
|
//ticket.text('Special 2: blåbærgrød', styles: PosStyles(codeTable: PosCodeTable.westEur));
|
||||||
|
|
||||||
ticket.text('Bold text', styles: PosStyles(bold: true));
|
bytes += ticket.text('Bold text', styles: PosStyles(bold: true));
|
||||||
ticket.text('Reverse text', styles: PosStyles(reverse: true));
|
bytes += ticket.text('Reverse text', styles: PosStyles(reverse: true));
|
||||||
ticket.text('Underlined text',
|
bytes += ticket.text('Underlined text',
|
||||||
styles: PosStyles(underline: true), linesAfter: 1);
|
styles: PosStyles(underline: true), linesAfter: 1);
|
||||||
ticket.text('Align left', styles: PosStyles(align: PosAlign.left));
|
bytes += ticket.text('Align left', styles: PosStyles(align: PosAlign.left));
|
||||||
ticket.text('Align center', styles: PosStyles(align: PosAlign.center));
|
bytes += ticket.text('Align center', styles: PosStyles(align: PosAlign.center));
|
||||||
ticket.text('Align right',
|
bytes += ticket.text('Align right',
|
||||||
styles: PosStyles(align: PosAlign.right), linesAfter: 1);
|
styles: PosStyles(align: PosAlign.right), linesAfter: 1);
|
||||||
|
|
||||||
ticket.row([
|
bytes += ticket.row([
|
||||||
PosColumn(
|
PosColumn(
|
||||||
text: 'col3',
|
text: 'col3',
|
||||||
width: 3,
|
width: 3,
|
||||||
|
|
@ -86,7 +47,7 @@ Future<Ticket> testTicket(PaperSize paper) async {
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ticket.text('Text size 200%',
|
bytes += ticket.text('Text size 200%',
|
||||||
styles: PosStyles(
|
styles: PosStyles(
|
||||||
height: PosTextSize.size2,
|
height: PosTextSize.size2,
|
||||||
width: PosTextSize.size2,
|
width: PosTextSize.size2,
|
||||||
|
|
@ -101,66 +62,69 @@ Future<Ticket> testTicket(PaperSize paper) async {
|
||||||
|
|
||||||
// Print barcode
|
// Print barcode
|
||||||
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
|
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
|
||||||
ticket.barcode(Barcode.upcA(barData));
|
bytes += ticket.barcode(Barcode.upcA(barData));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ticket.feed(2);
|
bytes += ticket.feed(2);
|
||||||
|
|
||||||
ticket.cut();
|
bytes += ticket.cut();
|
||||||
return ticket;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Ticket> testTicketImage(PaperSize paper) async {
|
Future<List<int>> testTicketImage(PaperSize paper) async {
|
||||||
final Ticket ticket = Ticket(paper);
|
final profile = await CapabilityProfile.load();
|
||||||
|
final ticket = Generator(paper, profile);
|
||||||
|
List<int> bytesResult = [];
|
||||||
|
|
||||||
// Print image
|
// Print image
|
||||||
final ByteData byteData = await rootBundle.load('assets/images/check.png');
|
final ByteData byteData = await rootBundle.load('assets/images/check.png');
|
||||||
final Uint8List bytes = byteData.buffer.asUint8List();
|
final Uint8List bytes = byteData.buffer.asUint8List();
|
||||||
final Im.Image image = Im.decodeImage(bytes);
|
final Im.Image? image = Im.decodeImage(bytes);
|
||||||
// Using `ESC *`
|
// Using `ESC *`
|
||||||
//ticket.image(imagea);
|
//ticket.image(imagea);
|
||||||
// Using `GS v 0` (obsolete)
|
// Using `GS v 0` (obsolete)
|
||||||
//ticket.imageRaster(imagea);
|
//ticket.imageRaster(imagea);
|
||||||
// Using `GS ( L`
|
// Using `GS ( L`
|
||||||
ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster);
|
if(image !=null) {
|
||||||
|
bytesResult += ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster);
|
||||||
|
}
|
||||||
//ticket.image(imagea);
|
//ticket.image(imagea);
|
||||||
|
|
||||||
|
|
||||||
ticket.feed(2);
|
bytesResult += ticket.feed(2);
|
||||||
|
|
||||||
ticket.cut();
|
bytesResult += ticket.cut();
|
||||||
return ticket;
|
return bytesResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Ticket> printImageCheck(PaperSize paper, String base64Src) async {
|
Future<List<int>> printImageCheck(PaperSize paper, String base64Src) async {
|
||||||
final Ticket ticket = Ticket(paper);
|
final profile = await CapabilityProfile.load();
|
||||||
|
final ticket = Generator(paper, profile);
|
||||||
|
List<int> bytesResult = [];
|
||||||
final Uint8List bytes = base64Decode(base64Src);
|
final Uint8List bytes = base64Decode(base64Src);
|
||||||
final Im.Image image = Im.decodeImage(bytes);
|
final Im.Image? image = Im.decodeImage(bytes);
|
||||||
ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster);
|
if(image != null) {
|
||||||
//ticket.image(image);
|
bytesResult += ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster);
|
||||||
ticket.feed(2);
|
}
|
||||||
ticket.cut();
|
bytesResult += ticket.feed(2);
|
||||||
return ticket;
|
bytesResult += ticket.cut();
|
||||||
|
return bytesResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async {
|
Future<List<int>> printTextCheck(PaperSize paper, String encoding, var data ) async {
|
||||||
final Ticket ticket = Ticket(paper);
|
final profile = await CapabilityProfile.load();
|
||||||
ticket.emptyLines(1);
|
final ticket = Generator(paper, profile);
|
||||||
|
List<int> bytesResult = [];
|
||||||
|
String codeTable = 'CP866';
|
||||||
PosCodeTable codeTable;
|
|
||||||
if(encoding == SettingPrinterEncodingCp866) {
|
if(encoding == SettingPrinterEncodingCp866) {
|
||||||
codeTable = PosCodeTable.pc866_2;
|
codeTable = 'CP866';
|
||||||
} else if(encoding == SettingPrinterEncodingWin1251) {
|
} else if(encoding == SettingPrinterEncodingWin1251) {
|
||||||
codeTable = PosCodeTable.wpc1251;
|
codeTable = 'CP1251';
|
||||||
}
|
}
|
||||||
|
ticket.setGlobalCodeTable(codeTable);
|
||||||
//ticket.setGlobalCodeTable(codeTable);
|
bytesResult += ticket.emptyLines(1);
|
||||||
ticket.setGlobalFont(PosFontType.fontB);
|
|
||||||
|
|
||||||
|
|
||||||
String qr = data['qr'];
|
String qr = data['qr'];
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -172,7 +136,7 @@ Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async
|
||||||
if(text is List) {
|
if(text is List) {
|
||||||
Uint8List firstCol = await CharsetConverter.encode(encoding, (text).first as String);
|
Uint8List firstCol = await CharsetConverter.encode(encoding, (text).first as String);
|
||||||
Uint8List lastCol = await CharsetConverter.encode(encoding, (text).last as String);
|
Uint8List lastCol = await CharsetConverter.encode(encoding, (text).last as String);
|
||||||
ticket.row([
|
bytesResult += ticket.row([
|
||||||
PosColumn(
|
PosColumn(
|
||||||
textEncoded: firstCol,
|
textEncoded: firstCol,
|
||||||
width: 6,
|
width: 6,
|
||||||
|
|
@ -187,16 +151,16 @@ Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async
|
||||||
} else {
|
} else {
|
||||||
String line = text as String;
|
String line = text as String;
|
||||||
if(line == 'breakline') {
|
if(line == 'breakline') {
|
||||||
ticket.hr();
|
bytesResult += ticket.hr();
|
||||||
} else if(line == 'br') {
|
} else if(line == 'br') {
|
||||||
ticket.emptyLines(1);
|
bytesResult += ticket.emptyLines(1);
|
||||||
} else if(line.trim() == '') {
|
} else if(line.trim() == '') {
|
||||||
ticket.emptyLines(1);
|
bytesResult += ticket.emptyLines(1);
|
||||||
} else {
|
} else {
|
||||||
line = line.replaceAll("«", '\"');
|
line = line.replaceAll("«", '\"');
|
||||||
line = line.replaceAll("»", '\"');
|
line = line.replaceAll("»", '\"');
|
||||||
Uint8List encTxt11 = await CharsetConverter.encode(encoding, line);
|
Uint8List encTxt11 = await CharsetConverter.encode(encoding, line);
|
||||||
ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left, codeTable: codeTable ));
|
bytesResult += ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left, codeTable: codeTable ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +169,7 @@ Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async
|
||||||
//final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
|
//final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
|
||||||
//ticket.barcode(Barcode.upcA(barData));
|
//ticket.barcode(Barcode.upcA(barData));
|
||||||
//ticket.qrcode(qr, align: PosAlign.center);
|
//ticket.qrcode(qr, align: PosAlign.center);
|
||||||
ticket.emptyLines(1);
|
bytesResult += ticket.emptyLines(1);
|
||||||
const double qrSize = 200;
|
const double qrSize = 200;
|
||||||
try {
|
try {
|
||||||
final uiImg = await QrPainter(
|
final uiImg = await QrPainter(
|
||||||
|
|
@ -217,8 +181,12 @@ Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async
|
||||||
//final pathName = '${dir.path}/qr_tmp.png';
|
//final pathName = '${dir.path}/qr_tmp.png';
|
||||||
//final qrFile = File(pathName);
|
//final qrFile = File(pathName);
|
||||||
//final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
|
//final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
|
||||||
final img = Im.decodePng(uiImg.buffer.asUint8List());
|
if(uiImg !=null) {
|
||||||
ticket.image(img);
|
final Im.Image? img = Im.decodePng(uiImg.buffer.asUint8List());
|
||||||
|
if(img !=null) {
|
||||||
|
bytesResult += ticket.image(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//ticket.qrcode(qr, size: QRSize.Size1 );
|
//ticket.qrcode(qr, size: QRSize.Size1 );
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -226,9 +194,9 @@ Future<Ticket> printTextCheck(PaperSize paper, String encoding, var data ) async
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ticket.emptyLines(1);
|
bytesResult += ticket.emptyLines(1);
|
||||||
ticket.feed(1);
|
bytesResult += ticket.feed(1);
|
||||||
|
|
||||||
ticket.cut();
|
bytesResult += ticket.cut();
|
||||||
return ticket;
|
return bytesResult;
|
||||||
}
|
}
|
||||||
|
|
@ -1,28 +1,19 @@
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
|
||||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
|
||||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart' hide Image;
|
import 'package:flutter/material.dart' hide Image;
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../data/settings_envi.dart';
|
import '../data/settings_envi.dart';
|
||||||
|
|
||||||
|
|
||||||
class PrinterEncodingView extends StatefulWidget {
|
class PrinterEncodingView extends StatefulWidget {
|
||||||
PrinterEncodingView({Key key, this.title}) : super(key: key);
|
PrinterEncodingView({Key? key, this.title}) : super(key: key);
|
||||||
final String title;
|
final String? title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PrinterEncodingViewState createState() => _PrinterEncodingViewState();
|
_PrinterEncodingViewState createState() => _PrinterEncodingViewState();
|
||||||
|
|
@ -44,7 +35,7 @@ class _PrinterEncodingViewState extends State<PrinterEncodingView> {
|
||||||
|
|
||||||
void _selectPrinter(String encoding, BuildContext context, ) async {
|
void _selectPrinter(String encoding, BuildContext context, ) async {
|
||||||
_logger.i(encoding);
|
_logger.i(encoding);
|
||||||
await Redux.store.dispatch(selectPrinterEncodingFromSetting(encoding));
|
await Redux.store!.dispatch(selectPrinterEncodingFromSetting(encoding));
|
||||||
Navigator.of(context).pop(false);
|
Navigator.of(context).pop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +67,7 @@ class _PrinterEncodingViewState extends State<PrinterEncodingView> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(encoding.values.elementAt(index) ?? ''),
|
Text(encoding.values.elementAt(index)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,19 @@
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
|
||||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
|
||||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart' hide Image;
|
import 'package:flutter/material.dart' hide Image;
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../data/settings_envi.dart';
|
import '../data/settings_envi.dart';
|
||||||
|
|
||||||
|
|
||||||
class PrinterPaperView extends StatefulWidget {
|
class PrinterPaperView extends StatefulWidget {
|
||||||
PrinterPaperView({Key key, this.title}) : super(key: key);
|
PrinterPaperView({Key? key, this.title}) : super(key: key);
|
||||||
final String title;
|
final String? title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PrinterEncodingViewState createState() => _PrinterEncodingViewState();
|
_PrinterEncodingViewState createState() => _PrinterEncodingViewState();
|
||||||
|
|
@ -44,7 +35,7 @@ class _PrinterEncodingViewState extends State<PrinterPaperView> {
|
||||||
|
|
||||||
void _selectPaper(String paperSize, BuildContext context, ) async {
|
void _selectPaper(String paperSize, BuildContext context, ) async {
|
||||||
_logger.i(encoding);
|
_logger.i(encoding);
|
||||||
await Redux.store.dispatch(selectPrinterPaperSizeFromSetting(paperSize));
|
await Redux.store!.dispatch(selectPrinterPaperSizeFromSetting(paperSize));
|
||||||
Navigator.of(context).pop(false);
|
Navigator.of(context).pop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +67,7 @@ class _PrinterEncodingViewState extends State<PrinterPaperView> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(paperSize.values.elementAt(index) ?? ''),
|
Text(paperSize.values.elementAt(index)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,19 @@
|
||||||
import 'dart:async';
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
import 'package:bluetooth_print/bluetooth_print_model.dart';
|
||||||
|
|
||||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
|
||||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart' hide Image;
|
import 'package:flutter/material.dart' hide Image;
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../PrinterTest.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class PrinterSelectView extends StatefulWidget {
|
class PrinterSelectView extends StatefulWidget {
|
||||||
PrinterSelectView({Key key, this.title}) : super(key: key);
|
PrinterSelectView({Key? key, this.title}) : super(key: key);
|
||||||
final String title;
|
final String? title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PrinterSelectViewState createState() => _PrinterSelectViewState();
|
_PrinterSelectViewState createState() => _PrinterSelectViewState();
|
||||||
|
|
@ -30,16 +21,14 @@ class PrinterSelectView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PrinterSelectViewState extends State<PrinterSelectView> {
|
class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||||
PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
BluePrintService printerManager = locator<BluePrintService>();
|
||||||
List<PrinterBluetooth> _devices = [];
|
List<BluetoothDevice> _devices = [];
|
||||||
Logger _logger = getLogger('PrinterSelectView');
|
Logger _logger = getLogger('PrinterSelectView');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
printerManager.scanResult.listen((devices) async {
|
||||||
printerManager.scanResults.listen((devices) async {
|
|
||||||
// print('UI: Devices found ${devices.length}');
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_devices = devices;
|
_devices = devices;
|
||||||
});
|
});
|
||||||
|
|
@ -51,172 +40,15 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_devices = [];
|
_devices = [];
|
||||||
});
|
});
|
||||||
printerManager.startScan(Duration(seconds: 4));
|
printerManager.scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _stopScanDevices() {
|
void _stopScanDevices() {
|
||||||
printerManager.stopScan();
|
printerManager.stopScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Ticket> demoReceipt(PaperSize paper) async {
|
void _selectPrinter(BluetoothDevice printer, BuildContext context, ) async {
|
||||||
final Ticket ticket = Ticket(paper, );
|
printerManager.device = printer;
|
||||||
|
|
||||||
// Print image
|
|
||||||
// final ByteData data = await rootBundle.load('assets/images/aman_kassa_check.png');
|
|
||||||
// final Uint8List bytes = data.buffer.asUint8List();
|
|
||||||
// final Im.Image image = Im.decodeImage(bytes);
|
|
||||||
// Im.Image thumbnail = Im.copyResize(image, width: 270);
|
|
||||||
// ticket.image(thumbnail, align: PosAlign.center);
|
|
||||||
|
|
||||||
//ticket.imageRaster(image, align: PosAlign.center);
|
|
||||||
|
|
||||||
ticket.text('AMAN-SATU',
|
|
||||||
styles: PosStyles(
|
|
||||||
align: PosAlign.center,
|
|
||||||
height: PosTextSize.size2,
|
|
||||||
width: PosTextSize.size2,
|
|
||||||
),
|
|
||||||
linesAfter: 1);
|
|
||||||
|
|
||||||
ticket.text('889 Watson Lane', styles: PosStyles(align: PosAlign.center));
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, codeTable: PosCodeTable.westEur), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, fontType: PosFontType.fontA), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, fontType: PosFontType.fontB), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, height: PosTextSize.size1), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size2), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size3), containsChinese: true);
|
|
||||||
ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size4), containsChinese: true);
|
|
||||||
ticket.text('Tel: 830-221-1234', styles: PosStyles(align: PosAlign.center));
|
|
||||||
ticket.text('Web: www.example.com',
|
|
||||||
styles: PosStyles(align: PosAlign.center), linesAfter: 1);
|
|
||||||
|
|
||||||
ticket.hr();
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(text: 'Qty', width: 1),
|
|
||||||
PosColumn(text: 'Item', width: 7),
|
|
||||||
PosColumn(
|
|
||||||
text: 'Price', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
PosColumn(
|
|
||||||
text: 'Total', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(text: '2', width: 1),
|
|
||||||
PosColumn(text: 'ONION RINGS', width: 7),
|
|
||||||
PosColumn(
|
|
||||||
text: '0.99', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
PosColumn(
|
|
||||||
text: '1.98', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
]);
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(text: '1', width: 1),
|
|
||||||
PosColumn(text: 'PIZZA', width: 7),
|
|
||||||
PosColumn(
|
|
||||||
text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
PosColumn(
|
|
||||||
text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
]);
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(text: '1', width: 1),
|
|
||||||
PosColumn(text: 'SPRING ROLLS', width: 7),
|
|
||||||
PosColumn(
|
|
||||||
text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
PosColumn(
|
|
||||||
text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
]);
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(text: '3', width: 1),
|
|
||||||
PosColumn(text: 'CRUNCHY STICKS', width: 7),
|
|
||||||
PosColumn(
|
|
||||||
text: '0.85', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
PosColumn(
|
|
||||||
text: '2.55', width: 2, styles: PosStyles(align: PosAlign.right)),
|
|
||||||
]);
|
|
||||||
ticket.hr();
|
|
||||||
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'TOTAL',
|
|
||||||
width: 6,
|
|
||||||
styles: PosStyles(
|
|
||||||
height: PosTextSize.size2,
|
|
||||||
width: PosTextSize.size2,
|
|
||||||
)),
|
|
||||||
PosColumn(
|
|
||||||
text: '\$10.97',
|
|
||||||
width: 6,
|
|
||||||
styles: PosStyles(
|
|
||||||
align: PosAlign.right,
|
|
||||||
height: PosTextSize.size2,
|
|
||||||
width: PosTextSize.size2,
|
|
||||||
)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
ticket.hr(ch: '=', linesAfter: 1);
|
|
||||||
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Cash',
|
|
||||||
width: 7,
|
|
||||||
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
|
|
||||||
PosColumn(
|
|
||||||
text: '\$15.00',
|
|
||||||
width: 5,
|
|
||||||
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
|
|
||||||
]);
|
|
||||||
ticket.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Change',
|
|
||||||
width: 7,
|
|
||||||
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
|
|
||||||
PosColumn(
|
|
||||||
text: '\$4.03',
|
|
||||||
width: 5,
|
|
||||||
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
ticket.feed(2);
|
|
||||||
ticket.text('Thank you!',
|
|
||||||
styles: PosStyles(align: PosAlign.center, bold: true));
|
|
||||||
|
|
||||||
final now = DateTime.now();
|
|
||||||
final formatter = DateFormat('MM/dd/yyyy H:m');
|
|
||||||
final String timestamp = formatter.format(now);
|
|
||||||
ticket.text(timestamp,
|
|
||||||
styles: PosStyles(align: PosAlign.center), linesAfter: 2);
|
|
||||||
|
|
||||||
// Print QR Code from image
|
|
||||||
// try {
|
|
||||||
// const String qrData = 'example.com';
|
|
||||||
// const double qrSize = 200;
|
|
||||||
// final uiImg = await QrPainter(
|
|
||||||
// data: qrData,
|
|
||||||
// version: QrVersions.auto,
|
|
||||||
// gapless: false,
|
|
||||||
// ).toImageData(qrSize);
|
|
||||||
// final dir = await getTemporaryDirectory();
|
|
||||||
// final pathName = '${dir.path}/qr_tmp.png';
|
|
||||||
// final qrFile = File(pathName);
|
|
||||||
// final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
|
|
||||||
// final img = decodeImage(imgFile.readAsBytesSync());
|
|
||||||
|
|
||||||
// ticket.image(img);
|
|
||||||
// } catch (e) {
|
|
||||||
// print(e);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Print QR Code using native function
|
|
||||||
// ticket.qrcode('example.com');
|
|
||||||
|
|
||||||
ticket.feed(2);
|
|
||||||
ticket.cut();
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _selectPrinter(PrinterBluetooth printer, BuildContext context, ) async {
|
|
||||||
printerManager.selectPrinter(printer);
|
|
||||||
_logger.i(printer.name);
|
_logger.i(printer.name);
|
||||||
_logger.i(printer.address);
|
_logger.i(printer.address);
|
||||||
|
|
||||||
|
|
@ -225,33 +57,9 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||||
..name=printer.name
|
..name=printer.name
|
||||||
..type=printer.type;
|
..type=printer.type;
|
||||||
|
|
||||||
await Redux.store.dispatch(selectPrinterFromSetting(device));
|
await Redux.store!.dispatch(selectPrinterFromSetting(device));
|
||||||
Navigator.of(context).pop(false);
|
Navigator.of(context).pop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _testPrint(PrinterBluetooth printer) async {
|
|
||||||
printerManager.selectPrinter(printer);
|
|
||||||
|
|
||||||
// TODO Don't forget to choose printer's paper
|
|
||||||
const PaperSize paper = PaperSize.mm58;
|
|
||||||
|
|
||||||
// TEST PRINT
|
|
||||||
// final PosPrintResult res =
|
|
||||||
// await printerManager.printTicket(await testTicket(paper), queueSleepTimeMs: 50);
|
|
||||||
|
|
||||||
final PosPrintResult res =
|
|
||||||
await printerManager.printTicket(
|
|
||||||
await testTicketImage(paper),
|
|
||||||
chunkSizeBytes: 1024,
|
|
||||||
queueSleepTimeMs: 50
|
|
||||||
);
|
|
||||||
|
|
||||||
// DEMO RECEIPT
|
|
||||||
// final PosPrintResult res =
|
|
||||||
// await printerManager.printTicket(await demoReceipt(paper) , queueSleepTimeMs: 50);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
final key = GlobalKey();
|
final key = GlobalKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -283,7 +91,7 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(_devices[index].name ?? ''),
|
Text(_devices[index].name ?? ''),
|
||||||
Text(_devices[index].address),
|
Text(_devices[index].address ?? ''),
|
||||||
Text(
|
Text(
|
||||||
'Click to print a test receipt',
|
'Click to print a test receipt',
|
||||||
style: TextStyle(color: Colors.grey[700]),
|
style: TextStyle(color: Colors.grey[700]),
|
||||||
|
|
@ -300,10 +108,10 @@ class _PrinterSelectViewState extends State<PrinterSelectView> {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
floatingActionButton: StreamBuilder<bool>(
|
floatingActionButton: StreamBuilder<bool>(
|
||||||
stream: printerManager.isScanningStream,
|
stream: printerManager.isScanning,
|
||||||
initialData: false,
|
initialData: false,
|
||||||
builder: (c, snapshot) {
|
builder: (c, snapshot) {
|
||||||
if (snapshot.data) {
|
if (snapshot.data != null) {
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
child: Icon(Icons.stop),
|
child: Icon(Icons.stop),
|
||||||
onPressed: _stopScanDevices,
|
onPressed: _stopScanDevices,
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/models/dialog_models.dart';
|
import 'package:aman_kassa_flutter/core/models/dialog_models.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
||||||
import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/logger.dart';
|
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
import 'package:aman_kassa_flutter/core/route_names.dart';
|
||||||
|
|
@ -12,9 +12,6 @@ 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/constants/setting_const.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/aman_icon_button_horizontal.dart';
|
|
||||||
import 'package:esc_pos_bluetooth/esc_pos_bluetooth.dart';
|
|
||||||
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
@ -34,8 +31,7 @@ class SettingPrinterView extends StatefulWidget {
|
||||||
class _SettingPrinterViewState extends State<SettingPrinterView> {
|
class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
NavigatorService _navigatorService = locator<NavigatorService>();
|
NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
final PrinterBluetoothManager printerManager = PrinterBluetoothManager();
|
final BluePrintService printerManager = locator<BluePrintService>();
|
||||||
final BluetoothManager bluetoothManager = BluetoothManager.instance;
|
|
||||||
final Logger log = getLogger('SettingPrinterView');
|
final Logger log = getLogger('SettingPrinterView');
|
||||||
|
|
||||||
bool _printing = false;
|
bool _printing = false;
|
||||||
|
|
@ -44,17 +40,30 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_permission();
|
_permission();
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
disconnect();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect() async {
|
||||||
|
await printerManager.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
void _testPrint() async {
|
void _testPrint() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_printing = true;
|
_printing = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
final SettingState state = Redux.store.state.settingState;
|
final SettingState state = Redux.store!.state.settingState!;
|
||||||
printerManager.selectPrinter(PrinterBluetooth(state.printerBT));
|
printerManager.device = state.printerBT!;
|
||||||
|
|
||||||
|
await disconnect();
|
||||||
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
|
||||||
|
await printerManager.connect();
|
||||||
|
await Future.delayed(Duration(seconds: 3));
|
||||||
bool isIos = Platform.isIOS;
|
bool isIos = Platform.isIOS;
|
||||||
int chunkSizeBytes = 3096;
|
int chunkSizeBytes = 3096;
|
||||||
int queueSleepTimeMs = 100;
|
int queueSleepTimeMs = 100;
|
||||||
|
|
@ -68,34 +77,33 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
log.i(queueSleepTimeMs);
|
log.i(queueSleepTimeMs);
|
||||||
|
|
||||||
// TODO Don't forget to choose printer's paper
|
// TODO Don't forget to choose printer's paper
|
||||||
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80 ? PaperSize.mm80 : PaperSize.mm58;
|
PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80
|
||||||
|
? PaperSize.mm80
|
||||||
|
: PaperSize.mm58;
|
||||||
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
if (SettingPrinterEncodingImage == state.printerEncoding) {
|
||||||
final PosPrintResult res = await printerManager.printTicket(
|
final bool res = await printerManager.printBytes(
|
||||||
await testTicketImage(paper),
|
Uint8List.fromList(await testTicketImage(paper)),
|
||||||
chunkSizeBytes: chunkSizeBytes,
|
chunkSizeBytes: chunkSizeBytes,
|
||||||
queueSleepTimeMs: queueSleepTimeMs
|
queueSleepTimeMs: queueSleepTimeMs);
|
||||||
);
|
//_dialogService.showDialog(description: 'result is $res');
|
||||||
_dialogService.showDialog(description: res.msg);
|
|
||||||
} else {
|
} else {
|
||||||
final PosPrintResult res = await printerManager.printTicket(
|
final bool res = await printerManager.printBytes(
|
||||||
await printTextCheck(paper, state.printerEncoding, exampleJson['check_text']),
|
Uint8List.fromList(await printTextCheck(
|
||||||
|
paper, state.printerEncoding!, exampleJson['check_text'])),
|
||||||
chunkSizeBytes: chunkSizeBytes,
|
chunkSizeBytes: chunkSizeBytes,
|
||||||
queueSleepTimeMs: queueSleepTimeMs
|
queueSleepTimeMs: queueSleepTimeMs);
|
||||||
);
|
//_dialogService.showDialog(description: 'result is $res');
|
||||||
_dialogService.showDialog(description: res.msg);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('ERROR');
|
print('ERROR');
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
|
//10 sec safe disconnect
|
||||||
//7 sec safe disconnect
|
await Future.delayed(Duration(seconds: 14));
|
||||||
await Future.delayed(Duration(seconds: 7));
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_printing = false;
|
_printing = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -107,28 +115,32 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: StoreConnector<AppState, SettingState>(
|
child: StoreConnector<AppState, SettingState>(
|
||||||
converter: (store) => store.state.settingState,
|
converter: (store) => store.state.settingState!,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SettingItem(
|
SettingItem(
|
||||||
title: 'Принтер',
|
title: 'Принтер',
|
||||||
name: vm.printerBT?.name,
|
name: vm.printerBT?.name ?? '',
|
||||||
value: vm.printerBT != null
|
value: vm.printerBT != null
|
||||||
? 'BT: ${vm.printerBT.address} '
|
? 'BT: ${vm.printerBT?.address ?? ''} '
|
||||||
: 'не выбран',
|
: 'не выбран',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_navigatorService.push(SettingsPrinterBTRoute);
|
_navigatorService.push(SettingsPrinterBTRoute);
|
||||||
}),
|
}),
|
||||||
SettingItem(
|
SettingItem(
|
||||||
title: 'Кодировка',
|
title: 'Кодировка',
|
||||||
name: vm.printerEncoding != null ? encoding[vm.printerEncoding] : null ,
|
name: vm.printerEncoding != null
|
||||||
|
? encoding[vm.printerEncoding]
|
||||||
|
: '',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_navigatorService.push(SettingsPrinterEncodingRoute);
|
_navigatorService.push(SettingsPrinterEncodingRoute);
|
||||||
}),
|
}),
|
||||||
SettingItem(
|
SettingItem(
|
||||||
title: 'Ширина ленты',
|
title: 'Ширина ленты',
|
||||||
name: vm.printerPaperSize != null ? paperSize[vm.printerPaperSize] : null ,
|
name: vm.printerPaperSize != null
|
||||||
|
? paperSize[vm.printerPaperSize]
|
||||||
|
: null,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_navigatorService.push(SettingsPrinterPaperRoute);
|
_navigatorService.push(SettingsPrinterPaperRoute);
|
||||||
}),
|
}),
|
||||||
|
|
@ -144,9 +156,7 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
busy: _printing,
|
busy: _printing,
|
||||||
enabled: vm.printerBT != null,
|
enabled: vm.printerBT != null,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
||||||
_startInitialPrint();
|
_startInitialPrint();
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -163,24 +173,24 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
//Метод для получения постоянного доступа к местополения
|
//Метод для получения постоянного доступа к местополения
|
||||||
//только для Android
|
//только для Android
|
||||||
void _permission() async {
|
void _permission() async {
|
||||||
if( Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
var status = await Permission.location.status;
|
var status = await Permission.location.status;
|
||||||
log.i(status);
|
log.i(status);
|
||||||
if (status.isUndetermined || status.isDenied || status.isPermanentlyDenied) {
|
if (status.isDenied || status.isPermanentlyDenied) {
|
||||||
DialogResponse response = await _dialogService.showConfirmationDialog(
|
DialogResponse response = await _dialogService.showConfirmationDialog(
|
||||||
title: 'Доступ',
|
title: 'Доступ',
|
||||||
description: 'Для поиска устройств Bluetooth необходимо предоставить доступ к отслеживанию геолокации.',
|
description:
|
||||||
|
'Для поиска устройств Bluetooth необходимо предоставить доступ к отслеживанию геолокации.',
|
||||||
cancelTitle: 'Нет',
|
cancelTitle: 'Нет',
|
||||||
confirmationTitle: 'Хорошо',
|
confirmationTitle: 'Хорошо',
|
||||||
);
|
);
|
||||||
if (response.confirmed) {
|
if (response.confirmed) {
|
||||||
if (await Permission.location
|
if (await Permission.location.request().isGranted) {
|
||||||
.request()
|
|
||||||
.isGranted) {
|
|
||||||
print('Granted');
|
print('Granted');
|
||||||
} else {
|
} else {
|
||||||
_dialogService.showDialog(
|
_dialogService.showDialog(
|
||||||
description: 'Необходимо указать постоянный доступ к местоположении для поиска принтера');
|
description:
|
||||||
|
'Необходимо указать постоянный доступ к местоположении для поиска принтера');
|
||||||
_navigatorService.pop();
|
_navigatorService.pop();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -192,22 +202,20 @@ class _SettingPrinterViewState extends State<SettingPrinterView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startInitialPrint() async {
|
void _startInitialPrint() async {
|
||||||
|
|
||||||
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
await _testPrint();
|
_testPrint();
|
||||||
} else {
|
} else {
|
||||||
bluetoothManager.state.listen((val) {
|
printerManager.state.listen((val) {
|
||||||
print("state = $val");
|
print("state = $val");
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (val == 12) {
|
if (val == 12) {
|
||||||
print('on');
|
print('on');
|
||||||
_testPrint();
|
_testPrint();
|
||||||
|
|
||||||
} else if (val == 10) {
|
} else if (val == 10) {
|
||||||
print('off');
|
print('off');
|
||||||
_dialogService.showDialog(
|
_dialogService.showDialog(
|
||||||
description: 'Отсутвует соеденение Bluetooth или он отключен' , title: 'Bluetooth');
|
description: 'Отсутвует соеденение Bluetooth или он отключен',
|
||||||
|
title: 'Bluetooth');
|
||||||
}
|
}
|
||||||
print('state is $val');
|
print('state is $val');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ class SettingView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SettingViewState extends State<SettingView> {
|
class _SettingViewState extends State<SettingView> {
|
||||||
TextEditingController _pinController;
|
late TextEditingController _pinController;
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
SettingState state = Redux.store.state.settingState;
|
SettingState state = Redux.store!.state.settingState!;
|
||||||
_pinController = new TextEditingController(text: state.pinCode);
|
_pinController = new TextEditingController(text: state.pinCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ class _SettingViewState extends State<SettingView> {
|
||||||
if(value.isNotEmpty && value.length !=4){
|
if(value.isNotEmpty && value.length !=4){
|
||||||
_dialogService.showDialog(description: 'Необходимо указать 4-х значный числовой код');
|
_dialogService.showDialog(description: 'Необходимо указать 4-х значный числовой код');
|
||||||
} else {
|
} else {
|
||||||
await Redux.store.dispatch(changePinCodeFromSetting(_pinController.text));
|
await Redux.store!.dispatch(changePinCodeFromSetting(_pinController.text));
|
||||||
_dialogService.showDialog(description: 'Данные успешно сохранены');
|
_dialogService.showDialog(description: 'Данные успешно сохранены');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class StartUpView extends StatefulWidget {
|
class StartUpView extends StatefulWidget {
|
||||||
|
|
@ -16,17 +15,14 @@ class _StartUpViewState extends State<StartUpView> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
Redux.store.dispatch(checkUserAction);
|
Redux.store!.dispatch(checkUserAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//print(MediaQuery.of(context).size.width);
|
|
||||||
//print(MediaQuery.of(context).size.height);
|
|
||||||
//ScreenUtil.init(context, width: 411.43, height: 683.43, allowFontScaling: false);
|
|
||||||
//ScreenUtil.init(, designSize: Size(360, 690));
|
|
||||||
return StoreConnector<AppState, UserState>(
|
return StoreConnector<AppState, UserState>(
|
||||||
converter: (store) => store.state.userState,
|
converter: (store) => store.state.userState!,
|
||||||
builder: (context, userState) {
|
builder: (context, userState) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class ProductListItem extends StatelessWidget {
|
||||||
final ProductDao item;
|
final ProductDao item;
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
ProductListItem({this.item, this.index});
|
ProductListItem({required this.item, required this.index});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -26,7 +26,7 @@ class ProductListItem extends StatelessWidget {
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 4),
|
vertical: 8, horizontal: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
item.name ?? 'name',
|
item.name,
|
||||||
style: productTextStyle,
|
style: productTextStyle,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
@ -35,7 +35,7 @@ class ProductListItem extends StatelessWidget {
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 4),
|
vertical: 8, horizontal: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${item.price?.toString()} x ${item.count?.toString()} = ${item.total?.toString()}',
|
'${item.price.toString()} x ${item.count.toString()} = ${item.total.toString()}',
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: productTextStyle)),
|
style: productTextStyle)),
|
||||||
)
|
)
|
||||||
|
|
@ -60,13 +60,13 @@ class ProductListItem extends StatelessWidget {
|
||||||
// }),
|
// }),
|
||||||
if(item.excise == null)
|
if(item.excise == null)
|
||||||
buildClipRect(primaryColor, Icons.remove, () {
|
buildClipRect(primaryColor, Icons.remove, () {
|
||||||
Redux.store
|
Redux.store!
|
||||||
.dispatch(
|
.dispatch(
|
||||||
counterProductFromKassaItems(index, -1));
|
counterProductFromKassaItems(index, -1));
|
||||||
}),
|
}),
|
||||||
if(item.excise == null)
|
if(item.excise == null)
|
||||||
buildClipRect(primaryColor, Icons.add, () {
|
buildClipRect(primaryColor, Icons.add, () {
|
||||||
Redux.store
|
Redux.store!
|
||||||
.dispatch(
|
.dispatch(
|
||||||
counterProductFromKassaItems(index, 1));
|
counterProductFromKassaItems(index, 1));
|
||||||
}),
|
}),
|
||||||
|
|
@ -75,7 +75,7 @@ class ProductListItem extends StatelessWidget {
|
||||||
child: Container(),
|
child: Container(),
|
||||||
),
|
),
|
||||||
buildClipRect(redColor, Icons.close, () {
|
buildClipRect(redColor, Icons.close, () {
|
||||||
Redux.store
|
Redux.store!
|
||||||
.dispatch(removeProductFromKassaItems(index));
|
.dispatch(removeProductFromKassaItems(index));
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
typedef void CalculatorButtonTapCallback({String buttonText});
|
typedef void CalculatorButtonTapCallback({required String buttonText});
|
||||||
|
|
||||||
List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE];
|
List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE];
|
||||||
List operationsRed = [Calculations.CLEAR];
|
List operationsRed = [Calculations.CLEAR];
|
||||||
|
|
||||||
class CalculatorButton extends StatelessWidget {
|
class CalculatorButton extends StatelessWidget {
|
||||||
CalculatorButton({this.text, @required this.onTap});
|
CalculatorButton({required this.text, required this.onTap});
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final CalculatorButtonTapCallback onTap;
|
final CalculatorButtonTapCallback onTap;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import 'calculator-button.dart';
|
||||||
import 'calculator-row.dart';
|
import 'calculator-row.dart';
|
||||||
|
|
||||||
class CalculatorButtons extends StatelessWidget {
|
class CalculatorButtons extends StatelessWidget {
|
||||||
CalculatorButtons({@required this.onTap});
|
CalculatorButtons({required this.onTap});
|
||||||
|
|
||||||
final CalculatorButtonTapCallback onTap;
|
final CalculatorButtonTapCallback onTap;
|
||||||
final calculatorButtonRows = [
|
final calculatorButtonRows = [
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'calculator-button.dart';
|
import 'calculator-button.dart';
|
||||||
|
|
||||||
class CalculatorRow extends StatelessWidget {
|
class CalculatorRow extends StatelessWidget {
|
||||||
CalculatorRow({@required this.buttons, @required this.onTap });
|
CalculatorRow({required this.buttons, required this.onTap });
|
||||||
|
|
||||||
final List<String> buttons;
|
final List<String> buttons;
|
||||||
final CalculatorButtonTapCallback onTap;
|
final CalculatorButtonTapCallback onTap;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Calculator {
|
||||||
var row = items[i];
|
var row = items[i];
|
||||||
if (row.operation == Calculations.MULTIPLY) {
|
if (row.operation == Calculations.MULTIPLY) {
|
||||||
str += "${row.num1} * ${row.num2}" ;
|
str += "${row.num1} * ${row.num2}" ;
|
||||||
summ += double.parse(row.num1) * double.parse(row.num2);
|
summ += double.parse(row.num1) * double.parse(row.num2!);
|
||||||
} else {
|
} else {
|
||||||
str += row.num1;
|
str += row.num1;
|
||||||
summ += double.parse(row.num1) ;
|
summ += double.parse(row.num1) ;
|
||||||
|
|
@ -85,7 +85,7 @@ class Calculator {
|
||||||
if (row.num2 == null) {
|
if (row.num2 == null) {
|
||||||
str += row.num1 + " * ";
|
str += row.num1 + " * ";
|
||||||
} else {
|
} else {
|
||||||
str += row.num1 + " * " + row.num2;
|
str += row.num1 + " * " + row.num2!;
|
||||||
}
|
}
|
||||||
} else if (row.operation == Calculations.NONE) {
|
} else if (row.operation == Calculations.NONE) {
|
||||||
str += row.num1;
|
str += row.num1;
|
||||||
|
|
@ -99,7 +99,7 @@ class Calculator {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> action({String value, List<CalcModel> items}) {
|
static List<CalcModel> action({required String value, required List<CalcModel> items}) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case Calculations.ADD:
|
case Calculations.ADD:
|
||||||
{
|
{
|
||||||
|
|
@ -142,7 +142,7 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setNumber({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setNumber({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isEmpty) {
|
if (items.isEmpty) {
|
||||||
items.add(CalcModel(num1: value, operation: Calculations.NONE));
|
items.add(CalcModel(num1: value, operation: Calculations.NONE));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -169,8 +169,9 @@ class Calculator {
|
||||||
} else if (last.operation == Calculations.MULTIPLY) {
|
} else if (last.operation == Calculations.MULTIPLY) {
|
||||||
if(last.num2 == null)
|
if(last.num2 == null)
|
||||||
last.num2 = value;
|
last.num2 = value;
|
||||||
else
|
else if(last.num2 !=null) {
|
||||||
last.num2 += value;
|
last.num2 = last.num2! + value;
|
||||||
|
}
|
||||||
last.operation = Calculations.MULTIPLY;
|
last.operation = Calculations.MULTIPLY;
|
||||||
items.add(last);
|
items.add(last);
|
||||||
} else if (last.operation == Calculations.ADD) {
|
} else if (last.operation == Calculations.ADD) {
|
||||||
|
|
@ -183,7 +184,7 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setPlus({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setPlus({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
CalcModel last = items.removeLast();
|
CalcModel last = items.removeLast();
|
||||||
if (last.closed) {
|
if (last.closed) {
|
||||||
|
|
@ -212,11 +213,11 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setDot({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setDot({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
CalcModel last = items.removeLast();
|
CalcModel last = items.removeLast();
|
||||||
if (last.operation == Calculations.NONE) {
|
if (last.operation == Calculations.NONE) {
|
||||||
if (last.num1?.contains('.') == false) {
|
if (last.num1.contains('.') == false) {
|
||||||
last.num1 += '.';
|
last.num1 += '.';
|
||||||
}
|
}
|
||||||
last.operation = Calculations.NONE;
|
last.operation = Calculations.NONE;
|
||||||
|
|
@ -226,10 +227,10 @@ class Calculator {
|
||||||
items.add(CalcModel(num1: '0.', operation: Calculations.NONE));
|
items.add(CalcModel(num1: '0.', operation: Calculations.NONE));
|
||||||
} else if (last.operation == Calculations.MULTIPLY) {
|
} else if (last.operation == Calculations.MULTIPLY) {
|
||||||
if (last.num2 == null) {
|
if (last.num2 == null) {
|
||||||
last.num2 += '0.';
|
last.num2 = last.num2! + '0.';
|
||||||
} else {
|
} else {
|
||||||
if (last.num2?.contains('.') == false) {
|
if (last.num2?.contains('.') == false) {
|
||||||
last.num2 += '.';
|
last.num2 = last.num2! + '.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last.operation = Calculations.MULTIPLY;
|
last.operation = Calculations.MULTIPLY;
|
||||||
|
|
@ -241,11 +242,11 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setClean({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setClean({required String value, required List<CalcModel> items}) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setEqual({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setEqual({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
CalcModel last = items.removeLast();
|
CalcModel last = items.removeLast();
|
||||||
last.operation = Calculations.EQUAL;
|
last.operation = Calculations.EQUAL;
|
||||||
|
|
@ -254,7 +255,7 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setMultiply({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setMultiply({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
CalcModel last = items.removeLast();
|
CalcModel last = items.removeLast();
|
||||||
if (last.closed) {
|
if (last.closed) {
|
||||||
|
|
@ -282,7 +283,7 @@ class Calculator {
|
||||||
return [...items];
|
return [...items];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CalcModel> _setBackward({String value, List<CalcModel> items}) {
|
static List<CalcModel> _setBackward({required String value, required List<CalcModel> items}) {
|
||||||
if (items.isNotEmpty) {
|
if (items.isNotEmpty) {
|
||||||
items.removeLast();
|
items.removeLast();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
|
||||||
class NumberDisplay extends StatelessWidget {
|
class NumberDisplay extends StatelessWidget {
|
||||||
NumberDisplay({this.value});
|
NumberDisplay({required this.value});
|
||||||
|
|
||||||
final String value;
|
final String value;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||||
|
|
||||||
class DialogManager extends StatefulWidget {
|
class DialogManager extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
|
|
||||||
DialogManager({Key key, this.child}) : super(key: key);
|
DialogManager({Key? key, this.child}) : super(key: key);
|
||||||
|
|
||||||
_DialogManagerState createState() => _DialogManagerState();
|
_DialogManagerState createState() => _DialogManagerState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DialogManagerState extends State<DialogManager> {
|
class _DialogManagerState extends State<DialogManager> {
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
TextEditingController _controller;
|
late TextEditingController _controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -33,7 +33,7 @@ class _DialogManagerState extends State<DialogManager> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return widget.child;
|
return widget.child ?? Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showDialog(DialogRequest request) {
|
void _showDialog(DialogRequest request) {
|
||||||
|
|
@ -59,7 +59,7 @@ class _DialogManagerState extends State<DialogManager> {
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
if (isConfirmationDialog)
|
if (isConfirmationDialog)
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(request.cancelTitle),
|
child: Text(request.cancelTitle!),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_dialogService
|
_dialogService
|
||||||
.dialogComplete(DialogResponse(confirmed: false));
|
.dialogComplete(DialogResponse(confirmed: false));
|
||||||
|
|
@ -132,7 +132,7 @@ class _DialogManagerState extends State<DialogManager> {
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
color: redColor,
|
color: redColor,
|
||||||
child: Text(
|
child: Text(
|
||||||
request.cancelTitle,
|
request.cancelTitle!,
|
||||||
style: TextStyle(fontSize: 18),
|
style: TextStyle(fontSize: 18),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
@ -163,7 +163,7 @@ class _DialogManagerState extends State<DialogManager> {
|
||||||
dialogController.whenComplete(() {
|
dialogController.whenComplete(() {
|
||||||
//hook when press overlay and response not completed
|
//hook when press overlay and response not completed
|
||||||
if (_dialogService.completer != null) {
|
if (_dialogService.completer != null) {
|
||||||
_dialogService.completer.complete(DialogResponse(confirmed: false));
|
_dialogService.completer!.complete(DialogResponse(confirmed: false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@ class AmanIconButton extends StatefulWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
const AmanIconButton(
|
const AmanIconButton(
|
||||||
{
|
{
|
||||||
@required this.title,
|
required this.title,
|
||||||
this.busy = false,
|
this.busy = false,
|
||||||
@required this.onPressed,
|
required this.onPressed,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.mainColor,
|
required this.mainColor,
|
||||||
@required this.icon
|
required this.icon
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -29,7 +29,7 @@ class _AmanIconButtonState extends State<AmanIconButton> {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
onTap: widget.busy ? () {} : widget.onPressed,
|
onTap: widget.busy ? () {} : () => widget.onPressed(),
|
||||||
child: Container(
|
child: Container(
|
||||||
//height: 75,
|
//height: 75,
|
||||||
width: 120,
|
width: 120,
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,14 @@ class AmanIconButtonHorizontal extends StatefulWidget {
|
||||||
final Color inactiveColor;
|
final Color inactiveColor;
|
||||||
final bool selected;
|
final bool selected;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
|
||||||
const AmanIconButtonHorizontal(
|
const AmanIconButtonHorizontal(
|
||||||
{@required this.title,
|
{required this.title,
|
||||||
this.onPressed,
|
required this.onPressed,
|
||||||
this.activeColor = primaryColor,
|
this.activeColor = primaryColor,
|
||||||
this.inactiveColor = Colors.black26,
|
this.inactiveColor = Colors.black26,
|
||||||
this.selected = false,
|
this.selected = false,
|
||||||
@required this.icon});
|
required this.icon});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AmanIconButtonHorizontalState createState() =>
|
_AmanIconButtonHorizontalState createState() =>
|
||||||
|
|
@ -29,7 +30,7 @@ class _AmanIconButtonHorizontalState extends State<AmanIconButtonHorizontal> {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius: BorderRadius.circular(3),
|
||||||
onTap: widget.onPressed,
|
onTap: () => widget.onPressed(),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue