Offers & discounts UI updating

merge-update-with-lab-changes
haroon amjad 4 years ago
parent d5c68c5032
commit 502c7fd3de

@ -1630,4 +1630,6 @@ const Map localizedValues = {
"RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"},
"RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"},
"transportation": {"en": "Transportation", "ar": "النقل"}, "transportation": {"en": "Transportation", "ar": "النقل"},
"myCart": {"en": "Cart", "ar": "عربة التسوق"},
"browseOffers": {"en": "Browse offers by clinic", "ar": "تصفح العروض حسب العيادة"},
}; };

@ -192,6 +192,8 @@ class PackagesResponseModel with JsonConvert<PackagesResponseModel> {
List<dynamic> discountIds; List<dynamic> discountIds;
@JSONField(name: "store_ids") @JSONField(name: "store_ids")
List<dynamic> storeIds; List<dynamic> storeIds;
@JSONField(name: "store_names")
List<dynamic> storeNames;
@JSONField(name: "manufacturer_ids") @JSONField(name: "manufacturer_ids")
List<int> manufacturerIds; List<int> manufacturerIds;
List<dynamic> reviews; List<dynamic> reviews;

@ -110,6 +110,7 @@ class OffersAndPackagesServices extends BaseService {
var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS;
await baseAppClient.simpleGet(url, headers: packagesAuthHeader, await baseAppClient.simpleGet(url, headers: packagesAuthHeader,
onSuccess: (dynamic stringResponse, int statusCode) { onSuccess: (dynamic stringResponse, int statusCode) {
latestOffersList.clear();
if (statusCode == 200) { if (statusCode == 200) {
var jsonResponse = json.decode(stringResponse); var jsonResponse = json.decode(stringResponse);
jsonResponse['products'].forEach((json) { jsonResponse['products'].forEach((json) {

@ -313,6 +313,12 @@ offerProductsResponseModelFromJson(PackagesResponseModel data, Map<String, dynam
data.storeIds = new List<dynamic>(); data.storeIds = new List<dynamic>();
data.storeIds.addAll(json['store_ids']); data.storeIds.addAll(json['store_ids']);
} }
if (json['store_names'] != null) {
data.storeNames = new List<dynamic>();
data.storeNames.addAll(json['store_names']);
}
if (json['manufacturer_ids'] != null) { if (json['manufacturer_ids'] != null) {
data.manufacturerIds = json['manufacturer_ids']?.map((v) => v?.toInt())?.toList()?.cast<int>(); data.manufacturerIds = json['manufacturer_ids']?.map((v) => v?.toInt())?.toList()?.cast<int>();
} }

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/gradient_color.dart'; import 'package:diplomaticquarterapp/models/gradient_color.dart';
import 'package:diplomaticquarterapp/models/hmg_services.dart'; import 'package:diplomaticquarterapp/models/hmg_services.dart';
import 'package:diplomaticquarterapp/models/slider_data.dart'; import 'package:diplomaticquarterapp/models/slider_data.dart';
@ -282,7 +283,7 @@ class _HomePageFragment2State extends State<HomePageFragment2> {
flex: 1, flex: 1,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
final user = projectViewModel.user; AuthenticatedUser user = projectViewModel.user;
Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage(user))); Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage(user)));
}, },
child: Container( child: Container(

@ -1,33 +1,37 @@
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/ProductCheckTypeWidget.dart'; import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:expandable/expandable.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:html/parser.dart';
import 'package:rating_bar/rating_bar.dart';
class OfferAndPackagesDetail extends StatefulWidget{ class OfferAndPackagesDetail extends StatefulWidget {
final PackagesResponseModel itemModel; final PackagesResponseModel itemModel;
final Function(PackagesResponseModel product) onCartClick;
const OfferAndPackagesDetail({@required this.itemModel, Key key}) : super(key: key); const OfferAndPackagesDetail({@required this.itemModel, @required this.onCartClick, Key key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => OfferAndPackagesDetailState(); State<StatefulWidget> createState() => OfferAndPackagesDetailState();
} }
class OfferAndPackagesDetailState extends State<OfferAndPackagesDetail> {
class OfferAndPackagesDetailState extends State<OfferAndPackagesDetail>{
PackagesViewModel viewModel; PackagesViewModel viewModel;
bool expandFlag = false;
var controller = new ExpandableController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PackagesViewModel>( return BaseView<PackagesViewModel>(
onModelReady: (model){ onModelReady: (model) {
viewModel = model; viewModel = model;
}, },
builder: (_, model, wi) => AppScaffold( builder: (_, model, wi) => AppScaffold(
@ -39,176 +43,212 @@ class OfferAndPackagesDetailState extends State<OfferAndPackagesDetail>{
isOfferPackages: true, isOfferPackages: true,
showOfferPackagesCart: true, showOfferPackagesCart: true,
isShowDecPage: false, isShowDecPage: false,
body: Stack( showNewAppBar: true,
children: [ showNewAppBarTitle: true,
Padding( body: SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 60), child: Column(
child: ListView( crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(5),
child: Stack(
children: [ children: [
Padding( Container(
padding: const EdgeInsets.all(10), color: Colors.white,
child: AspectRatio( padding: const EdgeInsets.all(21.0),
aspectRatio: 1/1,
child: utils.applyShadow(
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(15.0),
child: utils.Utils.loadNetworkImage(url: "https://wallpaperaccess.com/full/30103.jpg",) child: Image.network("https://mdlaboratories.com/offersdiscounts/images/thumbs/0000162_dermatology-testing.jpeg", fit: BoxFit.fill),
), ),
) ),
), Container(
), padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 21.0),
Align( child: Text(widget.itemModel.name, maxLines: 1, style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -1.14))),
alignment: Alignment.topLeft, Container(
child: Image.asset( padding: const EdgeInsets.only(left: 21.0, right: 21.0),
'assets/images/discount_${'en'}.png', child: Text(widget.itemModel.shortDescription,
height: 70, maxLines: 2, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), overflow: TextOverflow.clip)),
width: 70, Row(
children: [
Container(
padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 12.0),
child: RatingBar.readOnly(
initialRating: 4.5,
size: 18.0,
filledColor: Color(0XFFD02127),
emptyColor: Color(0XFFD02127),
isHalfAllowed: true,
halfFilledIcon: Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star_border,
), ),
), ),
], ],
), ),
Container(
padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 18.0),
width: double.infinity,
height: 50.0,
child: ListView.separated(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: widget.itemModel.storeNames.length,
separatorBuilder: (context, index) {
return mWidth(5.0);
},
itemBuilder: (BuildContext context, int index) {
return contactButton(widget.itemModel.storeNames[index].toString());
},
), ),
),
Padding( Container(
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20), padding: const EdgeInsets.only(top: 18.0),
child: ExpandableNotifier(
initialExpanded: true,
child: Container(
color: Colors.white,
child: Column(
children: <Widget>[
ScrollOnExpand(
scrollOnExpand: true,
scrollOnCollapse: false,
child: ExpandablePanel(
hasIcon: false,
theme: const ExpandableThemeData(
headerAlignment: ExpandablePanelHeaderAlignment.center,
tapBodyToCollapse: true,
),
header: Padding(
padding: const EdgeInsets.only(top: 20, bottom: 20, left: 21, right: 21),
child: InkWell(
onTap: () {
setState(() {
expandFlag = !expandFlag;
controller.expanded = expandFlag;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Text(
"Child Dental Offer", TranslationBase.of(context).description,
fontSize: 25, maxLines: 1,
fontWeight: FontWeight.normal, style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -1.14),
color: Colors.black,
), ),
],
Stack(
children: [
Texts(
"200 SAR",
fontWeight: FontWeight.normal,
decoration: TextDecoration.lineThrough,
color: Colors.grey,
fontSize: 12
), ),
Padding(
padding: const EdgeInsets.only(top: 15),
child: Texts(
"894.99 SAR",
fontWeight: FontWeight.bold,
color: Colors.green,
fontSize: 18
), ),
Icon(
expandFlag ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
color: Color(0xff2E303A),
), ),
], ],
), ),
StarRating(
size: 20,
totalCount: null,
totalAverage: 5,
forceStars: true),
SizedBox(height: 20,),
Texts(
"Details",
fontWeight: FontWeight.bold,
color: Colors.grey,
fontSize: 20
), ),
),
builder: (_, collapsed, expanded) {
return Expandable(
AspectRatio( controller: controller,
aspectRatio: 2/1, collapsed: collapsed,
child: Container( expanded: Container(
color: Colors.grey[300], padding: const EdgeInsets.only(left: 21.0, right: 21.0, bottom: 21.0),
child: Padding( child: Text(parseHtmlString(widget.itemModel.fullDescription),
padding: const EdgeInsets.all(10), style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), overflow: TextOverflow.clip)),
child: Texts("Detail of offers written here"), theme: const ExpandableThemeData(crossFadePoint: 0),
) );
},
), ),
), ),
SizedBox(height: 10,),
], ],
), ),
), ),
),
),
], ],
), ),
), ),
bottomSheet: Container(
Padding( padding: const EdgeInsets.only(top: 16, bottom: 16, left: 21, right: 21),
padding: const EdgeInsets.all(10), color: Colors.white,
child: Align(
alignment: Alignment.bottomRight,
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: RaisedButton.icon( child: Column(
padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), mainAxisSize: MainAxisSize.min,
shape: RoundedRectangleBorder( crossAxisAlignment: CrossAxisAlignment.start,
borderRadius: BorderRadius.circular(8.0), children: [
side: BorderSide(color: Colors.red, width: 0.5) if(widget.itemModel.hasDiscountsApplied) Container(
margin: const EdgeInsets.only(top: 0.0),
child: Text(widget.itemModel.oldPrice.toString() + " " + TranslationBase.of(context).sar,
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w600, letterSpacing: -0.6, decoration: TextDecoration.lineThrough, color: CustomColors.grey2))),
Container(
margin: const EdgeInsets.only(top: 0.0),
child: Text(widget.itemModel.price.toString().trim() + " " + TranslationBase.of(context).sar,
style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))),
],
), ),
color: Colors.red,
icon: Icon(
Icons.add_shopping_cart_outlined,
size: 25,
color: Colors.white,
), ),
label: Texts( SizedBox(width: 8),
"Add to Cart", Expanded(
fontSize: 17, color: Colors.white, fontWeight: FontWeight.normal, child: SizedBox(
height: 43,
width: double.infinity,
child: FlatButton(
onPressed: () {
// onCartClick();
widget.onCartClick(widget.itemModel);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: SvgPicture.asset("assets/images/new/add-to-cart.svg", color: Colors.white),
), ),
onPressed: (){},), Container(
child: Text(
TranslationBase.of(context).addToCart,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48),
), ),
),
SizedBox(width: 15,), ],
),
Expanded( color: const Color(0xffD02127),
child: OutlineButton.icon(
padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0),
borderSide: BorderSide(width: 1.0, color: Colors.red),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0), borderRadius: BorderRadius.circular(6),
), ),
color: Colors.white,
icon: Icon(
Icons.favorite_rounded,
size: 25,
color: Colors.red,
), ),
label: Texts(
"Add to Favorites",
fontSize: 17, color: Colors.red, fontWeight: FontWeight.normal
), ),
onPressed: (){
},),
), ),
], ],
), ),
), ),
) ),
);
}
String parseHtmlString(String htmlString) {
var document = parse(htmlString);
String parsedString = parse(document.body.text).documentElement.text;
return parsedString;
}
], Widget contactButton(String title) {
) return SizedBox(
height: 32,
width: 80.0,
child: FlatButton(
onPressed: () {},
color: Colors.white,
shape: StadiumBorder(side: BorderSide(color: CustomColors.devider, width: 1)),
child: Text(
title,
style: TextStyle(fontSize: 10, letterSpacing: -0.4, color: CustomColors.textColor),
maxLines: 1,
),
), ),
); );
} }
} }

@ -32,20 +32,18 @@ class PackagesCartPage extends StatefulWidget {
_PackagesCartPageState createState() => _PackagesCartPageState(); _PackagesCartPageState createState() => _PackagesCartPageState();
} }
class _PackagesCartPageState extends State<PackagesCartPage> class _PackagesCartPageState extends State<PackagesCartPage> with AfterLayoutMixin<PackagesCartPage>, SingleTickerProviderStateMixin {
with AfterLayoutMixin<PackagesCartPage>, SingleTickerProviderStateMixin {
getLanguageID() async { getLanguageID() async {
languageID = await sharedPref.getString(APP_LANGUAGE); languageID = await sharedPref.getString(APP_LANGUAGE);
} }
double subtotal,tax, total; double subtotal, tax, total;
@override @override
void initState() { void initState() {
_agreeTerms = false; _agreeTerms = false;
_selectedPaymentMethod = null; _selectedPaymentMethod = null;
_animationController = _animationController = AnimationController(vsync: this, duration: Duration(seconds: 500));
AnimationController(vsync: this, duration: Duration(seconds: 500));
super.initState(); super.initState();
} }
@ -69,22 +67,13 @@ class _PackagesCartPageState extends State<PackagesCartPage>
} }
onPayNowClick() async { onPayNowClick() async {
await viewModel.service await viewModel.service.placeOrder(context: context, paymentParams: _selectedPaymentParams).then((orderId) {
.placeOrder(
context: context,
paymentParams: _selectedPaymentParams)
.then((orderId) {
if (orderId.runtimeType == int) { if (orderId.runtimeType == int) {
// result == order_id // result == order_id
var browser = MyInAppBrowser( var browser = MyInAppBrowser(context: context, onExitCallback: (data, isDone) => paymentClosed(orderId: orderId, withStatus: isDone, data: data));
context: context, browser.openPackagesPaymentBrowser(customer_id: viewModel.service.customer.id, order_id: orderId);
onExitCallback: (data, isDone) => paymentClosed(
orderId: orderId, withStatus: isDone, data: data));
browser.openPackagesPaymentBrowser(
customer_id: viewModel.service.customer.id, order_id: orderId);
} else { } else {
utils.Utils.showErrorToast( utils.Utils.showErrorToast('Failed to place order, please try again later');
'Failed to place order, please try again later');
} }
}).catchError((error) { }).catchError((error) {
utils.Utils.showErrorToast(error.toString()); utils.Utils.showErrorToast(error.toString());
@ -111,11 +100,11 @@ class _PackagesCartPageState extends State<PackagesCartPage>
isOfferPackages: true, isOfferPackages: true,
showOfferPackagesCart: false, showOfferPackagesCart: false,
isShowDecPage: false, isShowDecPage: false,
showNewAppBar: true,
showNewAppBarTitle: true,
body: Column( body: Column(
children: [ children: [
Expanded( Expanded(
child: Padding(
padding: const EdgeInsets.all(5),
child: StaggeredGridView.countBuilder( child: StaggeredGridView.countBuilder(
crossAxisCount: (_columnCount * _columnCount), crossAxisCount: (_columnCount * _columnCount),
itemCount: viewModel.cartItemList.length, itemCount: viewModel.cartItemList.length,
@ -127,40 +116,32 @@ class _PackagesCartPageState extends State<PackagesCartPage>
background: _cartItemDeleteContainer(), background: _cartItemDeleteContainer(),
secondaryBackground: _cartItemDeleteContainer(), secondaryBackground: _cartItemDeleteContainer(),
confirmDismiss: (direction) async { confirmDismiss: (direction) async {
bool status = await viewModel.service bool status = await viewModel.service.deleteProductFromCart(item.id, context: context, showLoading: false);
.deleteProductFromCart(item.id,
context: context, showLoading: false);
return status; return status;
}, },
onDismissed: (direction) { onDismissed: (direction) {
debugPrint('Index: $index');
viewModel.cartItemList.removeAt(index); viewModel.cartItemList.removeAt(index);
}, },
child: PackagesCartItemCard( child: PackagesCartItemCard(
itemModel: item, itemModel: item,
viewModel: viewModel,
getCartItems: fetchData,
shouldStepperChangeApply: (apply, total) async { shouldStepperChangeApply: (apply, total) async {
var request = AddProductToCartRequestModel( var request = AddProductToCartRequestModel(product_id: item.productId, quantity: apply);
product_id: item.productId, ResponseModel response = await viewModel.service.addProductToCart(request, context: context, showLoading: false).catchError((error) {
quantity: apply);
ResponseModel response = await viewModel
.service
.addProductToCart(request,
context: context, showLoading: false)
.catchError((error) {
utils.Utils.showErrorToast(error); utils.Utils.showErrorToast(error);
}); });
if(response.status){ if (response.status) {
fetchData(); fetchData();
} }
return response.status ?? false; return response.status ?? false;
}, },
)); ));
}, },
staggeredTileBuilder: (int index) => staggeredTileBuilder: (int index) => StaggeredTile.fit(_columnCount),
StaggeredTile.fit(_columnCount),
mainAxisSpacing: 0, mainAxisSpacing: 0,
crossAxisSpacing: 10, crossAxisSpacing: 10,
)), ),
), ),
Container( Container(
height: 0.25, height: 0.25,
@ -170,8 +151,7 @@ class _PackagesCartPageState extends State<PackagesCartPage>
color: Colors.white, color: Colors.white,
child: Column( child: Column(
children: [ children: [
Texts(TranslationBase.of(context).selectPaymentOption, Texts(TranslationBase.of(context).selectPaymentOption, fontSize: 10, fontWeight: FontWeight.bold),
fontSize: 10, fontWeight: FontWeight.bold),
Container( Container(
height: 0.25, height: 0.25,
width: 100, width: 100,
@ -184,11 +164,7 @@ class _PackagesCartPageState extends State<PackagesCartPage>
height: 0.25, height: 0.25,
color: Colors.grey[300], color: Colors.grey[300],
), ),
Container( Container(height: 40, child: _termsAndCondition(context, onSelected: onTermsClick, onInfoClick: onTermsInfoClick)),
height: 40,
child: _termsAndCondition(context,
onSelected: onTermsClick,
onInfoClick: onTermsInfoClick)),
Container( Container(
height: 0.25, height: 0.25,
color: Colors.grey[300], color: Colors.grey[300],
@ -204,7 +180,7 @@ class _PackagesCartPageState extends State<PackagesCartPage>
} }
fetchData() async { fetchData() async {
await viewModel.service.cartItems(context: context).then((value){ await viewModel.service.cartItems(context: context).then((value) {
subtotal = value['subtotal'] ?? 0.0; subtotal = value['subtotal'] ?? 0.0;
tax = value['tax'] ?? 0.0; tax = value['tax'] ?? 0.0;
total = value['total'] ?? 0.0; total = value['total'] ?? 0.0;
@ -213,15 +189,12 @@ class _PackagesCartPageState extends State<PackagesCartPage>
setState(() {}); setState(() {});
} }
paymentClosed( paymentClosed({@required int orderId, @required bool withStatus, dynamic data}) async {
{@required int orderId, @required bool withStatus, dynamic data}) async {
viewModel.service.getOrderById(orderId, context: context).then((value) { viewModel.service.getOrderById(orderId, context: context).then((value) {
var heading = withStatus ? "Success" : "Failed"; var heading = withStatus ? "Success" : "Failed";
var title = withStatus ? "Your order has been placed successfully" : "Failed to place your order"; var title = withStatus ? "Your order has been placed successfully" : "Failed to place your order";
var subTitle = "Order# ${value.data.customOrderNumber}"; var subTitle = "Order# ${value.data.customOrderNumber}";
Navigator.of(context).pushReplacement(MaterialPageRoute( Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => PackageOrderCompletedPage(heading: heading, title: title, subTitle: subTitle)));
builder: (context) => PackageOrderCompletedPage(
heading: heading, title: title, subTitle: subTitle)));
}).catchError((error) { }).catchError((error) {
debugPrint(error); debugPrint(error);
}); });
@ -231,7 +204,8 @@ class _PackagesCartPageState extends State<PackagesCartPage>
// /* Payment Footer Widgets */ // /* Payment Footer Widgets */
// --------------------------- // ---------------------------
String _selectedPaymentMethod; String _selectedPaymentMethod;
Map<dynamic,dynamic> _selectedPaymentParams; Map<dynamic, dynamic> _selectedPaymentParams;
Widget _paymentOptions(BuildContext context, Function(String) onSelected, {PackagesViewModel viewModel}) { Widget _paymentOptions(BuildContext context, Function(String) onSelected, {PackagesViewModel viewModel}) {
double height = 30; double height = 30;
@ -247,18 +221,17 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
), ),
], ],
borderRadius: BorderRadius.all(Radius.circular(5)), borderRadius: BorderRadius.all(Radius.circular(5)),
border: Border.all( border: Border.all(color: isSelected ? Colors.green : Colors.grey, width: isSelected ? 1 : 0.5)),
color: isSelected ? Colors.green : Colors.grey,
width: isSelected ? 1 : 0.5)),
child: Padding( child: Padding(
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
child: Image.asset('assets/images/new-design/$imageName'), child: Image.asset('assets/images/new-design/$imageName'),
)); ));
} }
Future<String> selectTamaraPaymentOption() async{ Future<String> selectTamaraPaymentOption() async {
final tamara_options = await viewModel.service.getTamaraOptions(context: context, showLoading: true); final tamara_options = await viewModel.service.getTamaraOptions(context: context, showLoading: true);
final selected = await SingleSelectionDialog<TamaraPaymentOption>(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context); final selected =
await SingleSelectionDialog<TamaraPaymentOption>(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context);
return selected.name; return selected.name;
} }
@ -272,9 +245,9 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
children: [ children: [
InkWell( InkWell(
child: buttonContent(_selectedPaymentMethod == "tamara", 'tamara.png'), child: buttonContent(_selectedPaymentMethod == "tamara", 'tamara.png'),
onTap: () async{ onTap: () async {
final tamara_option = await selectTamaraPaymentOption(); final tamara_option = await selectTamaraPaymentOption();
_selectedPaymentParams = {"channel" : "Web", "payment_method_system_name" : "Payments.Tamara", "payment_option" : tamara_option}; _selectedPaymentParams = {"channel": "Web", "payment_method_system_name": "Payments.Tamara", "payment_option": tamara_option};
onSelected("tamara"); onSelected("tamara");
}, },
), ),
@ -284,7 +257,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
InkWell( InkWell(
child: buttonContent(_selectedPaymentMethod == "mada", 'mada.png'), child: buttonContent(_selectedPaymentMethod == "mada", 'mada.png'),
onTap: () { onTap: () {
_selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "MADA"}; _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MADA"};
onSelected("mada"); onSelected("mada");
}, },
), ),
@ -294,7 +267,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
InkWell( InkWell(
child: buttonContent(_selectedPaymentMethod == "visa", 'visa.png'), child: buttonContent(_selectedPaymentMethod == "visa", 'visa.png'),
onTap: () { onTap: () {
_selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "VISA"}; _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "VISA"};
onSelected("visa"); onSelected("visa");
}, },
), ),
@ -304,7 +277,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
InkWell( InkWell(
child: buttonContent(_selectedPaymentMethod == "mastercard", 'mastercard.png'), child: buttonContent(_selectedPaymentMethod == "mastercard", 'mastercard.png'),
onTap: () { onTap: () {
_selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "MASTERCARD"}; _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MASTERCARD"};
onSelected("mastercard"); onSelected("mastercard");
}, },
), ),
@ -326,17 +299,15 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa
} }
bool _agreeTerms = false; bool _agreeTerms = false;
Widget _termsAndCondition(BuildContext context,
{@required Function(bool) onSelected, @required VoidCallback onInfoClick}) { Widget _termsAndCondition(BuildContext context, {@required Function(bool) onSelected, @required VoidCallback onInfoClick}) {
return Padding( return Padding(
padding: const EdgeInsets.all(5), padding: const EdgeInsets.all(5),
child: Row( child: Row(
children: [ children: [
InkWell( InkWell(
child: Icon( child: Icon(
_agreeTerms _agreeTerms ? Icons.check_circle : Icons.radio_button_unchecked_sharp,
? Icons.check_circle
: Icons.radio_button_unchecked_sharp,
size: 20, size: 20,
color: _agreeTerms ? Colors.green[600] : Colors.grey[400], color: _agreeTerms ? Colors.green[600] : Colors.grey[400],
), ),
@ -386,18 +357,8 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Texts('${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8),
'${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', Texts('${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8),
heightFactor: 1.5,
fontWeight: FontWeight.bold,
color: Colors.grey,
fontSize: 8),
Texts(
'${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}',
heightFactor: 1.5,
fontWeight: FontWeight.bold,
color: Colors.grey,
fontSize: 8),
Padding( Padding(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
child: Container( child: Container(
@ -406,12 +367,7 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total,
color: Colors.grey[300], color: Colors.grey[300],
), ),
), ),
Texts( Texts('${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.black54, fontSize: 15)
'${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}',
heightFactor: 1.5,
fontWeight: FontWeight.bold,
color: Colors.black54,
fontSize: 15)
], ],
), ),
), ),
@ -425,10 +381,7 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5), side: BorderSide(color: Theme.of(context).primaryColor, width: 0.5)),
borderRadius: BorderRadius.circular(5),
side: BorderSide(
color: Theme.of(context).primaryColor, width: 0.5)),
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
onPressed: isPayNowAQctive ? onPayNowClick : null, onPressed: isPayNowAQctive ? onPayNowClick : null,
), ),

@ -12,24 +12,20 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/ClinicOfferAndPackagesPage.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/ClinicOfferAndPackagesPage.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/CreateCustomerDailogPage.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackageDetailPage.dart';
import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesCartPage.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesCartPage.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth;
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; import 'package:diplomaticquarterapp/uitl/utils.dart' as utils;
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart';
import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesOfferCard.dart'; import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesOfferCard.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class PackagesHomePage extends StatefulWidget { class PackagesHomePage extends StatefulWidget {
@ -48,6 +44,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
viewModel.service.patientUser = widget.user;
viewModel.service.loadOffersPackagesDataForMainPage( viewModel.service.loadOffersPackagesDataForMainPage(
context: context, context: context,
completion: () { completion: () {
@ -111,11 +108,8 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
SizedBox(
height: 10,
),
Padding( Padding(
padding: const EdgeInsets.all(21), padding: projectViewModel.isArabic ? const EdgeInsets.only(top: 21, right: 21, bottom: 21) : const EdgeInsets.only(top: 21, left: 21, bottom: 21),
child: Column( child: Column(
children: [ children: [
inputWidget(TranslationBase.of(context).search, "", _searchTextController, isInputTypeNum: false), inputWidget(TranslationBase.of(context).search, "", _searchTextController, isInputTypeNum: false),
@ -126,6 +120,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
onTap: () => showClinicSelectionList(), onTap: () => showClinicSelectionList(),
child: Container( child: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
margin: projectViewModel.isArabic ? const EdgeInsets.only(left: 21) : const EdgeInsets.only(right: 21),
width: double.infinity, width: double.infinity,
height: 65, height: 65,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -139,7 +134,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
selectedClinic != null ? selectedClinic.name : "Browse offers by clinic", selectedClinic != null ? selectedClinic.name : TranslationBase.of(context).browseOffers,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -218,15 +213,16 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Icon( child: SvgPicture.asset("assets/images/new/cart.svg"),
Icons.add_shopping_cart_rounded, // child: Icon(
size: 30.0, // Icons.add_shopping_cart_rounded,
color: Colors.white, // size: 30.0,
), // color: Colors.white,
// ),
), ),
Container( Container(
child: Text( child: Text(
TranslationBase.of(context).shoppingCart, TranslationBase.of(context).myCart,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48),
), ),
@ -315,7 +311,9 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
Widget separator(BuildContext context, int index) { Widget separator(BuildContext context, int index) {
return Container( return Container(
width: 1, width: 1,
decoration: BoxDecoration(gradient: LinearGradient(begin: Alignment(-1.0, -2.0), end: Alignment(1.0, 4.0), colors: [Colors.grey, Colors.grey[100], Colors.grey[200], Colors.grey[300], Colors.grey[400], Colors.grey[500]])), decoration: BoxDecoration(
gradient:
LinearGradient(begin: Alignment(-1.0, -2.0), end: Alignment(1.0, 4.0), colors: [Colors.grey, Colors.grey[100], Colors.grey[200], Colors.grey[300], Colors.grey[400], Colors.grey[500]])),
); );
} }
@ -346,9 +344,11 @@ class _PackagesHomePageState extends State<PackagesHomePage> {
} }
} }
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) { Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller,
{VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) {
return Container( return Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
margin: projectViewModel.isArabic ? const EdgeInsets.only(left: 21) : const EdgeInsets.only(right: 21),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),

@ -509,7 +509,7 @@ class TranslationBase {
String get switchUser => localizedValues['switch-login'][locale.languageCode]; String get switchUser => localizedValues['switch-login'][locale.languageCode];
String get removeMember => localizedValues['remove-membe'][locale.languageCode]; String get removeMember => localizedValues['remove-member'][locale.languageCode];
String get allowView => localizedValues['allow-view'][locale.languageCode]; String get allowView => localizedValues['allow-view'][locale.languageCode];
@ -2618,6 +2618,10 @@ class TranslationBase {
String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode]; String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode];
String get transportation => localizedValues["transportation"][locale.languageCode]; String get transportation => localizedValues["transportation"][locale.languageCode];
String get browseOffers => localizedValues["browseOffers"][locale.languageCode];
String get myCart => localizedValues["myCart"][locale.languageCode];
} }
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> { class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -1,217 +1,136 @@
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart';
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/CounterView.dart'; import 'package:diplomaticquarterapp/widgets/CounterView.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
bool wide = true; bool wide = true;
class PackagesCartItemCard extends StatefulWidget { class PackagesCartItemCard extends StatefulWidget {
final PackagesCartItemsResponseModel itemModel; final PackagesCartItemsResponseModel itemModel;
final StepperCallbackFuture shouldStepperChangeApply ; final StepperCallbackFuture shouldStepperChangeApply;
final PackagesViewModel viewModel;
final Function getCartItems;
const PackagesCartItemCard( const PackagesCartItemCard({@required this.itemModel, @required this.shouldStepperChangeApply, @required this.viewModel, this.getCartItems, Key key}) : super(key: key);
{
@required this.itemModel,
@required this.shouldStepperChangeApply,
Key key})
: super(key: key);
@override @override
State<StatefulWidget> createState() => PackagesCartItemCardState(); State<StatefulWidget> createState() => PackagesCartItemCardState();
} }
class PackagesCartItemCardState extends State<PackagesCartItemCard> { class PackagesCartItemCardState extends State<PackagesCartItemCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
wide = !wide; wide = !wide;
return Container( return Container(
color: Colors.transparent, decoration: cardRadius(15.0),
child: Card( margin: EdgeInsets.only(left: 21.0, right: 21.0, top: 12.0),
elevation: 3, height: 90,
shadowColor: Colors.grey[100],
color: Colors.white,
child: Stack(
children: [
Container(
height: 100,
child: Row( child: Row(
mainAxisSize: MainAxisSize.max,
children: [ children: [
_image(widget.itemModel.product), _image(widget.itemModel.product),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
_itemName(widget.itemModel.product.getName()), _itemName(widget.itemModel.product.getName()),
Row( _itemDescription(widget.itemModel.product.shortDescription),
Container(
padding: const EdgeInsets.only(top: 12.0),
width: MediaQuery.of(context).size.width * 0.65,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
_itemPrice(widget.itemModel.product.price, context: context), _itemPrice(widget.itemModel.product.price, context: context),
_priceSeperator(), InkWell(
_itemOldPrice(widget.itemModel.product.oldPrice, context: context), onTap: () async {
], await widget.viewModel.service.deleteProductFromCart(widget.itemModel.id, context: context, showLoading: false);
), widget.getCartItems();
Row( },
child: Row(
children: [ children: [
_itemCounter( Padding(
widget.itemModel.quantity, padding: const EdgeInsets.only(left: 5.0, right: 5.0),
minQuantity: widget.itemModel.product.orderMinimumQuantity, child: Text(
maxQuantity: widget.itemModel.product.orderMaximumQuantity, TranslationBase.of(context).removeMember,
shouldStepperChangeApply: (apply,total) async{ style: TextStyle(
bool success = await widget.shouldStepperChangeApply(apply,total); fontSize: 10,
if(success == true) color: CustomColors.accentColor,
setState(() => widget.itemModel.quantity = total); fontWeight: FontWeight.w600,
return success; letterSpacing: -0.36,
} ),
), ),
],
), ),
SvgPicture.asset("assets/images/new-design/delete.svg", color: CustomColors.accentColor),
], ],
) ),
),
], ],
), ),
), ),
// Positioned(
// bottom: 8,
// left: 10,
// child: Row(
// children: [
// _totalLabel(context: context),
// _totalPrice((widget.itemModel.product.price * widget.itemModel.quantity), context: context),
// ],
// ),
// )
], ],
) )
) ],
),
); );
} }
} }
// --------------------
// Product Image
// --------------------
Widget _image(PackagesResponseModel model) => AspectRatio( Widget _image(PackagesResponseModel model) => AspectRatio(
aspectRatio: 1/1, aspectRatio: 1 / 1,
child: Padding( child: Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(9),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300], width: 0.25), border: Border.all(color: Colors.grey[300], width: 0.25),
boxShadow: [ boxShadow: [BoxShadow(color: Colors.grey[200], blurRadius: 2.0, spreadRadius: 1, offset: Offset(1, 1.5))],
BoxShadow(color: Colors.grey[200], blurRadius: 2.0, spreadRadius: 1, offset: Offset(1,1.5)) borderRadius: BorderRadius.circular(15),
],
borderRadius: BorderRadius.circular(8),
color: Colors.white, color: Colors.white,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(15),
child: (model.images.isNotEmpty) child: (model.images.isNotEmpty) ? Utils.loadNetworkImage(url: model.images.first.src, fitting: BoxFit.fill) : Container(color: Colors.grey[200])),
? Utils.loadNetworkImage(url: model.images.first.src, fitting:BoxFit.fill)
: Container(color: Colors.grey[200])
), ),
), ),
), );
);
// --------------------
// Product Name
// --------------------
Widget _itemName(String name) => Padding( Widget _itemName(String name) => Padding(
padding: const EdgeInsets.all(0), padding: const EdgeInsets.only(top: 9.0),
child: Texts( child: Text(name,
name, style: TextStyle(
fontWeight: FontWeight.normal, fontSize: 14,
color: Colors.black, fontWeight: FontWeight.bold,
fontSize: 15 letterSpacing: -0.56,
) )));
);
Widget _itemDescription(String desc) => Padding(
padding: const EdgeInsets.only(top: 0.0),
child: Text(desc,
style: TextStyle(
fontSize: 10,
// fontWeight: FontWeight.bold,
letterSpacing: -0.4,
)));
Widget _itemPrice(double price, {@required BuildContext context}) { Widget _itemPrice(double price, {@required BuildContext context}) {
final prc = (price ?? 0.0).toStringAsFixed(2); final prc = (price ?? 0.0).toStringAsFixed(2);
return Padding( return Padding(
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
child: Texts( child: Text(
'${prc} ${TranslationBase.of(context).sar}',
fontWeight: FontWeight.bold,
color: Colors.green,
fontSize: 15
)
);
}
// --------------------
// Price Seperator
// --------------------
Widget _priceSeperator() => Padding(
padding: const EdgeInsets.only(left: 3, right: 3),
child: Container(height: 0.5, width: 5, color: Colors.grey[100],),
);
// --------------------
// Product Price
// --------------------
Widget _itemOldPrice(double oldPrice, {@required BuildContext context}) {
final prc = (oldPrice ?? 0.0).toStringAsFixed(2);
return Padding(
padding: const EdgeInsets.all(0),
child: Texts(
'${prc} ${TranslationBase.of(context).sar}', '${prc} ${TranslationBase.of(context).sar}',
fontWeight: FontWeight.normal, style: TextStyle(
decoration: TextDecoration.lineThrough, fontSize: 11,
color: Colors.grey, fontWeight: FontWeight.w600,
fontSize: 10 letterSpacing: -0.4,
) ),
); ),
);
} }
// --------------------
// Product Price
// --------------------
Widget _itemCounter(int quantity, {int minQuantity, int maxQuantity, StepperCallbackFuture shouldStepperChangeApply}) => Padding(
padding: const EdgeInsets.all(0),
child: StepperView(
height: 25,
backgroundColor: Colors.grey[300],
foregroundColor: Colors.grey[200],
initialNumber: quantity,
minNumber: minQuantity,
maxNumber: maxQuantity,
counterCallback: shouldStepperChangeApply,
decreaseCallback: (){},
increaseCallback: (){},
)
);
Widget _totalLabel({@required BuildContext context}) => Padding(
padding: const EdgeInsets.all(0),
child: Texts(
'${TranslationBase.of(context).totalWithColonRight}',
fontWeight: FontWeight.bold,
color: Colors.grey[600],
fontSize: 13
)
);
Widget _totalPrice(double totalPrice, {@required BuildContext context}) => Padding(
padding: const EdgeInsets.all(0),
child: Texts(
'${totalPrice.toStringAsFixed(2)} ${TranslationBase.of(context).sar}',
fontWeight: FontWeight.normal,
color: Colors.green,
)
);

