From 2723422bbf8d563aea35209b385aa8faeda2c509 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 8 Mar 2021 17:37:11 +0200 Subject: [PATCH] daynimic listing --- .../model/pharmacies/PharmacyProduct.dart | 253 ++- .../service/pharmacy_categorise_service.dart | 2 +- .../pharmacy_categorise_view_model.dart | 6 +- lib/pages/parent_categorise_page.dart | 1834 ++++++++--------- lib/pages/sub_categorise_page.dart | 11 +- lib/widgets/others/entity_checkbox_list.dart | 170 ++ 6 files changed, 1211 insertions(+), 1065 deletions(-) create mode 100644 lib/widgets/others/entity_checkbox_list.dart diff --git a/lib/core/model/pharmacies/PharmacyProduct.dart b/lib/core/model/pharmacies/PharmacyProduct.dart index c472cb4c..f69d035b 100644 --- a/lib/core/model/pharmacies/PharmacyProduct.dart +++ b/lib/core/model/pharmacies/PharmacyProduct.dart @@ -4,29 +4,29 @@ import 'PharmacyImageObject.dart'; import 'Reviews.dart'; class PharmacyProduct { - String id; + dynamic id; bool visibleIndividually; - String name; - String namen; - String shortDescription; - String shortDescriptionn; - String fullDescription; - String fullDescriptionn; + dynamic name; + dynamic namen; + dynamic shortDescription; + dynamic shortDescriptionn; + dynamic fullDescription; + dynamic fullDescriptionn; bool markasNew; bool showOnHomePage; - String metaKeywords; - String metaDescription; - String metaTitle; + dynamic metaKeywords; + dynamic metaDescription; + dynamic metaTitle; bool allowCustomerReviews; int approvedRatingSum; int notApprovedRatingSum; int approvedTotalReviews; int notApprovedTotalReviews; - String sku; + dynamic sku; bool isRx; bool prescriptionRequired; - String rxMessage; - String rxMessagen; + dynamic rxMessage; + dynamic rxMessagen; String manufacturerPartNumber; String gtin; bool isGiftCard; @@ -115,118 +115,117 @@ class PharmacyProduct { int vendorId; String seName; - PharmacyProduct( {this.id, - this.visibleIndividually, - this.name, - this.namen, - this.shortDescription, - this.shortDescriptionn, - this.fullDescription, - this.fullDescriptionn, - this.markasNew, - this.showOnHomePage, - this.metaKeywords, - this.metaDescription, - this.metaTitle, - this.allowCustomerReviews, - this.approvedRatingSum, - this.notApprovedRatingSum, - this.approvedTotalReviews, - this.notApprovedTotalReviews, - this.sku, - this.isRx, - this.prescriptionRequired, - this.rxMessage, - this.rxMessagen, - this.manufacturerPartNumber, - this.gtin, - this.isGiftCard, - this.requireOtherProducts, - this.automaticallyAddRequiredProducts, - this.isDownload, - this.unlimitedDownloads, - this.maxNumberOfDownloads, - this.downloadExpirationDays, - this.hasSampleDownload, - this.hasUserAgreement, - this.isRecurring, - this.recurringCycleLength, - this.recurringTotalCycles, - this.isRental, - this.rentalPriceLength, - this.isShipEnabled, - this.isFreeShipping, - this.shipSeparately, - this.additionalShippingCharge, - this.isTaxExempt, - this.isTelecommunicationsOrBroadcastingOrElectronicServices, - this.useMultipleWarehouses, - this.manageInventoryMethodId, - this.stockQuantity, - this.stockAvailability, - this.stockAvailabilityn, - this.displayStockAvailability, - this.displayStockQuantity, - this.minStockQuantity, - this.notifyAdminForQuantityBelow, - this.allowBackInStockSubscriptions, - this.orderMinimumQuantity, - this.orderMaximumQuantity, - this.allowedQuantities, - this.allowAddingOnlyExistingAttributeCombinations, - this.disableBuyButton, - this.disableWishlistButton, - this.availableForPreOrder, - this.preOrderAvailabilityStartDateTimeUtc, - this.callForPrice, - this.price, - this.oldPrice, - this.productCost, - this.specialPrice, - this.specialPriceStartDateTimeUtc, - this.specialPriceEndDateTimeUtc, - this.customerEntersPrice, - this.minimumCustomerEnteredPrice, - this.maximumCustomerEnteredPrice, - this.basepriceEnabled, - this.basepriceAmount, - this.basepriceBaseAmount, - this.hasTierPrices, - this.hasDiscountsApplied, - this.discountName, - this.discountNamen, - this.discountDescription, - this.discountDescriptionn, - this.discountPercentage, - this.currency, - this.currencyn, - this.weight, - this.length, - this.width, - this.height, - this.availableStartDateTimeUtc, - this.availableEndDateTimeUtc, - this.displayOrder, - this.published, - this.deleted, - this.createdOnUtc, - this.updatedOnUtc, - this.productType, - this.parentGroupedProductId, - this.roleIds, - this.discountIds, - this.storeIds, - this.manufacturerIds, - this.reviews, - this.images, - this.attributes, - this.specifications, - this.associatedProductIds, - this.tags, - this.vendorId, - this.seName}); + this.visibleIndividually, + this.name, + this.namen, + this.shortDescription, + this.shortDescriptionn, + this.fullDescription, + this.fullDescriptionn, + this.markasNew, + this.showOnHomePage, + this.metaKeywords, + this.metaDescription, + this.metaTitle, + this.allowCustomerReviews, + this.approvedRatingSum, + this.notApprovedRatingSum, + this.approvedTotalReviews, + this.notApprovedTotalReviews, + this.sku, + this.isRx, + this.prescriptionRequired, + this.rxMessage, + this.rxMessagen, + this.manufacturerPartNumber, + this.gtin, + this.isGiftCard, + this.requireOtherProducts, + this.automaticallyAddRequiredProducts, + this.isDownload, + this.unlimitedDownloads, + this.maxNumberOfDownloads, + this.downloadExpirationDays, + this.hasSampleDownload, + this.hasUserAgreement, + this.isRecurring, + this.recurringCycleLength, + this.recurringTotalCycles, + this.isRental, + this.rentalPriceLength, + this.isShipEnabled, + this.isFreeShipping, + this.shipSeparately, + this.additionalShippingCharge, + this.isTaxExempt, + this.isTelecommunicationsOrBroadcastingOrElectronicServices, + this.useMultipleWarehouses, + this.manageInventoryMethodId, + this.stockQuantity, + this.stockAvailability, + this.stockAvailabilityn, + this.displayStockAvailability, + this.displayStockQuantity, + this.minStockQuantity, + this.notifyAdminForQuantityBelow, + this.allowBackInStockSubscriptions, + this.orderMinimumQuantity, + this.orderMaximumQuantity, + this.allowedQuantities, + this.allowAddingOnlyExistingAttributeCombinations, + this.disableBuyButton, + this.disableWishlistButton, + this.availableForPreOrder, + this.preOrderAvailabilityStartDateTimeUtc, + this.callForPrice, + this.price, + this.oldPrice, + this.productCost, + this.specialPrice, + this.specialPriceStartDateTimeUtc, + this.specialPriceEndDateTimeUtc, + this.customerEntersPrice, + this.minimumCustomerEnteredPrice, + this.maximumCustomerEnteredPrice, + this.basepriceEnabled, + this.basepriceAmount, + this.basepriceBaseAmount, + this.hasTierPrices, + this.hasDiscountsApplied, + this.discountName, + this.discountNamen, + this.discountDescription, + this.discountDescriptionn, + this.discountPercentage, + this.currency, + this.currencyn, + this.weight, + this.length, + this.width, + this.height, + this.availableStartDateTimeUtc, + this.availableEndDateTimeUtc, + this.displayOrder, + this.published, + this.deleted, + this.createdOnUtc, + this.updatedOnUtc, + this.productType, + this.parentGroupedProductId, + this.roleIds, + this.discountIds, + this.storeIds, + this.manufacturerIds, + this.reviews, + this.images, + this.attributes, + this.specifications, + this.associatedProductIds, + this.tags, + this.vendorId, + this.seName}); PharmacyProduct.fromJson(Map json) { id = json['id']; @@ -257,7 +256,7 @@ class PharmacyProduct { isGiftCard = json['is_gift_card']; requireOtherProducts = json['require_other_products']; automaticallyAddRequiredProducts = - json['automatically_add_required_products']; + json['automatically_add_required_products']; isDownload = json['is_download']; unlimitedDownloads = json['unlimited_downloads']; maxNumberOfDownloads = json['max_number_of_downloads']; @@ -275,7 +274,7 @@ class PharmacyProduct { additionalShippingCharge = json['additional_shipping_charge']; isTaxExempt = json['is_tax_exempt']; isTelecommunicationsOrBroadcastingOrElectronicServices = - json['is_telecommunications_or_broadcasting_or_electronic_services']; + json['is_telecommunications_or_broadcasting_or_electronic_services']; useMultipleWarehouses = json['use_multiple_warehouses']; manageInventoryMethodId = json['manage_inventory_method_id']; stockQuantity = json['stock_quantity']; @@ -290,12 +289,12 @@ class PharmacyProduct { orderMaximumQuantity = json['order_maximum_quantity']; allowedQuantities = json['allowed_quantities']; allowAddingOnlyExistingAttributeCombinations = - json['allow_adding_only_existing_attribute_combinations']; + json['allow_adding_only_existing_attribute_combinations']; disableBuyButton = json['disable_buy_button']; disableWishlistButton = json['disable_wishlist_button']; availableForPreOrder = json['available_for_pre_order']; preOrderAvailabilityStartDateTimeUtc = - json['pre_order_availability_start_date_time_utc']; + json['pre_order_availability_start_date_time_utc']; callForPrice = json['call_for_price']; price = json['price']; oldPrice = json['old_price']; diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 479fd25f..6b97ee85 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -112,7 +112,7 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getBrands() async { + Future getBrands({String id}) async { hasError = false; _brandsList.clear(); await baseAppClient.getPharmacy( diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index c98eedd7..8e5c755e 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -55,11 +55,11 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getBrands() async { + Future getBrands({String id}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _pharmacyCategoriseService.getBrands(); + await _pharmacyCategoriseService.getBrands(id: id); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); @@ -105,7 +105,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); } else await getParentProducts(i: i); - await getBrands(); + await getBrands(id: i); } Future getParentProducts({String i}) async { diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 46df3df7..e845e3bd 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; @@ -7,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -42,7 +44,7 @@ class _ParentCategorisePageState extends State { color: Colors.blue, size: 29.0, ); - + List entityList = List(); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -57,960 +59,721 @@ class _ParentCategorisePageState extends State { backgroundColor: Colors.white, isShowDecPage: false, baseViewModel: model, - body: Container( - child: ListView( - scrollDirection: Axis.vertical, - children: [ - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Image.network( - id == '1' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' - : id == '2' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' - : id == '3' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' - : id == '4' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' - : id == '5' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' - : id == '6' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' - : id == '7' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' - : id == '8' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' - : id == '9' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : id == '10' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' - : '', - fit: BoxFit.fill, - height: 160.0, - width: double.infinity), - ), - if (model.categoriseParent.length > 8) - Column( - crossAxisAlignment: CrossAxisAlignment.start, + body: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Image.network( + id == '1' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' + : id == '2' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' + : id == '3' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' + : id == '4' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' + : id == '5' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' + : id == '6' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' + : id == '7' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' + : id == '8' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' + : id == '9' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' + : id == '10' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' + : '', + fit: BoxFit.fill, + height: 160.0, + width: double.infinity), + ), + if (model.categoriseParent.length > 8) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: InkWell( - child: Container( - child: Texts( - 'View All Categories', - fontWeight: FontWeight.w300, - ), - ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return Container( - // height: MediaQuery.of(context) - // .size - // .height * - // 0.89, - color: Colors.white, - child: Center( - child: ListView.builder( - scrollDirection: - Axis.vertical, - itemCount: model - .categoriseParent - .length, - itemBuilder: - (BuildContext context, - int index) { - return Container( - child: Padding( - padding: - EdgeInsets.all( - 4.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Texts(model - .categoriseParent[ - index] - .name), - Divider( - thickness: - 0.6, - color: Colors - .black12, - ) - ], - ), - onTap: () { - Navigator.push( - context, - FadePage( - page: - SubCategorisePage( - title: model - .categoriseParent[ - index] - .name, - id: model - .categoriseParent[ - index] - .id, - parentId: - id, - )), - ); - }, - ), + Padding( + padding: EdgeInsets.all(10.0), + child: InkWell( + child: Container( + child: Texts( + 'View All Categories', + fontWeight: FontWeight.w300, + ), + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return Container( + // height: MediaQuery.of(context) + // .size + // .height * + // 0.89, + color: Colors.white, + child: Center( + child: ListView.builder( + scrollDirection: + Axis.vertical, + itemCount: model + .categoriseParent.length, + itemBuilder: + (BuildContext context, + int index) { + return Container( + child: Padding( + padding: + EdgeInsets.all(4.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Texts(model + .categoriseParent[ + index] + .name), + Divider( + thickness: 0.6, + color: Colors + .black12, + ) + ], ), - ); - }), - ), - ); - }, + onTap: () { + Navigator.push( + context, + FadePage( + page: + SubCategorisePage( + title: model + .categoriseParent[ + index] + .name, + id: model + .categoriseParent[ + index] + .id, + parentId: id, + )), + ); + }, + ), + ), + ); + }), + ), ); }, - ), - ), - Icon(Icons.arrow_forward) - ], - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, + ); + }, + ), ), + Icon(Icons.arrow_forward) ], ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + ], + ), //Expanded widget heree if nassery - Padding( - padding: EdgeInsets.only(top: 35.0), - child: Container( - height: MediaQuery.of(context).size.height * 0.2, - child: Center( - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, - itemBuilder: - (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.symmetric( - horizontal: 8.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), - child: Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors - .orange.shade200 - .withOpacity(0.45), - ), - child: Center( - child: Icon( - Icons.apps_sharp, - size: 32.0, - ), - ), - ), + Padding( + padding: EdgeInsets.only(top: 35.0), + child: Container( + height: MediaQuery.of(context).size.height * 0.2, + child: Center( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: model.categoriseParent.length > 8 + ? 8 + : model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: + EdgeInsets.symmetric(horizontal: 8.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 13.0), + child: Container( + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.orange.shade200 + .withOpacity(0.45), ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.197, - // height: MediaQuery.of(context) - // .size - // .height * - // 0.08, - child: Center( - child: Texts( - projectViewModel.isArabic - ? model - .categoriseParent[ - index] - .namen - : model - .categoriseParent[ - index] - .name, - fontSize: 13.4, - fontWeight: FontWeight.w600, - maxLines: 3, - ), + child: Center( + child: Icon( + Icons.apps_sharp, + size: 32.0, ), ), - ], + ), ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategorisePage( - title: model - .categoriseParent[index] - .name, - id: model - .categoriseParent[index].id, - parentId: id, - )), - ); - print(id); - }, - ), - ); - }), - ), - ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.197, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.08, + child: Center( + child: Texts( + projectViewModel.isArabic + ? model + .categoriseParent[index] + .namen + : model + .categoriseParent[index] + .name, + fontSize: 13.4, + fontWeight: FontWeight.w600, + maxLines: 3, + ), + ), + ), + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategorisePage( + title: model + .categoriseParent[index].name, + id: model + .categoriseParent[index].id, + parentId: id, + )), + ); + print(id); + }, + ), + ); + }), ), + ), + ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - 'Refine', - fontWeight: FontWeight.w600, - ), - ], + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon( + Icons.wrap_text, ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.95, - minChildSize: 0.9, - builder: (BuildContext context, - ScrollController - scrollController) { - return SingleChildScrollView( - controller: scrollController, - child: Container( - height: MediaQuery.of(context) - .size - .height * - 1.95, - child: Column( - children: [ - Padding( - padding: - EdgeInsets.all(8.0), - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - 'Refine', - fontWeight: - FontWeight - .w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( - 'Close', - color: - Colors.red, - fontWeight: - FontWeight - .w600, - fontSize: 15.0, - ), - onTap: () { - Navigator.pop( - context); - }, - ), - ], + SizedBox( + width: 10.0, + ), + Texts( + 'Refine', + fontWeight: FontWeight.w600, + ), + ], + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.95, + minChildSize: 0.9, + builder: (BuildContext context, + ScrollController scrollController) { + return SingleChildScrollView( + controller: scrollController, + child: Container( + color: Colors.white, + height: MediaQuery.of(context) + .size + .height * + 1.95, + child: Column( + children: [ + Padding( + padding: + EdgeInsets.all(8.0), + child: Row( + children: [ + Icon( + Icons.wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( + 'Refine', + fontWeight: + FontWeight.w600, + ), + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( + 'Close', + color: Colors.red, + fontWeight: + FontWeight.w600, + fontSize: 15.0, + ), + onTap: () { + Navigator.pop( + context); + }, ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + Column( + children: [ + ExpansionTile( + title: + Texts('Categorise'), + children: [ + ProcedureListWidget( + model: model, + masterList: model + .categoriseParent, + removeHistory: + (item) { + setState(() { + entityList + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityList.add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelected( + master), + ) + ], ), Divider( thickness: 1.0, color: Colors.black12, ), - Column( + ExpansionTile( + title: Texts('Brands'), children: [ - ExpansionTile( - title: Texts( - 'Categorise'), - children: [ - Container( - height: 350, - child: ListView - .builder( - controller: - scrollController, - scrollDirection: - Axis - .vertical, - shrinkWrap: + Container( + height: 350, + child: ListView + .builder( + scrollDirection: + Axis + .vertical, + shrinkWrap: + true, + itemCount: model + .brandsList + .length, + itemBuilder: + (BuildContext + context, + int index) { + return CheckboxListTile( + tristate: true, - itemCount: model - .categoriseParent - .length, - itemBuilder: - (BuildContext context, - int index) { - return CheckboxListTile( - tristate: - true, - title: - Texts(model.categoriseParent[index].name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedCategorise, - onChanged: - (bool value) { - setState(() { - checkedCategorise = value; - }); - }, - ); - }), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - ExpansionTile( - title: - Texts('Brands'), - children: [ - Container( - height: 350, - child: ListView - .builder( - scrollDirection: - Axis - .vertical, - shrinkWrap: + title: Texts(model + .brandsList[index] + .name), + controlAffinity: + ListTileControlAffinity.leading, + value: + checkedBrands, + onChanged: + (bool + value) { + setState( + () { + checkedBrands = + value; + }); + }, + autofocus: true, - itemCount: model - .brandsList - .length, - itemBuilder: - (BuildContext context, - int index) { - return CheckboxListTile( - tristate: - true, - title: - Texts(model.brandsList[index].name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedBrands, - onChanged: - (bool value) { - setState(() { - checkedBrands = value; - }); - }, - autofocus: - true, - ); - }), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - ExpansionTile( - title: - Texts('Price'), - children: [ - Container( - color: Color( - 0xffEEEEEE), - child: Row( + ); + }), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts('Price'), + children: [ + Container( + color: Color( + 0xffEEEEEE), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( mainAxisAlignment: MainAxisAlignment - .spaceAround, + .start, children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts( - 'Min'), - Container( - color: - Colors.white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: OutlineInputBorder(), - ), - ), + Texts( + 'Min'), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - ], + ), ), - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts( - 'Max'), - Container( - color: - Colors.white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: OutlineInputBorder(), - ), - ), + ], + ), + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + Texts( + 'Max'), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - ], + ), ), ], ), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, - ), - Padding( - padding: - EdgeInsets.all( - 8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, - children: [ - Container( - width: 100, - child: Button( - label: - 'Reset', - backgroundColor: - Colors - .red, - ), - ), - SizedBox( - width: 30, - ), - Container( - width: 200, - child: Button( - label: - 'Apply', - backgroundColor: - Colors - .green, - ), - ), ], ), - ), + ) ], ), - ], - ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, -//width: 0.3, -// indent: 0.0, - ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: Colors.blue, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: Colors.blue, - size: 29.0, - ); - } - }); - }, - ), - ), - ], - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - styleOne == true - ? Container( - height: SizeConfig.screenHeight * 7.8, - child: GridView.builder( - physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.parentProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular(110.0), - ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) - RotatedBox( - quarterTurns: 4, - child: Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets - .only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: Texts( - 'offer' - .toUpperCase(), - color: Colors - .red, - fontSize: - 13.0, - fontWeight: - FontWeight - .w900, - ), - ), - transform: new Matrix4 - .rotationZ( - 5.837200), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ), - ), - ], - ), - Container( - margin: - EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + Divider( + thickness: 1.0, + color: Colors.black12, ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) + SizedBox( + height: MediaQuery.of( + context) + .size + .height * + 0.4, + ), + Padding( + padding: + EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ Container( - width: double - .infinity, - height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), - ), - child: Center( - child: Texts( - model - .parentProducts[ - index] - .discountName, - regular: true, - color: Colors - .white, - fontSize: - 10.4, - ), + width: 100, + child: Button( + label: 'Reset', + backgroundColor: + Colors.red, ), ), - Texts( - model - .parentProducts[ - index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w700, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, + SizedBox( + width: 30, ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum.toDouble() / - model.parentProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: - true), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - ], - ), - ], + Container( + width: 200, + child: Button( + label: 'Apply', + backgroundColor: + Colors + .green, + ), + ), + ], + ), ), - ), - ], - ), + ], + ), + ], ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - )); + ); + }); + }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, +//width: 0.3, +// indent: 0.0, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: Colors.blue, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: Colors.blue, + size: 29.0, + ); + } + }); }, ), - ) - : Container( - height: - MediaQuery.of(context).size.height * 5.0, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { - return InkWell( - child: Card( - child: Row( + ), + ], + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + styleOne == true + ? Container( + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.15, + child: GridView.builder( + physics: NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model.parentProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ - Column( - children: [ - Container( + if (model + .parentProducts[ + index] + .discountName != + null) + RotatedBox( + quarterTurns: 4, + child: Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, + right: 5.0, + top: 20.0, + bottom: 5.0, ), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.contain, - height: 80, - ), - ), - ], - ), - Column( - children: [ - Container( - width: model - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Expanded( child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: - Colors.white, - regular: true, - fontSize: 10, + 'offer' + .toUpperCase(), + color: Colors.red, + fontSize: 13.0, fontWeight: FontWeight - .w400, + .w900, ), ), + transform: new Matrix4 + .rotationZ( + 5.837200), ), - ], + ), + Container( + margin: + EdgeInsets.fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, + ), + ), + Container( + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), ), ], ), @@ -1020,36 +783,46 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, crossAxisAlignment: CrossAxisAlignment .start, children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, - child: Texts( - model + if (model .parentProducts[ index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, + .discountName != + null) + Container( + width: + double.infinity, + height: 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .parentProducts[ + index] + .discountName, + regular: true, + color: + Colors.white, + fontSize: 10.4, + ), + ), ), - ), - SizedBox( - height: 8.0, + Texts( + model + .parentProducts[ + index] + .name, + regular: true, + fontSize: 12, + fontWeight: + FontWeight.w700, ), Padding( padding: @@ -1095,23 +868,224 @@ class _ParentCategorisePageState extends State { ], ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model - .parentProducts[index]), - )), - }, - ); - }), - ) - ], - ), - ), - ], + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model + .parentProducts[index]), + )), + }, + )); + }, + ), + ) + : Container( + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.122, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemCount: model.parentProducts.length, + itemBuilder: + (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets.only( + left: 9.0, + top: 8.0, + right: 10.0, + ), + ), + ), + Container( + margin: + EdgeInsets.fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.contain, + height: 80, + ), + ), + ], + ), + Column( + children: [ + Container( + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), + ), + ], + ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: + MediaQuery.of(context) + .size + .width * + 0.65, + child: Texts( + model + .parentProducts[index] + .name, + regular: true, + fontSize: 13.2, + fontWeight: + FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets.only( + top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model + .parentProducts[ + index] + .approvedRatingSum + .toDouble() / + model + .parentProducts[ + index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), + ], + ), + ), + ], + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.parentProducts[index]), + )), + }, + ); + }), + ) + ], + ), ), ), )); } + + bool isEntityListSelected(CategoriseParentModel masterKey) { + Iterable history = + entityList.where((element) => masterKey.id == element.id); + if (history.length > 0) { + return true; + } + return false; + } } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 7c14e05d..78dda218 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -56,7 +56,6 @@ class _SubCategorisePageState extends State { baseViewModel: model, body: SingleChildScrollView( child: Container( - height: MediaQuery.of(context).size.height * 5.97, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -596,7 +595,9 @@ class _SubCategorisePageState extends State { ), styleOne == true ? Container( - height: MediaQuery.of(context).size.height * 3.85, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), gridDelegate: @@ -604,7 +605,7 @@ class _SubCategorisePageState extends State { crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, - childAspectRatio: 1.0, + childAspectRatio: 0.9, ), itemCount: model.subProducts.length, itemBuilder: (BuildContext context, int index) { @@ -798,7 +799,9 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: MediaQuery.of(context).size.height * 5.0, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, diff --git a/lib/widgets/others/entity_checkbox_list.dart b/lib/widgets/others/entity_checkbox_list.dart new file mode 100644 index 00000000..da09a0ac --- /dev/null +++ b/lib/widgets/others/entity_checkbox_list.dart @@ -0,0 +1,170 @@ +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ProcedureListWidget extends StatefulWidget { + final PharmacyCategoriseViewModel model; + final Function addSelectedHistories; + final Function(CategoriseParentModel) removeHistory; + final Function(CategoriseParentModel) addHistory; + final Function(CategoriseParentModel) addRemarks; + + final bool Function(CategoriseParentModel) isEntityListSelected; + final List masterList; + + ProcedureListWidget( + {Key key, + this.model, + this.addSelectedHistories, + this.removeHistory, + this.masterList, + this.addHistory, + this.isEntityListSelected, + this.addRemarks}) + : super(key: key); + + @override + _ProcedureListWidgetState createState() => _ProcedureListWidgetState(); +} + +class _ProcedureListWidgetState extends State { + int selectedType = 0; + int typeUrgent; + int typeRegular; + + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + List items = List(); + List remarksList = List(); + List typeList = List(); + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + TextEditingController remarksController = TextEditingController(); + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: widget.model, + child: Container( + height: MediaQuery.of(context).size.height * 0.35, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + // TextFields( + // hintText: + // 'sss', //TranslationBase.of(context).searchProcedures, + // suffixIcon: EvaIcons.search, + // onChanged: (value) { + // filterSearchResults(value); + // }, + // ), + SizedBox( + height: 15, + ), + items.length != 0 + ? Column( + children: items.map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: widget.isEntityListSelected( + historyInfo), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (widget.isEntityListSelected( + historyInfo)) { + widget + .removeHistory(historyInfo); + } else { + widget.addHistory(historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: Texts(historyInfo.name, + variant: "bodyText", + bold: true, + color: Colors.black), + ), + ), + ], + ), + Divider( + height: 1, + ), + ], + ); + }).toList(), + ) + : Center( + child: Container( + child: AppText( + "There's no procedures for this category", + color: Color(0xFFB9382C)), + ), + ) + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + ], + ), + ); + } + + void filterSearchResults(String query) { + List dummySearchList = List(); + dummySearchList.addAll(widget.masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.name.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(item); + } + }); + setState(() { + items.clear(); + items.addAll(dummyListData); + }); + return; + } else { + setState(() { + items.clear(); + items.addAll(widget.masterList); + }); + } + } +}