From fcfb19963c4044db8b21b6d93c1eeefc5d582d2b Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 14 Sep 2020 17:11:43 +0300 Subject: [PATCH 1/3] request_permission on location --- android/app/src/main/AndroidManifest.xml | 2 + lib/core/service/orders_service.dart | 51 +- lib/pages/dashboard/dashboard_screen.dart | 774 +++++++++--------- .../setting/request_permission_page.dart | 1 + lib/uitl/utils.dart | 62 +- pubspec.yaml | 3 + 6 files changed, 484 insertions(+), 409 deletions(-) create mode 100644 lib/pages/setting/request_permission_page.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cdbc90e..41cc40e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,8 @@ In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + _orders = List(); @@ -30,32 +30,37 @@ class OrdersService extends BaseService { ); Future getPendingOrders() async { + // if (await Utils.isLocationPermissionGranted()) { LocationData loc = await Utils.getLocation(); - PendingOrders _requestGetPendingOrders = PendingOrders( - searchKey: "", - pageSize: 0, - pageIndex: 0, - latitude: loc.latitude.toString(), - longitude: loc.longitude.toString(), - ); - hasError = false; - try { - await baseAppClient.post(GET_ALL_ORDERS, - onSuccess: (dynamic response, int statusCode) { - _orders.clear(); - response['PatientER_Delivery_GetAllOrderList'].forEach((order) { - _orders.add(PendingOrdersRes.fromJson(order)); - }); - }, onFailure: (String error, int statusCode) { + + if (loc != null) { + PendingOrders _requestGetPendingOrders = PendingOrders( + searchKey: "", + pageSize: 0, + pageIndex: 0, + latitude: loc.latitude.toString(), + longitude: loc.longitude.toString(), + ); + hasError = false; + try { + await baseAppClient.post(GET_ALL_ORDERS, + onSuccess: (dynamic response, int statusCode) { + _orders.clear(); + response['PatientER_Delivery_GetAllOrderList'].forEach((order) { + _orders.add(PendingOrdersRes.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; + } } + // } } Future insertOrder(ScanQrRequestModel _scanQrRequestModel) async { diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index da4e318..c7bc69b 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -41,6 +41,12 @@ class _DashboardScreenState extends State { super.didChangeDependencies(); } + @override + void initState() { + super.initState(); + Utils.getLocationPermission(); + } + @override Widget build(BuildContext context) { int orderId; @@ -53,463 +59,463 @@ class _DashboardScreenState extends State { child: ListView( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(16.0), - child: Column( - children: [ - SafeArea( + 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( 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), + 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))); + }, ), ], ), ), - ], - ), - ), - 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))); - }, - ), - ], ), - ), + ], ), - ], - ), - Row( - children: [ - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == + 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, - children: [ - Expanded( - child: Padding( - padding: EdgeInsets.all(2.0), - child: Column( - mainAxisAlignment: + ? 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, + 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 == + children: [ + Text( + TranslationBase.of(context).youHave, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ), - Text( - '5', - style: TextStyle( - color: Colors.white, - fontSize: + ), + ), + 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 == + ), + Text( + TranslationBase.of(context) + .undeliveredPackages, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ) - ], + ), + ) + ], + ), + ), ), - ), - ), - Padding( - padding: EdgeInsets.only(right: 9.5), - child: Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle), - child: Column( - mainAxisAlignment: + 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 == + children: [ + Image.asset( + 'assets/images/closed_box.png', + height: MediaQuery.of(context) + .orientation == Orientation.portrait - ? MediaQuery.of(context) - .size - .height * + ? MediaQuery.of(context) + .size + .height * 0.09 - : MediaQuery.of(context) - .size - .height * + : MediaQuery.of(context) + .size + .height * 0.20, - width: MediaQuery.of(context) + width: MediaQuery.of(context) .size .width * - 0.20, - scale: 0.9, - fit: BoxFit.contain, + 0.20, + scale: 0.9, + fit: BoxFit.contain, + ), + ], ), - ], + ), ), - ), + ], ), - ], - ), - ), - ) - ], - ), - ), - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == + ), + ) + ], + ), + ), + 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, - ), - child: InkWell( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - DeliverdOrdersPage())), - child: Row( - mainAxisAlignment: + ? 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, + ), + 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: + 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 == + children: [ + Text( + TranslationBase.of(context).youHave, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ), - Text( - '3', - style: TextStyle( - color: Colors.white, - fontSize: + ), + ), + 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 == + ), + Text( + TranslationBase.of(context) + .deliveredPackages, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ) - ], - ), - ), - ), - Padding( - padding: EdgeInsets.only(right: 9.5), - child: Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle, + ), + ) + ], + ), + ), ), - child: Column( - mainAxisAlignment: + 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 == + children: [ + Image.asset( + 'assets/images/opend_box.png', + height: MediaQuery.of(context) + .orientation == Orientation.portrait - ? MediaQuery.of(context) - .size - .height * + ? MediaQuery.of(context) + .size + .height * 0.09 - : MediaQuery.of(context) - .size - .height * + : MediaQuery.of(context) + .size + .height * 0.20, - width: MediaQuery.of(context) + width: MediaQuery.of(context) .size .width * - 0.20, - scale: 0.9, - fit: BoxFit.contain, + 0.20, + scale: 0.9, + fit: BoxFit.contain, + ), + ], ), - ], + ), ), - ), + ], ), - ], + ), ), - ), - ), - ) - ], - ), + ) + ], + ), + ), + ], ), - ], - ), - 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 == + 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, + ? 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: [ - Image.asset( - 'assets/images/qr_code.png', - width: MediaQuery.of(context).size.width * - 0.26, - height: MediaQuery.of(context) - .orientation == + 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 * + ? MediaQuery.of(context).size.height * 0.14 - : MediaQuery.of(context).size.height * + : MediaQuery.of(context).size.height * 0.28, - fit: BoxFit.contain, - ) - ], - ), - Column( - mainAxisAlignment: + 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 == + 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, + ? 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 == + 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, + ? SizeConfig.textMultiplier * 3.0 + : SizeConfig.textMultiplier * 2.0, + color: Colors.white, + letterSpacing: 0.2, + wordSpacing: 0.5, + ), + ), ), - ), - ), + ], + ) ], - ) - ], + ), + ), ), - ), - ), - ) - ], - ), - ), - 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)), + ), + 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), + ), + ], ), - Icon( - Icons.arrow_forward_ios, - size: 15.0, - color: Color(0xff42B6AD), + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrdersListScreen()), ), - ], - ), - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => OrdersListScreen()), - ), + ), + ], ), - ], + ], + ), + ), + 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( + model.orders[index]))); + }), + ); + }, ), - ], - ), - ), - 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( - model.orders[index]))); - }), - ); - }, + ), ), - ), + ], ), - ], + ), ), - ), - ), ); } diff --git a/lib/pages/setting/request_permission_page.dart b/lib/pages/setting/request_permission_page.dart new file mode 100644 index 0000000..6763f73 --- /dev/null +++ b/lib/pages/setting/request_permission_page.dart @@ -0,0 +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 diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 5fbc743..841544a 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -1,5 +1,9 @@ +import 'package:app_settings/app_settings.dart'; import 'package:connectivity/connectivity.dart'; +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:location/location.dart'; import 'app_shared_preferences.dart'; @@ -21,7 +25,7 @@ class Utils { /// Check The Internet Connection static Future checkConnection() async { ConnectivityResult connectivityResult = - await (Connectivity().checkConnectivity()); + await (Connectivity().checkConnectivity()); if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)) { return true; @@ -44,9 +48,63 @@ class Utils { FocusScope.of(context).unfocus(); } + static isLocationPermissionGranted() async { + return (await location.hasPermission()) == PermissionStatus.granted; + } + + static Location location = new Location(); + + static Future getLocationPermission() async { + bool _serviceEnabled; + PermissionStatus _permissionGranted; + + _serviceEnabled = await location.serviceEnabled(); + if (!_serviceEnabled) { + try { + _serviceEnabled = await location.requestService(); + } catch (e) { + print(e); + } + if (!_serviceEnabled) { + // Route to another page and send to him message "You have to enable location" + } + } + + _permissionGranted = await location.hasPermission(); + if (_permissionGranted == PermissionStatus.denied) { +// _permissionGranted = await location.requestPermission(); + if (_permissionGranted == PermissionStatus.denied) { + // Route to another page and send to him message "You have to give Permission" + Navigator.pushReplacement( + AppGlobal.context, + MaterialPageRoute( + builder: (context) => RequestPermissionPage(), + ), + ); + //return _permissionGranted; + } else if (_permissionGranted == PermissionStatus.deniedForever) { + AppSettings.openLocationSettings(); + // open setting page + } + } else if (_permissionGranted == PermissionStatus.deniedForever) { + AppSettings.openLocationSettings(); + // open setting page + } + return _permissionGranted; + } + static getLocation() async { +// AppGlobal.context Location location = new Location(); - LocationData currentLocation = await location.getLocation(); + LocationData currentLocation; +// await getLocationPermission(); + + try { + currentLocation = await location.getLocation(); + } catch (e) { + await getLocationPermission(); + print(e); + } return currentLocation; } diff --git a/pubspec.yaml b/pubspec.yaml index 57e9498..90596bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,6 +75,9 @@ dependencies: #gradient gradient_app_bar: ^0.1.3 + app_settings: ^4.0.3 + + From 02f96e389166099a14cf6351e5a1750010c30d57 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 15 Sep 2020 12:15:25 +0300 Subject: [PATCH 2/3] Fix error happen in information_page --- lib/pages/dashboard/dashboard_screen.dart | 771 +++++++++--------- .../delivery/delivery_confirmed_page.dart | 5 +- lib/pages/delivery/information_page.dart | 495 ++++++++++- lib/pages/landing/landing_page.dart | 84 -- lib/pages/orders/pending_orders_page.dart | 7 +- lib/uitl/utils.dart | 2 +- 6 files changed, 887 insertions(+), 477 deletions(-) delete mode 100644 lib/pages/landing/landing_page.dart diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index c7bc69b..ea3cf61 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -55,467 +55,466 @@ class _DashboardScreenState extends State { builder: (BuildContext context, OrdersViewModel model, Widget child) => AppScaffold( body: Container( - height: MediaQuery.of(context).size.height * .95, - child: ListView( + 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( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(16.0), + child: Column( + children: [ + SafeArea( child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, 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, - ), - ), + 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), ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SettingPage( - driverName: _authenticationViewModel - .user.userName, - driverID: _authenticationViewModel - .user.userID))); - }, ), ], ), ), + ], + ), + ), + 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))); + }, + ), + ], ), - ], + ), ), - Row( - children: [ - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == + ], + ), + 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, - children: [ - Expanded( - child: Padding( - padding: EdgeInsets.all(2.0), - child: Column( - mainAxisAlignment: + ? 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, + 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 == + children: [ + Text( + TranslationBase.of(context).youHave, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ), - Text( - '5', - style: TextStyle( - color: Colors.white, - fontSize: + ), + ), + 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 == + ), + Text( + TranslationBase.of(context) + .undeliveredPackages, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ) - ], - ), - ), + ), + ) + ], ), - Padding( - padding: EdgeInsets.only(right: 9.5), - child: Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle), - child: Column( - mainAxisAlignment: + ), + ), + 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 == + children: [ + Image.asset( + 'assets/images/closed_box.png', + height: MediaQuery.of(context) + .orientation == Orientation.portrait - ? MediaQuery.of(context) - .size - .height * + ? MediaQuery.of(context) + .size + .height * 0.09 - : MediaQuery.of(context) - .size - .height * + : MediaQuery.of(context) + .size + .height * 0.20, - width: MediaQuery.of(context) + width: MediaQuery.of(context) .size .width * - 0.20, - scale: 0.9, - fit: BoxFit.contain, - ), - ], + 0.20, + scale: 0.9, + fit: BoxFit.contain, ), - ), + ], ), - ], + ), ), - ), - ) - ], - ), - ), - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - height: MediaQuery.of(context).orientation == + ], + ), + ), + ) + ], + ), + ), + 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, - ), - child: InkWell( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - DeliverdOrdersPage())), - child: Row( - mainAxisAlignment: + ? 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, + ), + 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: + 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 == + children: [ + Text( + TranslationBase.of(context).youHave, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ), - Text( - '3', - style: TextStyle( - color: Colors.white, - fontSize: + ), + ), + 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 == + ), + Text( + TranslationBase.of(context) + .deliveredPackages, + style: TextStyle( + color: Colors.white, + fontSize: MediaQuery.of(context) + .orientation == Orientation.landscape - ? SizeConfig.textMultiplier * + ? SizeConfig.textMultiplier * 2.2 - : SizeConfig.textMultiplier * + : SizeConfig.textMultiplier * 1.3, - ), - ) - ], - ), - ), + ), + ) + ], ), - Padding( - padding: EdgeInsets.only(right: 9.5), - child: Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.white10, - shape: BoxShape.circle, - ), - child: Column( - mainAxisAlignment: + ), + ), + 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 == + children: [ + Image.asset( + 'assets/images/opend_box.png', + height: MediaQuery.of(context) + .orientation == Orientation.portrait - ? MediaQuery.of(context) - .size - .height * + ? MediaQuery.of(context) + .size + .height * 0.09 - : MediaQuery.of(context) - .size - .height * + : MediaQuery.of(context) + .size + .height * 0.20, - width: MediaQuery.of(context) + width: MediaQuery.of(context) .size .width * - 0.20, - scale: 0.9, - fit: BoxFit.contain, - ), - ], + 0.20, + scale: 0.9, + fit: BoxFit.contain, ), - ), + ], ), - ], + ), ), - ), + ], ), - ) - ], - ), - ), - ], + ), + ), + ) + ], + ), ), - 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 == + ], + ), + 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, + ? 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: [ - 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 == + 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 * + ? MediaQuery.of(context).size.height * 0.14 - : MediaQuery.of(context).size.height * + : MediaQuery.of(context).size.height * 0.28, - fit: BoxFit.contain, - ) - ], - ), - Column( - mainAxisAlignment: + 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 == + 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, - ), - ), + ? 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 == + ), + ), + 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, - ), - ), + ? SizeConfig.textMultiplier * 3.0 + : SizeConfig.textMultiplier * 2.0, + color: Colors.white, + letterSpacing: 0.2, + wordSpacing: 0.5, ), - ], - ) + ), + ), ], - ), - ), + ) + ], ), - ) + ), + ), + ) + ], + ), + ), + 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)), ], ), - ), - 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), - ), - ], + 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)), ), - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => OrdersListScreen()), + Icon( + Icons.arrow_forward_ios, + size: 15.0, + color: Color(0xff42B6AD), ), - ), - ], + ], + ), + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrdersListScreen()), + ), ), - ], - ), - ), - NetworkBaseView( - baseViewModel: model, - child: Expanded( - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.vertical, - itemCount: model.orders == null + ], + ), + ], + ), + ), + NetworkBaseView( + baseViewModel: model, + child: Column( + children: [ + ...List.generate( + 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( - model.orders[index]))); - }), - ); - }, - ), - ), - ), - ], + (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], + ))); + }), + )) + ], + ), ), - ), + ], ), + ), + ), ); } diff --git a/lib/pages/delivery/delivery_confirmed_page.dart b/lib/pages/delivery/delivery_confirmed_page.dart index 69e337b..28ba731 100644 --- a/lib/pages/delivery/delivery_confirmed_page.dart +++ b/lib/pages/delivery/delivery_confirmed_page.dart @@ -3,7 +3,6 @@ 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/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/base/base_view.dart'; -import 'package:driverapp/pages/delivery/information_page.dart'; import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/widgets/buttons/secondary_button.dart'; import 'package:driverapp/widgets/delivery/customer_brief_card.dart'; @@ -13,6 +12,7 @@ import 'package:location/location.dart'; import '../../uitl/translations_delegate_base.dart'; import '../../widgets/others/app_scaffold_widget.dart'; +import 'information_page.dart'; class DeliveryConfirmedPage extends StatelessWidget { final PendingOrdersRes item; @@ -199,7 +199,8 @@ class DeliveryConfirmedPage extends StatelessWidget { Navigator.pushReplacement( context, MaterialPageRoute( - builder: (context) => InformationPage(model.nextOrdersList[0]), + builder: (context) => + InformationPage(item: model.nextOrdersList[0]), ), ); } diff --git a/lib/pages/delivery/information_page.dart b/lib/pages/delivery/information_page.dart index 02f0cf4..8555647 100644 --- a/lib/pages/delivery/information_page.dart +++ b/lib/pages/delivery/information_page.dart @@ -1 +1,494 @@ -import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/config/config.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: Color(0xff49C1BC), arrowColor: Colors.white, titleColor: Colors.white, appBarTitle: TranslationBase.of(context).deliveryInfo, 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: [ 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.1, ), Container( margin: MediaQuery.of(context).orientation == Orientation.portrait ? EdgeInsets.all(8.0) : EdgeInsets.symmetric(horizontal: 12.0), 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 +import 'package:driverapp/app-icons/driver_app_icons.dart'; +import 'package:driverapp/config/config.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/uitl/translations_delegate_base.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:driverapp/widgets/others/app_scaffold_widget.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 'delivery_confirmed_page.dart'; + +// ignore: must_be_immutable +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: Color(0xff49C1BC), + arrowColor: Colors.white, + titleColor: Colors.white, + appBarTitle: TranslationBase.of(context).deliveryInfo, + isAppBarGradient: true, + body: SingleChildScrollView( + child: Container( + decoration: BoxDecoration(gradient: LINEAR_GRADIENT), + child: 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.10 + : 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: [ + 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.1, + ), + Container( + margin: MediaQuery + .of(context) + .orientation == + Orientation.portrait + ? EdgeInsets.all(8.0) + : EdgeInsets.symmetric(horizontal: 12.0), + 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), + ), + ); + } + } +} diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart deleted file mode 100644 index 7d42558..0000000 --- a/lib/pages/landing/landing_page.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart'; -import 'package:driverapp/pages/delivery/information_page.dart'; -import 'package:driverapp/uitl/translations_delegate_base.dart'; -import 'package:driverapp/widgets/bottom_navigation/bottom_nav_bar.dart'; -import 'package:driverapp/widgets/drawer/app_drawer_widget.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'home_page.dart'; - -class LandingPage extends StatefulWidget { - @override - _LandingPageState createState() => _LandingPageState(); -} - -class _LandingPageState extends State { - int currentTab = 0; - PageController pageController; - - _changeCurrentTab(int tab) { - setState(() { - currentTab = tab; - pageController.jumpToPage(tab); - }); - } - - @override - void initState() { - super.initState(); - pageController = PageController(keepPage: true); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - elevation: 0, - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Text(getText(currentTab).toUpperCase()), - leading: Builder( - builder: (BuildContext context) { - return IconButton( - icon: Icon(Icons.menu), - color: Colors.white, - onPressed: () => Scaffold.of(context).openDrawer(), - ); - }, - ), - centerTitle: true, - ), - drawer: SafeArea(child: AppDrawer()), - extendBody: true, - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - children: [ - HomePage(), - InformationPage(null), - DeliveryConfirmedPage(null), - Container() - ], - ), - bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab), - ); - } - - getText(currentTab) { - switch (currentTab) { - case 0: - return TranslationBase.of(context).home; - case 1: - return 'new One'; - case 2: - return TranslationBase.of(context).booking; - case 3: - return TranslationBase.of(context).mySchedule; - case 4: - return TranslationBase.of(context).services; - } - } -} diff --git a/lib/pages/orders/pending_orders_page.dart b/lib/pages/orders/pending_orders_page.dart index e21f90b..5c5e645 100644 --- a/lib/pages/orders/pending_orders_page.dart +++ b/lib/pages/orders/pending_orders_page.dart @@ -17,7 +17,7 @@ class _OrdersListScreenState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getPendingOrders(), +// onModelReady: (model) => model.getPendingOrders(), builder: (BuildContext context, OrdersViewModel model, Widget child) => AppScaffold( isShowAppBar: true, @@ -42,8 +42,9 @@ class _OrdersListScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => - InformationPage(model.orders[index]))); + builder: (context) => InformationPage( + item: model.orders[index], + ))); }, ), ); diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 841544a..e208311 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -102,7 +102,7 @@ class Utils { try { currentLocation = await location.getLocation(); } catch (e) { - await getLocationPermission(); +// await getLocationPermission(); print(e); } return currentLocation; From 51c6688ba0963e0b3abcdf4b6b022dc320d8e721 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 15 Sep 2020 12:21:55 +0300 Subject: [PATCH 3/3] Fix error happen in information_page --- lib/pages/dashboard/dashboard_screen.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index ea3cf61..9fc30e4 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -44,7 +44,8 @@ class _DashboardScreenState extends State { @override void initState() { super.initState(); - Utils.getLocationPermission(); + // TODO return it + // Utils.getLocationPermission(); } @override