|
|
|
|
@ -20,28 +20,21 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
List<PharmacyProduct> filteredInPatientItems = [];
|
|
|
|
|
List<PharmacyProduct> filteredMyInPatientItems = [];
|
|
|
|
|
|
|
|
|
|
PharmacyCategoriseService _pharmacyCategoriseService =
|
|
|
|
|
locator<PharmacyCategoriseService>();
|
|
|
|
|
PharmacyCategoriseService _pharmacyCategoriseService = locator<PharmacyCategoriseService>();
|
|
|
|
|
|
|
|
|
|
List<PharmacyCategorise> get categorise =>
|
|
|
|
|
_pharmacyCategoriseService.categoriseList;
|
|
|
|
|
List<PharmacyCategorise> get categorise => _pharmacyCategoriseService.categoriseList;
|
|
|
|
|
|
|
|
|
|
List<CategoriseParentModel> get categoriseParent =>
|
|
|
|
|
_pharmacyCategoriseService.parentCategoriseList;
|
|
|
|
|
List<CategoriseParentModel> get categoriseParent => _pharmacyCategoriseService.parentCategoriseList;
|
|
|
|
|
|
|
|
|
|
List<PharmacyProduct> get parentProducts =>
|
|
|
|
|
_pharmacyCategoriseService.parentProductsList;
|
|
|
|
|
List<PharmacyProduct> get parentProducts => _pharmacyCategoriseService.parentProductsList;
|
|
|
|
|
|
|
|
|
|
List<CategoriseParentModel> get subCategorise =>
|
|
|
|
|
_pharmacyCategoriseService.subCategoriseList;
|
|
|
|
|
List<CategoriseParentModel> get subCategorise => _pharmacyCategoriseService.subCategoriseList;
|
|
|
|
|
|
|
|
|
|
List<PharmacyProduct> get subProducts =>
|
|
|
|
|
_pharmacyCategoriseService.subProductsList;
|
|
|
|
|
List<PharmacyProduct> get subProducts => _pharmacyCategoriseService.subProductsList;
|
|
|
|
|
|
|
|
|
|
List<PharmacyProduct> get finalProducts =>
|
|
|
|
|
_pharmacyCategoriseService.finalProducts;
|
|
|
|
|
List<CategoriseParentModel> get brandsList =>
|
|
|
|
|
_pharmacyCategoriseService.brandsList;
|
|
|
|
|
List<PharmacyProduct> get finalProducts => _pharmacyCategoriseService.finalProducts;
|
|
|
|
|
|
|
|
|
|
List<CategoriseParentModel> get brandsList => _pharmacyCategoriseService.brandsList;
|
|
|
|
|
|
|
|
|
|
List<PharmacyProduct> get searchList => _pharmacyCategoriseService.searchList;
|
|
|
|
|
|
|
|
|
|
@ -99,8 +92,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getCategoriseParent(
|
|
|
|
|
{String? i, int? pageIndex, bool? isLoading, BuildContext? context}) async {
|
|
|
|
|
Future getCategoriseParent({String? i, int? pageIndex, bool? isLoading, BuildContext? context}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
@ -111,19 +103,16 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
} else
|
|
|
|
|
await getBrands(id: i);
|
|
|
|
|
await getParentProducts(
|
|
|
|
|
i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
|
|
|
|
|
await getParentProducts(i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
|
|
|
|
|
// GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getParentProducts(
|
|
|
|
|
{String? i, int? pageIndex, bool? isLoading, BuildContext? context}) async {
|
|
|
|
|
Future getParentProducts({String? i, int? pageIndex, bool? isLoading, BuildContext? context}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context!);
|
|
|
|
|
await _pharmacyCategoriseService.getParentProducts(
|
|
|
|
|
id: i, pageNumber: pageIndex, isLoading: isLoading!);
|
|
|
|
|
await _pharmacyCategoriseService.getParentProducts(id: i, pageNumber: pageIndex, isLoading: isLoading!);
|
|
|
|
|
if (_pharmacyCategoriseService.hasError) {
|
|
|
|
|
error = _pharmacyCategoriseService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
@ -132,11 +121,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getSubCategorise(
|
|
|
|
|
{String? i,
|
|
|
|
|
int? pageIndex,
|
|
|
|
|
bool isLoading = false,
|
|
|
|
|
BuildContext? context}) async {
|
|
|
|
|
Future getSubCategorise({String? i, int? pageIndex, bool isLoading = false, BuildContext? context}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
@ -147,21 +132,15 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
error = _pharmacyCategoriseService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
} else
|
|
|
|
|
getSubProducts(
|
|
|
|
|
i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
|
|
|
|
|
getSubProducts(i: i, pageIndex: pageIndex, isLoading: isLoading, context: context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getSubProducts(
|
|
|
|
|
{String? i,
|
|
|
|
|
int? pageIndex,
|
|
|
|
|
bool isLoading = false,
|
|
|
|
|
BuildContext? context}) async {
|
|
|
|
|
Future getSubProducts({String? i, int? pageIndex, bool isLoading = false, BuildContext? context}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context!);
|
|
|
|
|
await _pharmacyCategoriseService.getSubProducts(
|
|
|
|
|
id: i, pageIndex: pageIndex, isLoading: isLoading);
|
|
|
|
|
await _pharmacyCategoriseService.getSubProducts(id: i, pageIndex: pageIndex, isLoading: isLoading);
|
|
|
|
|
if (_pharmacyCategoriseService.hasError) {
|
|
|
|
|
error = _pharmacyCategoriseService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
@ -182,13 +161,11 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getFilteredProducts(
|
|
|
|
|
{String? categoryId, String? brandId, String? min, String? max}) async {
|
|
|
|
|
Future getFilteredProducts({String? categoryId, String? brandId, String? min, String? max}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _pharmacyCategoriseService.getFilteredProducts(
|
|
|
|
|
categoryId: categoryId, brandId: brandId, max: max, min: min);
|
|
|
|
|
await _pharmacyCategoriseService.getFilteredProducts(categoryId: categoryId, brandId: brandId, max: max, min: min);
|
|
|
|
|
if (_pharmacyCategoriseService.hasError) {
|
|
|
|
|
error = _pharmacyCategoriseService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
@ -196,13 +173,11 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getFilteredSubProducts(
|
|
|
|
|
{String? categoryId, String? brandId, String? min, String? max}) async {
|
|
|
|
|
Future getFilteredSubProducts({String? categoryId, String? brandId, String? min, String? max}) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
// _insuranceCardService.clearInsuranceCard();
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _pharmacyCategoriseService.getFilteredSubProducts(
|
|
|
|
|
categoryId: categoryId, brandId: brandId, max: max, min: min);
|
|
|
|
|
await _pharmacyCategoriseService.getFilteredSubProducts(categoryId: categoryId, brandId: brandId, max: max, min: min);
|
|
|
|
|
if (_pharmacyCategoriseService.hasError) {
|
|
|
|
|
error = _pharmacyCategoriseService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
@ -267,16 +242,9 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
|
|
addOnFilteredList() {
|
|
|
|
|
if (lastSubsetIndex < parentProducts.length) {
|
|
|
|
|
firstSubsetIndex = firstSubsetIndex +
|
|
|
|
|
(parentProducts.length - lastSubsetIndex < inPatientPageSize - 1
|
|
|
|
|
? parentProducts.length - lastSubsetIndex
|
|
|
|
|
: inPatientPageSize - 1);
|
|
|
|
|
lastSubsetIndex = lastSubsetIndex +
|
|
|
|
|
(parentProducts.length - lastSubsetIndex < inPatientPageSize - 1
|
|
|
|
|
? parentProducts.length - lastSubsetIndex
|
|
|
|
|
: inPatientPageSize - 1);
|
|
|
|
|
filteredInPatientItems
|
|
|
|
|
.addAll(parentProducts.sublist(firstSubsetIndex, lastSubsetIndex));
|
|
|
|
|
firstSubsetIndex = firstSubsetIndex + (parentProducts.length - lastSubsetIndex < inPatientPageSize - 1 ? parentProducts.length - lastSubsetIndex : inPatientPageSize - 1);
|
|
|
|
|
lastSubsetIndex = lastSubsetIndex + (parentProducts.length - lastSubsetIndex < inPatientPageSize - 1 ? parentProducts.length - lastSubsetIndex : inPatientPageSize - 1);
|
|
|
|
|
filteredInPatientItems.addAll(parentProducts.sublist(firstSubsetIndex, lastSubsetIndex));
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|