@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:rating_bar/rating_bar.dart'; import 'package:rating_bar/rating_bar.dart';
bool wide = true; bool wide = true;
@ -33,7 +34,7 @@ class PackagesItemCardState extends State<PackagesItemCard> {
wide = !wide; wide = !wide;
return InkWell( return InkWell(
onTap: () { onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel))); Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel, onCartClick: widget.onCartClick)));
}, },
child: Container( child: Container(
// width: widget.itemWidth, // width: widget.itemWidth,
@ -73,11 +74,7 @@ class PackagesItemCardState extends State<PackagesItemCard> {
], ],
), ),
InkWell( InkWell(
child: Icon( child: SvgPicture.asset("assets/images/new/add-to-cart.svg"),
Icons.add_shopping_cart_rounded,
size: 30.0,
color: Colors.black,
),
onTap: () { onTap: () {
widget.onCartClick(widget.itemModel); widget.onCartClick(widget.itemModel);
}, },
@ -89,80 +86,5 @@ class PackagesItemCardState extends State<PackagesItemCard> {
), ),
), ),
); );
// Stack(
// children: [
// Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// AspectRatio(
// aspectRatio:1 / 1,
// child: applyShadow(
// child: ClipRRect(
// borderRadius: BorderRadius.circular(10),
// child: Utils.loadNetworkImage(
// url: imageUrl(),
// )),
// )),
// Texts(
// widget.itemModel.getName(),
// fontWeight: FontWeight.normal,
// color: Colors.black,
// fontSize: 15
// ),
// Padding(
// padding: const EdgeInsets.only(left: 10, right: 10),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.end,
// mainAxisSize: MainAxisSize.max,
// children: [
// Stack(
// children: [
// Texts(
// '${widget.itemModel.oldPrice} ${'SAR'}',
// fontWeight: FontWeight.normal,
// decoration: TextDecoration.lineThrough,
// color: Colors.grey,
// fontSize: 12
// ),
// Padding(
// padding: const EdgeInsets.only(top: 8),
// child: Texts(
// '${widget.itemModel.price} ${'SAR'}',
// fontWeight: FontWeight.bold,
// color: Colors.green,
// fontSize: 18
// ),
// ),
// Padding(
// padding: const EdgeInsets.only(top: 35),
// child: StarRating(
// size: 15,
// totalCount: null,
// totalAverage: widget.itemModel.approvedRatingSum.toDouble(),
// forceStars: true),
// )
// ],
// ),
// Spacer(
// flex: 1,
// ),
// InkWell(
// child: Icon(
// Icons.add_shopping_cart_rounded,
// size: 30.0,
// color: Colors.grey,
// ),
// onTap: () {
// widget.onCartClick(widget.itemModel);
// },
// ),
// ],
// ),
// ),
// ],
// ),
// ],
// ),
// );
} }
} }

Loading…
Cancel
Save