-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
493 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:ui_kit/ui_kit.dart'; | ||
import 'package:waiter_test/src/features/sales_mode/pages/sales_page.dart'; | ||
import 'package:waiter_test/src/features/area/pages/area_page.dart'; | ||
|
||
void main() { | ||
runApp( | ||
MaterialApp( | ||
theme: ThemeData( | ||
scaffoldBackgroundColor: ColorsApp.colorsApp.whiteSimple, | ||
), | ||
home: const SalesPage(), | ||
home: const AreaSelectPage(), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
library api_client; | ||
|
||
export 'models/models.dart'; | ||
|
||
// Call this | ||
export 'core/core.dart'; | ||
// -> | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import '../../interface/crud/crud_operation_interface.dart'; | ||
import '../../mock/fixture_crud_operation_interface.dart'; | ||
|
||
class DatabBaseLocal { | ||
static GroupCRUDOperation get currentDataBase => SQLORMFixture(); | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/api_client/lib/interface/crud/crud_operation.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import '../../models/models.dart'; | ||
|
||
abstract class CRUDoperationDBProductGroup { | ||
Future<int> createGroup(ProductGroup item); | ||
|
||
Future<List<ProductGroup>> readAllGroup(); | ||
|
||
Future<int> updateGroup(ProductGroup item); | ||
|
||
Future<int> deleteGroup(int id); | ||
} | ||
|
||
abstract class CRUDoperationDBProduct { | ||
Future<int> createProduct(Product item); | ||
|
||
Future<List<Product>> readAllProduct(); | ||
|
||
Future<int> updateProduct(Product item); | ||
|
||
Future<int> deleteProduct(int id); | ||
} | ||
|
||
abstract class CRUDoperationDBOrder { | ||
Future<int> createOrder(Order item); | ||
|
||
Future<List<Order>> readAllOrder(); | ||
|
||
Future<int> updateOrder(Order item); | ||
|
||
Future<int> deleteOrder(int id); | ||
} |
69 changes: 69 additions & 0 deletions
69
packages/api_client/lib/interface/crud/crud_operation_interface.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:api_client/models/models.dart'; | ||
|
||
import 'crud_operation.dart'; | ||
|
||
abstract class GroupCRUDOperation | ||
implements | ||
CRUDoperationDBProductGroup, | ||
CRUDoperationDBProduct, | ||
CRUDoperationDBOrder { | ||
@override | ||
Future<int> createGroup(ProductGroup item) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> createOrder(Order item) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> createProduct(Product item) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> deleteGroup(int id) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> deleteOrder(int id) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> deleteProduct(int id) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<List<ProductGroup>> readAllGroup() { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<List<Order>> readAllOrder() { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<List<Product>> readAllProduct() { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> updateGroup(ProductGroup item) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> updateOrder(Order item) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<int> updateProduct(Product item) { | ||
throw UnimplementedError(); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
packages/api_client/lib/mock/fixture_crud_operation_interface.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import 'package:api_client/interface/crud/crud_operation_interface.dart'; | ||
import 'package:api_client/models/models.dart'; | ||
|
||
class SQLORMFixture implements GroupCRUDOperation { | ||
final List<ProductGroup> _productGroups = [ | ||
ProductGroup(name: "Группа 1"), | ||
ProductGroup(name: "Группа 2"), | ||
]; | ||
final List<Product> _products = [ | ||
Product(name: "Товар 1.2", groupId: 1), | ||
Product(name: "Товар 2.3", groupId: 1), | ||
Product(name: "Товар 3.3", groupId: 2), | ||
]; | ||
final List<Order> _orders = [ | ||
Order(productId: 1, quantity: 2), | ||
Order(productId: 2, quantity: 1), | ||
]; | ||
|
||
@override | ||
Future<int> createGroup(ProductGroup item) async { | ||
_productGroups | ||
.add(ProductGroup(id: _productGroups.length + 1, name: item.name)); | ||
return _productGroups.length; | ||
} | ||
|
||
@override | ||
Future<List<ProductGroup>> readAllGroup() async { | ||
return _productGroups; | ||
} | ||
|
||
@override | ||
Future<int> updateGroup(ProductGroup item) async { | ||
final index = _productGroups.indexWhere((group) => group.id == item.id); | ||
if (index != -1) { | ||
_productGroups[index] = item; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
@override | ||
Future<int> deleteGroup(int id) async { | ||
_productGroups.removeWhere((group) => group.id == id); | ||
return 1; | ||
} | ||
|
||
@override | ||
Future<int> createProduct(Product item) async { | ||
_products.add(Product( | ||
id: _products.length + 1, name: item.name, groupId: item.groupId)); | ||
return _products.length; | ||
} | ||
|
||
@override | ||
Future<List<Product>> readAllProduct() async { | ||
return _products; | ||
} | ||
|
||
@override | ||
Future<int> updateProduct(Product item) async { | ||
final index = _products.indexWhere((product) => product.id == item.id); | ||
if (index != -1) { | ||
_products[index] = item; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
@override | ||
Future<int> deleteProduct(int id) async { | ||
_products.removeWhere((product) => product.id == id); | ||
return 1; | ||
} | ||
|
||
@override | ||
Future<int> createOrder(Order item) async { | ||
_orders.add(Order( | ||
id: _orders.length + 1, | ||
productId: item.productId, | ||
quantity: item.quantity)); | ||
return _orders.length; | ||
} | ||
|
||
@override | ||
Future<List<Order>> readAllOrder() async { | ||
return _orders; | ||
} | ||
|
||
@override | ||
Future<int> updateOrder(Order item) async { | ||
final index = _orders.indexWhere((order) => order.id == item.id); | ||
if (index != -1) { | ||
_orders[index] = item; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
@override | ||
Future<int> deleteOrder(int id) async { | ||
_orders.removeWhere((order) => order.id == id); | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Order { | ||
final int? id; | ||
final int productId; | ||
final int quantity; | ||
|
||
Order({this.id, required this.productId, required this.quantity}); | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'id': id, | ||
'product_id': productId, | ||
'quantity': quantity, | ||
}; | ||
} | ||
|
||
static Order fromMap(Map<String, dynamic> map) { | ||
return Order( | ||
id: map['id'], | ||
productId: map['product_id'], | ||
quantity: map['quantity'], | ||
); | ||
} | ||
|
||
@override | ||
bool operator ==(covariant Order other) { | ||
if (identical(this, other)) return true; | ||
|
||
return other.id == id && | ||
other.productId == productId && | ||
other.quantity == quantity; | ||
} | ||
|
||
@override | ||
int get hashCode => id.hashCode ^ productId.hashCode ^ quantity.hashCode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class Product { | ||
final int? id; | ||
final String name; | ||
final int groupId; | ||
|
||
Product({this.id, required this.name, required this.groupId}); | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'id': id, | ||
'name': name, | ||
'group_id': groupId, | ||
}; | ||
} | ||
|
||
static Product fromMap(Map<String, dynamic> map) { | ||
return Product( | ||
id: map['id'], | ||
name: map['name'], | ||
groupId: map['group_id'], | ||
); | ||
} | ||
|
||
@override | ||
bool operator ==(covariant Product other) { | ||
if (identical(this, other)) return true; | ||
|
||
return other.id == id && other.name == name && other.groupId == groupId; | ||
} | ||
|
||
@override | ||
int get hashCode => id.hashCode ^ name.hashCode ^ groupId.hashCode; | ||
} |
Oops, something went wrong.