You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1227 lines
83 KiB
Dart
1227 lines
83 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/locator.dart';
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_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';
|
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart' as utils;
|
|
|
|
import 'base/base_view.dart';
|
|
import 'final_products_page.dart';
|
|
|
|
class SubCategorisePage extends StatefulWidget {
|
|
String? id;
|
|
String? title;
|
|
String? parentId;
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
SubCategorisePage({this.id, this.parentId, this.title});
|
|
|
|
@override
|
|
_SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId);
|
|
}
|
|
|
|
class _SubCategorisePageState extends State<SubCategorisePage> {
|
|
bool checkedBrands = false;
|
|
bool checkedCategorise = false;
|
|
String? id;
|
|
String? title;
|
|
String? parentId;
|
|
|
|
_SubCategorisePageState({this.title, this.parentId, this.id});
|
|
|
|
String categoriseName = "Personal Care";
|
|
bool styleOne = true;
|
|
bool styleTwo = false;
|
|
Icon styleIcon = Icon(
|
|
Icons.widgets_sharp,
|
|
color: Colors.blue,
|
|
size: 29.0,
|
|
);
|
|
|
|
int pageIndex = 1;
|
|
|
|
RefreshController controller = RefreshController();
|
|
List<CategoriseParentModel> entityList = [];
|
|
List<CategoriseParentModel> entityListBrands = [];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
TextEditingController minField = TextEditingController();
|
|
TextEditingController maxField = TextEditingController();
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
ProjectViewModel projectProvider = Provider.of(context);
|
|
return BaseView<PharmacyCategoriseViewModel>(
|
|
onModelReady: (model) => model.getSubCategorise(i: id, pageIndex: pageIndex, isLoading: false, context: context),
|
|
allowAny: true,
|
|
builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => AppScaffold(
|
|
isPharmacy: true,
|
|
appBarTitle: title!,
|
|
isBottomBar: true,
|
|
isShowAppBar: true,
|
|
backgroundColor: Colors.white,
|
|
isShowDecPage: false,
|
|
showPharmacyCart: false,
|
|
showHomeAppBarIcon: false,
|
|
baseViewModel: model,
|
|
body: SmartRefresher(
|
|
controller: controller,
|
|
enablePullDown: false,
|
|
enablePullUp: true,
|
|
onLoading: () async {
|
|
setState(() {
|
|
++pageIndex;
|
|
});
|
|
await model.getSubProducts(pageIndex: pageIndex, i: id, isLoading: true, context: context);
|
|
if (model.state != ViewState.BusyLocal && pageIndex < 5) {
|
|
controller.loadComplete();
|
|
} else {
|
|
controller.loadFailed();
|
|
}
|
|
},
|
|
child: SingleChildScrollView(
|
|
child: Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
child: Image.network(
|
|
parentId == '1'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png'
|
|
: parentId == '2'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png'
|
|
: parentId == '3'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png'
|
|
: parentId == '4'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png'
|
|
: parentId == '5'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png'
|
|
: parentId == '6'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png'
|
|
: parentId == '7'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png'
|
|
: parentId == '8'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png'
|
|
: parentId == '9'
|
|
? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png'
|
|
: parentId == '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.subCategorise.length > 8)
|
|
Column(
|
|
children: [
|
|
InkWell(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.all(10.0),
|
|
child: Container(
|
|
child: Texts(TranslationBase.of(context).viewSubCategorise),
|
|
),
|
|
),
|
|
Icon(Icons.arrow_forward)
|
|
],
|
|
),
|
|
onTap: () {
|
|
showModalBottomSheet<void>(
|
|
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.subCategorise.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return Container(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(8.0),
|
|
child: InkWell(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Texts(
|
|
projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name,
|
|
// model.subCategorise[index].name
|
|
),
|
|
Divider(
|
|
thickness: 0.6,
|
|
color: Colors.black12,
|
|
)
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: FinalProductsPage(
|
|
id: model.subCategorise[index].id!,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
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.subCategorise.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,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * 0.17,
|
|
height: MediaQuery.of(context).size.height * 0.10,
|
|
child: Center(
|
|
child: Texts(
|
|
projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name,
|
|
// model.subCategorise[index].name,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
maxLines: 2,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: FinalProductsPage(
|
|
id: model.subCategorise[index].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(
|
|
TranslationBase.of(context).refine,
|
|
// 'Refine',
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
],
|
|
),
|
|
onTap: () {
|
|
showModalBottomSheet<void>(
|
|
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(
|
|
TranslationBase.of(context).refine,
|
|
// 'Refine',
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
SizedBox(
|
|
width: 250.0,
|
|
),
|
|
InkWell(
|
|
child: Texts(
|
|
TranslationBase.of(context).closeIt,
|
|
// '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(TranslationBase.of(context).subGroup),
|
|
children: [
|
|
ProcedureListWidget(
|
|
model: model,
|
|
masterList: model.subCategorise,
|
|
removeHistory: (item) {
|
|
setState(() {
|
|
entityList.remove(item);
|
|
});
|
|
},
|
|
addHistory: (history) {
|
|
setState(() {
|
|
entityList.add(history);
|
|
});
|
|
},
|
|
isEntityListSelected: (master) => isEntityListSelected(master),
|
|
)
|
|
],
|
|
),
|
|
Divider(
|
|
thickness: 1.0,
|
|
color: Colors.black12,
|
|
),
|
|
ExpansionTile(
|
|
title: Texts(TranslationBase.of(context).brands),
|
|
children: [
|
|
ProcedureListWidget(
|
|
model: model,
|
|
masterList: model.brandsList,
|
|
removeHistory: (item) {
|
|
setState(() {
|
|
entityListBrands.remove(item);
|
|
});
|
|
},
|
|
addHistory: (history) {
|
|
setState(() {
|
|
entityListBrands.add(history);
|
|
});
|
|
},
|
|
isEntityListSelected: (master) => isEntityListSelectedBrands(master),
|
|
)
|
|
],
|
|
),
|
|
Divider(
|
|
thickness: 1.0,
|
|
color: Colors.black12,
|
|
),
|
|
ExpansionTile(
|
|
title: Texts(TranslationBase.of(context).price),
|
|
children: [
|
|
Container(
|
|
color: Color(0xffEEEEEE),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Texts(TranslationBase.of(context).min),
|
|
Container(
|
|
color: Colors.white,
|
|
width: 200,
|
|
height: 40,
|
|
child: TextFormField(
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
),
|
|
controller: minField,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Texts(TranslationBase.of(context).max),
|
|
Container(
|
|
color: Colors.white,
|
|
width: 200,
|
|
height: 40,
|
|
child: TextFormField(
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
),
|
|
controller: maxField,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
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: [
|
|
Expanded(
|
|
child: Container(
|
|
width: 100,
|
|
child: Button(
|
|
label: TranslationBase.of(context).reset,
|
|
// 'Reset',
|
|
backgroundColor: Colors.red,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 30,
|
|
),
|
|
Container(
|
|
width: 200,
|
|
child: Button(
|
|
onTap: () async {
|
|
String categoriesId = "";
|
|
for (CategoriseParentModel category in entityList) {
|
|
if (categoriesId == "") {
|
|
categoriesId = category.id!;
|
|
} else {
|
|
categoriesId = "$categoriesId,${category.id}";
|
|
}
|
|
}
|
|
String brandIds = "";
|
|
|
|
for (CategoriseParentModel brand in entityListBrands) {
|
|
if (brandIds == "") {
|
|
brandIds = brand.id!;
|
|
} else {
|
|
brandIds = "$brandIds,${brand.id}";
|
|
}
|
|
}
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
await model.getFilteredSubProducts(
|
|
min: minField.text.isEmpty ? "" : minField.text.toString(),
|
|
max: maxField.text.isEmpty ? "" : maxField.text.toString(),
|
|
categoryId: categoriesId,
|
|
brandId: brandIds.isEmpty ? "" : "&manufacturerids=" + brandIds);
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
Navigator.pop(context);
|
|
},
|
|
label: TranslationBase.of(context).apply,
|
|
// '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: CustomColors.green,
|
|
size: 29.0,
|
|
);
|
|
} else {
|
|
styleOne = true;
|
|
styleTwo = false;
|
|
styleIcon = Icon(
|
|
Icons.widgets_sharp,
|
|
color: CustomColors.green,
|
|
size: 29.0,
|
|
);
|
|
}
|
|
});
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Divider(
|
|
thickness: 1.0,
|
|
color: Colors.grey.shade400,
|
|
),
|
|
model.subProducts.isNotEmpty
|
|
? styleOne == true
|
|
? Container(
|
|
height: model.subProducts.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.subProducts.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return InkWell(
|
|
child: Card(
|
|
color: model.subProducts[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: [
|
|
Container(
|
|
margin: EdgeInsets.fromLTRB(0, 16, 0, 0),
|
|
alignment: Alignment.center,
|
|
child: Image.network(
|
|
model.subProducts[index].images!.isNotEmpty
|
|
? model.subProducts[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.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 3 : 0,
|
|
padding: EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xffb23838),
|
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(6)),
|
|
),
|
|
child: model.subProducts[index].rxMessage != null
|
|
? Texts(
|
|
projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage,
|
|
color: Colors.white,
|
|
regular: true,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w400,
|
|
)
|
|
: Texts(""),
|
|
// Texts(
|
|
// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "",
|
|
// color: Colors.white,
|
|
// regular: true,
|
|
// fontSize: 10,
|
|
// fontWeight: FontWeight.w400,
|
|
// ),
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(
|
|
horizontal: 6,
|
|
vertical: 0,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Texts(
|
|
projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name,
|
|
// model.subProducts[index].name,
|
|
regular: true,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 4, bottom: 4),
|
|
child: Texts(
|
|
"SAR ${model.subProducts[index].price}",
|
|
bold: true,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
// StarRating(
|
|
// totalAverage: model.subProducts[index].approvedRatingSum > 0
|
|
// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble()
|
|
// : 0,
|
|
// forceStars: true),
|
|
RatingBar(
|
|
initialRating: model.subProducts[index].approvedRatingSum!.toDouble(),
|
|
ratingWidget: RatingWidget(
|
|
full: Icon(
|
|
Icons.star,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
half: Icon(
|
|
Icons.star_half,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
empty: Icon(
|
|
Icons.star_border,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
),
|
|
onRatingUpdate: (double value) {},
|
|
unratedColor: Colors.grey[500],
|
|
updateOnDrag: false,
|
|
tapOnlyMode: false,
|
|
),
|
|
Texts(
|
|
"(${model.subProducts[index].approvedTotalReviews})",
|
|
regular: true,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w400,
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
onTap: () => {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: ProductDetailPage(model.subProducts[index]),
|
|
)),
|
|
},
|
|
);
|
|
},
|
|
),
|
|
)
|
|
: Container(
|
|
height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122,
|
|
child: ListView.builder(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemCount: model.subProducts.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, 8),
|
|
alignment: Alignment.center,
|
|
child: (model.subProducts[index].images != null && model.subProducts[index].images!.length > 0)
|
|
? Image.network(
|
|
model.subProducts[index].images![0].src!,
|
|
fit: BoxFit.cover,
|
|
height: 80,
|
|
width: 80,
|
|
)
|
|
: Image.asset(
|
|
"assets/images/no_image.png",
|
|
fit: BoxFit.cover,
|
|
height: 80,
|
|
width: 80,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
children: [
|
|
Container(
|
|
width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 3.70 : 0,
|
|
padding: EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xffb23838),
|
|
//borderRadius: BorderRadius.only(topLeft: Radius.circular(5)),
|
|
),
|
|
child: model.subProducts[index].rxMessage != null
|
|
? Texts(
|
|
projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage,
|
|
color: Colors.white,
|
|
regular: true,
|
|
fontSize: 8,
|
|
fontWeight: FontWeight.w600,
|
|
)
|
|
: Texts(""),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
height: 100.0,
|
|
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.55,
|
|
child: Texts(
|
|
projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[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.subProducts[index].price}",
|
|
bold: true,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
RatingBar(
|
|
initialRating: model.subProducts[index].approvedRatingSum!.toDouble(),
|
|
ratingWidget: RatingWidget(
|
|
full: Icon(
|
|
Icons.star,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
half: Icon(
|
|
Icons.star_half,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
empty: Icon(
|
|
Icons.star_border,
|
|
color: CustomColors.accentColor,
|
|
),
|
|
),
|
|
onRatingUpdate: (double value) {},
|
|
unratedColor: Colors.grey[500],
|
|
updateOnDrag: false,
|
|
tapOnlyMode: false,
|
|
),
|
|
Texts(
|
|
"(${model.subProducts[index].approvedTotalReviews})",
|
|
regular: true,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w400,
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
widget.authenticatedUserObject.isLogin
|
|
? Container(
|
|
child: IconButton(
|
|
icon: Icon(
|
|
Icons.shopping_cart,
|
|
size: 18,
|
|
color: CustomColors.green,
|
|
),
|
|
onPressed: () async {
|
|
if (model.subProducts[index].isRx == false) {
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
await addToCartFunction(1, model.subProducts[index].id);
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
utils.Utils.navigateToCartPage();
|
|
} else {
|
|
AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription);
|
|
}
|
|
//
|
|
}),
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
onTap: () => {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: ProductDetailPage(model.subProducts[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: model
|
|
// .subProducts[
|
|
// index]
|
|
// .images
|
|
// .isNotEmpty
|
|
// ? Image.network(
|
|
// model
|
|
// .subProducts[
|
|
// index]
|
|
// .images[
|
|
// 0]
|
|
// .thumb,
|
|
// fit: BoxFit
|
|
// .contain,
|
|
// height: 70,
|
|
// )
|
|
// : Text(TranslationBase.of(
|
|
// context)
|
|
// .noImage),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// Column(
|
|
// children: [
|
|
// Container(
|
|
// width: model
|
|
// .subProducts[
|
|
// index]
|
|
// .rxMessage !=
|
|
// null
|
|
// ? MediaQuery.of(
|
|
// context)
|
|
// .size
|
|
// .width /
|
|
// 3.70
|
|
// : 0,
|
|
// padding:
|
|
// EdgeInsets.all(
|
|
// 4),
|
|
// decoration:
|
|
// BoxDecoration(
|
|
// color: Color(
|
|
// 0xffb23838),
|
|
// // borderRadius: BorderRadius.only(
|
|
// // topLeft: Radius
|
|
// // .circular(
|
|
// // 6)),
|
|
// ),
|
|
// child: model
|
|
// .subProducts[
|
|
// index]
|
|
// .rxMessage !=
|
|
// null
|
|
// ? Texts(
|
|
// projectProvider
|
|
// .isArabic
|
|
// ? model
|
|
// .subProducts[
|
|
// index]
|
|
// .rxMessagen
|
|
// : model
|
|
// .subProducts[index]
|
|
// .rxMessage,
|
|
// color: Colors
|
|
// .white,
|
|
// regular:
|
|
// true,
|
|
// fontSize:
|
|
// 10,
|
|
// fontWeight:
|
|
// FontWeight
|
|
// .w400,
|
|
// )
|
|
// : Texts(""),
|
|
// // Texts(
|
|
// // model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "",
|
|
// // color: Colors.white,
|
|
// // regular: true,
|
|
// // fontSize: 10,
|
|
// // fontWeight: FontWeight.w400,
|
|
// // ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// Container(
|
|
// height: 130.0,
|
|
// margin:
|
|
// EdgeInsets.symmetric(
|
|
// horizontal: 0,
|
|
// 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(
|
|
// projectViewModel
|
|
// .isArabic
|
|
// ? model
|
|
// .subProducts[
|
|
// index]
|
|
// .namen
|
|
// : model
|
|
// .subProducts[
|
|
// index]
|
|
// .name,
|
|
// // model.subProducts[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.subProducts[index].price}",
|
|
// bold: true,
|
|
// fontSize: 14,
|
|
// ),
|
|
// ),
|
|
// Row(
|
|
// children: [
|
|
// // StarRating(
|
|
// // totalAverage: model.subProducts[index].approvedRatingSum > 0
|
|
// // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble()
|
|
// // : 0,
|
|
// // forceStars: true),
|
|
// RatingBar.readOnly(
|
|
// initialRating: model
|
|
// .subProducts[
|
|
// index]
|
|
// .approvedRatingSum
|
|
// .toDouble(),
|
|
// size: 15.0,
|
|
// filledColor:
|
|
// Colors.yellow[
|
|
// 700],
|
|
// emptyColor: Colors
|
|
// .grey[500],
|
|
// isHalfAllowed:
|
|
// true,
|
|
// halfFilledIcon:
|
|
// Icons
|
|
// .star_half,
|
|
// filledIcon:
|
|
// Icons.star,
|
|
// emptyIcon:
|
|
// Icons.star,
|
|
// ),
|
|
// Texts(
|
|
// "(${model.subProducts[index].approvedTotalReviews})",
|
|
// regular: true,
|
|
// fontSize: 10,
|
|
// fontWeight:
|
|
// FontWeight
|
|
// .w400,
|
|
// )
|
|
// ],
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// widget.authenticatedUserObject
|
|
// .isLogin
|
|
// ? Container(
|
|
// child: IconButton(
|
|
// icon: Icon(
|
|
// Icons
|
|
// .shopping_cart,
|
|
// size: 18,
|
|
// color:
|
|
// CustomColors
|
|
// .green,
|
|
// ),
|
|
// onPressed:
|
|
// () async {
|
|
// if (model
|
|
// .subProducts[
|
|
// index]
|
|
// .isRx == false) {
|
|
// GifLoaderDialogUtils
|
|
// .showMyDialog(
|
|
// context);
|
|
// await addToCartFunction(
|
|
// 1,
|
|
// model
|
|
// .subProducts[
|
|
// index]
|
|
// .id);
|
|
// GifLoaderDialogUtils
|
|
// .hideDialog(
|
|
// context);
|
|
// Utils
|
|
// .navigateToCartPage();
|
|
// } else {
|
|
// AppToast.showErrorToast(
|
|
// message: TranslationBase.of(
|
|
// context)
|
|
// .needPrescription);
|
|
// }
|
|
// }),
|
|
// )
|
|
// : Container(),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// onTap: () => {
|
|
// Navigator.push(
|
|
// context,
|
|
// FadePage(
|
|
// page: ProductDetailPage(
|
|
// model.subProducts[
|
|
// index]),
|
|
// )),
|
|
// },
|
|
// );
|
|
}),
|
|
)
|
|
: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Container(
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Image.asset(
|
|
'assets/images/new-design/empty_box.png',
|
|
width: 100,
|
|
height: 100,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Text(
|
|
TranslationBase.of(context).noData,
|
|
style: TextStyle(fontSize: 30),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
bool isEntityListSelected(CategoriseParentModel masterKey) {
|
|
Iterable<CategoriseParentModel> history = entityList.where((element) => masterKey.id == element.id);
|
|
if (history.length > 0) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool isEntityListSelectedBrands(CategoriseParentModel masterKey) {
|
|
Iterable<CategoriseParentModel> history = entityListBrands.where((element) => masterKey.id == element.id);
|
|
if (history.length > 0) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
addToCartFunction(quantity, itemID) async {
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
await x.addToCartData(quantity, itemID, context);
|
|
}
|
|
}
|