Merge branch 'product_detail_page' into 'development'

Product detail page

See merge request Cloud_Solution/diplomatic-quarter!414
merge-update-with-lab-changes
Mohammad Aljammal 4 years ago
commit 48642a3c7c

@ -36,6 +36,8 @@ class CartOrderPage extends StatelessWidget {
appBarTitle: TranslationBase.of(context).shoppingCart,
isShowAppBar: true,
isPharmacy: true,
isShowDecPage: true,
description: "",
baseViewModel: model,
backgroundColor: Colors.white,
body: !(model.cartResponse.shoppingCarts == null ||

@ -11,11 +11,11 @@ class IconWithBg extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 25),
// margin: EdgeInsets.only(left: 25),
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.grey[300],
color: Colors.grey[200],
borderRadius: BorderRadius.circular(30),
),
child: IconButton(

@ -1,66 +1,134 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../../../../locator.dart';
import '../../compare-list.dart';
import '../cart-order-page.dart';
import 'CustomIcon.dart';
class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final PharmacyProduct product;
ProductAppBar({Key key, this.product}) : super(key: key);
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconWithBg(
icon: Icons.arrow_back_ios,
color: Colors.grey,
onPress: () {
Navigator.pop(context);
},
),
],
),
Row(
children: [
IconWithBg(
icon: Icons.shopping_cart,
child: FractionallySizedBox(
widthFactor: 0.95,
child: Column(
children: [
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconWithBg(
icon: Icons.arrow_back_ios,
color: Colors.grey,
onPress: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartOrderPage()),
);
}),
IconWithBg(
icon: FontAwesomeIcons.ellipsisV,
color: Colors.grey,
onPress: () {
//TODO Elham*
// settingModalBottomSheet(context);
},
),
],
)
],
),
],
Navigator.pop(context);
},
),
],
),
if(authenticatedUserObject.isLogin)
Row(
children: [
IconWithBg(
icon: Icons.shopping_cart,
color: Colors.grey,
onPress: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartOrderPage()),
);
}),
SizedBox(width: 10,),
IconWithBg(
icon: FontAwesomeIcons.ellipsisV,
color: Colors.grey,
onPress: () {
settingModalBottomSheet(context);
},
),
],
)
],
),
],
),
),
);
}
@override
// TODO: implement preferredSize
@override
Size get preferredSize => Size(double.maxFinite, 50);
settingModalBottomSheet(context) {
showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return Container(
child: new Wrap(
children: <Widget>[
if( product.stockAvailability != 'Out of stock')
new ListTile(
leading: Icon(Icons.shopping_cart),
title: Text(
TranslationBase.of(context).addToCart,
),
onTap: () => {
if (price > 0)
{addToCartFunction(price, itemID, context)}
else
{
AppToast.showErrorToast(
message: "you should add quantity")
}
}),
ListTile(
leading: Icon(Icons.favorite_border),
title: Text(
TranslationBase.of(context).addToWishlist,
),
onTap: () => {addToWishlistFunction(itemID)},
),
ListTile(
leading: Icon(Icons.compare),
title: Text(
TranslationBase.of(context).compare,
),
onTap: () => {
Provider.of<CompareList>(context, listen: false)
.addItem(specificationData),
},
),
],
),
);
});
}
}

