Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into fix_product_tile
Conflicts: lib/pages/pharmacy/profile/profile.dartmerge-requests/421/head
commit
b64a5b29c5
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class IconWithBg extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final Color color;
|
||||||
|
final Function onPress;
|
||||||
|
|
||||||
|
const IconWithBg({Key key, this.icon, this.color, this.onPress})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.only(left: 25),
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(icon),
|
||||||
|
color: color,
|
||||||
|
onPressed: () async {
|
||||||
|
onPress();
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
|
import '../cart-order-page.dart';
|
||||||
|
import 'CustomIcon.dart';
|
||||||
|
|
||||||
|
class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||||
|
@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,
|
||||||
|
color: Colors.grey,
|
||||||
|
onPress: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => CartOrderPage()),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
IconWithBg(
|
||||||
|
icon: FontAwesomeIcons.ellipsisV,
|
||||||
|
color: Colors.grey,
|
||||||
|
onPress: () {
|
||||||
|
//TODO Elham*
|
||||||
|
// settingModalBottomSheet(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement preferredSize
|
||||||
|
@override
|
||||||
|
Size get preferredSize => Size(double.maxFinite, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_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/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AvailabilityInfo extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<ProductDetailViewModel>(
|
||||||
|
onModelReady: (model) => model.getProductLocationData(),
|
||||||
|
|
||||||
|
builder: (_, model, wi) => NetworkBaseView(
|
||||||
|
baseViewModel: model,
|
||||||
|
child: model.productLocationService.length == 0
|
||||||
|
? Container(
|
||||||
|
padding: EdgeInsets.all(15),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
TranslationBase.of(context).noLocationAvailable,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: 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)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DetailsInfo extends StatelessWidget {
|
||||||
|
|
||||||
|
final PharmacyProduct product;
|
||||||
|
|
||||||
|
const DetailsInfo({Key key, this.product}) : super(key: key);
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.description,
|
||||||
|
fontSize: 17,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Divider(height: 1, color: Colors.grey),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: Texts(
|
||||||
|
projectViewModel.isArabic
|
||||||
|
? product.fullDescriptionn
|
||||||
|
: product
|
||||||
|
.fullDescription ??
|
||||||
|
"",
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class DiscountDescription extends StatelessWidget {
|
||||||
|
final PharmacyProduct product;
|
||||||
|
|
||||||
|
const DiscountDescription({Key key, this.product}) : super(key: key);
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return 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: Text(
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,240 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
|
|
||||||
|
import '../../cart-order-page.dart';
|
||||||
|
|
||||||
|
class FooterWidget extends StatefulWidget {
|
||||||
|
final bool isAvailable;
|
||||||
|
final int maxQuantity;
|
||||||
|
final int minQuantity;
|
||||||
|
final int quantityLimit;
|
||||||
|
final PharmacyProduct item;
|
||||||
|
final Function addToCartFunction;
|
||||||
|
|
||||||
|
int price;
|
||||||
|
bool isOverQuantity;
|
||||||
|
|
||||||
|
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
|
||||||
|
this.quantityLimit, this.item,
|
||||||
|
{this.price, this.isOverQuantity = false, this.addToCartFunction});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_FooterWidgetState createState() => _FooterWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FooterWidgetState extends State<FooterWidget> {
|
||||||
|
double quantityUI = 70;
|
||||||
|
bool showUI = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(0.0),
|
||||||
|
),
|
||||||
|
border: Border.all(color: HexColor('#707070'), width: 0),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: quantityUI,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
showUI
|
||||||
|
? Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 100,
|
||||||
|
color: Colors.white,
|
||||||
|
child: Container(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
"Quantity",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
child: Icon(Icons.close, color: Colors.black),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
quantityUI = 70;
|
||||||
|
showUI = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 50.0,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
QuantityBox(
|
||||||
|
label: i,
|
||||||
|
onTapFunc: onChangeValue,
|
||||||
|
isSelected: widget.price == i),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border:
|
||||||
|
Border.all(color: Colors.grey[300]),
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'quantity #'),
|
||||||
|
onChanged: (text) {
|
||||||
|
print(widget.price);
|
||||||
|
print(widget.quantityLimit);
|
||||||
|
if (int.tryParse(text) == null) {
|
||||||
|
text = '';
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
widget.price = int.parse(text);
|
||||||
|
if (widget.price >=
|
||||||
|
widget.quantityLimit) {
|
||||||
|
widget.isOverQuantity = true;
|
||||||
|
} else {
|
||||||
|
widget.isOverQuantity = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 70,
|
||||||
|
height: 50,
|
||||||
|
child: FlatButton(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: Text(
|
||||||
|
widget.price.toString(),
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 5,
|
||||||
|
child: Text(
|
||||||
|
TranslationBase.of(context).quantityShortcut,
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
if (showUI) {
|
||||||
|
quantityUI = 70;
|
||||||
|
showUI = false;
|
||||||
|
} else {
|
||||||
|
quantityUI = 150;
|
||||||
|
showUI = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
borderRadius: 5,
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.3,
|
||||||
|
child: SecondaryButton(
|
||||||
|
label: TranslationBase.of(context).buyNow.toUpperCase(),
|
||||||
|
disabled: !widget.isAvailable && widget.price > 0 ||
|
||||||
|
widget.price > widget.quantityLimit ||
|
||||||
|
widget.item.rxMessage != null,
|
||||||
|
onTap: () {
|
||||||
|
widget.addToCartFunction(
|
||||||
|
widget.price, widget.item.id, context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
FadePage(page: CartOrderPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
borderRadius: 5,
|
||||||
|
color: !widget.isAvailable && widget.price > 0 ||
|
||||||
|
widget.price > widget.quantityLimit ||
|
||||||
|
widget.item.rxMessage != null
|
||||||
|
? Colors.grey
|
||||||
|
: Colors.grey[800],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeValue(int i) {
|
||||||
|
setState(() {
|
||||||
|
///TODO Elham* Check this if its good
|
||||||
|
widget.price = i;
|
||||||
|
if (widget.price >= widget.quantityLimit) {
|
||||||
|
widget.isOverQuantity = true;
|
||||||
|
} else {
|
||||||
|
widget.isOverQuantity = false;
|
||||||
|
return widget.price;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class QuantityBox extends StatelessWidget {
|
||||||
|
final int label;
|
||||||
|
final bool isSelected;
|
||||||
|
final Function(int) onTapFunc;
|
||||||
|
|
||||||
|
QuantityBox({
|
||||||
|
Key key,
|
||||||
|
this.label,
|
||||||
|
this.onTapFunc, this.isSelected = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color:isSelected?Colors.green: Colors.grey[300]),
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
width: 50.0,
|
||||||
|
|
||||||
|
child: Text(
|
||||||
|
'$label',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap:(){
|
||||||
|
onTapFunc(label);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,966 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
||||||
|
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/compare-list.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.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/widgets/data_display/text.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:rating_bar/rating_bar.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
|
||||||
|
import '../cart-order-page.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'ProductAppBar.dart';
|
||||||
|
import 'availability_info.dart';
|
||||||
|
import 'details_info.dart';
|
||||||
|
import 'discount_description.dart';
|
||||||
|
import 'footor/footer-widget.dart';
|
||||||
|
|
||||||
|
int price = 0;
|
||||||
|
bool isOverQuantity = false;
|
||||||
|
bool isInWishList = false;
|
||||||
|
bool isSelected = true;
|
||||||
|
String itemID;
|
||||||
|
var customerId;
|
||||||
|
CompareList compareItems = new CompareList();
|
||||||
|
PharmacyProduct specificationData;
|
||||||
|
|
||||||
|
class ProductDetailPage extends StatefulWidget {
|
||||||
|
final PharmacyProduct product;
|
||||||
|
|
||||||
|
ProductDetailPage(this.product);
|
||||||
|
|
||||||
|
@override
|
||||||
|
__ProductDetailPageState createState() => __ProductDetailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class __ProductDetailPageState extends State<ProductDetailPage>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
TabController _tabController;
|
||||||
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
||||||
|
|
||||||
|
bool isTrue = true;
|
||||||
|
bool isDetails = true;
|
||||||
|
bool isReviews = false;
|
||||||
|
bool isAvailability = false;
|
||||||
|
int _activeTab = 0;
|
||||||
|
|
||||||
|
checkWishlist() async {
|
||||||
|
GifLoaderDialogUtils.showMyDialog(context);
|
||||||
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
||||||
|
await x.checkWishlistData();
|
||||||
|
|
||||||
|
for (int i = 0; i < x.wishListItems.length; i++) {
|
||||||
|
if (itemID == x.wishListItems[i].product.id) {
|
||||||
|
isInWishList = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
isInWishList = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void initState() {
|
||||||
|
price = 1;
|
||||||
|
specificationData = widget.product;
|
||||||
|
_tabController = TabController(length: 3, vsync: this);
|
||||||
|
|
||||||
|
userInfo();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_tabController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void userInfo() async {
|
||||||
|
print(specificationData);
|
||||||
|
customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
||||||
|
if (customerId != null) {
|
||||||
|
itemID = widget.product.id;
|
||||||
|
checkWishlist();
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
final screenSize = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
return customerId != null
|
||||||
|
? AppScaffold(
|
||||||
|
appBarTitle: TranslationBase.of(context).productDetails,
|
||||||
|
isShowAppBar: true,
|
||||||
|
isPharmacy: true,
|
||||||
|
isShowDecPage: false,
|
||||||
|
customAppBar: ProductAppBar(),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: Colors.white,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (widget.product.images.isNotEmpty)
|
||||||
|
Container(
|
||||||
|
height: MediaQuery.of(context).size.height * .40,
|
||||||
|
child: Image.network(
|
||||||
|
widget.product.images[0].src.trim(),
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.product.discountDescription != null)
|
||||||
|
DiscountDescription(product: widget.product)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: ProductNameAndPrice(
|
||||||
|
context,
|
||||||
|
widget.product,
|
||||||
|
customerId: customerId,
|
||||||
|
addToWishlistFunction: addToWishlistFunction,
|
||||||
|
deleteFromWishlistFunction: deleteFromWishlistFunction,
|
||||||
|
notifyMeWhenAvailable: notifyMeWhenAvailable,
|
||||||
|
isInWishList: isInWishList,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 6,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 15, horizontal: 10),
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context).specification,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
),
|
||||||
|
// Divider(color: Colors.grey),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 6,
|
||||||
|
),
|
||||||
|
// Container(
|
||||||
|
// height: 500,
|
||||||
|
// color: Colors.white,
|
||||||
|
// child: Scaffold(
|
||||||
|
// backgroundColor: Colors.white,
|
||||||
|
// extendBodyBehindAppBar: false,
|
||||||
|
// appBar: PreferredSize(
|
||||||
|
// preferredSize: Size.fromHeight(
|
||||||
|
// MediaQuery.of(context).size.height * 0.070),
|
||||||
|
// child: Container(
|
||||||
|
// height: MediaQuery.of(context).size.height * 0.070,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: Border(
|
||||||
|
// bottom: BorderSide(
|
||||||
|
// color: Theme.of(context).dividerColor,
|
||||||
|
// width: 0.5), //width: 0.7
|
||||||
|
// ),
|
||||||
|
// color: Colors.white),
|
||||||
|
// child: Center(
|
||||||
|
// child: TabBar(
|
||||||
|
// isScrollable: false,
|
||||||
|
// controller: _tabController,
|
||||||
|
// // indicatorColor: Colors.transparent,
|
||||||
|
// indicatorWeight: 1.0,
|
||||||
|
// indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
// indicatorColor:Colors.green,
|
||||||
|
// labelColor: Theme.of(context).primaryColor,
|
||||||
|
// labelPadding: EdgeInsets.only(
|
||||||
|
// top: 0, left: 0, right: 0, bottom: 0),
|
||||||
|
// unselectedLabelColor: Colors.grey[800],
|
||||||
|
// tabs: [
|
||||||
|
// tabWidget(screenSize, _activeTab == 0,
|
||||||
|
// TranslationBase.of(context).details,
|
||||||
|
// ),
|
||||||
|
// tabWidget(screenSize, _activeTab == 1,
|
||||||
|
// TranslationBase.of(context).review,
|
||||||
|
// ),
|
||||||
|
// tabWidget(screenSize, _activeTab == 2,
|
||||||
|
// TranslationBase.of(context).availability),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// body: Column(
|
||||||
|
// children: [
|
||||||
|
// Expanded(
|
||||||
|
// child: TabBarView(
|
||||||
|
// physics: BouncingScrollPhysics(),
|
||||||
|
// controller: _tabController,
|
||||||
|
// children: [
|
||||||
|
// DetailsInfo(
|
||||||
|
// product: widget.product,
|
||||||
|
// ),
|
||||||
|
// ReviewsInfo(
|
||||||
|
// product: widget.product,
|
||||||
|
// ),
|
||||||
|
// AvailabilityInfo()
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: 6,
|
||||||
|
),
|
||||||
|
|
||||||
|
//TODO Elham* Remove this
|
||||||
|
Container(
|
||||||
|
// width: 500,
|
||||||
|
margin: EdgeInsets.only(bottom: 6),
|
||||||
|
color: Colors.white,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
CustomDivider(
|
||||||
|
color: isDetails
|
||||||
|
? Colors.green
|
||||||
|
: Colors.transparent,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
CustomDivider(
|
||||||
|
color: isReviews
|
||||||
|
? Colors.green
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
CustomDivider(
|
||||||
|
color: isAvailability
|
||||||
|
? Colors.green
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
isDetails
|
||||||
|
? DetailsInfo(
|
||||||
|
product: widget.product,
|
||||||
|
)
|
||||||
|
: isReviews
|
||||||
|
? ReviewsInfo(
|
||||||
|
product: widget.product,
|
||||||
|
)
|
||||||
|
: isAvailability
|
||||||
|
? AvailabilityInfo()
|
||||||
|
: Container(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
///TODO Elham* check if we need recommanded
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
// customerId != null
|
||||||
|
// ? Container(
|
||||||
|
// width: 410,
|
||||||
|
// height: 50,
|
||||||
|
// color: Colors.white,
|
||||||
|
// child: Texts(
|
||||||
|
// TranslationBase.of(context).recommended,
|
||||||
|
// bold: true,
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : Container(),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// RecommendedProducts(product: widget.product)
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: 80,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: 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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomDivider extends StatelessWidget {
|
||||||
|
const CustomDivider({
|
||||||
|
Key key,
|
||||||
|
this.color,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: 120,
|
||||||
|
height: 2,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
convertCityName(txt) {
|
||||||
|
String stringTxt;
|
||||||
|
String newTxt;
|
||||||
|
stringTxt = txt.toString();
|
||||||
|
newTxt = stringTxt.split('.')[1];
|
||||||
|
|
||||||
|
return newTxt;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToCartFunction(quantity, itemID, BuildContext context) async {
|
||||||
|
GifLoaderDialogUtils.showMyDialog(context);
|
||||||
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
||||||
|
await x.addToCartData(quantity, itemID).then((value) {
|
||||||
|
GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyMeWhenAvailable(context, itemId) async {
|
||||||
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
||||||
|
await x.notifyMe(customerId, itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
addToWishlistFunction(itemID) async {
|
||||||
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
||||||
|
isInWishList = true;
|
||||||
|
await x.addToWishlistData(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteFromWishlistFunction(itemID) async {
|
||||||
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
||||||
|
isInWishList = false;
|
||||||
|
await x.deletWishlistData(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO Elham* move to file
|
||||||
|
Widget tabWidget(
|
||||||
|
Size screenSize,
|
||||||
|
bool isActive,
|
||||||
|
String title,
|
||||||
|
) {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
height: screenSize.height * 0.070,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
title,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 1.5,
|
||||||
|
// color: Color(0xFF2B353E),
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -0,0 +1,192 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:rating_bar/rating_bar.dart';
|
||||||
|
|
||||||
|
import 'CustomIcon.dart';
|
||||||
|
|
||||||
|
class ProductNameAndPrice extends StatefulWidget {
|
||||||
|
BuildContext context;
|
||||||
|
PharmacyProduct item;
|
||||||
|
final customerId;
|
||||||
|
final bool isInWishList;
|
||||||
|
final Function notifyMeWhenAvailable;
|
||||||
|
final Function addToWishlistFunction;
|
||||||
|
final Function deleteFromWishlistFunction;
|
||||||
|
|
||||||
|
ProductNameAndPrice(this.context, this.item,
|
||||||
|
{this.customerId,
|
||||||
|
this.isInWishList,
|
||||||
|
this.notifyMeWhenAvailable,
|
||||||
|
this.addToWishlistFunction,
|
||||||
|
this.deleteFromWishlistFunction});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ProductNameAndPriceState createState() => _ProductNameAndPriceState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.95,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Texts(widget.item.price.toString() + " " + "SAR",
|
||||||
|
fontWeight: FontWeight.bold, fontSize: 20),
|
||||||
|
Texts(
|
||||||
|
projectViewModel.isArabic
|
||||||
|
? widget.item.stockAvailabilityn
|
||||||
|
: widget.item.stockAvailability,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15,
|
||||||
|
color: widget.item.stockAvailability == 'Out of stock'
|
||||||
|
? Colors.red
|
||||||
|
: Colors.green,
|
||||||
|
),
|
||||||
|
// SizedBox(width: 20),
|
||||||
|
widget.item.stockAvailability == 'Out of stock' &&
|
||||||
|
widget.customerId != null
|
||||||
|
? InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
widget.notifyMeWhenAvailable(context, widget.item.id),
|
||||||
|
child: Row(children: [
|
||||||
|
Texts(
|
||||||
|
TranslationBase.of(context).notifyMe,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
Icon(
|
||||||
|
FontAwesomeIcons.bell,
|
||||||
|
color: Colors.blue,
|
||||||
|
size: 15.0,
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
: IconWithBg(
|
||||||
|
icon: !widget.isInWishList
|
||||||
|
? Icons.favorite_border
|
||||||
|
: Icons.favorite,
|
||||||
|
color: !widget.isInWishList ? Colors.white : Colors.red,
|
||||||
|
onPress: () async {
|
||||||
|
{
|
||||||
|
if (widget.customerId != null) {
|
||||||
|
if (!widget.isInWishList) {
|
||||||
|
GifLoaderDialogUtils.showMyDialog(context);
|
||||||
|
await widget
|
||||||
|
.addToWishlistFunction(widget.item.id);
|
||||||
|
GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
} else {
|
||||||
|
await widget
|
||||||
|
.deleteFromWishlistFunction(widget.item.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.only(left: 5),
|
||||||
|
child: Align(
|
||||||
|
alignment: projectViewModel.isArabic
|
||||||
|
? Alignment.topRight
|
||||||
|
: Alignment.topLeft,
|
||||||
|
child: Text(
|
||||||
|
projectViewModel.isArabic
|
||||||
|
? widget.item.namen
|
||||||
|
: widget.item.name,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.95,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
RatingBar.readOnly(
|
||||||
|
initialRating: double.parse(
|
||||||
|
widget.item.approvedRatingSum.toString()),
|
||||||
|
size: 15.0,
|
||||||
|
filledColor: Colors.yellow[700],
|
||||||
|
emptyColor: Colors.grey[400],
|
||||||
|
isHalfAllowed: true,
|
||||||
|
halfFilledIcon: Icons.star_half,
|
||||||
|
filledIcon: Icons.star,
|
||||||
|
emptyIcon: Icons.star,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
"${widget.item.approvedRatingSum}",
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 30,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
"(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})",
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Container(
|
||||||
|
child: widget.item.rxMessage != null
|
||||||
|
? Text(
|
||||||
|
projectViewModel.isArabic
|
||||||
|
? widget.item.rxMessagen.toString()
|
||||||
|
: widget.item.rxMessage.toString(),
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 10),
|
||||||
|
)
|
||||||
|
: Container()),
|
||||||
|
),
|
||||||
|
widget.item.rxMessage != null
|
||||||
|
? Icon(
|
||||||
|
FontAwesomeIcons.questionCircle,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 15.0,
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,388 @@
|
|||||||
|
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/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/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;
|
||||||
|
|
||||||
|
const RecommendedProducts({Key key, this.product}) : 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(
|
||||||
|
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) => Container(
|
||||||
|
child:
|
||||||
|
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 (customerId !=
|
||||||
|
null) {
|
||||||
|
if (!isInWishList &&
|
||||||
|
model.recommendedProductList[index].isinwishlist !=
|
||||||
|
true) {
|
||||||
|
GifLoaderDialogUtils.showMyDialog(
|
||||||
|
context);
|
||||||
|
await addToWishlistFunction(model
|
||||||
|
.recommendedProductList[index]
|
||||||
|
.id);
|
||||||
|
// checkWishlist();
|
||||||
|
GifLoaderDialogUtils.hideDialog(
|
||||||
|
context);
|
||||||
|
setState(
|
||||||
|
() {
|
||||||
|
model.recommendedProductList[index].isinwishlist =
|
||||||
|
true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
GifLoaderDialogUtils.showMyDialog(
|
||||||
|
context);
|
||||||
|
await deleteFromWishlistFunction(model
|
||||||
|
.recommendedProductList[index]
|
||||||
|
.id);
|
||||||
|
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,96 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rating_bar/rating_bar.dart';
|
||||||
|
|
||||||
|
class ReviewsInfo extends StatelessWidget {
|
||||||
|
final PharmacyProduct product;
|
||||||
|
|
||||||
|
const ReviewsInfo({Key key, this.product}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<ProductDetailViewModel>(
|
||||||
|
onModelReady: (model) => model.getProductReviewsData(product.id),
|
||||||
|
builder: (_, model, wi) => NetworkBaseView(
|
||||||
|
baseViewModel:model ,
|
||||||
|
child: 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,
|
||||||
|
),
|
||||||
|
// Text('No Reviews Available'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
class AccountItem extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String itemIcon;
|
||||||
|
final bool isTerms;
|
||||||
|
|
||||||
|
const AccountItem({this.title, this.itemIcon, this.isTerms = false});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
isTerms == false
|
||||||
|
? Container(
|
||||||
|
height: 35.0,
|
||||||
|
width: 35.0,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
'$itemIcon',
|
||||||
|
width: 35,
|
||||||
|
height: 35,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
height: 35.0,
|
||||||
|
width: 35.0,
|
||||||
|
child: Image.asset(
|
||||||
|
'$itemIcon',
|
||||||
|
width: 35,
|
||||||
|
height: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
title,
|
||||||
|
fontSize: 15.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
class AccountServices extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String serviceImage;
|
||||||
|
final Function onTap;
|
||||||
|
|
||||||
|
const AccountServices({this.title, this.onTap, this.serviceImage});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Expanded(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
// () {
|
||||||
|
// if (customerId == null) {
|
||||||
|
// AppToast.showErrorToast(
|
||||||
|
// message: "Customer not found");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// Navigator.push(
|
||||||
|
// context,
|
||||||
|
// FadePage(
|
||||||
|
// page: OrderPage(
|
||||||
|
// customerID: customerId)));
|
||||||
|
// },
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
// Image(image: AssetImage('assets/images/pharmacy/orders_icon.svg')),
|
||||||
|
SvgPicture.asset(
|
||||||
|
'$serviceImage',
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 7,
|
||||||
|
),
|
||||||
|
Texts(
|
||||||
|
title,
|
||||||
|
fontSize: 15.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue