merge-requests/271/head
mosazaid 5 years ago
parent d02b74142a
commit 5d0a122689

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart';
@ -229,12 +230,12 @@ class PharmacyCategoriseService extends BaseService {
hasError = false;
Map<String, String> queryParams = {'ManufacturerId': id};
manufacturerProducts.clear();
_finalProducts.clear();
await baseAppClient.getPharmacy(
GET_BRAND_ITEMS,
onSuccess: (dynamic response, int statusCode) {
response['products'].forEach((item) {
manufacturerProducts.add(FinalProductsModel.fromJson(item));
_finalProducts.add(FinalProductsModel.fromJson(item));
});
},
onFailure: (String error, int statusCode) {
@ -243,4 +244,44 @@ class PharmacyCategoriseService extends BaseService {
}, queryParams: queryParams,
);
}
Future getLastVisitedProducts() async {
String lastVisited = "";
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) {
lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
try {
await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(FinalProductsModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
});
} catch (error) {
throw error;
}
}
}
Future getBestSellerProducts() async {
Map<String, String> queryParams = {
'fields':
'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews',
};
try {
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(FinalProductsModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
}
}

@ -158,4 +158,26 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
}
Future getLastVisitedProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getLastVisitedProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
Future getBestSellerProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getBestSellerProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
}

