From 94db86ee667af01163a4bac067a15e50802027ca Mon Sep 17 00:00:00 2001 From: suvaysov Date: Fri, 11 Nov 2022 12:47:28 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=9D=D0=B2=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 +- .../response/dict_response_entity.dart | 60 --------- .../inventarization_response.dart | 45 +++++++ .../inventarization_response.g.dart | 39 ++++++ lib/core/models/response/response_entity.dart | 60 +++++++++ .../response_entity.g.dart} | 29 ++--- lib/core/services/api_service.dart | 35 ++--- lib/core/services/dictionary_service.dart | 28 ++-- .../services/inventarization_service.dart | 35 +++++ lib/core/utils/locator.dart | 8 +- lib/shared/app_colors.dart | 1 + lib/shared/shared_styles.dart | 4 + .../view/inventarization_view.dart | 123 ++++++++++++++++++ .../widget/inventarization_list_tile.dart | 94 +++++++++++++ lib/views/main/main_view.dart | 5 + lib/widgets/drawer/app_drawer.dart | 7 +- pubspec.lock | 109 +++++++++------- pubspec.yaml | 32 ++--- 18 files changed, 544 insertions(+), 172 deletions(-) delete mode 100644 lib/core/models/dictionary/response/dict_response_entity.dart create mode 100644 lib/core/models/inventarization/inventarization_response.dart create mode 100644 lib/core/models/inventarization/inventarization_response.g.dart create mode 100644 lib/core/models/response/response_entity.dart rename lib/core/models/{dictionary/response/dict_response_entity.g.dart => response/response_entity.g.dart} (57%) create mode 100644 lib/core/services/inventarization_service.dart create mode 100644 lib/views/inventarization/view/inventarization_view.dart create mode 100644 lib/views/inventarization/widget/inventarization_list_tile.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index 04112d6..b7289d2 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 31 + compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/lib/core/models/dictionary/response/dict_response_entity.dart b/lib/core/models/dictionary/response/dict_response_entity.dart deleted file mode 100644 index 932b3a3..0000000 --- a/lib/core/models/dictionary/response/dict_response_entity.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'dart:convert'; - -part 'dict_response_entity.g.dart'; - -@JsonSerializable() -class DictResponseEntity { - factory DictResponseEntity.fromJson(Map json) => - _$DictResponseEntityFromJson(json); - - DictResponseEntity(); - - late DictResponseHeaders headers; - late DictResponseOriginal original; - String? exception; - - Map toJson() => _$DictResponseEntityToJson(this); - - @override - String toString() { - return jsonEncode(this); - } -} - -@JsonSerializable() -class DictResponseHeaders { - DictResponseHeaders(); - - factory DictResponseHeaders.fromJson(Map json) => - _$DictResponseHeadersFromJson(json); - - Map toJson() => _$DictResponseHeadersToJson(this); - - @override - String toString() { - return jsonEncode(this); - } -} - -@JsonSerializable() -class DictResponseOriginal { - factory DictResponseOriginal.fromJson(Map json) => - _$DictResponseOriginalFromJson(json); - - DictResponseOriginal(); - - int? overall; - int? page; - int? perpage; - List? data; - Map>? errors; - String? message; - - Map toJson() => _$DictResponseOriginalToJson(this); - - @override - String toString() { - return jsonEncode(this); - } -} diff --git a/lib/core/models/inventarization/inventarization_response.dart b/lib/core/models/inventarization/inventarization_response.dart new file mode 100644 index 0000000..e318cc4 --- /dev/null +++ b/lib/core/models/inventarization/inventarization_response.dart @@ -0,0 +1,45 @@ +import 'package:json_annotation/json_annotation.dart'; + +@JsonSerializable() +part 'inventarization_response.g.dart'; + +@JsonSerializable(explicitToJson: true) +class InventarizationResponse { + InventarizationResponse( + {required this.id, + required this.appCompanyId, + required this.inventoryDate, + required this.docNumber, + required this.molUserId, + required this.refInvoiceStatus, + required this.createdAt, + required this.updatedAt, + this.deletedAt, + this.act}); + + int id; + + @JsonKey(name: 'app_company_id') + int appCompanyId; + @JsonKey(name: 'inventory_date') + DateTime inventoryDate; + @JsonKey(name: 'doc_number') + int docNumber; + @JsonKey(name: 'mol_user_id') + int molUserId; + @JsonKey(name: 'act') + int? act; + @JsonKey(name: 'ref_invoice_status') + int refInvoiceStatus; + @JsonKey(name: 'created_at') + DateTime createdAt; + @JsonKey(name: 'updated_at') + DateTime updatedAt; + @JsonKey(name: 'deleted_at') + DateTime? deletedAt; + + factory InventarizationResponse.fromJson(Map json) => + _$InventarizationResponseFromJson(json); + + Map toJson() => _$InventarizationResponseToJson(this); +} diff --git a/lib/core/models/inventarization/inventarization_response.g.dart b/lib/core/models/inventarization/inventarization_response.g.dart new file mode 100644 index 0000000..0a6b85c --- /dev/null +++ b/lib/core/models/inventarization/inventarization_response.g.dart @@ -0,0 +1,39 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'inventarization_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +InventarizationResponse _$InventarizationResponseFromJson( + Map json) => + InventarizationResponse( + id: json['id'] as int, + appCompanyId: json['app_company_id'] as int, + inventoryDate: DateTime.parse(json['inventory_date'] as String), + docNumber: json['doc_number'] as int, + molUserId: json['mol_user_id'] as int, + refInvoiceStatus: json['ref_invoice_status'] as int, + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + deletedAt: json['deleted_at'] == null + ? null + : DateTime.parse(json['deleted_at'] as String), + act: json['act'] as int?, + ); + +Map _$InventarizationResponseToJson( + InventarizationResponse instance) => + { + 'id': instance.id, + 'app_company_id': instance.appCompanyId, + 'inventory_date': instance.inventoryDate.toIso8601String(), + 'doc_number': instance.docNumber, + 'mol_user_id': instance.molUserId, + 'act': instance.act, + 'ref_invoice_status': instance.refInvoiceStatus, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'deleted_at': instance.deletedAt?.toIso8601String(), + }; diff --git a/lib/core/models/response/response_entity.dart b/lib/core/models/response/response_entity.dart new file mode 100644 index 0000000..db13b52 --- /dev/null +++ b/lib/core/models/response/response_entity.dart @@ -0,0 +1,60 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'dart:convert'; + +part 'response_entity.g.dart'; + +@JsonSerializable() +class ResponseEntity { + factory ResponseEntity.fromJson(Map json) => + _$ResponseEntityFromJson(json); + + ResponseEntity(); + + late ResponseHeaders headers; + late ResponseOriginal original; + String? exception; + + Map toJson() => _$ResponseEntityToJson(this); + + @override + String toString() { + return jsonEncode(this); + } +} + +@JsonSerializable() +class ResponseHeaders { + ResponseHeaders(); + + factory ResponseHeaders.fromJson(Map json) => + _$ResponseHeadersFromJson(json); + + Map toJson() => _$ResponseHeadersToJson(this); + + @override + String toString() { + return jsonEncode(this); + } +} + +@JsonSerializable() +class ResponseOriginal { + factory ResponseOriginal.fromJson(Map json) => + _$ResponseOriginalFromJson(json); + + ResponseOriginal(); + + int? overall; + int? page; + int? perpage; + List? data; + Map>? errors; + String? message; + + Map toJson() => _$ResponseOriginalToJson(this); + + @override + String toString() { + return jsonEncode(this); + } +} diff --git a/lib/core/models/dictionary/response/dict_response_entity.g.dart b/lib/core/models/response/response_entity.g.dart similarity index 57% rename from lib/core/models/dictionary/response/dict_response_entity.g.dart rename to lib/core/models/response/response_entity.g.dart index c5923d8..168f124 100644 --- a/lib/core/models/dictionary/response/dict_response_entity.g.dart +++ b/lib/core/models/response/response_entity.g.dart @@ -1,36 +1,34 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'dict_response_entity.dart'; +part of 'response_entity.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -DictResponseEntity _$DictResponseEntityFromJson(Map json) => - DictResponseEntity() +ResponseEntity _$ResponseEntityFromJson(Map json) => + ResponseEntity() ..headers = - DictResponseHeaders.fromJson(json['headers'] as Map) - ..original = DictResponseOriginal.fromJson( - json['original'] as Map) + ResponseHeaders.fromJson(json['headers'] as Map) + ..original = + ResponseOriginal.fromJson(json['original'] as Map) ..exception = json['exception'] as String?; -Map _$DictResponseEntityToJson(DictResponseEntity instance) => +Map _$ResponseEntityToJson(ResponseEntity instance) => { 'headers': instance.headers, 'original': instance.original, 'exception': instance.exception, }; -DictResponseHeaders _$DictResponseHeadersFromJson(Map json) => - DictResponseHeaders(); +ResponseHeaders _$ResponseHeadersFromJson(Map json) => + ResponseHeaders(); -Map _$DictResponseHeadersToJson( - DictResponseHeaders instance) => +Map _$ResponseHeadersToJson(ResponseHeaders instance) => {}; -DictResponseOriginal _$DictResponseOriginalFromJson( - Map json) => - DictResponseOriginal() +ResponseOriginal _$ResponseOriginalFromJson(Map json) => + ResponseOriginal() ..overall = json['overall'] as int? ..page = json['page'] as int? ..perpage = json['perpage'] as int? @@ -41,8 +39,7 @@ DictResponseOriginal _$DictResponseOriginalFromJson( ) ..message = json['message'] as String?; -Map _$DictResponseOriginalToJson( - DictResponseOriginal instance) => +Map _$ResponseOriginalToJson(ResponseOriginal instance) => { 'overall': instance.overall, 'page': instance.page, diff --git a/lib/core/services/api_service.dart b/lib/core/services/api_service.dart index 76f0e76..2a659a7 100644 --- a/lib/core/services/api_service.dart +++ b/lib/core/services/api_service.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:satu/core/base/base_service.dart'; import 'package:http/http.dart' as http; import 'package:satu/core/models/auth/auth_response.dart'; -import 'package:satu/core/models/dictionary/response/dict_response_entity.dart'; +import 'package:satu/core/models/response/response_entity.dart'; import 'package:satu/core/models/flow/analytics/analytics_bean.dart'; import 'package:satu/core/models/flow/sell_request.dart'; import 'package:satu/core/models/flow/sell_response.dart'; @@ -44,15 +44,16 @@ class ApiService extends BaseService { headers.addAll(header); } final String url = '$endpoint$point'; - if (requestBody != null) { - //log.i(host); - //log.i(url); - //log.i(headers); - log.i(jsonEncode(requestBody)); - } + final response = await http.post(Uri.https(host, url), body: jsonEncode(requestBody), headers: headers); - + if (requestBody != null) { + // log.i(host); + // log.i(url); + // log.i(headers); + log.i(jsonEncode(requestBody)); + log.i(jsonEncode(response.body)); + } return response.body; } @@ -124,9 +125,9 @@ class ApiService extends BaseService { return result; } - Future dictionaries(String target, + Future postRequest(String target, {Map? requestBody}) async { - DictResponseEntity result; + ResponseEntity result; try { final Map headers = { HttpHeaders.authorizationHeader: 'Bearer $token' @@ -134,27 +135,27 @@ class ApiService extends BaseService { final String response = await _post(target, header: headers, requestBody: requestBody); - result = DictResponseEntity.fromJson(json.decode(response)); + result = ResponseEntity.fromJson(json.decode(response)); } catch (e, stack) { - log.e('dictionaries', e, stack); - result = DictResponseEntity()..exception = e.toString(); + log.e('postRequest', e, stack); + result = ResponseEntity()..exception = e.toString(); } return result; } - Future dictionarySave( + Future dictionarySave( String target, Map? body) async { - DictResponseEntity response; + ResponseEntity response; try { final Map headers = { HttpHeaders.authorizationHeader: 'Bearer $token' }; final String responseBody = await _post(target, header: headers, requestBody: body); - response = DictResponseEntity.fromJson(json.decode(responseBody)); + response = ResponseEntity.fromJson(json.decode(responseBody)); } catch (e, stack) { log.e('dictionarySave', e, stack); - response = DictResponseEntity()..exception = e.toString(); + response = ResponseEntity()..exception = e.toString(); } return response; } diff --git a/lib/core/services/dictionary_service.dart b/lib/core/services/dictionary_service.dart index c0a3ccc..5e83f93 100644 --- a/lib/core/services/dictionary_service.dart +++ b/lib/core/services/dictionary_service.dart @@ -4,7 +4,7 @@ import 'package:satu/core/entity/goods_entity.dart'; import 'package:satu/core/models/dictionary/category/category_response.dart'; import 'package:satu/core/models/dictionary/contragent/contragent_response_entity.dart'; import 'package:satu/core/models/dictionary/good/good_response_entity.dart'; -import 'package:satu/core/models/dictionary/response/dict_response_entity.dart'; +import 'package:satu/core/models/response/response_entity.dart'; import 'package:satu/core/redux/store.dart'; import 'package:satu/core/utils/locator.dart'; @@ -132,8 +132,8 @@ class DictionaryService extends BaseService { 'filter': [filter] }; - DictResponseEntity categories = await _api - .dictionaries('/goods_categories_get', requestBody: requestBody); + ResponseEntity categories = await _api + .postRequest('/goods_categories_get', requestBody: requestBody); if (categories.original.data != null && categories.original.data!.isNotEmpty) { for (final dynamic map in categories.original.data!) { @@ -148,7 +148,7 @@ class DictionaryService extends BaseService { } Future saveCategory(CategoryResponse category) async { - DictResponseEntity? status; + ResponseEntity? status; log.i(category.toJson()); if (category.id != null) { status = await _api.dictionarySave( @@ -163,7 +163,7 @@ class DictionaryService extends BaseService { } Future deleteCategory(CategoryResponse category) async { - DictResponseEntity status = await _api.dictionarySave( + ResponseEntity status = await _api.dictionarySave( '/goods_categories_delete', category.toJson()); String? message = getErrorMsg(status); return message; @@ -179,8 +179,8 @@ class DictionaryService extends BaseService { 'filter': [filter] }; - DictResponseEntity categories = - await _api.dictionaries('/goods_goods_get', requestBody: requestBody); + ResponseEntity categories = + await _api.postRequest('/goods_goods_get', requestBody: requestBody); if (categories.original.data != null && categories.original.data!.isNotEmpty) { for (final dynamic map in categories.original.data!) { @@ -195,7 +195,7 @@ class DictionaryService extends BaseService { } Future saveGood(GoodResponseEntity good) async { - DictResponseEntity? status; + ResponseEntity? status; if (good.id != null) { status = await _api.dictionarySave('/goods_goods_edit', good.toJson()); } else { @@ -207,7 +207,7 @@ class DictionaryService extends BaseService { } Future deleteGood(GoodResponseEntity good) async { - DictResponseEntity status = + ResponseEntity status = await _api.dictionarySave('/goods_goods_delete', good.toJson()); String? message = getErrorMsg(status); return message; @@ -224,8 +224,8 @@ class DictionaryService extends BaseService { {'col': 'name', 'action': 'like', 'val': query ?? ''} ] }; - final DictResponseEntity contragents = await _api - .dictionaries('/general_contragents_get', requestBody: requestBody); + final ResponseEntity contragents = await _api + .postRequest('/general_contragents_get', requestBody: requestBody); if (contragents.original.data != null) { if (contragents.original.data!.isNotEmpty) { for (dynamic map in contragents.original.data!) { @@ -240,7 +240,7 @@ class DictionaryService extends BaseService { } Future saveContragent(ContragentResponseEntity contragent) async { - DictResponseEntity? status; + ResponseEntity? status; if (contragent.id != null) { status = await _api.dictionarySave( '/general_contragents_edit', contragent.toJson()); @@ -254,13 +254,13 @@ class DictionaryService extends BaseService { } Future deleteContragent(ContragentResponseEntity contragent) async { - DictResponseEntity status = await _api.dictionarySave( + ResponseEntity status = await _api.dictionarySave( '/general_contragents_delete', contragent.toJson()); String? message = getErrorMsg(status); return message; } - String? getErrorMsg(DictResponseEntity status) { + String? getErrorMsg(ResponseEntity status) { String? message; if (status.exception != null) { diff --git a/lib/core/services/inventarization_service.dart b/lib/core/services/inventarization_service.dart new file mode 100644 index 0000000..33ec9e7 --- /dev/null +++ b/lib/core/services/inventarization_service.dart @@ -0,0 +1,35 @@ +import 'package:satu/core/base/base_service.dart'; +import 'package:satu/core/models/inventarization/inventarization_response.dart'; +import 'package:satu/core/utils/locator.dart'; + +import '../models/response/response_entity.dart'; +import 'api_service.dart'; + +class InventarizationService extends BaseService { + final ApiService _api = locator(); + + Future> getList( + {required int page, required int perpage, dynamic filter}) async { + List list = []; + try { + final Map requestBody = { + 'page': page, + 'perpage': perpage + }; + + ResponseEntity categories = await _api + .postRequest('/goods_inventory_get', requestBody: requestBody); + if (categories.original.data != null && + categories.original.data!.isNotEmpty) { + for (final dynamic map in categories.original.data!) { + final InventarizationResponse item = InventarizationResponse.fromJson(map); + list.add(item); + } + } + } catch (e, stack) { + log.e('getList', e, stack); + } + return list; + } + +} \ No newline at end of file diff --git a/lib/core/utils/locator.dart b/lib/core/utils/locator.dart index 8076c01..481e384 100644 --- a/lib/core/utils/locator.dart +++ b/lib/core/utils/locator.dart @@ -7,6 +7,7 @@ import 'package:satu/core/services/data_service.dart'; import 'package:satu/core/services/db_service.dart'; import 'package:satu/core/services/dialog_service.dart'; import 'package:satu/core/services/dictionary_service.dart'; +import 'package:satu/core/services/inventarization_service.dart'; import 'package:satu/core/services/navigator_service.dart'; import 'logger.dart'; @@ -26,13 +27,14 @@ class LocatorInjector { _log.d('Initializing DbService Service'); locator.registerLazySingleton(() => DbService.instance); - // depencies - _log.d('Initializing DataService Service'); locator.registerLazySingleton(() => DataService()); _log.d('Initializing DictionaryService Service'); locator.registerLazySingleton(() => DictionaryService()); + _log.d('Initializing InventarizationService Service'); + locator.registerLazySingleton( + () => InventarizationService()); } -} \ No newline at end of file +} diff --git a/lib/shared/app_colors.dart b/lib/shared/app_colors.dart index dae6de4..cb950fc 100644 --- a/lib/shared/app_colors.dart +++ b/lib/shared/app_colors.dart @@ -7,6 +7,7 @@ const Color dangerColor = Color.fromRGBO(243, 98, 88, 1); const Color successColor = Color.fromRGBO(39, 174, 96, 1); const Color whiteColor = Color.fromRGBO(255, 255, 255, 1); const Color blackColor = Color.fromRGBO(35, 35, 35, 1); +const Color blueColor = Color.fromRGBO(17, 103, 217, 1); const Color shadowColor = Color.fromRGBO(72, 72, 72, 0.25); diff --git a/lib/shared/shared_styles.dart b/lib/shared/shared_styles.dart index 5b3d010..fdc3599 100644 --- a/lib/shared/shared_styles.dart +++ b/lib/shared/shared_styles.dart @@ -30,6 +30,10 @@ EdgeInsets largeFieldPadding = const TextStyle dropDownTradeTypeTextStyle = TextStyle(color: Colors.black54, fontWeight: FontWeight.bold, fontSize: 24); + +const TextStyle textGray11Style = +TextStyle(color: placeholderColor, fontWeight: FontWeight.w400, fontSize: 11); + // Box Shadow BoxShadow buttonShadowBox = const BoxShadow(blurRadius: 10, color: shadowColor, offset: Offset(0, 4)); diff --git a/lib/views/inventarization/view/inventarization_view.dart b/lib/views/inventarization/view/inventarization_view.dart new file mode 100644 index 0000000..373b5ff --- /dev/null +++ b/lib/views/inventarization/view/inventarization_view.dart @@ -0,0 +1,123 @@ +import 'package:flutter/material.dart'; +import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; +import 'package:satu/core/models/inventarization/inventarization_response.dart'; +import 'package:satu/core/services/inventarization_service.dart'; +import 'package:satu/core/utils/locator.dart'; +import 'package:satu/shared/app_colors.dart'; +import 'package:satu/shared/shared_styles.dart'; +import 'package:satu/shared/ui_helpers.dart'; +import 'package:satu/views/inventarization/widget/inventarization_list_tile.dart'; + +import '../../../widgets/bar/products_app_bar.dart'; + +class InventarizationView extends StatefulWidget { + const InventarizationView({Key? key}) : super(key: key); + + @override + State createState() => _InventarizationViewState(); +} + +class _InventarizationViewState extends State { + + final InventarizationService _service = locator(); + + static const _pageSize = 20; + + final PagingController _pagingController = + PagingController(firstPageKey: 1); + + @override + void initState() { + _pagingController.addPageRequestListener((pageKey) { + _fetchData(pageKey, _pageSize); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: const ProductsAppBar( + title: 'Инвентаризация', + drawerShow: true, + ), + body: Column( + children: [ + verticalSpaceSmall, + Padding( + padding: const EdgeInsets.only( left: 15.0), + child: SizedBox( + width: double.infinity, + child: Row( + children: [ + Expanded( + flex: 2, + child: Text( + 'Номер документа', + style: textGray11Style, + ), + ), + Expanded( + flex: 2, + child: Text( + 'Дата создания', + style: textGray11Style, + ), + ), + Expanded( + flex: 1, + child: Text( + 'Акты', + style: textGray11Style, + ), + ), + ], + ), + ), + ), + verticalSpaceSmall, + Expanded( + child: PagedListView.separated( + physics: const BouncingScrollPhysics(), + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1.0, + color: disableColor, + ); + }, + pagingController: _pagingController, + builderDelegate: PagedChildBuilderDelegate( + itemBuilder: (BuildContext context, InventarizationResponse item, + int index) { + return InventarizationListTile( + key: Key('category_${item.id}'), + // onPress: () async { + // final dynamic result = await _navigatorService + // .push(categoryEditRoute, arguments: item); + // if (result != null && true == (result as bool)) { + // _pagingController.refresh(); + // } + // }, + item: item, + ); + }, + ), + ), + ) + ], + ), + ); + } + + Future _fetchData(int pageKey, int perPage) async { + final List newItems = await _service + .getList(page: pageKey, perpage: perPage); + final isLastPage = newItems.length < _pageSize; + if (isLastPage) { + _pagingController.appendLastPage(newItems); + } else { + final nextPageKey = pageKey + 1; + _pagingController.appendPage(newItems, nextPageKey); + } + } +} diff --git a/lib/views/inventarization/widget/inventarization_list_tile.dart b/lib/views/inventarization/widget/inventarization_list_tile.dart new file mode 100644 index 0000000..38566ac --- /dev/null +++ b/lib/views/inventarization/widget/inventarization_list_tile.dart @@ -0,0 +1,94 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:satu/core/models/inventarization/inventarization_response.dart'; +import 'package:satu/shared/app_colors.dart'; + +class InventarizationListTile extends StatefulWidget { + const InventarizationListTile({required this.item, Key? key}) + : super(key: key); + + final InventarizationResponse item; + + @override + State createState() => + _InventarizationListTileState(); +} + +class _InventarizationListTileState extends State { + final DateFormat formatterDay = DateFormat('dd.MM.yyyy'); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration(color: whiteColor), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: InventarizationCellTile( + value: widget.item.docNumber.toString()), + ), + Expanded( + flex: 2, + child: InventarizationCellTile( + value: formatterDay.format(widget.item.createdAt), + ), + ), + Expanded( + flex: 1, + child: InventarizationCellButton( + value: formatterDay.format(widget.item.createdAt), + ), + ), + ], + ), + ); + } +} + +class InventarizationCellTile extends StatelessWidget { + const InventarizationCellTile({ + required this.value, + Key? key, + }) : super(key: key); + + final String value; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(15.0), + child: Text( + value, + style: TextStyle(fontSize: 12), + ), + ); + } +} + +class InventarizationCellButton extends StatelessWidget { + const InventarizationCellButton({ + required this.value, + Key? key, + }) : super(key: key); + + final String value; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only( right: 15.0), + child: OutlinedButton( + onPressed: () {}, + child: Text( + 'Акт', + style: TextStyle(fontSize: 12, color: whiteColor), + ), + style: OutlinedButton.styleFrom( + backgroundColor: blueColor, + ), + ), + ); + } +} diff --git a/lib/views/main/main_view.dart b/lib/views/main/main_view.dart index 15fec45..927c3a8 100644 --- a/lib/views/main/main_view.dart +++ b/lib/views/main/main_view.dart @@ -7,6 +7,7 @@ import 'package:satu/core/utils/locator.dart'; import 'package:satu/views/analytics/analytics_view.dart'; import 'package:satu/views/dictionaries/category/category_view.dart'; import 'package:satu/views/dictionaries/goods/goods_view.dart'; +import 'package:satu/views/inventarization/view/inventarization_view.dart'; import 'package:satu/views/settings/setting_view.dart'; import 'package:satu/views/work/work_view.dart'; import 'package:satu/widgets/drawer/app_drawer.dart'; @@ -28,6 +29,7 @@ class _MainViewState extends State { final _goodDictView = GoodsDictionaryView(); final _contragentDictView = ContragentsDictionaryView(); final _analyticsView = const AnalyticsView(); + final _inventarizationView = InventarizationView(); Widget _body(Type viewClass) { if(viewClass == WorkView) { @@ -39,6 +41,9 @@ class _MainViewState extends State { if(viewClass == CategoryDictionaryView) { return _categoryDictView; } + if(viewClass == InventarizationView) { + return _inventarizationView; + } if(viewClass == GoodsDictionaryView) { return _goodDictView; } diff --git a/lib/widgets/drawer/app_drawer.dart b/lib/widgets/drawer/app_drawer.dart index 390e496..0bc41ad 100644 --- a/lib/widgets/drawer/app_drawer.dart +++ b/lib/widgets/drawer/app_drawer.dart @@ -16,6 +16,8 @@ import 'package:satu/views/dictionaries/goods/goods_view.dart'; import 'package:satu/views/settings/setting_view.dart'; import 'package:satu/views/work/work_view.dart'; +import '../../views/inventarization/view/inventarization_view.dart'; + class AppDrawer extends StatelessWidget { @override Widget build(BuildContext context) { @@ -55,7 +57,10 @@ class AppDrawer extends StatelessWidget { _createDrawerItem( svgFile: 'inventarization', text: 'Инвентаризация', - disable: true, + onTap: () { + Navigator.of(context).pop(); + Redux.store!.dispatch(navigateDrawer(InventarizationView)); + }, ), _createDrawerSectionTitle(text: 'СПРАВОЧНИКИ'), _createDrawerItem( diff --git a/pubspec.lock b/pubspec.lock index d831591..303e783 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,35 +7,35 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "40.0.0" + version: "47.0.0" ai_barcode: dependency: "direct main" description: name: ai_barcode url: "https://pub.dartlang.org" source: hosted - version: "3.2.0" + version: "3.2.4" ai_barcode_platform_interface: dependency: transitive description: name: ai_barcode_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" ai_barcode_web: dependency: transitive description: name: ai_barcode_web url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.7.0" archive: dependency: transitive description: @@ -56,7 +56,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" auto_size_text: dependency: "direct main" description: @@ -84,7 +84,7 @@ packages: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.1" build_daemon: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.11" + version: "2.3.2" build_runner_core: dependency: transitive description: @@ -133,7 +133,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -161,14 +161,14 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.3.0" collection: dependency: transitive description: @@ -231,7 +231,7 @@ packages: name: equatable url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.5" esc_pos_bluetooth: dependency: "direct main" description: @@ -252,7 +252,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -306,14 +306,14 @@ packages: name: flutter_screenutil url: "https://pub.dartlang.org" source: hosted - version: "5.5.3+2" + version: "5.6.0" flutter_svg: dependency: "direct main" description: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "0.23.0+1" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter @@ -330,7 +330,7 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "3.1.0" gbk_codec: dependency: transitive description: @@ -386,7 +386,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.4" + version: "0.13.5" http_multi_server: dependency: transitive description: @@ -407,7 +407,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.2.2" implicitly_animated_reorderable_list: dependency: "direct main" description: @@ -449,14 +449,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.5.0" + version: "4.7.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "6.2.0" + version: "6.5.4" lints: dependency: transitive description: @@ -491,28 +491,28 @@ packages: name: mask_text_input_formatter url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" material_design_icons_flutter: dependency: "direct main" description: name: material_design_icons_flutter url: "https://pub.dartlang.org" source: hosted - version: "5.0.6595" + version: "5.0.6996" material_floating_search_bar: dependency: "direct main" description: @@ -526,7 +526,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mime: dependency: transitive description: @@ -554,21 +554,21 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_drawing: dependency: transitive description: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.5.1+1" + version: "1.0.1" path_parsing: dependency: transitive description: name: path_parsing url: "https://pub.dartlang.org" source: hosted - version: "0.2.1" + version: "1.0.1" path_provider: dependency: "direct main" description: @@ -624,21 +624,42 @@ packages: name: permission_handler url: "https://pub.dartlang.org" source: hosted - version: "8.3.0" + version: "10.2.0" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + url: "https://pub.dartlang.org" + source: hosted + version: "10.2.0" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.7" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "3.9.0" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "5.1.0" platform: dependency: transitive description: @@ -673,7 +694,7 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.0.4" pub_semver: dependency: transitive description: @@ -736,7 +757,7 @@ packages: name: responsive_builder url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" rxdart: dependency: transitive description: @@ -846,21 +867,21 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" sqflite: dependency: "direct main" description: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.2+1" + version: "2.2.0+3" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.2.1+1" + version: "2.4.0+2" stack_trace: dependency: transitive description: @@ -888,7 +909,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" synchronized: dependency: transitive description: @@ -902,14 +923,14 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" timing: dependency: transitive description: @@ -944,7 +965,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.1.3" + version: "6.1.6" url_launcher_android: dependency: transitive description: @@ -979,7 +1000,7 @@ packages: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.1" url_launcher_web: dependency: transitive description: @@ -1042,7 +1063,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.1" + version: "6.1.0" yaml: dependency: transitive description: @@ -1051,5 +1072,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.17.3 <3.0.0" - flutter: ">=2.10.0" + dart: ">=2.18.2 <3.0.0" + flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1b50567..42e7947 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ version: 1.0.0+1 environment: - sdk: ">=2.17.3 <3.0.0" + sdk: ">=2.18.2 <3.0.0" dependencies: flutter: @@ -30,30 +30,30 @@ dependencies: redux_thunk: ^0.4.0 redux_persist: ^0.9.0 redux_persist_flutter: ^0.9.0 - responsive_builder: ^0.4.2 - provider: ^6.0.3 + responsive_builder: ^0.4.3 + provider: ^6.0.4 logger: ^1.1.0 get_it: ^7.2.0 - equatable: ^2.0.3 - http: ^0.13.4 - sqflite: ^2.0.2+1 + equatable: ^2.0.5 + http: ^0.13.5 + sqflite: ^2.2.0+3 path_provider: ^2.0.11 - material_design_icons_flutter: ^5.0.6295 + material_design_icons_flutter: ^5.0.6996 intl: ^0.17.0 device_info: ^2.0.3 auto_size_text: ^3.0.0 - url_launcher: ^6.1.3 + url_launcher: ^6.1.6 qr_flutter: ^4.0.0 - mask_text_input_formatter: ^2.3.0 - flutter_screenutil: ^5.5.3+2 + mask_text_input_formatter: ^2.4.0 + flutter_screenutil: ^5.6.0 shared_preferences: ^2.0.15 material_floating_search_bar: ^0.3.7 implicitly_animated_reorderable_list: ^0.4.2 uuid: ^3.0.6 charset_converter: ^2.1.0 - ai_barcode: ^3.2.0 - permission_handler: ^8.3.0 - flutter_svg: ^0.23.0+1 + ai_barcode: ^3.2.4 + permission_handler: ^10.2.0 + flutter_svg: ^1.1.6 grouped_list: ^5.1.2 infinite_scroll_pagination: ^3.2.0 flutter_bluetooth_basic: ^0.1.7 @@ -61,17 +61,17 @@ dependencies: esc_pos_utils: ^1.1.0 esc_pos_bluetooth: ^0.4.1 dev_dependencies: - build_runner: ^2.1.5 + build_runner: ^2.3.2 flutter_test: sdk: flutter - json_serializable: ^6.0.1 + json_serializable: ^6.5.4 # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec