Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into pharmacy_fix_bugs
commit
c7f558b92e
@ -0,0 +1,377 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.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:provider/provider.dart';
|
||||
import 'package:rating_bar/rating_bar.dart';
|
||||
|
||||
class RecommendedProducts extends StatefulWidget {
|
||||
final PharmacyProduct product;
|
||||
final String customerId;
|
||||
final ProductDetailViewModel productDetailViewModel;
|
||||
final bool isOverQuantity;
|
||||
final bool isInWishList;
|
||||
final Function addToWishlistFunction;
|
||||
final Function deleteFromWishlistFunction;
|
||||
|
||||
RecommendedProducts(
|
||||
{Key key,
|
||||
this.product,
|
||||
this.productDetailViewModel,
|
||||
this.customerId,
|
||||
this.isOverQuantity = false,
|
||||
this.isInWishList = false,
|
||||
this.addToWishlistFunction,
|
||||
this.deleteFromWishlistFunction})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_RecommendedProductsState createState() => _RecommendedProductsState();
|
||||
}
|
||||
|
||||
class _RecommendedProductsState extends State<RecommendedProducts> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ProjectViewModel projectViewModel = Provider.of(context);
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: 410,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 9),
|
||||
width: 410,
|
||||
color: Colors.white,
|
||||
child: Texts(
|
||||
TranslationBase.of(context).recommended,
|
||||
fontWeight: FontWeight.bold, fontSize: 16
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: 210,
|
||||
margin: EdgeInsets.only(bottom: 75),
|
||||
padding: EdgeInsets.only(bottom: 5),
|
||||
// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4),
|
||||
child: BaseView<PharmacyModuleViewModel>(
|
||||
onModelReady: (model) =>
|
||||
model.getRecommendedProducts(widget.product.id),
|
||||
builder: (_, model, wi) => NetworkBaseView(
|
||||
isLocalLoader: true,
|
||||
baseViewModel: model,
|
||||
child: Container(
|
||||
child: model.state== ViewState.BusyLocal?Container(
|
||||
height: 80,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.grey[500],
|
||||
),
|
||||
),
|
||||
),
|
||||
):model.recommendedProductList.length != null
|
||||
? ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: ScrollPhysics(),
|
||||
// physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: model.recommendedProductList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
GifLoaderDialogUtils.showMyDialog(context);
|
||||
RecommendedProductModel data =
|
||||
model.recommendedProductList[index];
|
||||
var json = data.toJson();
|
||||
PharmacyProduct product =
|
||||
new PharmacyProduct.fromJson(json);
|
||||
await Navigator.pushReplacement(
|
||||
context,
|
||||
FadePage(
|
||||
page: ProductDetailPage(product),
|
||||
),
|
||||
);
|
||||
GifLoaderDialogUtils.hideDialog(context);
|
||||
},
|
||||
child: Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
color: Colors.grey[300], width: 2),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 0,
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(15),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Stack(children: [
|
||||
Container(
|
||||
child: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
icon: Icon(model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.isinwishlist !=
|
||||
true
|
||||
? Icons.favorite_border
|
||||
: Icons.favorite),
|
||||
color: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.isinwishlist !=
|
||||
true
|
||||
? Colors.grey
|
||||
: Colors.red,
|
||||
onPressed: () async {
|
||||
if (widget.customerId != null) {
|
||||
if (!widget.isInWishList &&
|
||||
model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.isinwishlist !=
|
||||
true) {
|
||||
GifLoaderDialogUtils
|
||||
.showMyDialog(context);
|
||||
await widget.addToWishlistFunction(
|
||||
itemID: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.id,
|
||||
model: widget
|
||||
.productDetailViewModel);
|
||||
// checkWishlist();
|
||||
GifLoaderDialogUtils
|
||||
.hideDialog(context);
|
||||
setState(() {
|
||||
model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.isinwishlist = true;
|
||||
});
|
||||
} else {
|
||||
GifLoaderDialogUtils
|
||||
.showMyDialog(context);
|
||||
await widget.deleteFromWishlistFunction(
|
||||
itemID: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.id,
|
||||
model: widget
|
||||
.productDetailViewModel);
|
||||
GifLoaderDialogUtils
|
||||
.hideDialog(context);
|
||||
setState(() {
|
||||
model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.isinwishlist = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
// checkWishlist();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.fromLTRB(
|
||||
0, 16, 10, 16),
|
||||
alignment: Alignment.center,
|
||||
child: (model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.images !=
|
||||
null &&
|
||||
model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.images
|
||||
.length >
|
||||
0)
|
||||
? Image.network(
|
||||
model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.images[0]
|
||||
.src
|
||||
.toString(),
|
||||
fit: BoxFit.cover,
|
||||
height: 60,
|
||||
)
|
||||
: Image.asset(
|
||||
"assets/images/no_image.png",
|
||||
fit: BoxFit.cover,
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: model
|
||||
.recommendedProductList[
|
||||
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: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.rxMessage !=
|
||||
null
|
||||
? Texts(
|
||||
projectViewModel.isArabic
|
||||
? model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.rxMessagen
|
||||
: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.rxMessage,
|
||||
color: Colors.white,
|
||||
regular: true,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400,
|
||||
)
|
||||
: Texts(""),
|
||||
),
|
||||
]),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
projectViewModel.isArabic
|
||||
? model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.namen
|
||||
: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.name,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 13.0,
|
||||
// fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
// padding: const EdgeInsets.only(top: 15, bottom: 10),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10, bottom: 5),
|
||||
child: Texts(
|
||||
"SAR ${model.recommendedProductList[index].price}",
|
||||
bold: true,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.only(right: 10),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: RatingBar.readOnly(
|
||||
initialRating: model
|
||||
.recommendedProductList[
|
||||
index]
|
||||
.approvedRatingSum
|
||||
.toDouble(),
|
||||
size: 13.0,
|
||||
filledColor:
|
||||
Colors.yellow[700],
|
||||
emptyColor: Colors.grey[500],
|
||||
isHalfAllowed: true,
|
||||
halfFilledIcon:
|
||||
Icons.star_half,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star,
|
||||
),
|
||||
),
|
||||
),
|
||||
Texts(
|
||||
"(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})",
|
||||
// bold: true,
|
||||
fontSize: 12,
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
: Container(
|
||||
// color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Texts(
|
||||
TranslationBase.of(context).nonRecommended,
|
||||
color: Colors.black,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/transitions/fade_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'base/base_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
class SubCategoriseModalsheet extends StatefulWidget {
|
||||
String id;
|
||||
String titleName;
|
||||
|
||||
SubCategoriseModalsheet({this.id, this.titleName});
|
||||
@override
|
||||
_SubCategoriseModalsheetState createState() => _SubCategoriseModalsheetState(id: id, titleName: titleName);
|
||||
|
||||
}
|
||||
|
||||
class _SubCategoriseModalsheetState extends State<SubCategoriseModalsheet> {
|
||||
String id;
|
||||
String titleName;
|
||||
// List<CategoriseParentModel> categoriesList = [];
|
||||
_SubCategoriseModalsheetState({this.id, this.titleName});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ProjectViewModel projectViewModel = Provider.of(context);
|
||||
return BaseView<PharmacyCategoriseViewModel>(
|
||||
onModelReady: (model) => model.getCategoriseParent(i: id),
|
||||
builder: (_, model, wi) => AppScaffold(
|
||||
// appBarTitle: titleName,
|
||||
appBarTitle: TranslationBase.of(context).categorise,
|
||||
isBottomBar: false,
|
||||
isShowAppBar: true,
|
||||
backgroundColor: Colors.white,
|
||||
isShowDecPage: false,
|
||||
baseViewModel: model,
|
||||
body: Container(
|
||||
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(projectViewModel.isArabic
|
||||
? model.categoriseParent[index].namen
|
||||
: model.categoriseParent[index].name),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
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,
|
||||
)),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
// getCatName() {
|
||||
//
|
||||
// if (widget.id == '1' )
|
||||
// return Texts("text1");
|
||||
// else if (widget.id == '2' )
|
||||
// return Texts("text2");
|
||||
// else if (widget.id == '3')
|
||||
// return Texts("text3");
|
||||
// else if (widget.id == '4' )
|
||||
// return Texts("text4");
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue