Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into fatima-new
# Conflicts: # lib/config/config.dart # lib/pages/parent_categorise_page.dart # lib/pages/pharmacies/screens/pharmacy_module_page.dart # lib/pages/pharmacies/wishlist.dartmerge-requests/425/head
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,26 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class BestSellerViewModel extends BaseViewModel {
|
||||
|
||||
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
|
||||
|
||||
List<PharmacyProduct> get bestSellerProduct =>
|
||||
_pharmacyService.bestSellerProducts;
|
||||
|
||||
getBestSellerProducts() async {
|
||||
setState(ViewState.BusyLocal);
|
||||
await _pharmacyService.getBestSellerProducts();
|
||||
// if (_pharmacyService.hasError) {
|
||||
// error = _pharmacyService.error;
|
||||
// setState(ViewState.Error);
|
||||
// } else {
|
||||
setState(ViewState.Idle);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class BrandViewModel extends BaseViewModel {
|
||||
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
|
||||
|
||||
List<Manufacturer> get manufacturerList => _pharmacyService.manufacturerList;
|
||||
|
||||
Future getTopManufacturerList() async {
|
||||
setState(ViewState.BusyLocal);
|
||||
await _pharmacyService.getTopManufacturerList();
|
||||
// if (_pharmacyService.hasError) {
|
||||
// error = _pharmacyService.error;
|
||||
// setState(ViewState.Error);
|
||||
// } else {
|
||||
setState(ViewState.Idle);
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class LastVisitedViewModel extends BaseViewModel {
|
||||
|
||||
PharmacyModuleService _pharmacyService = locator<PharmacyModuleService>();
|
||||
|
||||
List<PharmacyProduct> get lastVisitedProducts =>
|
||||
_pharmacyService.lastVisitedProducts;
|
||||
|
||||
getLastVisitedProducts() async {
|
||||
setState(ViewState.BusyLocal);
|
||||
await _pharmacyService.getLastVisitedProducts();
|
||||
// if (_pharmacyService.hasError) {
|
||||
// error = _pharmacyService.error;
|
||||
// setState(ViewState.Error);
|
||||
// } else {
|
||||
setState(ViewState.Idle);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class PrescriptionViewModel extends BaseViewModel {
|
||||
|
||||
PrescriptionService _prescriptionService = locator<PrescriptionService>();
|
||||
|
||||
List<Prescriptions> get prescriptionsList =>
|
||||
_prescriptionService.prescriptionsList;
|
||||
|
||||
getPrescription() async {
|
||||
await getSavedLanguage();
|
||||
if(prescriptionsList.isNotEmpty){
|
||||
setState(ViewState.Busy);
|
||||
await _prescriptionService.getPrescription();
|
||||
if (_prescriptionService.hasError) {
|
||||
error = _prescriptionService.error;
|
||||
setState(ViewState.Error);
|
||||
} else {
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/locator.dart';
|
||||
|
||||
class ProductCategoriesViewModel extends BaseViewModel {
|
||||
bool hasError = false;
|
||||
|
||||
PharmacyCategoriseService _pharmacyCategoriseService =
|
||||
locator<PharmacyCategoriseService>();
|
||||
|
||||
List<PharmacyCategorise> get categorise =>
|
||||
_pharmacyCategoriseService.categoriseList;
|
||||
|
||||
Future getCategorise() async {
|
||||
hasError = false;
|
||||
// _insuranceCardService.clearInsuranceCard();
|
||||
setState(ViewState.Busy);
|
||||
await _pharmacyCategoriseService.getCategorise();
|
||||
if (_pharmacyCategoriseService.hasError) {
|
||||
error = _pharmacyCategoriseService.error;
|
||||
setState(ViewState.ErrorLocal);
|
||||
} else
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
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 {
|
||||
final ProductDetailViewModel previousModel;
|
||||
|
||||
const AvailabilityInfo({Key key, this.previousModel}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return previousModel.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: previousModel.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(previousModel
|
||||
.productLocationService[index].projectImageUrl),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
previousModel.productLocationService[index]
|
||||
.locationDescription +
|
||||
"\n" +
|
||||
convertCityName(
|
||||
previousModel.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)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
convertCityName(txt) {
|
||||
String stringTxt;
|
||||
String newTxt;
|
||||
stringTxt = txt.toString();
|
||||
newTxt = stringTxt.split('.')[1];
|
||||
|
||||
return newTxt;
|
||||
}
|
||||
}
|
||||
@ -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,47 @@
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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,252 @@
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.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 '../../../../../locator.dart';
|
||||
import '../../../../../routes.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 quantity;
|
||||
bool isOverQuantity;
|
||||
|
||||
FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity,
|
||||
this.quantityLimit, this.item,
|
||||
{this.quantity, this.isOverQuantity = false, this.addToCartFunction});
|
||||
|
||||
@override
|
||||
_FooterWidgetState createState() => _FooterWidgetState();
|
||||
}
|
||||
|
||||
class _FooterWidgetState extends State<FooterWidget> {
|
||||
double quantityUI = 80;
|
||||
bool showUI = false;
|
||||
AuthenticatedUserObject authenticatedUserObject =
|
||||
locator<AuthenticatedUserObject>();
|
||||
|
||||
@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 = 80;
|
||||
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.quantity == 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.quantity);
|
||||
print(widget.quantityLimit);
|
||||
if (int.tryParse(text) == null) {
|
||||
text = '';
|
||||
} else {
|
||||
setState(() {
|
||||
widget.quantity = int.parse(text);
|
||||
if (widget.quantity >=
|
||||
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.quantity.toString(),
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
TranslationBase.of(context).quantityShortcut,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (showUI) {
|
||||
quantityUI = 80;
|
||||
showUI = false;
|
||||
} else {
|
||||
quantityUI = 150;
|
||||
showUI = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.45,
|
||||
child: SecondaryButton(
|
||||
label: TranslationBase.of(context).addToCart.toUpperCase(),
|
||||
disabled: !widget.isAvailable && widget.quantity > 0 ||
|
||||
widget.quantity > widget.quantityLimit ||
|
||||
widget.item.rxMessage != null,
|
||||
disableColor: Color(0xFF4CAF50),
|
||||
onTap: () async {
|
||||
if (!authenticatedUserObject.isLogin) {
|
||||
Navigator.of(context).pushNamed(
|
||||
WELCOME_LOGIN,
|
||||
);
|
||||
} else
|
||||
await widget.addToCartFunction(
|
||||
widget.quantity, widget.item.id, context);
|
||||
},
|
||||
borderColor: Color(0xFF4CAF50),
|
||||
borderRadius: 5,
|
||||
color: Color(0xFF4CAF50),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.35,
|
||||
child: SecondaryButton(
|
||||
label: TranslationBase.of(context).buyNow.toUpperCase(),
|
||||
disabled: !widget.isAvailable && widget.quantity > 0 ||
|
||||
widget.quantity > widget.quantityLimit ||
|
||||
widget.item.rxMessage != null,
|
||||
onTap: () async {
|
||||
await widget.addToCartFunction(
|
||||
widget.quantity, widget.item.id, context);
|
||||
Navigator.push(
|
||||
context,
|
||||
FadePage(page: CartOrderPage()),
|
||||
);
|
||||
},
|
||||
borderRadius: 5,
|
||||
disableColor: Colors.grey[700],
|
||||
color: !widget.isAvailable && widget.quantity > 0 ||
|
||||
widget.quantity > widget.quantityLimit ||
|
||||
widget.item.rxMessage != null
|
||||
? Colors.grey
|
||||
: Colors.grey[800],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
onChangeValue(int i) {
|
||||
setState(() {
|
||||
widget.quantity = i;
|
||||
if (widget.quantity >= widget.quantityLimit) {
|
||||
widget.isOverQuantity = true;
|
||||
} else {
|
||||
widget.isOverQuantity = false;
|
||||
return widget.quantity;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -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,356 @@
|
||||
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/product_detail_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/reviews_info.dart';
|
||||
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.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:flutter/material.dart';
|
||||
|
||||
import 'availability_info.dart';
|
||||
import 'details_info.dart';
|
||||
import 'discount_description.dart';
|
||||
import 'footor/footer-widget.dart';
|
||||
import 'shared/product_details_app_bar.dart';
|
||||
|
||||
String itemID;
|
||||
PharmacyProduct specificationData;
|
||||
|
||||
class ProductDetailPage extends StatefulWidget {
|
||||
final PharmacyProduct product;
|
||||
|
||||
ProductDetailPage(this.product);
|
||||
|
||||
@override
|
||||
__ProductDetailPageState createState() => __ProductDetailPageState();
|
||||
}
|
||||
|
||||
class __ProductDetailPageState extends State<ProductDetailPage> {
|
||||
AppSharedPreferences sharedPref = AppSharedPreferences();
|
||||
|
||||
bool isTrue = true;
|
||||
bool isDetails = true;
|
||||
bool isReviews = false;
|
||||
bool isAvailability = false;
|
||||
String customerId;
|
||||
bool isSelected = true;
|
||||
bool isOverQuantity = false;
|
||||
bool isInWishList = false;
|
||||
int quantity = 0;
|
||||
|
||||
checkWishlist() async {
|
||||
GifLoaderDialogUtils.showMyDialog(context);
|
||||
ProductDetailViewModel model = new ProductDetailViewModel();
|
||||
await model.checkWishlistData();
|
||||
|
||||
for (int i = 0; i < model.wishListItems.length; i++) {
|
||||
if (itemID == model.wishListItems[i].product.id) {
|
||||
isInWishList = true;
|
||||
break;
|
||||
} else {
|
||||
isInWishList = false;
|
||||
}
|
||||
}
|
||||
GifLoaderDialogUtils.hideDialog(context);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void initState() {
|
||||
quantity = 1;
|
||||
specificationData = widget.product;
|
||||
|
||||
userInfo();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void 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) {
|
||||
return BaseView<ProductDetailViewModel>(
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => AppScaffold(
|
||||
appBarTitle: TranslationBase.of(context).productDetails,
|
||||
isShowAppBar: true,
|
||||
isPharmacy: true,
|
||||
isShowDecPage: false,
|
||||
customAppBar: ProductAppBar(
|
||||
product: widget.product,
|
||||
quantity: quantity,
|
||||
model: model,
|
||||
addToWishlistFunction: () async {
|
||||
await addToWishlistFunction(itemID: itemID, model: model);
|
||||
},
|
||||
deleteFromWishlistFunction: () async {
|
||||
await deleteFromWishlistFunction(itemID: itemID, model: model);
|
||||
},
|
||||
isInWishList:isInWishList
|
||||
),
|
||||
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: (item) {
|
||||
addToWishlistFunction(itemID: item, model: model);
|
||||
setState(() {});
|
||||
},
|
||||
deleteFromWishlistFunction: (item) {
|
||||
deleteFromWishlistFunction(
|
||||
itemID: item, model: model);
|
||||
setState(() {});
|
||||
},
|
||||
notifyMeWhenAvailable: (context, itemId) {
|
||||
notifyMeWhenAvailable(
|
||||
itemId: itemId,
|
||||
customerId: customerId,
|
||||
model: model);
|
||||
},
|
||||
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(
|
||||
// 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: () async {
|
||||
if (widget.product.approvedTotalReviews >
|
||||
0) {
|
||||
GifLoaderDialogUtils.showMyDialog(
|
||||
context);
|
||||
await model.getProductReviewsData(
|
||||
widget.product.id);
|
||||
GifLoaderDialogUtils.hideDialog(
|
||||
context);
|
||||
} else {
|
||||
model.clearReview();
|
||||
}
|
||||
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: () async {
|
||||
GifLoaderDialogUtils.showMyDialog(
|
||||
context);
|
||||
await model.getProductLocationData();
|
||||
GifLoaderDialogUtils.hideDialog(context);
|
||||
|
||||
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,
|
||||
previousModel: model,
|
||||
)
|
||||
: isAvailability
|
||||
? AvailabilityInfo(
|
||||
previousModel: model,
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 80,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomSheet: FooterWidget(
|
||||
widget.product.stockAvailability != 'Out of stock',
|
||||
widget.product.orderMaximumQuantity,
|
||||
widget.product.orderMinimumQuantity,
|
||||
widget.product.stockQuantity,
|
||||
widget.product,
|
||||
quantity: quantity,
|
||||
isOverQuantity: isOverQuantity,
|
||||
addToCartFunction: addToCartFunction,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
|
||||
isInWishList = true;
|
||||
await model.addToWishlistData(itemID);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
|
||||
isInWishList = false;
|
||||
await model.deleteWishlistData(itemID);
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
addToCartFunction(
|
||||
{quantity,
|
||||
itemID,
|
||||
BuildContext context,
|
||||
ProductDetailViewModel model}) async {
|
||||
GifLoaderDialogUtils.showMyDialog(context);
|
||||
await model.addToCartData(quantity, itemID);
|
||||
GifLoaderDialogUtils.hideDialog(context);
|
||||
}
|
||||
|
||||
notifyMeWhenAvailable(
|
||||
{itemId, customerId, ProductDetailViewModel model}) async {
|
||||
await model.notifyMe(customerId, itemId);
|
||||
}
|
||||
@ -0,0 +1,203 @@
|
||||
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';
|
||||
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 '../../../../locator.dart';
|
||||
import 'shared/icon_with_bg.dart';
|
||||
|
||||
class ProductNameAndPrice extends StatefulWidget {
|
||||
BuildContext context;
|
||||
PharmacyProduct item;
|
||||
final customerId;
|
||||
final bool isInWishList;
|
||||
final Function notifyMeWhenAvailable;
|
||||
final Function addToWishlistFunction;
|
||||
final Function deleteFromWishlistFunction;
|
||||
|
||||
AuthenticatedUserObject authenticatedUserObject =
|
||||
locator<AuthenticatedUserObject>();
|
||||
|
||||
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() + " " + "SR",
|
||||
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),
|
||||
if (widget.authenticatedUserObject.isLogin)
|
||||
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[800],
|
||||
onPress: () async {
|
||||
{
|
||||
if (widget.customerId != null) {
|
||||
if (!widget.isInWishList) {
|
||||
|
||||
await widget
|
||||
.addToWishlistFunction(widget.item.id);
|
||||
|
||||
} 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,
|
||||
),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
),
|
||||
if (widget.item.rxMessage != null)
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
projectViewModel.isArabic
|
||||
? widget.item.rxMessagen.toString()
|
||||
: widget.item.rxMessage.toString(),
|
||||
style: TextStyle(color: Colors.red, fontSize: 10),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Icon(
|
||||
FontAwesomeIcons.questionCircle,
|
||||
color: Colors.red,
|
||||
size: 15.0,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rating_bar/rating_bar.dart';
|
||||
|
||||
class ReviewsInfo extends StatelessWidget {
|
||||
final PharmacyProduct product;
|
||||
final ProductDetailViewModel previousModel;
|
||||
|
||||
const ReviewsInfo({Key key, this.product, this.previousModel})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return previousModel.productDetailService.length != 0 &&
|
||||
previousModel.productDetailService[0].reviews.length != 0
|
||||
? ListView.builder(
|
||||
physics: ScrollPhysics(),
|
||||
itemCount: previousModel.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(
|
||||
previousModel.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: previousModel
|
||||
.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(
|
||||
previousModel
|
||||
.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,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
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(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
icon: Icon(icon, size: 20,),
|
||||
color: color,
|
||||
onPressed: () async {
|
||||
onPress();
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,182 @@
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.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: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 '../../../../../locator.dart';
|
||||
import '../../../compare-list.dart';
|
||||
import '../../cart-order-page.dart';
|
||||
import 'icon_with_bg.dart';
|
||||
|
||||
class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
|
||||
final PharmacyProduct product;
|
||||
|
||||
final ProductDetailViewModel model;
|
||||
final Function addToWishlistFunction;
|
||||
final Function deleteFromWishlistFunction;
|
||||
final int quantity;
|
||||
final bool isInWishList;
|
||||
|
||||
ProductAppBar(
|
||||
{Key key,
|
||||
this.product,
|
||||
this.model,
|
||||
this.addToWishlistFunction,
|
||||
this.quantity,
|
||||
this.deleteFromWishlistFunction,
|
||||
this.isInWishList})
|
||||
: super(key: key);
|
||||
|
||||
AuthenticatedUserObject authenticatedUserObject =
|
||||
locator<AuthenticatedUserObject>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: 0.95,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
IconWithBg(
|
||||
icon: Icons.arrow_back,
|
||||
color: Colors.grey,
|
||||
onPress: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (authenticatedUserObject.isLogin)
|
||||
Row(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
IconWithBg(
|
||||
icon: Icons.shopping_cart,
|
||||
color: Colors.grey[800],
|
||||
onPress: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CartOrderPage()),
|
||||
);
|
||||
}),
|
||||
|
||||
if(Provider.of<OrderPreviewViewModel>(context, listen: false).cartResponse.quantityCount !=0)
|
||||
Positioned(
|
||||
top:0, right: -1.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
|
||||
),
|
||||
padding: EdgeInsets.only(left: 5, right: 4.5),
|
||||
height: 18,
|
||||
child: Center(child: Texts(Provider.of<OrderPreviewViewModel>(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
IconWithBg(
|
||||
icon: FontAwesomeIcons.ellipsisV,
|
||||
color: Colors.grey,
|
||||
onPress: () {
|
||||
settingModalBottomSheet(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@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: () async {
|
||||
if (quantity > 0) {
|
||||
{
|
||||
await addToCartFunction(
|
||||
quantity: quantity,
|
||||
itemID: itemID,
|
||||
context: context,
|
||||
model: model);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
AppToast.showErrorToast(
|
||||
message: "you should add quantity");
|
||||
}
|
||||
}),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
!isInWishList ? Icons.favorite_border : Icons.favorite,
|
||||
color: !isInWishList ? Colors.white : Colors.red[800],
|
||||
),
|
||||
title: Text(
|
||||
isInWishList
|
||||
? TranslationBase.of(context).removeFromWishlist
|
||||
: TranslationBase.of(context).addToWishlist,
|
||||
),
|
||||
onTap: () async {
|
||||
if (isInWishList)
|
||||
await deleteFromWishlistFunction();
|
||||
else
|
||||
await addToWishlistFunction();
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
ListTile(
|
||||
leading: Icon(Icons.compare),
|
||||
title: Text(
|
||||
TranslationBase.of(context).compare,
|
||||
),
|
||||
onTap: () {
|
||||
Provider.of<CompareList>(context, listen: false)
|
||||
.addItem(specificationData);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.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 '../../../final_products_page.dart';
|
||||
import '../ProductTileItem.dart';
|
||||
import 'ViewAllHomeWidget.dart';
|
||||
|
||||
class BestSellerWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<BestSellerViewModel>(
|
||||
onModelReady: (model) => model.getBestSellerProducts(),
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => NetworkBaseView(
|
||||
isLocalLoader: true,
|
||||
baseViewModel: model,
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
ViewAllHomeWidget(
|
||||
TranslationBase.of(context).bestSellers,
|
||||
FinalProductsPage(
|
||||
id: "",
|
||||
productType: 20,
|
||||
)),
|
||||
if (model.state != ViewState.BusyLocal)
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height / 3 + 20,
|
||||
child: ListView.builder(
|
||||
itemBuilder: (ctx, i) =>
|
||||
ProductTileItem(model.bestSellerProduct[i], MediaQuery.of(context).size.height / 4 + 20),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: model.bestSellerProduct.length,
|
||||
),
|
||||
) else
|
||||
Container(
|
||||
height: 80,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.grey[500],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/landing/home_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../offers_categorise_page.dart';
|
||||
import 'GridViewCard.dart';
|
||||
|
||||
class GridViewButtons extends StatelessWidget {
|
||||
final PharmacyModuleViewModel model;
|
||||
|
||||
GridViewButtons(this.model);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8;
|
||||
return Container(
|
||||
child: SizedBox(
|
||||
height: gridHeight,
|
||||
child: GridView.count(
|
||||
childAspectRatio: 2.2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
controller: new ScrollController(keepScrollOffset: false),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
crossAxisCount: 2,
|
||||
children: [
|
||||
DashboardItem(
|
||||
imageName: 'pharmacy_module/bg_1.png',
|
||||
hasColorFilter: false,
|
||||
opacity: 0.8,
|
||||
child: GridViewCard(
|
||||
TranslationBase.of(context).offersAndPromotions,
|
||||
'assets/images/pharmacy_module/offer_icon.png', () {
|
||||
Navigator.push(context, FadePage(page: OffersCategorisePage()));
|
||||
}),
|
||||
),
|
||||
DashboardItem(
|
||||
imageName: 'pharmacy_module/bg_2.png',
|
||||
opacity: 0,
|
||||
hasColorFilter: false,
|
||||
child: GridViewCard(TranslationBase.of(context).medicationRefill,
|
||||
'assets/images/pharmacy_module/medication_icon.png', () {
|
||||
// model.checkUserIsActivated().then((isActivated) {
|
||||
// if (isActivated) {
|
||||
// Navigator.push(context, FadePage(page: LakumMainPage()));
|
||||
// } else {
|
||||
// Navigator.push(
|
||||
// context, FadePage(page: LakumActivationVidaPage()));
|
||||
// }
|
||||
// });
|
||||
}),
|
||||
),
|
||||
DashboardItem(
|
||||
imageName: 'pharmacy_module/bg_3.png',
|
||||
opacity: 0,
|
||||
hasColorFilter: false,
|
||||
child: GridViewCard(TranslationBase.of(context).myPrescriptions,
|
||||
'assets/images/pharmacy_module/prescription_icon.png', () {
|
||||
Navigator.push(
|
||||
context, FadePage(page: HomePrescriptionsPage()));
|
||||
}),
|
||||
),
|
||||
DashboardItem(
|
||||
imageName: 'pharmacy_module/bg_4.png',
|
||||
opacity: 0,
|
||||
hasColorFilter: false,
|
||||
child: GridViewCard(
|
||||
TranslationBase.of(context).searchAndScanMedication,
|
||||
'assets/images/pharmacy_module/search_scan_icon.png',
|
||||
() {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GridViewCard extends StatelessWidget {
|
||||
final String text;
|
||||
final String cardImage;
|
||||
final Function handler;
|
||||
|
||||
GridViewCard(this.text, this.cardImage, this.handler);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Column(
|
||||
children: [
|
||||
Texts(
|
||||
text,
|
||||
color: Colors.white,
|
||||
bold: true,
|
||||
fontSize: SizeConfig.textMultiplier * 1.5,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
BorderedButton(
|
||||
TranslationBase.of(context).viewAll,
|
||||
handler: handler,
|
||||
tPadding: 0,
|
||||
textColor: Color(0xFF5ab145),
|
||||
bPadding: 0,
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Image.asset(
|
||||
cardImage,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String getDate(String date) {
|
||||
DateTime dateObj = DateUtil.convertStringToDate(date);
|
||||
return DateUtil.getWeekDay(dateObj.weekday) +
|
||||
", " +
|
||||
dateObj.day.toString() +
|
||||
" " +
|
||||
DateUtil.getMonth(dateObj.month) +
|
||||
" " +
|
||||
dateObj.year.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,233 @@
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rating_bar/rating_bar.dart';
|
||||
|
||||
class PrescriptionsWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<PrescriptionViewModel>(
|
||||
onModelReady: (model) async {
|
||||
if (Provider.of<ProjectViewModel>(context, listen: false).isLogin) {
|
||||
model.getPrescription();
|
||||
}
|
||||
},
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => model.prescriptionsList.length > 0
|
||||
? NetworkBaseView(
|
||||
isLocalLoader: true,
|
||||
baseViewModel: model,
|
||||
child: Container(
|
||||
height: model.prescriptionsList.length > 0
|
||||
? MediaQuery.of(context).size.height * 0.28
|
||||
: 0,
|
||||
child: Column(
|
||||
children: [
|
||||
ViewAllHomeWidget(
|
||||
TranslationBase.of(context).myPrescription,
|
||||
HomePrescriptionsPage()),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 18.0, vertical: 14.0),
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: ScrollPhysics(),
|
||||
// physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: model.prescriptionsList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.3,
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 5.0, left: 5.0, right: 8.0),
|
||||
margin: EdgeInsets.only(right: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
style: BorderStyle.solid,
|
||||
width: 1.0,
|
||||
),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10.0)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Column(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10.0,
|
||||
left: 10.0,
|
||||
right: 10.0,
|
||||
bottom: 15.0,
|
||||
),
|
||||
child: CircleAvatar(
|
||||
radius: 30,
|
||||
backgroundColor:
|
||||
Colors.transparent,
|
||||
child: Image.network(
|
||||
model.prescriptionsList[index]
|
||||
.doctorImageURL,
|
||||
width: 60,
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
margin:
|
||||
EdgeInsets.only(left: 1),
|
||||
padding: EdgeInsets.only(
|
||||
left: 15.0, right: 15.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.green,
|
||||
style: BorderStyle.solid,
|
||||
width: 4.0,
|
||||
),
|
||||
color: Colors.green,
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
30.0)),
|
||||
child: Text(
|
||||
model.languageID == "ar"
|
||||
? model
|
||||
.prescriptionsList[
|
||||
index]
|
||||
.isInOutPatientDescriptionN
|
||||
.toString()
|
||||
: model
|
||||
.prescriptionsList[
|
||||
index]
|
||||
.isInOutPatientDescription
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15.0,
|
||||
),
|
||||
)),
|
||||
Row(children: <Widget>[
|
||||
Image.asset(
|
||||
'assets/images/Icon-awesome-calendar.png',
|
||||
width: 30,
|
||||
height: 30,
|
||||
),
|
||||
Text(
|
||||
DateUtil.convertStringToDate(
|
||||
model
|
||||
.prescriptionsList[
|
||||
index]
|
||||
.appointmentDate
|
||||
.toString())
|
||||
.toString()
|
||||
.substring(0, 10),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 15.0,
|
||||
),
|
||||
)
|
||||
]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 5),
|
||||
child: Row(children: <Widget>[
|
||||
Text(
|
||||
model.prescriptionsList[index]
|
||||
.doctorTitle
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
model.prescriptionsList[index]
|
||||
.doctorName
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
model.prescriptionsList[index]
|
||||
.clinicDescription
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 15.0,
|
||||
// fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 5),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: RatingBar.readOnly(
|
||||
initialRating: model
|
||||
.prescriptionsList[index]
|
||||
.actualDoctorRate
|
||||
.toDouble(),
|
||||
// initialRating: productRate,
|
||||
size: 15.0,
|
||||
filledColor: Colors.yellow[700],
|
||||
emptyColor: Colors.grey[500],
|
||||
isHalfAllowed: true,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star,
|
||||
),
|
||||
),
|
||||
)
|
||||
]),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.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 '../../../final_products_page.dart';
|
||||
import '../ProductTileItem.dart';
|
||||
import 'ViewAllHomeWidget.dart';
|
||||
|
||||
class RecentlyViewedWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<LastVisitedViewModel>(
|
||||
onModelReady: (model) => model.getLastVisitedProducts(),
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => NetworkBaseView(
|
||||
isLocalLoader: true,
|
||||
baseViewModel: model,
|
||||
child: model.lastVisitedProducts.isNotEmpty ? Container(
|
||||
child: Column(
|
||||
children: [
|
||||
ViewAllHomeWidget(
|
||||
TranslationBase.of(context).recentlyViewed,
|
||||
FinalProductsPage(
|
||||
id: "",
|
||||
productType: 3,
|
||||
)),
|
||||
if (model.state != ViewState.BusyLocal)
|
||||
Container(
|
||||
height: model.lastVisitedProducts.length > 0
|
||||
? MediaQuery.of(context).size.height / 3 + 20
|
||||
: 0,
|
||||
child: ListView.builder(
|
||||
itemBuilder: (ctx, i) =>
|
||||
ProductTileItem(model.lastVisitedProducts[i], MediaQuery.of(context).size.height / 4 + 20),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: model.lastVisitedProducts.length,
|
||||
),
|
||||
)
|
||||
else
|
||||
Container(
|
||||
height: 80,
|
||||
child: Center(
|
||||
child:CircularProgressIndicator(
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.grey[500],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
) : Container(),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.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 '../../product-brands.dart';
|
||||
import '../manufacturerItem.dart';
|
||||
import 'ViewAllHomeWidget.dart';
|
||||
|
||||
class ShopByBrandWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<BrandViewModel>(
|
||||
onModelReady: (model) => model.getTopManufacturerList(),
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => NetworkBaseView(
|
||||
isLocalLoader: true,
|
||||
baseViewModel: model,
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
ViewAllHomeWidget(TranslationBase.of(context).shopByBrands,
|
||||
ProductBrandsPage()),
|
||||
if (model.state != ViewState.BusyLocal)
|
||||
Container(
|
||||
height: 150,
|
||||
child: ListView.builder(
|
||||
itemBuilder: (ctx, i) =>
|
||||
ManufacturerItem(model.manufacturerList[i]),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: model.manufacturerList.length,
|
||||
),
|
||||
)
|
||||
else
|
||||
Container(
|
||||
height: 80,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.grey[500],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ViewAllHomeWidget extends StatelessWidget {
|
||||
|
||||
final String title;
|
||||
final Widget navigationWidget;
|
||||
|
||||
|
||||
ViewAllHomeWidget(this.title, this.navigationWidget);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.fromLTRB(16, 10, 16, 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Texts(
|
||||
title,
|
||||
bold: true,
|
||||
fontSize: 16,
|
||||
),
|
||||
BorderedButton(
|
||||
TranslationBase.of(context).viewAll,
|
||||
hasBorder: true,
|
||||
borderColor: Colors.green,
|
||||
textColor: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
vPadding: 6,
|
||||
hPadding: 14,
|
||||
handler: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
navigationWidget));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,236 +0,0 @@
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart';
|
||||
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
|
||||
import 'package:diplomaticquarterapp/routes.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../locator.dart';
|
||||
import 'floating_button_search.dart';
|
||||
import '../progress_indicator/app_loader_widget.dart';
|
||||
import 'arrow_back.dart';
|
||||
import 'network_base_view.dart';
|
||||
import 'not_auh_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart';
|
||||
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
|
||||
|
||||
class DetailPageScafold extends StatefulWidget {
|
||||
final String appBarTitle;
|
||||
final Widget body;
|
||||
final Widget bottomSheet;
|
||||
final bool isLoading;
|
||||
final bool isShowAppBar;
|
||||
final bool hasAppBarParam;
|
||||
final BaseViewModel baseViewModel;
|
||||
final bool isBottomBar;
|
||||
final Widget floatingActionButton;
|
||||
final bool isPharmacy;
|
||||
final String title;
|
||||
final String description;
|
||||
final String image;
|
||||
final bool isShowDecPage;
|
||||
final List<String> infoList;
|
||||
final Color backgroundColor;
|
||||
final double preferredSize;
|
||||
final List<Widget> appBarIcons;
|
||||
final PreferredSizeWidget appBarWidget;
|
||||
|
||||
DetailPageScafold(
|
||||
{@required this.body,
|
||||
this.appBarTitle = '',
|
||||
this.isLoading = false,
|
||||
this.isShowAppBar = false,
|
||||
this.hasAppBarParam,
|
||||
this.bottomSheet,
|
||||
this.baseViewModel,
|
||||
this.floatingActionButton,
|
||||
this.isPharmacy = false,
|
||||
this.title,
|
||||
this.description,
|
||||
this.isShowDecPage = true,
|
||||
this.isBottomBar,
|
||||
this.backgroundColor,
|
||||
this.preferredSize = 0.0,
|
||||
this.appBarIcons,
|
||||
this.appBarWidget,
|
||||
this.image,
|
||||
this.infoList});
|
||||
|
||||
@override
|
||||
_DetailPageScafoldState createState() => _DetailPageScafoldState();
|
||||
}
|
||||
|
||||
class _DetailPageScafoldState extends State<DetailPageScafold> {
|
||||
AuthenticatedUserObject authenticatedUserObject =
|
||||
locator<AuthenticatedUserObject>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppGlobal.context = context;
|
||||
PreferredSizeWidget appBar;
|
||||
|
||||
if (this.widget.appBarWidget == null) {
|
||||
PreferredSizeWidget appBarWidget = AppBarWidget(
|
||||
widget.appBarTitle,
|
||||
widget.appBarIcons,
|
||||
widget.isShowAppBar,
|
||||
isPharmacy: widget.isPharmacy,
|
||||
isShowDecPage: widget.isShowDecPage,
|
||||
image: widget.image,
|
||||
);
|
||||
appBar = widget.preferredSize == 0
|
||||
? appBarWidget
|
||||
: PreferredSize(
|
||||
child: appBarWidget,
|
||||
preferredSize: Size.fromHeight(widget.preferredSize));
|
||||
} else {
|
||||
appBar = this.widget.appBarWidget;
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor:
|
||||
widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: appBar,
|
||||
body: (!Provider.of<ProjectViewModel>(context, listen: false).isLogin &&
|
||||
widget.isShowDecPage)
|
||||
? NotAutPage(
|
||||
title: widget.appBarTitle,
|
||||
description: widget.description,
|
||||
infoList: widget.infoList,
|
||||
)
|
||||
: widget.baseViewModel != null
|
||||
? NetworkBaseView(
|
||||
child: buildBodyWidget(),
|
||||
baseViewModel: widget.baseViewModel,
|
||||
)
|
||||
: buildBodyWidget(),
|
||||
bottomSheet: widget.bottomSheet,
|
||||
//floatingActionButton: floatingActionButton ?? floatingActionButton,
|
||||
// bottomNavigationBar:
|
||||
// this.isBottomBar == true ? BottomBarSearch() : SizedBox()
|
||||
// floatingActionButton: FloatingSearchButton(),
|
||||
);
|
||||
}
|
||||
|
||||
buildAppLoaderWidget(bool isLoading) {
|
||||
return isLoading ? AppLoaderWidget() : Container();
|
||||
}
|
||||
|
||||
buildBodyWidget() {
|
||||
// return body; //Stack(children: <Widget>[body, buildAppLoaderWidget(isLoading)]);
|
||||
return Stack(children: <Widget>[
|
||||
widget.body, /*FloatingSearchButton()*/
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class AppBarWidget extends StatelessWidget with PreferredSizeWidget {
|
||||
final AuthenticatedUserObject authenticatedUserObject =
|
||||
locator<AuthenticatedUserObject>();
|
||||
|
||||
final String appBarTitle;
|
||||
final List<Widget> appBarIcons;
|
||||
final bool isShowAppBar;
|
||||
final bool isPharmacy;
|
||||
final bool isShowDecPage;
|
||||
final String image;
|
||||
|
||||
AppBarWidget(this.appBarTitle, this.appBarIcons, this.isShowAppBar,
|
||||
{this.isPharmacy = true, this.isShowDecPage = true, this.image});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return buildAppBar(context);
|
||||
}
|
||||
|
||||
Widget buildAppBar(BuildContext context) {
|
||||
return isShowAppBar
|
||||
? AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
// isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color,
|
||||
textTheme: TextTheme(
|
||||
headline6:
|
||||
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
),
|
||||
title: Texts(
|
||||
authenticatedUserObject.isLogin || !isShowDecPage
|
||||
? appBarTitle.toUpperCase()
|
||||
: TranslationBase.of(context).serviceInformationTitle,
|
||||
color: Colors.white,
|
||||
bold: true,
|
||||
),
|
||||
leading: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Icon(Icons.arrow_back_ios, color: Colors.grey),
|
||||
);
|
||||
},
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: <Widget>[
|
||||
isPharmacy
|
||||
? IconButton(
|
||||
icon: Icon(Icons.shopping_cart),
|
||||
color: Colors.grey,
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CartOrderPage()),
|
||||
);
|
||||
// Navigator.of(context)
|
||||
// .popUntil(ModalRoute.withName('/'));
|
||||
})
|
||||
: Container(),
|
||||
image != null
|
||||
? InkWell(
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
FadePage(
|
||||
page: InsuranceUpdate(),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset(
|
||||
image,
|
||||
height: SizeConfig.heightMultiplier * 5,
|
||||
width: SizeConfig.heightMultiplier * 5,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(FontAwesomeIcons.ellipsisV),
|
||||
color: Colors.grey,
|
||||
onPressed: () {
|
||||
settingModalBottomSheet(context);
|
||||
},
|
||||
),
|
||||
if (appBarIcons != null) ...appBarIcons
|
||||
],
|
||||
)
|
||||
: Container(
|
||||
height: 0,
|
||||
width: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => Size(double.maxFinite, 60);
|
||||
}
|
||||
@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||