From ae3853ad965e5c5522bb5aea342b362d843862f4 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 15 Sep 2020 15:59:53 +0300 Subject: [PATCH 1/2] finish location request permission --- lib/core/service/orders_service.dart | 42 ++++++++-------- lib/core/viewModels/orders_view_model.dart | 8 ++-- lib/pages/dashboard/dashboard_screen.dart | 2 +- .../setting/request_permission_page.dart | 2 +- lib/uitl/utils.dart | 48 +++++++++---------- 5 files changed, 53 insertions(+), 49 deletions(-) diff --git a/lib/core/service/orders_service.dart b/lib/core/service/orders_service.dart index 301507a..3320ab6 100644 --- a/lib/core/service/orders_service.dart +++ b/lib/core/service/orders_service.dart @@ -13,15 +13,17 @@ import 'package:location/location.dart'; class OrdersService extends BaseService { List _orders = List(); List _nextOrdersList = List(); - List _deliverdOrderList = List(); + List _deliveredOrderList = List(); + List get orders => _orders; - List get deliverdOrderList => _deliverdOrderList; + + List get deliveredOrderList => _deliveredOrderList; List get nextOrdersList => _nextOrdersList; bool isOrderInserted; bool isOrderStatusUpdated; - DeliverdOrderModel _requestGetDeliverdOrders = DeliverdOrderModel( + DeliverdOrderModel _requestGetDeliveredOrders = DeliverdOrderModel( searchKey: "", pageSize: 0, pageIndex: 0, @@ -30,7 +32,6 @@ class OrdersService extends BaseService { ); Future getPendingOrders() async { - // if (await Utils.isLocationPermissionGranted()) { LocationData loc = await Utils.getLocation(); if (loc != null) { @@ -117,7 +118,7 @@ class OrdersService extends BaseService { } } - Future getDeliverdList() async { + Future getDeliveredList() async { LocationData loc = await Utils.getLocation(); PendingOrders _requestGetPendingOrders = PendingOrders( searchKey: "", @@ -126,23 +127,26 @@ class OrdersService extends BaseService { latitude: loc.latitude.toString(), longitude: loc.longitude.toString(), ); - hasError = false; - try { - await baseAppClient.post(GET_ALL_DELIVERD_ORDER, - onSuccess: (dynamic response, int statusCode) { - _deliverdOrderList.clear(); - response['PatientER_Delivery_GetAllDeliverdOrderList'].forEach((order) { - _deliverdOrderList.add(DeliverdOrderResModel.fromJson(order)); - }); - }, onFailure: (String error, int statusCode) { + if (loc != null) { + hasError = false; + try { + await baseAppClient.post(GET_ALL_DELIVERD_ORDER, + onSuccess: (dynamic response, int statusCode) { + _deliveredOrderList.clear(); + response['PatientER_Delivery_GetAllDeliverdOrderList'] + .forEach((order) { + _deliveredOrderList.add(DeliverdOrderResModel.fromJson(order)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestGetPendingOrders.toJson()); + } catch (e) { hasError = true; super.error = error; - }, body: _requestGetPendingOrders.toJson()); - } catch (e) { - hasError = true; - super.error = error; - throw e; + throw e; + } } } } diff --git a/lib/core/viewModels/orders_view_model.dart b/lib/core/viewModels/orders_view_model.dart index 028656e..878004c 100644 --- a/lib/core/viewModels/orders_view_model.dart +++ b/lib/core/viewModels/orders_view_model.dart @@ -1,11 +1,11 @@ import 'package:driverapp/core/enum/viewstate.dart'; -import 'package:driverapp/core/model/orders/deliverd_order_req_model.dart'; +import 'package:driverapp/core/model/orders/deliverd_order_res_model.dart'; import 'package:driverapp/core/model/orders/next_order_request_model.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/model/scan_qr/scan_qr_request_model.dart'; import 'package:driverapp/core/service/orders_service.dart'; -import 'package:driverapp/core/model/orders/deliverd_order_res_model.dart'; + import '../../locator.dart'; import 'base_view_model.dart'; @@ -15,7 +15,7 @@ class OrdersViewModel extends BaseViewModel { List get orders => _ordersService.orders; List get deliverdOrders => - _ordersService.deliverdOrderList; + _ordersService.deliveredOrderList; List get nextOrdersList => _ordersService.nextOrdersList; bool isBottomSheetAppear = false; @@ -32,7 +32,7 @@ class OrdersViewModel extends BaseViewModel { Future getDeliverdOrders() async { setState(ViewState.Busy); - await _ordersService.getDeliverdList(); + await _ordersService.getDeliveredList(); if (_ordersService.hasError) { error = _ordersService.error; setState(ViewState.Error); diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 9fc30e4..6b9289a 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -45,7 +45,7 @@ class _DashboardScreenState extends State { void initState() { super.initState(); // TODO return it - // Utils.getLocationPermission(); + Utils.getLocation(); } @override diff --git a/lib/pages/setting/request_permission_page.dart b/lib/pages/setting/request_permission_page.dart index 6763f73..205dbab 100644 --- a/lib/pages/setting/request_permission_page.dart +++ b/lib/pages/setting/request_permission_page.dart @@ -1 +1 @@ -import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/config/config.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/root_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/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:location/location.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class RequestPermissionPage extends StatelessWidget { RequestPermissionPage(); @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: () {}, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredAccepted, icon: DriverApp.not_available, onTap: () {}, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context) .deliveredRejected, icon: DriverApp.rejected_icon, onTap: () {}, ), SizedBox(height: 15), ActionSheetButton( label: TranslationBase.of(context).canceled, icon: DriverApp.not_reachable_icon, onTap: () {}, ), SizedBox(height: 15), ], ), ], ), ), ) ], ), ), ], ); }); } return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Color(0xff49C1BC), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: "request Permissions", isAppBarGradient: true, body: Container( child: Container( decoration: BoxDecoration(gradient: LINEAR_GRADIENT), child: ListView( children: [ Column( children: [ Stack( children: [ // Container( // width: MediaQuery.of(context).size.width, // height: MediaQuery.of(context).size.width, // ), Padding( padding: const EdgeInsets.only(top: 75.0), child: Container( width: MediaQuery.of(context).size.width * 1.0, height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.70 : MediaQuery.of(context).size.height * 1.7, 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.spaceEvenly, children: [ SizedBox( height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.05 : MediaQuery.of(context).size.height * 0.29, //MediaQuery.of(context).size.width * 0.005, ), Padding( padding: MediaQuery.of(context).orientation == Orientation.portrait ? EdgeInsets.only(top: 60.0) : EdgeInsets.only(top: 15.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Delivery app need permission") ], ), ), 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(), ), ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: MediaQuery.of(context).orientation == Orientation.portrait ? EdgeInsets.all(8.0) : EdgeInsets.symmetric(horizontal: 12.0), child: SecondaryButton( label: "Give permission", onTap: () async { Location location = new Location(); await location.requestPermission(); Utils.getLocationPermission() .then((value) { if (value == PermissionStatus.granted) { Navigator.pushReplacement( AppGlobal.context, MaterialPageRoute( builder: (context) => RootPage(), ), ); } }); }, ), ), ], ), ), ), // CustomerBriefCard( // itemId: 11, // customerFirstName: "item.firstName", // customerLastName: "item.lastName", // mobileNo: "item.mobileNumber", // totalPayment: "item.amount", // deliveryTime: "item.orderCreatedOn", // ), ], ), ], ), ], ), ), ), ), ); } } \ No newline at end of file +import 'package:driverapp/config/config.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; import 'package:driverapp/root_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:location/location.dart'; import '../../widgets/others/app_scaffold_widget.dart'; class RequestPermissionPage extends StatelessWidget { RequestPermissionPage(); @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarColor: Color(0xff49C1BC), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: "Request Permissions", isAppBarGradient: true, body: Container( child: Container( decoration: BoxDecoration(gradient: LINEAR_GRADIENT), child: ListView( children: [ Column( children: [ Stack( children: [ Padding( padding: const EdgeInsets.only(top: 75.0), child: Container( width: MediaQuery.of(context).size.width * 1.0, height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.70 : MediaQuery.of(context).size.height * 1.7, 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.spaceEvenly, children: [ SizedBox( height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.height * 0.05 : MediaQuery.of(context).size.height * 0.29, //MediaQuery.of(context).size.width * 0.005, ), Padding( padding: MediaQuery.of(context).orientation == Orientation.portrait ? EdgeInsets.only(top: 60.0) : EdgeInsets.only(top: 15.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Delivery app need permission to your location information") ], ), ), 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: [ ], ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.1, ), Container( margin: MediaQuery.of(context).orientation == Orientation.portrait ? EdgeInsets.all(8.0) : EdgeInsets.symmetric(horizontal: 12.0), child: SecondaryButton( label: "request permission", onTap: () async { LocationData loc = await Utils.getLocation(); if (loc != null) { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => RootPage(), ), ); } // Location location = new Location(); // await location.requestPermission(); // Utils.getLocationPermission() // .then((value) { // if (value == PermissionStatus.granted) { // // } // }); }, ), ), ], ), ), ), ], ), ], ), ], ), ), ), ), ); } } \ No newline at end of file diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index e208311..1ad9f4c 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -4,6 +4,7 @@ import 'package:driverapp/config/config.dart'; import 'package:driverapp/pages/setting/request_permission_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:location/location.dart'; import 'app_shared_preferences.dart'; @@ -48,13 +49,9 @@ class Utils { FocusScope.of(context).unfocus(); } - static isLocationPermissionGranted() async { - return (await location.hasPermission()) == PermissionStatus.granted; - } - - static Location location = new Location(); - - static Future getLocationPermission() async { + static getLocation() async { + Location location = new Location(); + LocationData currentLocation; bool _serviceEnabled; PermissionStatus _permissionGranted; @@ -67,12 +64,18 @@ class Utils { } if (!_serviceEnabled) { // Route to another page and send to him message "You have to enable location" + Navigator.pushReplacement( + AppGlobal.context, + MaterialPageRoute( + builder: (context) => RequestPermissionPage(), + ), + ); } } _permissionGranted = await location.hasPermission(); if (_permissionGranted == PermissionStatus.denied) { -// _permissionGranted = await location.requestPermission(); + _permissionGranted = await location.requestPermission(); if (_permissionGranted == PermissionStatus.denied) { // Route to another page and send to him message "You have to give Permission" Navigator.pushReplacement( @@ -83,29 +86,26 @@ class Utils { ); //return _permissionGranted; } else if (_permissionGranted == PermissionStatus.deniedForever) { - AppSettings.openLocationSettings(); + try { + SystemNavigator.pop(); + AppSettings.openLocationSettings(); + } catch (e) { + print(e); + } // open setting page + } else { + currentLocation = await location.getLocation(); + return currentLocation; } } else if (_permissionGranted == PermissionStatus.deniedForever) { + SystemNavigator.pop(); AppSettings.openLocationSettings(); - // open setting page - } - return _permissionGranted; - } - - static getLocation() async { -// AppGlobal.context - Location location = new Location(); - LocationData currentLocation; -// await getLocationPermission(); - try { + // open setting page + } else { currentLocation = await location.getLocation(); - } catch (e) { -// await getLocationPermission(); - print(e); + return currentLocation; } - return currentLocation; } static formatStringToPascalCase(String name) { From 344e37988241aa4ab772c2fe07a1b2814fddef3d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 16 Sep 2020 08:17:27 +0300 Subject: [PATCH 2/2] dashboard design updates --- lib/pages/dashboard/dashboard_screen.dart | 704 +++++++++++---------- lib/pages/orders/deliverd_orders_page.dart | 7 +- lib/pages/orders/pending_orders_page.dart | 5 + 3 files changed, 371 insertions(+), 345 deletions(-) diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 9fc30e4..c89fbb1 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -55,210 +55,98 @@ class _DashboardScreenState extends State { onModelReady: (model) => model.getPendingOrders(), builder: (BuildContext context, OrdersViewModel model, Widget child) => AppScaffold( - body: Container( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(16.0), - child: Column( - children: [ - SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).haveGreatDay, - style: TextStyle( - fontSize: 14.5, - color: Color(0xff636363), - fontWeight: FontWeight.w300), - ), - Padding( - padding: EdgeInsets.only(top: 4.5), - child: Text( - _authenticationViewModel.user.userName, - style: TextStyle( - fontSize: 22.0, - color: Hexcolor("#343333"), - fontWeight: FontWeight.bold), - ), - ), - ], - ), - ), - ], - ), - ), - Padding( - padding: EdgeInsets.all(16.0), - child: SafeArea( + body: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 1.6, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(16.0), child: Column( children: [ - InkWell( - child: 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, - ), - ), - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SettingPage( - driverName: _authenticationViewModel - .user.userName, - driverID: _authenticationViewModel - .user.userID))); - }, - ), - ], - ), - ), - ), - ], - ), - Row( - children: [ - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == - Orientation.portrait - ? MediaQuery.of(context).size.height * 0.16 - : MediaQuery.of(context).size.height * 0.30, - width: MediaQuery.of(context).size.width * 0.44, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.0), - gradient: LINEAR_GRADIENT, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Padding( - padding: EdgeInsets.all(2.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Text( - TranslationBase.of(context).youHave, - style: TextStyle( - color: Colors.white, - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape - ? SizeConfig.textMultiplier * - 2.2 - : SizeConfig.textMultiplier * - 1.3, - ), - ), - Text( - '5', - style: TextStyle( - color: Colors.white, - fontSize: - SizeConfig.textMultiplier * - 3.0), - ), - Text( - TranslationBase.of(context) - .undeliveredPackages, - style: TextStyle( - color: Colors.white, - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape - ? SizeConfig.textMultiplier * - 2.2 - : SizeConfig.textMultiplier * - 1.3, - ), - ) - ], - ), - ), + Text( + TranslationBase.of(context).haveGreatDay, + style: TextStyle( + fontSize: 14.5, + color: Color(0xff636363), + fontWeight: FontWeight.w300), ), Padding( - padding: EdgeInsets.only(right: 9.5), - child: Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Image.asset( - 'assets/images/closed_box.png', - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .height * - 0.09 - : MediaQuery.of(context) - .size - .height * - 0.20, - width: MediaQuery.of(context) - .size - .width * - 0.20, - scale: 0.9, - fit: BoxFit.contain, - ), - ], - ), + padding: EdgeInsets.only(top: 4.5), + child: Text( + _authenticationViewModel.user.userName, + style: TextStyle( + fontSize: 22.0, + color: Hexcolor("#343333"), + fontWeight: FontWeight.bold), ), ), ], ), ), - ) - ], + ], + ), ), - ), - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == - Orientation.portrait - ? MediaQuery.of(context).size.height * 0.16 - : MediaQuery.of(context).size.height * 0.30, - width: MediaQuery.of(context).size.width * 0.45, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.0), - gradient: LINEAR_GRADIENT, + Padding( + padding: EdgeInsets.all(16.0), + child: SafeArea( + child: Column( + children: [ + InkWell( + child: 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, + ), + ), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SettingPage( + driverName: _authenticationViewModel + .user.userName, + driverID: _authenticationViewModel + .user.userID))); + }, ), - child: InkWell( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - DeliverdOrdersPage())), + ], + ), + ), + ), + ], + ), + Row( + children: [ + Expanded( + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 10.0), + child: Container( + height: MediaQuery.of(context).orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * 0.16 + : MediaQuery.of(context).size.height * 0.30, + width: MediaQuery.of(context).size.width * 0.44, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + gradient: LINEAR_GRADIENT, + ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -284,7 +172,7 @@ class _DashboardScreenState extends State { ), ), Text( - '3', + '5', style: TextStyle( color: Colors.white, fontSize: @@ -293,7 +181,7 @@ class _DashboardScreenState extends State { ), Text( TranslationBase.of(context) - .deliveredPackages, + .undeliveredPackages, style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context) @@ -315,15 +203,14 @@ class _DashboardScreenState extends State { width: 100, height: 100, decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle, - ), + color: Colors.white10, + shape: BoxShape.circle), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( - 'assets/images/opend_box.png', + 'assets/images/closed_box.png', height: MediaQuery.of(context) .orientation == Orientation.portrait @@ -349,170 +236,301 @@ class _DashboardScreenState extends State { ], ), ), - ), - ) - ], + ) + ], + ), ), - ), - ], - ), - Padding( - padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 15.0), - child: Row( - children: [ Expanded( - child: InkWell( - onTap: () { - _scanQrAndGetPatient(context, model); - }, - child: Container( - height: MediaQuery.of(context).orientation == - Orientation.portrait - ? MediaQuery.of(context).size.height * 0.18 - : MediaQuery.of(context).size.height * 0.30, - width: MediaQuery.of(context).size.width * 0.50, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.0), - gradient: LINEAR_GRADIENT, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'assets/images/qr_code.png', - width: MediaQuery.of(context).size.width * - 0.26, - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context).size.height * - 0.14 - : MediaQuery.of(context).size.height * - 0.28, - fit: BoxFit.contain, - ) - ], + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 10.0), + child: Container( + height: MediaQuery.of(context).orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * 0.16 + : MediaQuery.of(context).size.height * 0.30, + width: MediaQuery.of(context).size.width * 0.45, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + gradient: LINEAR_GRADIENT, ), - Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 8.0), - child: Text( - TranslationBase.of(context).scan, - style: TextStyle( - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape - ? SizeConfig.textMultiplier * 6.0 - : SizeConfig.textMultiplier * 4.0, - color: Colors.white, - fontWeight: FontWeight.w400, + child: InkWell( + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + DeliverdOrdersPage())), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.all(2.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Text( + TranslationBase.of(context) + .youHave, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == + Orientation.landscape + ? SizeConfig + .textMultiplier * + 2.2 + : SizeConfig + .textMultiplier * + 1.3, + ), + ), + Text( + '3', + style: TextStyle( + color: Colors.white, + fontSize: SizeConfig + .textMultiplier * + 3.0), + ), + Text( + TranslationBase.of(context) + .deliveredPackages, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == + Orientation.landscape + ? SizeConfig + .textMultiplier * + 2.2 + : SizeConfig + .textMultiplier * + 1.3, + ), + ) + ], + ), ), ), - ), - Padding( - padding: EdgeInsets.only(top: 0.0), - child: Text( - TranslationBase.of(context) - .toAddPackageToQue, - style: TextStyle( - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape - ? SizeConfig.textMultiplier * 3.0 - : SizeConfig.textMultiplier * 2.0, - color: Colors.white, - letterSpacing: 0.2, - wordSpacing: 0.5, + Padding( + padding: EdgeInsets.only(right: 9.5), + child: Container( + width: 100, + height: 100, + decoration: BoxDecoration( + color: Colors.white10, + shape: BoxShape.circle, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/opend_box.png', + height: MediaQuery.of(context) + .orientation == + Orientation.portrait + ? MediaQuery.of(context) + .size + .height * + 0.09 + : MediaQuery.of(context) + .size + .height * + 0.20, + width: MediaQuery.of(context) + .size + .width * + 0.20, + scale: 0.9, + fit: BoxFit.contain, + ), + ], + ), ), ), - ), - ], - ) - ], - ), - ), + ], + ), + ), + ), + ) + ], ), - ) + ), ], ), - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - children: [ - Text(TranslationBase.of(context).nearestDropOffs, - style: TextStyle( - fontSize: 18.0, - color: Hexcolor("#343333"), - fontWeight: FontWeight.bold)), - ], - ), - if (model.state == ViewState.Idle) - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( + Padding( + padding: + EdgeInsets.symmetric(vertical: 16.0, horizontal: 15.0), + child: Row( + children: [ + Expanded( + child: InkWell( + onTap: () { + _scanQrAndGetPatient(context, model); + }, + child: Container( + height: MediaQuery.of(context).orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * 0.18 + : MediaQuery.of(context).size.height * 0.30, + width: MediaQuery.of(context).size.width * 0.50, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + gradient: LINEAR_GRADIENT, + ), child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - TranslationBase.of(context).seeAll, - style: TextStyle( - fontSize: 14.5, color: Color(0xff42B6AD)), - ), - Icon( - Icons.arrow_forward_ios, - size: 15.0, - color: Color(0xff42B6AD), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/qr_code.png', + width: MediaQuery.of(context).size.width * + 0.26, + height: MediaQuery.of(context) + .orientation == + Orientation.portrait + ? MediaQuery.of(context).size.height * + 0.14 + : MediaQuery.of(context).size.height * + 0.28, + fit: BoxFit.contain, + ) + ], ), + Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 8.0), + child: Text( + TranslationBase.of(context).scan, + style: TextStyle( + fontSize: MediaQuery.of(context) + .orientation == + Orientation.landscape + ? SizeConfig.textMultiplier * 6.0 + : SizeConfig.textMultiplier * 4.0, + color: Colors.white, + fontWeight: FontWeight.w400, + ), + ), + ), + Padding( + padding: EdgeInsets.only(top: 0.0), + child: Text( + TranslationBase.of(context) + .toAddPackageToQue, + style: TextStyle( + fontSize: MediaQuery.of(context) + .orientation == + Orientation.landscape + ? SizeConfig.textMultiplier * 3.0 + : SizeConfig.textMultiplier * 2.0, + color: Colors.white, + letterSpacing: 0.2, + wordSpacing: 0.5, + ), + ), + ), + ], + ) ], ), - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => OrdersListScreen()), - ), ), + ), + ) + ], + ), + ), + Padding( + padding: + EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Text(TranslationBase.of(context).nearestDropOffs, + style: TextStyle( + fontSize: 18.0, + color: Hexcolor("#343333"), + fontWeight: FontWeight.bold)), ], ), - ], + if (model.state == ViewState.Idle) + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + child: Row( + children: [ + Text( + TranslationBase.of(context).seeAll, + style: TextStyle( + fontSize: 14.5, + color: Color(0xff42B6AD)), + ), + Icon( + Icons.arrow_forward_ios, + size: 15.0, + color: Color(0xff42B6AD), + ), + ], + ), + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrdersListScreen()), + ), + ), + ], + ), + ], + ), ), - ), - NetworkBaseView( - baseViewModel: model, - child: Column( - children: [ - ...List.generate( - model.orders == null - ? 0 - : model.orders.length < 3 ? model.orders.length : 3, - (index) => Padding( - padding: EdgeInsets.symmetric(horizontal: 0.2), - child: OrderInfoCard( - order: model.orders[index], - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - InformationPage( - item: model.orders[index], - ))); - }), - )) - ], + if (model.state == ViewState.Idle) + model.orders.length == 0 + ? Text("There's No Orders To deliver") + : Text(""), + NetworkBaseView( + baseViewModel: model, + child: Expanded( + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: model.orders == null + ? 0 + : model.orders.length < 3 ? model.orders.length : 3, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 0.2), + child: OrderInfoCard( + order: model.orders[index], + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => InformationPage( + item: model.orders[index], + ))); + }, + ), + ); + }, + ), + ), ), - ), - ], + ], + ), ), ), ), @@ -537,5 +555,3 @@ class _DashboardScreenState extends State { } } } - - diff --git a/lib/pages/orders/deliverd_orders_page.dart b/lib/pages/orders/deliverd_orders_page.dart index 8fa2b19..9f73296 100644 --- a/lib/pages/orders/deliverd_orders_page.dart +++ b/lib/pages/orders/deliverd_orders_page.dart @@ -1,3 +1,4 @@ +import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/widgets/order/order_info_card.dart'; import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; @@ -27,6 +28,10 @@ class _DeliverdOrdersPageState extends State { SizedBox( height: 20, ), + if (model.state == ViewState.Idle) + model.deliverdOrders.length == 0 + ? Text("There's No Orders To deliver") + : Text(''), NetworkBaseView( baseViewModel: model, child: Expanded( @@ -38,7 +43,7 @@ class _DeliverdOrdersPageState extends State { : model.deliverdOrders.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 12.2), + padding: EdgeInsets.symmetric(horizontal: 12.2), child: OrderInfoCard( order: model.deliverdOrders[index], )); diff --git a/lib/pages/orders/pending_orders_page.dart b/lib/pages/orders/pending_orders_page.dart index 5c5e645..7e8e098 100644 --- a/lib/pages/orders/pending_orders_page.dart +++ b/lib/pages/orders/pending_orders_page.dart @@ -1,3 +1,4 @@ +import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/delivery/information_page.dart'; import 'package:driverapp/uitl/translations_delegate_base.dart'; @@ -28,6 +29,10 @@ class _OrdersListScreenState extends State { SizedBox( height: 20, ), + if (model.state == ViewState.Idle) + model.orders.length == 0 + ? Text("There's No Orders To deliver") + : Text(""), Expanded( child: ListView.builder( shrinkWrap: true,