Skip to content

Commit

Permalink
DEV-39629
Browse files Browse the repository at this point in the history
  • Loading branch information
DCrow committed Jul 10, 2020
1 parent 3e1cd8e commit 8102911
Show file tree
Hide file tree
Showing 21 changed files with 1,005 additions and 606 deletions.
10 changes: 8 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PODS:
- Flutter (1.0.0)
- flutter_keyboard_visibility (0.7.0):
- Flutter
- flutter_user_agent (1.2.2):
- Flutter
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
Expand Down Expand Up @@ -36,6 +38,7 @@ DEPENDENCIES:
- device_info (from `.symlinks/plugins/device_info/ios`)
- Flutter (from `Flutter`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_user_agent (from `.symlinks/plugins/flutter_user_agent/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
Expand All @@ -47,7 +50,7 @@ DEPENDENCIES:
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
https://github.com/CocoaPods/Specs.git:
- FMDB
- MTBBarcodeScanner

Expand All @@ -60,6 +63,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
flutter_user_agent:
:path: ".symlinks/plugins/flutter_user_agent/ios"
package_info:
:path: ".symlinks/plugins/package_info/ios"
path_provider:
Expand All @@ -84,6 +89,7 @@ SPEC CHECKSUMS:
device_info: cbf09d2ec12aa7110e0b09fabe54b5bd6c8efe74
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_keyboard_visibility: 6195387fb6d8f46e5cd6dda4a4154e41f800f545
flutter_user_agent: 27c45d034dc31b80948d29998cea52cd3a7bf936
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
package_info: 48b108e75b8802c2d5e126f208ef540561c98aef
Expand All @@ -98,4 +104,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 49ec7d4076524b7e225c38b98147173651ac4b9d

COCOAPODS: 1.6.1
COCOAPODS: 1.9.1
14 changes: 1 addition & 13 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand All @@ -29,8 +25,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -41,15 +35,13 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
7BD47EDCCE1645464ABDA388 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7D7106F98A3A2F169F802D6B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -65,8 +57,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
BCBCB572DC2649B1FB01DD99 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -77,9 +67,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -249,7 +237,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
3D98E192959125665D20AD11 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down

This file was deleted.

24 changes: 15 additions & 9 deletions lib/app/models/partners.dart → lib/app/models/act.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import 'package:sqflite/sqflite.dart';
import 'package:retog/app/app.dart';
import 'package:retog/app/models/database_model.dart';

class Partner extends DatabaseModel {
static String _tableName = 'goods';
class Act extends DatabaseModel {
static String _tableName = 'acts';

int id;
String name;
int number;
String typeName;
int goodsCnt;

get tableName => _tableName;

Partner({Map<String, dynamic> values, this.id, this.name}) {
Act({Map<String, dynamic> values, this.id, this.number, this.typeName, this.goodsCnt}) {
if (values != null) build(values);
}

Expand All @@ -22,24 +24,28 @@ class Partner extends DatabaseModel {
super.build(values);

id = values['id'];
name = values['name'];
number = values['number'];
typeName = values['type_name'];
goodsCnt = values['goods_cnt'];
}

Map<String, dynamic> toMap() {
Map<String, dynamic> map = Map<String, dynamic>();
map['id'] = id;
map['name'] = name;
map['number'] = number;
map['type_name'] = typeName;
map['goods_cnt'] = goodsCnt;

return map;
}

static Future<List<Partner>> all() async {
return (await App.application.data.db.query(_tableName)).map((rec) => Partner(values: rec)).toList();
static Future<List<Act>> all() async {
return (await App.application.data.db.query(_tableName)).map((rec) => Act(values: rec)).toList();
}

static Future<void> import(List<dynamic> recs, Batch batch) async {
batch.delete(_tableName);
recs.forEach((rec) => batch.insert(_tableName, Partner(values: rec).toMap()));
recs.forEach((rec) => batch.insert(_tableName, Act(values: rec).toMap()));
}

static Future<void> deleteAll() async {
Expand Down
10 changes: 10 additions & 0 deletions lib/app/models/buyer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@ class Buyer extends DatabaseModel {
order by buyers.name
""")).map((rec) => Buyer(values: rec)).first;
}

static Future<List<Buyer>> byPartnerId(int partnerId) async {
return (await App.application.data.db.rawQuery("""
select
buyers.*
from $_tableName buyers
where partner_id = $partnerId
order by buyers.name
""")).map((rec) => Buyer(values: rec)).toList();
}
}
5 changes: 3 additions & 2 deletions lib/app/models/return_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ class ReturnType extends DatabaseModel {
return await App.application.data.db.delete(_tableName);
}

static Future<List<ReturnType>> byPartner(int partnerId) async {
static Future<List<ReturnType>> byBuyer(int buyerId) async {
return (await App.application.data.db.rawQuery("""
select
return_types.*
from $_tableName return_types
join partner_return_types on partner_return_types.return_type_id = return_types.id
where partner_return_types.partner_id = $partnerId
join buyers on buyers.partner_id = partner_return_types.partner_id
where buyers.id = $buyerId
""")).map((rec) => ReturnType(values: rec)).toList();
}
}
13 changes: 13 additions & 0 deletions lib/app/models/user.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:pub_semver/pub_semver.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'package:retog/app/app.dart';
Expand All @@ -12,6 +13,7 @@ class User {
String email = '';
String salesmanName;
String token;
String remoteVersion;
int cReturnOrder;

static const int kGuestId = 1;
Expand All @@ -26,11 +28,18 @@ class User {
email = App.application.data.prefs.getString('email');
token = App.application.data.prefs.getString('token');
cReturnOrder = App.application.data.prefs.getInt('cReturnOrder');
remoteVersion = App.application.data.prefs.getString('remoteVersion');
}

static User _currentUser;
static User get currentUser => _currentUser;

bool get newVersionAvailable {
String currentVersion = App.application.config.packageInfo.version;

return remoteVersion != null && Version.parse(remoteVersion) > Version.parse(currentVersion);
}

Map<String, dynamic> toMap() {
Map<String, dynamic> map = Map<String, dynamic>();
map['id'] = id;
Expand All @@ -39,6 +48,7 @@ class User {
map['salesman_name'] = salesmanName;
map['email'] = email;
map['token'] = token;
map['remote_version'] = remoteVersion;

return map;
}
Expand All @@ -53,6 +63,7 @@ class User {
id = userData['id'];
email = userData['email'];
salesmanName = userData['salesman_name'];
remoteVersion = userData['app']['version'];
await save();
}

Expand All @@ -63,6 +74,7 @@ class User {
email = '';
salesmanName = null;
token = null;
remoteVersion = null;
cReturnOrder = null;

await save();
Expand All @@ -77,6 +89,7 @@ class User {
await (email != null ? prefs.setString('email', email) : prefs.remove('email'));
await (salesmanName != null ? prefs.setString('salesmanName', salesmanName) : prefs.remove('salesmanName'));
await (token != null ? prefs.setString('token', token) : prefs.remove('token'));
await (remoteVersion != null ? prefs.setString('remoteVersion', remoteVersion) : prefs.remove('remoteVersion'));
await (cReturnOrder != null ? prefs.setInt('cReturnOrder', cReturnOrder) : prefs.remove('cReturnOrder'));
}
}
Loading

0 comments on commit 8102911

Please sign in to comment.