@ -10,7 +10,7 @@ import 'base/base_view.dart';
class FinalProductsPage extends StatefulWidget {
final String id;
final int productType;
final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed
FinalProductsPage({this.id, this.productType = 1});
@ -35,9 +35,18 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
@override
Widget build(BuildContext context) {
return BaseView<PharmacyCategoriseViewModel>(
onModelReady: (model) => widget.productType == 1
? model.getFinalProducts(i: id)
: model.getManufacturerProducts(id),
onModelReady: (model) {
if (widget.productType == 1) {
model.getFinalProducts(i: id);
} else if (widget.productType == 2) {
model.getManufacturerProducts(id);
} else if (widget.productType == 3) {
model.getLastVisitedProducts();
} else {
model.getBestSellerProducts();
}
},
allowAny: true,
builder: (BuildContext context, PharmacyCategoriseViewModel model,
Widget child) =>
PharmacyAppScaffold(

@ -49,78 +49,74 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:
// currentTab == 0 || currentTab == 1 || currentTab == 2
// ?
AppBar(
backgroundColor: Color(0xff5AB145),
elevation: 0,
title: Container(
height: MediaQuery.of(context).size.height * 0.056,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.white,
),
child: InkWell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Row(
//crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Icons.search, size: 25.0),
SizedBox(
width: 15.0,
appBar: currentTab != 4
? AppBar(
backgroundColor: Color(0xff5AB145),
elevation: 0,
title: Container(
height: MediaQuery.of(context).size.height * 0.056,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.white,
),
child: InkWell(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Row(
//crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Icons.search, size: 25.0),
SizedBox(
width: 15.0,
),
Texts(
TranslationBase.of(context).searchProductHere,
fontSize: 13,
)
],
),
),
Texts(
TranslationBase.of(context).searchProductHere,
fontSize: 13,
)
],
),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SearchProductsPage()),
);
},
),
),
leading: Builder(
builder: (BuildContext context) {
return InkWell(
onTap: () {
setState(() {
currentTab = 0;
pageController.jumpToPage(0);
});
},
child: Container(
height: 2.0,
width: 10.0,
child: Image.asset(
'assets/images/pharmacy_logo.png',
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SearchProductsPage()),
);
},
),
),
);
},
),
actions: [
IconButton(
// iconSize: 70,
icon: Image.asset(
'assets/images/new-design/qr-code.png',
leading: Builder(
builder: (BuildContext context) {
return InkWell(
onTap: () {
setState(() {
currentTab = 0;
pageController.jumpToPage(0);
});
},
child: Container(
height: 2.0,
width: 10.0,
child: Image.asset(
'assets/images/pharmacy_logo.png',
),
),
);
},
),
onPressed: _scanQrAndGetProduct //do something,
)
],
centerTitle: true,
),
// : currentTab == 4
// ? null:null,
actions: [
IconButton(
// iconSize: 70,
icon: Image.asset(
'assets/images/new-design/qr-code.png',
),
onPressed: _scanQrAndGetProduct //do something,
)
],
centerTitle: true,
)
: null,
// : AppBar(
// backgroundColor: Color(0xff5AB145),
// elevation: 0,
@ -155,7 +151,6 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
physics: NeverScrollableScrollPhysics(),
controller: pageController,
children: [
// TODO mosa_comeback
PharmacyPage(),
PharmacyCategorisePage(),
// OffersCategorisePage(),
@ -180,8 +175,9 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
try {
String barcode = result;
GifLoaderDialogUtils.showMyDialog(context);
await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode",
onSuccess: (dynamic response, int statusCode) {
await BaseAppClient()
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode",
onSuccess: (dynamic response, int statusCode) {
print(response);
var product = PharmacyProduct.fromJson(response["products"][0]);
GifLoaderDialogUtils.hideDialog(context);

@ -27,7 +27,7 @@ class CartOrderPage extends StatelessWidget {
value: model.cartResponse,
child: AppScaffold(
appBarTitle: TranslationBase.of(context).shoppingCart,
isShowAppBar: false,
isShowAppBar: true,
isPharmacy: true,
baseViewModel: model,
backgroundColor: Colors.white,

@ -20,6 +20,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:rating_bar/rating_bar.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart';
import '../../final_products_page.dart';
import 'lacum-activitaion-vida-page.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
@ -48,8 +49,8 @@ class PharmacyPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
BannerPager(model),
// GridViewButtons(model),
BannerPager(model),
GridViewButtons(model),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
@ -77,181 +78,193 @@ class PharmacyPage extends StatelessWidget {
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
padding:
EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
height: MediaQuery.of(context).size.height * 0.30,
// width: 200.0,
// height: MediaQuery.of(context).size.height / 4 + 20,
margin: EdgeInsets.only(left: 10),
child: BaseView<PharmacyModuleViewModel>(
onModelReady: (model) => model.getPrescription(),
builder: (_, model, wi) => model.prescriptionsList.length != 0
onModelReady: (model) => model.getPrescription(),
builder: (_, model, wi) => model.prescriptionsList.length !=
0
// model.getPrescription();
? ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
physics: ScrollPhysics(),
// physics: NeverScrollableScrollPhysics(),
// itemCount: 4,
itemCount: model.prescriptionsList.length,
itemBuilder: (context, index) {
return Container(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
physics: ScrollPhysics(),
// physics: NeverScrollableScrollPhysics(),
// itemCount: 4,
itemCount: model.prescriptionsList.length,
itemBuilder: (context, index) {
return Container(
// width: 160.0,
height: MediaQuery.of(context).size.height * 0.6,
padding: EdgeInsets.only(bottom: 5.0, left: 5.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(
height:
MediaQuery.of(context).size.height * 0.6,
padding:
EdgeInsets.only(bottom: 5.0, left: 5.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>[
Column(children: [
Container(
padding: EdgeInsets.only(
top: 10.0,
left: 10.0,
right: 3.0,
bottom: 15.0,
),
child: Image.network(
model.prescriptionsList[index]
.doctorImageURL,
width: 60,
height: 60,
),
),
]),
Column(
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(left: 1),
Row(
children: <Widget>[
Column(children: [
Container(
padding: EdgeInsets.only(
left: 15.0, right: 15.0),
decoration: BoxDecoration(
border: Border.all(
color: Colors.green,
style: BorderStyle.solid,
width: 4.0,
top: 10.0,
left: 10.0,
right: 3.0,
bottom: 15.0,
),
child: Image.network(
model.prescriptionsList[index]
.doctorImageURL,
width: 60,
height: 60,
),
),
]),
Column(
// crossAxisAlignment: CrossAxisAlignment.center,
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
.prescriptionsList[
index]
.isInOutPatientDescription
.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
),
)),
Row(children: <Widget>[
Image.asset(
'assets/images/Icon-awesome-calendar.png',
width: 30,
height: 30,
),
Text(
model.prescriptionsList[index]
.appointmentDate
.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
),
color: Colors.green,
borderRadius:
BorderRadius.circular(
30.0)),
child: Text(
)
]),
],
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Row(children: <Widget>[
Text(
model.prescriptionsList[index]
.isInOutPatientDescription
.doctorTitle
.toString(),
style: TextStyle(
color: Colors.white,
color: Colors.black,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
fontWeight: FontWeight.bold,
),
)),
Row(children: <Widget>[
Image.asset(
'assets/images/Icon-awesome-calendar.png',
width: 30,
height: 30,
),
Text(
),
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]
.appointmentDate
.clinicDescription
.toString(),
style: TextStyle(
color: Colors.black,
color: Colors.green,
fontSize: 15.0,
// fontWeight: FontWeight.bold,
// fontWeight: FontWeight.bold,
),
)
]),
],
),
],
),
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(
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 5),
child: Align(
alignment: Alignment.topLeft,
child: RatingBar.readOnly(
// 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(),
),
size: 15.0,
filledColor:
Colors.yellow[700],
emptyColor: Colors.grey[500],
isHalfAllowed: true,
halfFilledIcon:
Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star,
),
),
)
]),
]),
);
})
: Container(),
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
@ -333,7 +346,17 @@ class PharmacyPage extends StatelessWidget {
hPadding: 4,
borderColor: Colors.green,
textColor: Colors.green,
handler: () {},
handler: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FinalProductsPage(
id: "",
productType: 3,
),
),
);
},
),
],
),
@ -367,7 +390,14 @@ class PharmacyPage extends StatelessWidget {
hPadding: 4,
handler: () => {
Navigator.push(
context, FadePage(page: ProductBrandsPage())),
context,
MaterialPageRoute(
builder: (context) => FinalProductsPage(
id: "",
productType: 4,
),
),
),
},
),
],

Loading…
Cancel
Save