@ -10,7 +10,7 @@ class AvailabilityInfo extends StatelessWidget {
Widget build(BuildContext context) {
return BaseView<ProductDetailViewModel>(
onModelReady: (model) => model.getProductLocationData(),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
baseViewModel: model,
child: model.productLocationService.length == 0

@ -1,4 +1,8 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/login/login.dart';
import 'package:diplomaticquarterapp/pages/login/welcome.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
@ -6,6 +10,8 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import '../../../../../locator.dart';
import '../../../../../routes.dart';
import '../../cart-order-page.dart';
class FooterWidget extends StatefulWidget {
@ -30,6 +36,8 @@ class FooterWidget extends StatefulWidget {
class _FooterWidgetState extends State<FooterWidget> {
double quantityUI = 70;
bool showUI = false;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
@override
Widget build(BuildContext context) {
@ -178,15 +186,20 @@ class _FooterWidgetState extends State<FooterWidget> {
),
),
Container(
width: MediaQuery.of(context).size.width * 0.4,
width: MediaQuery.of(context).size.width * 0.45,
child: SecondaryButton(
label: TranslationBase.of(context).addToCart.toUpperCase(),
disabled: !widget.isAvailable && widget.price > 0 ||
widget.price > widget.quantityLimit ||
widget.item.rxMessage != null,
onTap: () {
widget.addToCartFunction(
widget.price, widget.item.id, context);
if (!authenticatedUserObject.isLogin) {
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
} else
widget.addToCartFunction(
widget.price, widget.item.id, context);
},
borderRadius: 5,
color: Colors.green,
@ -196,7 +209,7 @@ class _FooterWidgetState extends State<FooterWidget> {
width: 5,
),
Container(
width: MediaQuery.of(context).size.width * 0.3,
width: MediaQuery.of(context).size.width * 0.35,
child: SecondaryButton(
label: TranslationBase.of(context).buyNow.toUpperCase(),
disabled: !widget.isAvailable && widget.price > 0 ||

@ -58,7 +58,6 @@ class __ProductDetailPageState extends State<ProductDetailPage>
bool isDetails = true;
bool isReviews = false;
bool isAvailability = false;
int _activeTab = 0;
checkWishlist() async {
GifLoaderDialogUtils.showMyDialog(context);
@ -106,13 +105,12 @@ class __ProductDetailPageState extends State<ProductDetailPage>
ProjectViewModel projectViewModel = Provider.of(context);
final screenSize = MediaQuery.of(context).size;
return customerId != null
? AppScaffold(
return AppScaffold(
appBarTitle: TranslationBase.of(context).productDetails,
isShowAppBar: true,
isPharmacy: true,
isShowDecPage: false,
customAppBar: ProductAppBar(),
customAppBar: ProductAppBar(product: widget.product,),
body: SingleChildScrollView(
child: Column(
children: [
@ -143,9 +141,17 @@ class __ProductDetailPageState extends State<ProductDetailPage>
context,
widget.product,
customerId: customerId,
addToWishlistFunction: addToWishlistFunction,
deleteFromWishlistFunction: deleteFromWishlistFunction,
notifyMeWhenAvailable: notifyMeWhenAvailable,
addToWishlistFunction: (item) {
addToWishlistFunction(item);
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(item);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(context, itemId);
},
isInWishList: isInWishList,
),
),
@ -392,500 +398,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>
isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction,
),
)
: AppScaffold(
appBarTitle: TranslationBase.of(context).productDetails,
isShowAppBar: true,
isPharmacy: true,
isShowDecPage: false,
showPharmacyCart: false,
showHomeAppBarIcon: false,
body: SingleChildScrollView(
child: Column(
children: [
Container(
width: double.infinity,
color: Colors.white,
child: Column(
children: [
Image.network(
widget.product.images[0].src.trim(),
),
widget.product.discountDescription != null
? Container(
width: double.infinity,
height: 50,
color: Colors.yellowAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Container(
alignment: Alignment.centerRight,
child: projectViewModel.isArabic
? Text(
widget.product
.discountDescriptionn,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 17),
)
: Text(
widget.product
.discountDescription,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 17),
),
),
),
SizedBox(
width: 10,
),
Expanded(
flex: 0,
child: Container(
child: Image(
image: AssetImage(
'assets/images/offer.png'),
),
),
),
],
),
)
: Container(),
],
),
),
SizedBox(
height: 4,
),
Container(
width: 500,
height: 150,
color: Colors.white,
child: ProductNameAndPrice(
context,
widget.product,
customerId: customerId,
addToWishlistFunction: addToWishlistFunction,
deleteFromWishlistFunction: deleteFromWishlistFunction,
notifyMeWhenAvailable: notifyMeWhenAvailable,
isInWishList: isInWishList,
),
),
SizedBox(
height: 6,
),
Container(
width: 500,
height: 120,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Text(
TranslationBase.of(context).specification,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
Divider(color: Colors.grey)
],
),
),
SizedBox(
height: 6,
),
Container(
width: 500,
margin: EdgeInsets.only(bottom: 100),
// height: 350,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
FlatButton(
onPressed: () {
setState(() {
isDetails = true;
isReviews = false;
isAvailability = false;
});
},
child: Text(
TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
),
color: Colors.white,
),
isDetails
? Container(
width: 100,
height: 5,
color: Colors.green,
)
: Container()
],
),
SizedBox(
width: 20,
),
Column(
children: [
FlatButton(
onPressed: () {
setState(() {
isDetails = false;
isReviews = true;
isAvailability = false;
});
},
child: Text(
TranslationBase.of(context).reviews,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
),
color: Colors.white,
),
isReviews
? Container(
width: 100,
height: 5,
color: Colors.green,
)
: Container(),
],
),
SizedBox(
width: 20,
),
Column(
children: [
FlatButton(
onPressed: () {
setState(() {
isDetails = false;
isReviews = false;
isAvailability = true;
});
},
child: Text(
TranslationBase.of(context).availability,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
),
color: Colors.white,
),
isAvailability
? Container(
width: 100,
height: 5,
color: Colors.green,
)
: Container(),
],
),
],
),
SizedBox(
height: 10,
),
isDetails
? Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Text(
TranslationBase.of(context).description,
style: TextStyle(
fontSize: 17,
color: Colors.grey,
fontWeight: FontWeight.w600),
),
),
SizedBox(
height: 6,
),
Divider(height: 1, color: Colors.grey),
SizedBox(
height: 10,
),
Container(
child: Text(
projectViewModel.isArabic
? widget.product.shortDescriptionn
: widget.product.shortDescription,
style: TextStyle(
fontSize: 16,
fontFamily: 'WorkSans-Regular'),
),
),
SizedBox(
height: 10,
),
Container(
child: Text(
TranslationBase.of(context).howToUse,
style: TextStyle(
fontSize: 17,
color: Colors.grey,
fontWeight: FontWeight.w600),
),
),
SizedBox(
height: 6,
),
Divider(height: 2, color: Colors.grey),
SizedBox(
height: 10,
),
Container(
child: Text(
projectViewModel.isArabic
? widget.product.fullDescriptionn
: widget.product.fullDescription,
style: TextStyle(
fontSize: 16,
fontFamily: 'WorkSans-Regular'),
),
),
],
),
)
: isReviews
? BaseView<ProductDetailViewModel>(
onModelReady: (model) =>
model.getProductReviewsData(
widget.product.id),
builder: (_, model, wi) => model
.productDetailService
.length !=
0 &&
model.productDetailService[0]
.reviews.length !=
0
? ListView.builder(
physics: ScrollPhysics(),
itemCount: model
.productDetailService[0]
.reviews
.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (BuildContext context,
int index) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
child: Row(
children: [
Container(
child: Text(
model
.productDetailService[
0]
.reviews[
index]
.customerId
.toString(),
style: TextStyle(
fontSize: 17,
color: Colors
.grey,
fontWeight:
FontWeight
.w600),
),
),
Container(
margin:
EdgeInsets.only(
left: 210),
child: RatingBar
.readOnly(
initialRating: model
.productDetailService[
0]
.reviews[
index]
.rating
.toDouble(),
size: 15.0,
filledColor:
Colors.yellow[
700],
emptyColor: Colors
.grey[500],
isHalfAllowed:
true,
halfFilledIcon:
Icons
.star_half,
filledIcon:
Icons.star,
emptyIcon:
Icons.star,
),
),
],
),
),
SizedBox(
height: 10,
),
Container(
child: Text(
model
.productDetailService[
0]
.reviews[index]
.reviewText,
style: TextStyle(
fontSize: 20),
),
),
SizedBox(
height: 50,
),
Divider(
height: 1,
color: Colors.grey),
],
),
);
},
)
: Container(
padding: EdgeInsets.all(15),
alignment: Alignment.center,
child: Text(
TranslationBase.of(context)
.noReviewsAvailable),
),
)
: isAvailability
? BaseView<ProductDetailViewModel>(
onModelReady: (model) =>
model.getProductLocationData(),
builder: (_, model, wi) =>
ListView.builder(
physics: ScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: model
.productLocationService.length,
itemBuilder: (BuildContext context,
int index) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Expanded(
flex: 1,
child: Image.network(model
.productLocationService[
index]
.projectImageUrl),
),
SizedBox(
width: 10,
),
Expanded(
flex: 4,
child: Text(
model
.productLocationService[
index]
.locationDescription +
"\n" +
convertCityName(
model
.productLocationService[
0]
.cityName
.toString(),
),
style: TextStyle(
fontSize: 12),
),
),
Expanded(
flex: 1,
child: IconButton(
icon: Icon(Icons
.location_on),
color: Colors.red,
onPressed: () {},
),
),
Expanded(
flex: 1,
child: IconButton(
icon:
Icon(Icons.phone),
color: Colors.red,
onPressed: () {},
),
),
],
),
Divider(
height: 1.2,
color: Colors.grey)
],
),
);
},
),
)
: Container(),
],
),
),
],
),
),
bottomSheet: FooterWidget(
widget.product.stockAvailability != 'Out of stock',
widget.product.orderMaximumQuantity,
widget.product.orderMinimumQuantity,
widget.product.stockQuantity,
widget.product,
price: price,
isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction,
),
);
}
}

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -8,6 +9,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
import '../../../../locator.dart';
import 'CustomIcon.dart';
class ProductNameAndPrice extends StatefulWidget {
@ -19,6 +21,9 @@ class ProductNameAndPrice extends StatefulWidget {
final Function addToWishlistFunction;
final Function deleteFromWishlistFunction;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
ProductNameAndPrice(this.context, this.item,
{this.customerId,
this.isInWishList,
@ -46,7 +51,7 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(widget.item.price.toString() + " " + "SAR",
Texts(widget.item.price.toString() + " " + "SR",
fontWeight: FontWeight.bold, fontSize: 20),
Texts(
projectViewModel.isArabic
@ -59,6 +64,7 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
: Colors.green,
),
// SizedBox(width: 20),
if(widget.authenticatedUserObject.isLogin)
widget.item.stockAvailability == 'Out of stock' &&
widget.customerId != null
? InkWell(

@ -15,6 +15,7 @@ class ReviewsInfo extends StatelessWidget {
Widget build(BuildContext context) {
return BaseView<ProductDetailViewModel>(
onModelReady: (model) => model.getProductReviewsData(product.id),
allowAny: true,
builder: (_, model, wi) => NetworkBaseView(
baseViewModel:model ,
child: model.productDetailService.length != 0 &&

Loading…
Cancel
Save