From 36f11f1474b2389c2f6eb3a89572f4b9fe8ec83a Mon Sep 17 00:00:00 2001 From: enadhilal Date: Mon, 7 Sep 2020 14:29:35 +0300 Subject: [PATCH 1/8] Merge branch 'master' of gitlab.com:Cloud_Solution/driver-app into delivery_confirmed # Conflicts: # lib/pages/delivery/delivery_confirmed_page.dart # lib/pages/delivery/information_page.dart --- lib/pages/dashboard/dashboard_screen.dart | 24 ++++++++++----- lib/pages/setting/setting.dart | 36 +++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 lib/pages/setting/setting.dart diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index d62ab89..afea5de 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -4,6 +4,7 @@ import 'package:driverapp/core/model/scan_qr/scan_qr_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/delivery/information_page.dart'; import 'package:driverapp/pages/orders/pending_orders_page.dart'; +import 'package:driverapp/pages/setting/setting.dart'; import 'package:driverapp/uitl/app_toast.dart'; import 'package:driverapp/uitl/translations_delegate_base.dart'; import 'package:driverapp/uitl/utils.dart'; @@ -74,17 +75,26 @@ class _DashboardScreenState extends State { child: SafeArea( child: Column( children: [ - CircleAvatar( - radius: 25.5, - backgroundColor: Color(0xff30B7B9), + InkWell( child: CircleAvatar( + radius: 25.5, backgroundColor: Color(0xff30B7B9), - maxRadius: 26.0, - child: Image.asset( - 'assets/images/driver.png', - fit: BoxFit.contain, + child: CircleAvatar( + backgroundColor: Color(0xff30B7B9), + maxRadius: 26.0, + child: Image.asset( + 'assets/images/driver.png', + fit: BoxFit.contain, + ), ), ), + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + SettingPage())); + }, ), ], ), diff --git a/lib/pages/setting/setting.dart b/lib/pages/setting/setting.dart new file mode 100644 index 0000000..a86ce95 --- /dev/null +++ b/lib/pages/setting/setting.dart @@ -0,0 +1,36 @@ +import 'package:driverapp/uitl/translations_delegate_base.dart'; +import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + + +class SettingPage extends StatelessWidget { + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowAppBar: true, + appBarColor: Theme.of(context).primaryColor, + arrowColor: Colors.white, + titleColor: Colors.white, + body: Container( + child: Column( + children: [ + CircleAvatar( + radius: 25.5, + backgroundColor: Color(0xff30B7B9), + child: CircleAvatar( + backgroundColor: Color(0xff30B7B9), + maxRadius: 26.0, + child: Image.asset( + 'assets/images/driver.png', + fit: BoxFit.contain, + ), + ), + ), + ], + ), + ), + ); + } +} \ No newline at end of file From c5987bcbdf816a02f5bdb32e6b2a4099892bcfa8 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 7 Sep 2020 16:47:39 +0300 Subject: [PATCH 2/8] delivery information design update --- lib/pages/delivery/information_page.dart | 2 +- lib/widgets/delivery/customer_brief_card.dart | 73 +++++++++---------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lib/pages/delivery/information_page.dart b/lib/pages/delivery/information_page.dart index 685d5bd..6367d63 100644 --- a/lib/pages/delivery/information_page.dart +++ b/lib/pages/delivery/information_page.dart @@ -1 +1 @@ -import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/custom_bottom_sheet.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Theme.of(context).primaryColor, arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Theme.of(context).primaryColor, child: Container( color: Theme.of(context).primaryColor, child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery.of(context).size.width * 1, height: MediaQuery.of(context).size.width * 1.5, margin: EdgeInsets.only( top: MediaQuery.of(context).size.width * 0.23, ), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white,//Color(0xffED1C24), btnIcon: Icon( DriverApp.location_1, size: 40, color: Color(0xffED1C24) ), btnName: TranslationBase.of(context).location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); },), DeliveryInfoButton( btnColor: Colors.white,//Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: 40, color: Color(0xFF61B260), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white,//Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: 40, color: Color(0xFFFCB657), ), btnName: TranslationBase.of(context).sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white,//Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: 40, color: Theme.of(context).primaryColor, ), btnName: TranslationBase.of(context).call, btnFunction: () => launch("tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8), child: Text( TranslationBase.of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.05, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.01, ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase .of(context) .clientReached, onTap: () { model.showBottomSheet(); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), bottomSheet: !model.isBottomSheetAppear ? Container( width: 0, height: 0, ) : CustomBottomSheet(children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.43, width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )), ]), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase .of(context) .delivered; break; case 4: orderStatusText = TranslationBase .of(context) .deliveredAccepted; break; case 5: orderStatusText = TranslationBase .of(context) .deliveredRejected; break; case 6: orderStatusText = TranslationBase .of(context) .canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model,); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel(deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file +import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/custom_bottom_sheet.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Color(0xff45B7AE), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Colors.red, child: Container( color: Color(0xff45B7AE), child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery.of(context).size.width * 1, height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 1.5 : MediaQuery.of(context).size.width * 0.8, margin: EdgeInsets.only( top: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 0.23 : MediaQuery.of(context).size.width * 0.13), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white, //Color(0xffED1C24), btnIcon: Icon(DriverApp.location_1, size: MediaQuery.of(context) .orientation == Orientation.portrait ? 40 : 90, color: Color(0xffED1C24)), btnName: TranslationBase.of(context).location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); }, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Color(0xFF61B260), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Color(0xFFFCB657), ), btnName: TranslationBase.of(context).sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors .white, //Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Theme.of(context).primaryColor, ), btnName: TranslationBase.of(context).call, btnFunction: () => launch("tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery.of(context).size.width * 0.08, ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8), child: Text( TranslationBase.of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.05, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.01, ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase.of(context).clientReached, onTap: () { model.showBottomSheet(); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), bottomSheet: !model.isBottomSheetAppear ? Container( width: 0, height: 0, ) : CustomBottomSheet(children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.43, width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )), ]), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase.of(context).delivered; break; case 4: orderStatusText = TranslationBase.of(context).deliveredAccepted; break; case 5: orderStatusText = TranslationBase.of(context).deliveredRejected; break; case 6: orderStatusText = TranslationBase.of(context).canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model, ); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel( deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file diff --git a/lib/widgets/delivery/customer_brief_card.dart b/lib/widgets/delivery/customer_brief_card.dart index 7a6899d..1dcba37 100644 --- a/lib/widgets/delivery/customer_brief_card.dart +++ b/lib/widgets/delivery/customer_brief_card.dart @@ -1,3 +1,4 @@ +import 'package:driverapp/widgets/data_display/circle-container.dart'; import 'package:flutter/material.dart'; import '../../uitl/date_uitl.dart'; @@ -16,25 +17,27 @@ class CustomerBriefCard extends StatelessWidget { final double latitude; final bool showDistance; - CustomerBriefCard( - {this.itemId, - this.time, - this.customerFirstName, - this.customerLastName, - this.mobileNo, - this.direction, - this.totalPayment, - this.deliveryTime, - this.longitude, - this.latitude, - this.showDistance = true, - }); + CustomerBriefCard({ + this.itemId, + this.time, + this.customerFirstName, + this.customerLastName, + this.mobileNo, + this.direction, + this.totalPayment, + this.deliveryTime, + this.longitude, + this.latitude, + this.showDistance = true, + }); @override Widget build(BuildContext context) { return Center( child: Container( - width: 350, + width: MediaQuery.of(context).orientation == Orientation.landscape + ? 580 + : 370, height: 270, decoration: BoxDecoration( color: Colors.white, @@ -66,43 +69,39 @@ class CustomerBriefCard extends StatelessWidget { style: TextStyle(color: Color(0xFFADACAD)), ), ), - Visibility( - visible: showDistance, - child: Expanded( - child: CircleAvatar( - backgroundColor: Colors.black45, - radius: 28.0, - child: CircleAvatar( - backgroundColor: Colors.white, - maxRadius: 26.1, - child: Padding( - padding: const EdgeInsets.only(left: 3), - child: Text( - '3 K.m \n away', - style: TextStyle( - color: Color(0xff30B7B9), - fontSize: 12.5, - fontWeight: FontWeight.w600), - ), - ), + Expanded( + child: Padding( + padding: EdgeInsets.all(8.0), + child: CircleContainer( + borderWidth: 0.9, + child: Text( + '0 K.m\naway', + style: TextStyle( + color: Color(0xff42B6AD), + fontWeight: FontWeight.w800, + fontStyle: FontStyle.normal), ), ), ), ), ], ), - SizedBox(height: MediaQuery.of(context).size.width * 0.02,), + SizedBox( + height: MediaQuery.of(context).size.width * 0.02, + ), Text( '${customerFirstName} ${customerLastName}', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w900), ), - SizedBox(height: MediaQuery.of(context).size.width * 0.019,), + SizedBox( + height: MediaQuery.of(context).size.width * 0.019, + ), Text( mobileNo, style: TextStyle(color: Color(0xFF50BDC5)), ), SizedBox( - height:MediaQuery.of(context).size.width*0.005, + height: MediaQuery.of(context).size.width * 0.005, ), // Text( // 'Olaya street, behind KFC resturant, next to kingdom towers 2nd floor ofice 277', @@ -149,7 +148,7 @@ class CustomerBriefCard extends StatelessWidget { ], ), SizedBox( - height: MediaQuery.of(context).size.width*0.03, + height: MediaQuery.of(context).size.width * 0.03, ), Row( children: [ From 9bc404fa2a5a2a180580da56d5f5736e16a484b6 Mon Sep 17 00:00:00 2001 From: enadhilal Date: Tue, 8 Sep 2020 09:07:43 +0300 Subject: [PATCH 3/8] add scroll for landscape --- lib/pages/setting/setting.dart | 184 +++++++++++++++++---------------- 1 file changed, 93 insertions(+), 91 deletions(-) diff --git a/lib/pages/setting/setting.dart b/lib/pages/setting/setting.dart index 7ea5f37..7464459 100644 --- a/lib/pages/setting/setting.dart +++ b/lib/pages/setting/setting.dart @@ -13,114 +13,116 @@ class SettingPage extends StatelessWidget { appBarColor: Color(0xff30B7B9), arrowColor: Colors.white, titleColor: Colors.white, - body: Column( - children: [ - Container( - width: double.infinity, - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width * 0.7, - child: CircleAvatar( - radius: 25.5, - backgroundColor: Theme.of(context).primaryColor, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.width * 0.7, child: CircleAvatar( + radius: 25.5, backgroundColor: Theme.of(context).primaryColor, - maxRadius: 200.0, - child: Image.asset( - 'assets/images/driver.png', - height: 280, - width: 280, - fit: BoxFit.contain, + child: CircleAvatar( + backgroundColor: Theme.of(context).primaryColor, + maxRadius: 200.0, + child: Image.asset( + 'assets/images/driver.png', + height: 280, + width: 280, + fit: BoxFit.contain, + ), ), ), ), - ), - SizedBox(height: 10,), - Container( - child: Text('Driver Name', style: TextStyle(fontSize: 40, fontWeight: FontWeight.w600, color: Colors.white),), - ), - SizedBox(height: 10,), - Container( - child: Text('ID: 123456789', style: TextStyle(fontSize: 20, color: Colors.white),), - ), - ], + SizedBox(height: 10,), + Container( + child: Text('Driver Name', style: TextStyle(fontSize: 40, fontWeight: FontWeight.w600, color: Colors.white),), + ), + SizedBox(height: 10,), + Container( + child: Text('ID: 123456789', style: TextStyle(fontSize: 20, color: Colors.white),), + ), + ], + ), ), - ), - SizedBox(height: 50,), - Container( - margin: EdgeInsets.only(left: 35), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 15), - child: Row( - children: [ - Icon( - Icons.input, - size: 40, + SizedBox(height: 50,), + Container( + margin: EdgeInsets.only(left: 35), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 15), + child: Row( + children: [ + Icon( + Icons.input, + size: 40, + color: Colors.white, + ), + SizedBox(width: 20,), + Text('Log out', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + ], + ), + ), + SizedBox( + height: 10.0, + child: Center( + child: Container( + margin: EdgeInsetsDirectional.only(start: 0, end: 30), + height: 1.0, color: Colors.white, ), - SizedBox(width: 20,), - Text('Log out', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), - ], - ), - ), - SizedBox( - height: 10.0, - child: Center( - child: Container( - margin: EdgeInsetsDirectional.only(start: 0, end: 30), - height: 1.0, - color: Colors.white, ), ), - ), - ], + ], + ), ), - ), - SizedBox(height: 8,), - InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 15), - child: Row( - children: [ - Icon( - Icons.settings, - size: 40, + SizedBox(height: 8,), + InkWell( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 15), + child: Row( + children: [ + Icon( + Icons.settings, + size: 40, + color: Colors.white, + ), + SizedBox(width: 20,), + Text('Settings', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + ], + ), + ), + SizedBox( + height: 10.0, + child: Center( + child: Container( + margin: EdgeInsetsDirectional.only(start: 0, end: 30), + height: 1.0, color: Colors.white, ), - SizedBox(width: 20,), - Text('Settings', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), - ], - ), - ), - SizedBox( - height: 10.0, - child: Center( - child: Container( - margin: EdgeInsetsDirectional.only(start: 0, end: 30), - height: 1.0, - color: Colors.white, ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ); } From f3bea772b5c963b85e14a6811bcca25d19852ad9 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 8 Sep 2020 10:34:45 +0300 Subject: [PATCH 4/8] fix bottom sheet design + make the latitude and longitude dynamic --- ios/Podfile.lock | 12 +++++++++++ ios/Runner.xcodeproj/project.pbxproj | 2 ++ ios/Runner/Info.plist | 4 ++++ .../delivery/delivery_confirmed_page.dart | 20 +++++++++++++------ lib/pages/delivery/information_page.dart | 2 +- lib/uitl/utils.dart | 7 +++++++ pubspec.yaml | 7 ++++++- 7 files changed, 46 insertions(+), 8 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9702d5e..e091971 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -28,6 +28,10 @@ PODS: - Flutter - local_auth (0.0.1): - Flutter + - location (0.0.1): + - Flutter + - location_web (0.0.1): + - Flutter - map_launcher (0.0.1): - Flutter - maps_launcher (0.0.1): @@ -71,6 +75,8 @@ DEPENDENCIES: - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) - local_auth (from `.symlinks/plugins/local_auth/ios`) + - location (from `.symlinks/plugins/location/ios`) + - location_web (from `.symlinks/plugins/location_web/ios`) - map_launcher (from `.symlinks/plugins/map_launcher/ios`) - maps_launcher (from `.symlinks/plugins/maps_launcher/ios`) - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) @@ -118,6 +124,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_picker/ios" local_auth: :path: ".symlinks/plugins/local_auth/ios" + location: + :path: ".symlinks/plugins/location/ios" + location_web: + :path: ".symlinks/plugins/location_web/ios" map_launcher: :path: ".symlinks/plugins/map_launcher/ios" maps_launcher: @@ -157,6 +167,8 @@ SPEC CHECKSUMS: image_cropper: c8f9b4157933c7bb965a66d1c5e6c8fd408c6eb4 image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd + location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740 + location_web: b94e7433cfe28c0f7c8923c2ee482824b32e55a7 map_launcher: e325db1261d029ff33e08e03baccffe09593ffea maps_launcher: eae38ee13a9c3f210fa04e04bb4c073fa4c6ed92 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2f73b5c..6c769fb 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -242,6 +242,7 @@ "${BUILT_PRODUCTS_DIR}/image_cropper/image_cropper.framework", "${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework", "${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework", + "${BUILT_PRODUCTS_DIR}/location/location.framework", "${BUILT_PRODUCTS_DIR}/map_launcher/map_launcher.framework", "${BUILT_PRODUCTS_DIR}/maps_launcher/maps_launcher.framework", "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", @@ -264,6 +265,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_cropper.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/map_launcher.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/maps_launcher.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 933c8db..b980cec 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -41,5 +41,9 @@ UIViewControllerBasedStatusBarAppearance + NSLocationAlwaysUsageDescription + Needed to access location + NSLocationWhenInUseUsageDescription + Needed to access location diff --git a/lib/pages/delivery/delivery_confirmed_page.dart b/lib/pages/delivery/delivery_confirmed_page.dart index 2a4a57d..70b49fd 100644 --- a/lib/pages/delivery/delivery_confirmed_page.dart +++ b/lib/pages/delivery/delivery_confirmed_page.dart @@ -9,6 +9,7 @@ import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:location/location.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; @@ -131,11 +132,14 @@ class DeliveryConfirmedPage extends StatelessWidget { ), Container( margin: EdgeInsets.all(10), - child: SecondaryButton( - label: TranslationBase.of(context).nextDelivery, + child: SecondaryButton( + label: TranslationBase + .of(context) + .nextDelivery, + loading: model.state == ViewState.BusyLocal, onTap: () { - getNextOrder(context, model); - },), + getNextOrder(context, model); + },), ), ], ), @@ -166,11 +170,15 @@ class DeliveryConfirmedPage extends StatelessWidget { } getNextOrder(BuildContext context, OrdersViewModel model) async { + model.setState(ViewState.BusyLocal); + LocationData loc = await Utils.getLocation(); NextOrderRequestModel nextOrderRequestModel = NextOrderRequestModel( pageIndex: 0, pageSize: 0, - latitude: "46.621730", - longitude: "24.797682", + latitude: loc.latitude.toString(), + //"46.621730", + longitude: loc.longitude.toString(), + //"24.797682", searchKey: ""); await model.nextOrder(nextOrderRequestModel); if (model.state == ViewState.ErrorLocal) { diff --git a/lib/pages/delivery/information_page.dart b/lib/pages/delivery/information_page.dart index 685d5bd..701c2ee 100644 --- a/lib/pages/delivery/information_page.dart +++ b/lib/pages/delivery/information_page.dart @@ -1 +1 @@ -import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/custom_bottom_sheet.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Theme.of(context).primaryColor, arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Theme.of(context).primaryColor, child: Container( color: Theme.of(context).primaryColor, child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery.of(context).size.width * 1, height: MediaQuery.of(context).size.width * 1.5, margin: EdgeInsets.only( top: MediaQuery.of(context).size.width * 0.23, ), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white,//Color(0xffED1C24), btnIcon: Icon( DriverApp.location_1, size: 40, color: Color(0xffED1C24) ), btnName: TranslationBase.of(context).location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); },), DeliveryInfoButton( btnColor: Colors.white,//Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: 40, color: Color(0xFF61B260), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white,//Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: 40, color: Color(0xFFFCB657), ), btnName: TranslationBase.of(context).sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white,//Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: 40, color: Theme.of(context).primaryColor, ), btnName: TranslationBase.of(context).call, btnFunction: () => launch("tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8), child: Text( TranslationBase.of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.05, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.01, ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase .of(context) .clientReached, onTap: () { model.showBottomSheet(); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), bottomSheet: !model.isBottomSheetAppear ? Container( width: 0, height: 0, ) : CustomBottomSheet(children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.43, width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )), ]), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase .of(context) .delivered; break; case 4: orderStatusText = TranslationBase .of(context) .deliveredAccepted; break; case 5: orderStatusText = TranslationBase .of(context) .deliveredRejected; break; case 6: orderStatusText = TranslationBase .of(context) .canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model,); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel(deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file +import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { showDeliveryOptions(OrdersViewModel model) { showModalBottomSheet( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(50.0), topRight: Radius.circular(50.0), ), ), context: context, builder: (BuildContext bc) { return ListView( children: [ Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(50.0), topRight: Radius.circular(50.0), ), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.45, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(50.0), topRight: Radius.circular(50.0), ), ), width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )) ], ), ), ], ); }); } return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Theme.of(context).primaryColor, arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Theme.of(context).primaryColor, child: Container( color: Theme .of(context) .primaryColor, child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery .of(context) .size .width * 1, height: MediaQuery .of(context) .size .width * 1.5, margin: EdgeInsets.only( top: MediaQuery .of(context) .size .width * 0.23, ), decoration: BoxDecoration( color: Theme .of(context) .scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery .of(context) .size .width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white, //Color(0xffED1C24), btnIcon: Icon( DriverApp.location_1, size: 40, color: Color(0xffED1C24) ), btnName: TranslationBase .of(context) .location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); },), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: 40, color: Color(0xFF61B260), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: 40, color: Color(0xFFFCB657), ), btnName: TranslationBase .of(context) .sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white, //Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: 40, color: Theme .of(context) .primaryColor, ), btnName: TranslationBase .of(context) .call, btnFunction: () => launch( "tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery .of(context) .size .width * 0.1, ), Container( margin: EdgeInsets.only( left: MediaQuery .of(context) .size .width * 0.05, right: MediaQuery .of(context) .size .width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment .start, children: [ Padding( padding: const EdgeInsets.only( left: 8), child: Text( TranslationBase .of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery .of(context) .size .width * 0.05, ), Padding( padding: const EdgeInsets.only( left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery .of(context) .size .width * 0.01, ), ], ), ), SizedBox( height: MediaQuery .of(context) .size .width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase .of(context) .clientReached, onTap: () { showDeliveryOptions(model); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase .of(context) .delivered; break; case 4: orderStatusText = TranslationBase .of(context) .deliveredAccepted; break; case 5: orderStatusText = TranslationBase .of(context) .deliveredRejected; break; case 6: orderStatusText = TranslationBase .of(context) .canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model,); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel(deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 1c2da2b..6919cff 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -1,5 +1,6 @@ import 'package:connectivity/connectivity.dart'; import 'package:flutter/cupertino.dart'; +import 'package:location/location.dart'; import 'app_shared_preferences.dart'; import 'app_toast.dart'; @@ -42,4 +43,10 @@ class Utils { static hideKeyboard(BuildContext context) { FocusScope.of(context).unfocus(); } + + static getLocation() async { + Location location = new Location(); + LocationData currentLocation = await location.getLocation(); + return currentLocation; + } } diff --git a/pubspec.yaml b/pubspec.yaml index 6184287..778cf11 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,9 +67,14 @@ dependencies: # Qr code Scanner barcode_scan: ^3.0.1 - #mape + # map map_launcher: ^0.12.0 + # location + location: ^3.0.2 + + + From 3eedb7e66779876922834aca2168cf206fa978ef Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 8 Sep 2020 11:00:54 +0300 Subject: [PATCH 5/8] service update and design updates --- .../orders/pending_orders_req_model.dart | 7 + lib/core/service/orders_service.dart | 2 + lib/pages/dashboard/dashboard_screen.dart | 2 +- .../delivery/delivery_confirmed_page.dart | 230 +++++++++--------- lib/pages/delivery/information_page.dart | 2 +- lib/pages/orders/pending_orders_page.dart | 2 +- .../data_display/circle-container.dart | 4 +- lib/widgets/delivery/customer_brief_card.dart | 11 +- .../delivery/delivery_action_button.dart | 22 +- 9 files changed, 148 insertions(+), 134 deletions(-) diff --git a/lib/core/model/orders/pending_orders_req_model.dart b/lib/core/model/orders/pending_orders_req_model.dart index 782bddc..3db7263 100644 --- a/lib/core/model/orders/pending_orders_req_model.dart +++ b/lib/core/model/orders/pending_orders_req_model.dart @@ -10,6 +10,8 @@ class PendingOrders { String lastName; String mobileNumber; int distanceInKilometers; + String longitude; + String latitude; PendingOrders({ this.driverID, @@ -23,6 +25,8 @@ class PendingOrders { this.lastName, this.mobileNumber, this.distanceInKilometers, + this.longitude, + this.latitude, }); PendingOrders.fromJson(Map json) { @@ -48,6 +52,9 @@ class PendingOrders { data['TokenID'] = this.tokenID; data['UserID'] = this.userID; data['MobileNo'] = this.mobileNo; + data['Longitude'] = this.longitude; + data['Latitude'] = this.latitude; + return data; } } diff --git a/lib/core/service/orders_service.dart b/lib/core/service/orders_service.dart index d95c7fe..785ad1e 100644 --- a/lib/core/service/orders_service.dart +++ b/lib/core/service/orders_service.dart @@ -23,6 +23,8 @@ class OrdersService extends BaseService { searchKey: "", pageSize: 0, pageIndex: 0, + latitude: "24.640000", + longitude: "46.753000", ); DeliverdOrderModel _requestGetDeliverdOrders = DeliverdOrderModel( searchKey: "", diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 8b9d0a5..a055cda 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -588,7 +588,7 @@ class _DashboardScreenState extends State { child: Text( model.orders[index].distanceInKilometers .toString() + - ' K.m\naway', + '\nK.m\naway', style: TextStyle( color: Color(0xff42B6AD), fontWeight: FontWeight.w800, diff --git a/lib/pages/delivery/delivery_confirmed_page.dart b/lib/pages/delivery/delivery_confirmed_page.dart index 2a4a57d..ebb598d 100644 --- a/lib/pages/delivery/delivery_confirmed_page.dart +++ b/lib/pages/delivery/delivery_confirmed_page.dart @@ -23,39 +23,41 @@ class DeliveryConfirmedPage extends StatelessWidget { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, - appBarColor: Theme.of(context).primaryColor, - arrowColor: Colors.white, - titleColor: Colors.white, - body: SafeArea( - child: Container( - color: Theme.of(context).primaryColor, - child: ListView( - children: [ - Stack( + appBarColor: Theme.of(context).primaryColor, + arrowColor: Colors.white, + titleColor: Colors.white, + body: SafeArea( + child: Container( + color: Theme.of(context).primaryColor, + child: ListView( + children: [ + Stack( children: [ Column( children: [ Container( - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width * 0.7, - padding: EdgeInsets.only( - top: MediaQuery.of(context).size.width * 0.12, - ), - decoration: BoxDecoration( - color: Colors.white10, shape: BoxShape.circle), - child: Column( - children: [ - Icon( - Icons.check_circle, - color: Colors.white, - size: 75, - ), - SizedBox( - height: - MediaQuery.of(context).size.width * 0.03, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.width * 0.7, + padding: EdgeInsets.only( + top: MediaQuery.of(context).size.width * 0.12, + ), + decoration: BoxDecoration( + color: Colors.white10, + shape: BoxShape.circle), + child: Column( + children: [ + Icon( + Icons.check_circle, + color: Colors.white, + size: 75, + ), + SizedBox( + height: + MediaQuery.of(context).size.width * + 0.03, ), Text( TranslationBase.of(context).deliveryInfo, @@ -65,100 +67,106 @@ class DeliveryConfirmedPage extends StatelessWidget { fontWeight: FontWeight.bold), ), SizedBox( - height: - MediaQuery.of(context).size.width * 0.03, - ), - Text( - TranslationBase.of(context).confirmationSent, - style: TextStyle( - color: Colors.white, - fontSize: 13, + height: + MediaQuery.of(context).size.width * + 0.03, ), - ), - ], + Text( + TranslationBase.of(context) + .confirmationSent, + style: TextStyle( + color: Colors.white, + fontSize: 13, + ), + ), + ], + ), ), - ), - ], + ], + ), ), - ), - ], - ), - Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width, - ), - Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width * 1.0, - margin: EdgeInsets.only( - top: MediaQuery.of(context).size.width * 0.75, + ], ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(80), - topRight: Radius.circular(80)), + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.width, ), - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.only( - bottom: MediaQuery.of(context).size.width * 0.09, - ), - child: Column( - children: [ - FlatButton.icon( - padding: EdgeInsets.all(8), - color: Colors.orangeAccent, - shape: RoundedRectangleBorder( - borderRadius: new BorderRadius.circular(10.0), + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.width * 1.0, + margin: EdgeInsets.only( + top: MediaQuery.of(context).size.width * 0.75, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(80), + topRight: Radius.circular(80)), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only( + bottom: MediaQuery.of(context).size.width * 0.09, + ), + child: Column( + children: [ + FlatButton.icon( + padding: EdgeInsets.all(8), + color: Colors.orangeAccent, + shape: RoundedRectangleBorder( + borderRadius: + new BorderRadius.circular(10.0), + ), + label: Text( + TranslationBase.of(context).addNoteBtn, + style: TextStyle(color: Colors.white), + ), + icon: Icon( + Icons.mode_edit, + color: Colors.white, + ), + onPressed: () {}, ), - label: Text( - TranslationBase.of(context).addNoteBtn, - style: TextStyle(color: Colors.white), + SizedBox( + height: MediaQuery.of(context).size.width * + 0.02, //20, ), - icon: Icon( - Icons.mode_edit, - color: Colors.white, + Container( + margin: EdgeInsets.all(10), + child: SecondaryButton( + label: TranslationBase.of(context) + .nextDelivery, + onTap: () { + getNextOrder(context, model); + }, + ), ), - onPressed: () {}, - ), - SizedBox( - height: - MediaQuery.of(context).size.width * 0.02, //20, - ), - Container( - margin: EdgeInsets.all(10), - child: SecondaryButton( - label: TranslationBase.of(context).nextDelivery, - onTap: () { - getNextOrder(context, model); - },), - ), - ], + ], + ), ), - ), - ], + ], + ), ), - ), - Container( - margin: EdgeInsets.only( + Container( + margin: EdgeInsets.only( top: MediaQuery.of(context).size.width * 0.6, + ), + child: CustomerBriefCard( + itemId: item.orderID, + customerFirstName: item.firstName, + customerLastName: item.lastName, + mobileNo: item.mobileNumber, + totalPayment: item.amount, + showDistance: false, + deliveryTime: item.orderCreatedOn), ), - child: CustomerBriefCard( - itemId: item.orderID, - customerFirstName: item.firstName, - customerLastName: item.lastName, - mobileNo: item.mobileNumber, - totalPayment: item.amount, - showDistance: false, - deliveryTime: item.orderCreatedOn), - ), - ], - ), - ],), + ], + ), + ], + ), ), ), ), diff --git a/lib/pages/delivery/information_page.dart b/lib/pages/delivery/information_page.dart index 6367d63..cbe19fe 100644 --- a/lib/pages/delivery/information_page.dart +++ b/lib/pages/delivery/information_page.dart @@ -1 +1 @@ -import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/custom_bottom_sheet.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Color(0xff45B7AE), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Colors.red, child: Container( color: Color(0xff45B7AE), child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery.of(context).size.width * 1, height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 1.5 : MediaQuery.of(context).size.width * 0.8, margin: EdgeInsets.only( top: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 0.23 : MediaQuery.of(context).size.width * 0.13), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white, //Color(0xffED1C24), btnIcon: Icon(DriverApp.location_1, size: MediaQuery.of(context) .orientation == Orientation.portrait ? 40 : 90, color: Color(0xffED1C24)), btnName: TranslationBase.of(context).location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); }, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Color(0xFF61B260), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Color(0xFFFCB657), ), btnName: TranslationBase.of(context).sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors .white, //Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: MediaQuery.of(context).orientation == Orientation.portrait ? 40 : 90, color: Theme.of(context).primaryColor, ), btnName: TranslationBase.of(context).call, btnFunction: () => launch("tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery.of(context).size.width * 0.08, ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8), child: Text( TranslationBase.of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.05, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.01, ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase.of(context).clientReached, onTap: () { model.showBottomSheet(); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), bottomSheet: !model.isBottomSheetAppear ? Container( width: 0, height: 0, ) : CustomBottomSheet(children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.43, width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )), ]), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase.of(context).delivered; break; case 4: orderStatusText = TranslationBase.of(context).deliveredAccepted; break; case 5: orderStatusText = TranslationBase.of(context).deliveredRejected; break; case 6: orderStatusText = TranslationBase.of(context).canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model, ); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel( deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file +import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/custom_bottom_sheet.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/data_display/dialog/custom_dialog.dart'; import 'package:driverapp/widgets/data_display/text.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; import 'package:driverapp/widgets/delivery/delivery_action_button.dart'; import 'package:driverapp/widgets/delivery/package_content.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class InformationPage extends StatelessWidget { final PendingOrdersRes item; int orderStatus; InformationPage(this.item); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Color(0xff45B7AE), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, body: Container( color: Colors.red, child: Container( color: Color(0xff45B7AE), child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Container( width: MediaQuery.of(context).size.width * 1, height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 1.5 : MediaQuery.of(context).size.width * 0.9, margin: EdgeInsets.only( top: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width * 0.23 : MediaQuery.of(context).size.width * 0.13), decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.only( topLeft: Radius.circular(45), topRight: Radius.circular(45)), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.width * 0.23, //MediaQuery.of(context).size.width * 0.005, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DeliveryInfoButton( btnColor: Colors.white, //Color(0xffED1C24), btnIcon: Icon(DriverApp.location_1, size: MediaQuery.of(context) .orientation == Orientation.portrait ? 50 : 90, color: Color(0xffED1C24)), btnName: TranslationBase.of(context).location, btnFunction: () { MapsLauncher.launchCoordinates( item.latitude, item.longitude); }, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFF61B260), btnIcon: Icon( DriverApp.whatsapp, size: MediaQuery.of(context).orientation == Orientation.portrait ? 50 : 90, color: Color(0xFF5EA34A), ), btnName: 'Whatsapp', btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors.white, //Color(0xFFFCB657), btnIcon: Icon( DriverApp.message, size: MediaQuery.of(context).orientation == Orientation.portrait ? 50 : 90, color: Color(0xffFFA540), ), btnName: TranslationBase.of(context).sms, btnFunction: () {}, ), DeliveryInfoButton( btnColor: Colors .white, //Theme.of(context).primaryColor, btnIcon: Icon( DriverApp.call, size: MediaQuery.of(context).orientation == Orientation.portrait ? 50 : 90, color: Theme.of(context).primaryColor, ), btnName: TranslationBase.of(context).call, btnFunction: () => launch("tel://" + item.mobileNumber), ), ], ), SizedBox( height: MediaQuery.of(context).size.width * 0.08, ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8), child: Text( TranslationBase.of(context) .packageContent, style: TextStyle( fontWeight: FontWeight.w900, fontSize: 20), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.05, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( children: List.generate( item.itemsQuantitiesList != null ? item .itemsQuantitiesList.length : 0, (index) { return packageContent( packageName: item .itemsQuantitiesList[index] .itemName .toString(), packageCount: item .itemsQuantitiesList[index] .quantity .toString(), ); }), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.01, ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: EdgeInsets.all(10), child: SecondaryButton( label: TranslationBase.of(context).clientReached, onTap: () { model.showBottomSheet(); }, ), ), ], ), ), CustomerBriefCard( itemId: item.orderID, customerFirstName: item.firstName, customerLastName: item.lastName, mobileNo: item.mobileNumber, totalPayment: item.amount, deliveryTime: item.orderCreatedOn, longitude: item.longitude, latitude: item.latitude, ), ], ), ], ), ], ), ), ), bottomSheet: !model.isBottomSheetAppear ? Container( width: 0, height: 0, ) : CustomBottomSheet(children: [ SizedBox( height: 10, ), Center( child: Texts( TranslationBase.of(context).selectAction, color: Colors.black, fontSize: 22, ), ), SizedBox( height: 10, ), FractionallySizedBox( widthFactor: MediaQuery.of(context).orientation == Orientation.portrait ? 0.9 : 0.98, child: Container( height: MediaQuery.of(context).size.height * 0.43, width: double.infinity, child: ListView( children: [ Column( children: [ SizedBox( height: 3, child: Container( color: Hexcolor("#D5D5D5"), ), ), SizedBox( height: 15, ), ActionSheetButton( label: TranslationBase.of(context).delivered, icon: DriverApp.deliverd_icon, onTap: () { selectAction(context, 3, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () { selectAction(context, 4, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () { selectAction(context, 5, model); }, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () { selectAction(context, 6, model); }, ), SizedBox(height: 15), ], ), ], ), )), ]), ), ); } selectAction(BuildContext context, orderStatus, OrdersViewModel model) { String orderStatusText; this.orderStatus = orderStatus; switch (orderStatus) { case 3: orderStatusText = TranslationBase.of(context).delivered; break; case 4: orderStatusText = TranslationBase.of(context).deliveredAccepted; break; case 5: orderStatusText = TranslationBase.of(context).deliveredRejected; break; case 6: orderStatusText = TranslationBase.of(context).canceled; break; } showDialog( context: context, builder: (BuildContext context) { return CustomDialog( orderStatusText: orderStatusText, callService: () { updateOrderStatus(context, model); }, model: model, ); }); } updateOrderStatus(BuildContext context, OrdersViewModel model) async { UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel( deliveryOrderID: item.orderID, deliveryOrderStatus: orderStatus, rejectionReason: "NO Reason", cancleReason: ""); await model.updateOrderStatus(updateOrderStatusRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); Navigator.of(context).pop(); model.hideBottomSheet(); } else { Navigator.of(context).pop(); model.hideBottomSheet(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => DeliveryConfirmedPage(item), ), ); } } } \ No newline at end of file diff --git a/lib/pages/orders/pending_orders_page.dart b/lib/pages/orders/pending_orders_page.dart index e926443..50eb090 100644 --- a/lib/pages/orders/pending_orders_page.dart +++ b/lib/pages/orders/pending_orders_page.dart @@ -115,7 +115,7 @@ class _OrdersListScreenState extends State { child: Text( model.orders[index].distanceInKilometers .toString() + - ' K.m\naway', + '\nK.m\naway', style: TextStyle( color: Color(0xff42B6AD), fontWeight: FontWeight.w800, diff --git a/lib/widgets/data_display/circle-container.dart b/lib/widgets/data_display/circle-container.dart index bb0ebdd..02efbdf 100644 --- a/lib/widgets/data_display/circle-container.dart +++ b/lib/widgets/data_display/circle-container.dart @@ -26,8 +26,8 @@ class CircleContainer extends StatelessWidget { color: color, border: Border.all( color: borderColor ?? Hexcolor("#707070"), width: borderWidth)), - height: 60, - width: 60, + height: 80, + width: 80, ), ); } diff --git a/lib/widgets/delivery/customer_brief_card.dart b/lib/widgets/delivery/customer_brief_card.dart index 1dcba37..9e39e7f 100644 --- a/lib/widgets/delivery/customer_brief_card.dart +++ b/lib/widgets/delivery/customer_brief_card.dart @@ -66,7 +66,10 @@ class CustomerBriefCard extends StatelessWidget { flex: 3, child: Text( 'ID: ${itemId}', - style: TextStyle(color: Color(0xFFADACAD)), + style: TextStyle( + color: Color(0xFFADACAD), + fontWeight: FontWeight.w800, + fontSize: 17.5), ), ), Expanded( @@ -91,7 +94,7 @@ class CustomerBriefCard extends StatelessWidget { ), Text( '${customerFirstName} ${customerLastName}', - style: TextStyle(fontSize: 20, fontWeight: FontWeight.w900), + style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500), ), SizedBox( height: MediaQuery.of(context).size.width * 0.019, @@ -142,7 +145,7 @@ class CustomerBriefCard extends StatelessWidget { child: Text( totalPayment.toString(), textAlign: TextAlign.end, - style: TextStyle(fontWeight: FontWeight.w600), + style: TextStyle(fontWeight: FontWeight.w400), ), ), ], @@ -163,7 +166,7 @@ class CustomerBriefCard extends StatelessWidget { child: Text( '${DateUtil.getMonthDayYearDateFormatted(DateUtil.convertStringToDate(deliveryTime))} ${(DateUtil.convertStringToHours(deliveryTime))}', textAlign: TextAlign.end, - style: TextStyle(fontWeight: FontWeight.w600)), + style: TextStyle(fontWeight: FontWeight.w400)), ), ], ) diff --git a/lib/widgets/delivery/delivery_action_button.dart b/lib/widgets/delivery/delivery_action_button.dart index 00ea320..7a25e6e 100644 --- a/lib/widgets/delivery/delivery_action_button.dart +++ b/lib/widgets/delivery/delivery_action_button.dart @@ -12,25 +12,19 @@ class DeliveryInfoButton extends StatelessWidget { Widget build(BuildContext context) { print(btnColor); return Padding( - padding: EdgeInsets.all(8.0), + padding: MediaQuery.of(context).orientation == Orientation.portrait + ? EdgeInsets.all(4.0) + : EdgeInsets.all(7.0), child: Column( children: [ SizedBox( - height: MediaQuery - .of(context) - .size - .width * 0.14, - width: MediaQuery - .of(context) - .size - .width * 0.165, // specific value - child: - InkWell( - child: btnIcon, + height: MediaQuery.of(context).size.width * 0.14, + width: MediaQuery.of(context).size.width * 0.165, // specific value + child: InkWell( + child: btnIcon, onTap: btnFunction, ), ), - Text( btnName, style: TextStyle( @@ -42,4 +36,4 @@ class DeliveryInfoButton extends StatelessWidget { ), ); } -} \ No newline at end of file +} From be8dd59c6d4c46d39be7dd1d53192fe18ef3e7ca Mon Sep 17 00:00:00 2001 From: enadhilal Date: Tue, 8 Sep 2020 11:31:26 +0300 Subject: [PATCH 6/8] make driver name and ID dynamic, add translate to logout and settings label. --- lib/pages/dashboard/dashboard_screen.dart | 2 +- lib/pages/setting/setting.dart | 31 +++++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 460bce7..8b7b411 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -109,7 +109,7 @@ class _DashboardScreenState extends State { context, MaterialPageRoute( builder: (context) => - SettingPage())); + SettingPage(driverName:_authenticationViewModel.user.userName, driverID:_authenticationViewModel.user.userID))); }, ), ], diff --git a/lib/pages/setting/setting.dart b/lib/pages/setting/setting.dart index 7464459..0de7d9a 100644 --- a/lib/pages/setting/setting.dart +++ b/lib/pages/setting/setting.dart @@ -5,6 +5,10 @@ import 'package:flutter/material.dart'; class SettingPage extends StatelessWidget { + final String driverName;//_authenticationViewModel.user.userName + final int driverID; + + SettingPage({this.driverName, this.driverID}); @override Widget build(BuildContext context) { @@ -31,25 +35,25 @@ class SettingPage extends StatelessWidget { maxRadius: 200.0, child: Image.asset( 'assets/images/driver.png', - height: 280, - width: 280, + height: MediaQuery.of(context).size.width * 1 , + width: MediaQuery.of(context).size.width * 1, fit: BoxFit.contain, ), ), ), ), - SizedBox(height: 10,), + SizedBox(height: MediaQuery.of(context).size.width *0.05,), Container( - child: Text('Driver Name', style: TextStyle(fontSize: 40, fontWeight: FontWeight.w600, color: Colors.white),), + child: Text(driverName, style: TextStyle(fontSize: 40, fontWeight: FontWeight.w600, color: Colors.white),), ), - SizedBox(height: 10,), + SizedBox(height: MediaQuery.of(context).size.width *0.05,), Container( - child: Text('ID: 123456789', style: TextStyle(fontSize: 20, color: Colors.white),), + child: Text('ID: ${driverID.toString()}', style: TextStyle(fontSize: 20, color: Colors.white),), ), ], ), ), - SizedBox(height: 50,), + SizedBox(height: MediaQuery.of(context).size.width *0.1,), Container( margin: EdgeInsets.only(left: 35), child: Column( @@ -68,13 +72,13 @@ class SettingPage extends StatelessWidget { size: 40, color: Colors.white, ), - SizedBox(width: 20,), - Text('Log out', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + SizedBox(width: MediaQuery.of(context).size.width *0.05,), + Text(TranslationBase.of(context).logout, style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), ], ), ), SizedBox( - height: 10.0, + height: MediaQuery.of(context).size.width *0.05, child: Center( child: Container( margin: EdgeInsetsDirectional.only(start: 0, end: 30), @@ -86,7 +90,7 @@ class SettingPage extends StatelessWidget { ], ), ), - SizedBox(height: 8,), + SizedBox(height: MediaQuery.of(context).size.width*0.05,), InkWell( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -100,8 +104,8 @@ class SettingPage extends StatelessWidget { size: 40, color: Colors.white, ), - SizedBox(width: 20,), - Text('Settings', style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + SizedBox(width: MediaQuery.of(context).size.width * 0.05,), + Text(TranslationBase.of(context).settings, style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), ], ), ), @@ -115,6 +119,7 @@ class SettingPage extends StatelessWidget { ), ), ), + SizedBox(height: MediaQuery.of(context).size.width*0.05,), ], ), ), From 99a2233733a5d94c61a0017e3365d1bd325ce131 Mon Sep 17 00:00:00 2001 From: enadhilal Date: Tue, 8 Sep 2020 11:33:33 +0300 Subject: [PATCH 7/8] make driver name and ID dynamic, add translate to logout and settings label. --- lib/pages/setting/setting.dart | 39 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/pages/setting/setting.dart b/lib/pages/setting/setting.dart index 0de7d9a..c084d7f 100644 --- a/lib/pages/setting/setting.dart +++ b/lib/pages/setting/setting.dart @@ -44,11 +44,24 @@ class SettingPage extends StatelessWidget { ), SizedBox(height: MediaQuery.of(context).size.width *0.05,), Container( - child: Text(driverName, style: TextStyle(fontSize: 40, fontWeight: FontWeight.w600, color: Colors.white),), + child: Text( + driverName, + style: TextStyle( + fontSize: 40, + fontWeight: FontWeight.w600, + color: Colors.white + ), + ), ), SizedBox(height: MediaQuery.of(context).size.width *0.05,), Container( - child: Text('ID: ${driverID.toString()}', style: TextStyle(fontSize: 20, color: Colors.white),), + child: Text( + 'ID: ${driverID.toString()}', + style: TextStyle( + fontSize: 20, + color: Colors.white + ), + ), ), ], ), @@ -73,7 +86,14 @@ class SettingPage extends StatelessWidget { color: Colors.white, ), SizedBox(width: MediaQuery.of(context).size.width *0.05,), - Text(TranslationBase.of(context).logout, style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + Text( + TranslationBase.of(context).logout, + style: TextStyle( + fontWeight: FontWeight.w500, + color: Colors.white, + fontSize: 18 + ), + ), ], ), ), @@ -104,8 +124,17 @@ class SettingPage extends StatelessWidget { size: 40, color: Colors.white, ), - SizedBox(width: MediaQuery.of(context).size.width * 0.05,), - Text(TranslationBase.of(context).settings, style: TextStyle(fontWeight: FontWeight.w500, color: Colors.white, fontSize: 18),), + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + ), + Text( + TranslationBase.of(context).settings, + style: TextStyle( + fontWeight: FontWeight.w500, + color: Colors.white, + fontSize: 18 + ), + ), ], ), ), From c85b82d5538e310477b2ddd581fcc95e6ae7e862 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 8 Sep 2020 12:24:24 +0300 Subject: [PATCH 8/8] fix login issue --- .../viewModels/authentication_view_model.dart | 5 ++- lib/locator.dart | 3 +- lib/pages/authentication/login_page.dart | 44 +++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/core/viewModels/authentication_view_model.dart b/lib/core/viewModels/authentication_view_model.dart index 96f3dc0..1f89a60 100644 --- a/lib/core/viewModels/authentication_view_model.dart +++ b/lib/core/viewModels/authentication_view_model.dart @@ -69,7 +69,10 @@ class AuthenticationViewModel with ChangeNotifier { isError = true; notifyListeners(); } else { - sharedPref.setObject( + isLoading = false; + isError = false; + isLogin = true; + await sharedPref.setObject( USER_PROFILE, _authenticationService.authenticatedUser); sharedPref.setString(TOKEN, _authenticationService.token); user = _authenticationService.authenticatedUser; diff --git a/lib/locator.dart b/lib/locator.dart index 66afadd..d1b2ba3 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -3,7 +3,6 @@ import 'package:get_it/get_it.dart'; import 'core/service/authentication_service.dart'; import 'core/service/hospital_service.dart'; import 'core/service/orders_service.dart'; -import 'core/viewModels/authentication_view_model.dart'; import 'core/viewModels/hospital_view_model.dart'; import 'core/viewModels/orders_view_model.dart'; @@ -18,6 +17,6 @@ void setupLocator() { /// View Model locator.registerFactory(() => HospitalViewModel()); - locator.registerFactory(() => AuthenticationViewModel()); + // locator.registerFactory(() => AuthenticationViewModel()); locator.registerFactory(() => OrdersViewModel()); } diff --git a/lib/pages/authentication/login_page.dart b/lib/pages/authentication/login_page.dart index 5d45d5c..79046f7 100644 --- a/lib/pages/authentication/login_page.dart +++ b/lib/pages/authentication/login_page.dart @@ -2,11 +2,9 @@ import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/core/model/authentication/login_request.dart'; import 'package:driverapp/core/viewModels/authentication_view_model.dart'; import 'package:driverapp/core/viewModels/project_view_model.dart'; -import 'package:driverapp/pages/dashboard/dashboard_screen.dart'; import 'package:driverapp/uitl/translations_delegate_base.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; -import 'package:driverapp/widgets/data_display/circle-container.dart'; import 'package:driverapp/widgets/input/text_field.dart'; import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -25,16 +23,27 @@ class LoginPage extends StatelessWidget { Widget build(BuildContext context) { projectViewModel = Provider.of(context); authenticationViewModel = Provider.of(context); + + login() async { + if (loginFormKey.currentState.validate()) { + loginFormKey.currentState.save(); + await authenticationViewModel.login(loginRequest); + if (authenticationViewModel.isError) { + Utils.showErrorToast(authenticationViewModel.error); + } + } + } + return AnimatedSwitcher( duration: Duration(microseconds: 350), - child: AppScaffold( - isShowAppBar: false, - body: SingleChildScrollView( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - FractionallySizedBox( + child: AppScaffold( + isShowAppBar: false, + body: SingleChildScrollView( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + FractionallySizedBox( widthFactor: 0.80, child: Column( children: [ @@ -237,7 +246,7 @@ class LoginPage extends StatelessWidget { SecondaryButton( label: TranslationBase.of(context).login, onTap: () { - login(context); + login(); }, disabled: authenticationViewModel.isLoading, loading: authenticationViewModel.isLoading, @@ -255,17 +264,4 @@ class LoginPage extends StatelessWidget { ); } - login(BuildContext context) async { - if (loginFormKey.currentState.validate()) { - loginFormKey.currentState.save(); - await authenticationViewModel.login(loginRequest); - if (authenticationViewModel.isError) { - Utils.showErrorToast(authenticationViewModel.error); - } else { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => DashboardScreen())); - } - } - } }