diff --git a/lib/screen_ui/cab_service_screens/cab_booking_screen.dart b/lib/screen_ui/cab_service_screens/cab_booking_screen.dart index dfb6c7c..7df5709 100644 --- a/lib/screen_ui/cab_service_screens/cab_booking_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_booking_screen.dart @@ -56,22 +56,57 @@ class CabBookingScreen extends StatelessWidget { options: flutterMap.MapOptions( initialCenter: Constant.currentLocation != null - ? latlong.LatLng(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude) + ? latlong.LatLng( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ) : controller.currentOrder.value.id != null ? latlong.LatLng( - double.parse(controller.currentOrder.value.sourceLocation!.latitude.toString()), - double.parse(controller.currentOrder.value.sourceLocation!.longitude.toString()), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .latitude + .toString(), + ), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .longitude + .toString(), + ), ) - : latlong.LatLng(41.4219057, -102.0840772), - initialZoom: 10, + : latlong.LatLng( + 41.4219057, + -102.0840772, + ), + initialZoom: 14, ), children: [ flutterMap.TileLayer( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: Platform.isAndroid ? "com.emart.customer" : "com.emart.customer.ios", + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: + Platform.isAndroid + ? "com.emart.customer" + : "com.emart.customer.ios", ), - flutterMap.MarkerLayer(markers: controller.osmMarker), - if (controller.routePoints.isNotEmpty) flutterMap.PolylineLayer(polylines: [flutterMap.Polyline(points: controller.routePoints, strokeWidth: 5.0, color: Colors.blue)]), + flutterMap.MarkerLayer( + markers: controller.osmMarker, + ), + if (controller.routePoints.isNotEmpty) + flutterMap.PolylineLayer( + polylines: [ + flutterMap.Polyline( + points: controller.routePoints, + strokeWidth: 5.0, + color: Colors.blue, + ), + ], + ), ], ) : GoogleMap( @@ -79,16 +114,26 @@ class CabBookingScreen extends StatelessWidget { controller.mapController = googleMapController; if (Constant.currentLocation != null) { - controller.setDepartureMarker(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude); + controller.setDepartureMarker( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ); controller.searchPlaceNameGoogle(); } }, - initialCameraPosition: CameraPosition(target: controller.currentPosition.value, zoom: 14), + initialCameraPosition: CameraPosition( + target: controller.currentPosition.value, + zoom: 14, + ), myLocationEnabled: true, zoomControlsEnabled: true, zoomGesturesEnabled: true, - polylines: Set.of(controller.polyLines.values), - markers: controller.markers.toSet(), // reactive marker set + polylines: Set.of( + controller.polyLines.values, + ), + markers: + controller.markers + .toSet(), // reactive marker set ), Positioned( @@ -97,36 +142,64 @@ class CabBookingScreen extends StatelessWidget { right: Constant.isRtl ? 20 : null, child: InkWell( onTap: () { - if (controller.bottomSheetType.value == "vehicleSelection") { + if (controller.bottomSheetType.value == + "vehicleSelection") { controller.bottomSheetType.value = "location"; - } else if (controller.bottomSheetType.value == "payment") { - controller.bottomSheetType.value = "vehicleSelection"; - } else if (controller.bottomSheetType.value == "conformRide") { + } else if (controller.bottomSheetType.value == + "payment") { + controller.bottomSheetType.value = + "vehicleSelection"; + } else if (controller.bottomSheetType.value == + "conformRide") { controller.bottomSheetType.value = "payment"; - } else if (controller.bottomSheetType.value == "waitingDriver" || controller.bottomSheetType.value == "driverDetails") { + } else if (controller.bottomSheetType.value == + "waitingDriver" || + controller.bottomSheetType.value == + "driverDetails") { Get.back(result: true); } else { Get.back(); } }, child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + borderRadius: BorderRadius.circular(30), + ), child: Padding( padding: const EdgeInsets.all(10), - child: Center(child: Icon(Icons.arrow_back_ios_new, color: isDark ? AppThemeData.grey50 : AppThemeData.greyDark50, size: 20)), + child: Center( + child: Icon( + Icons.arrow_back_ios_new, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.greyDark50, + size: 20, + ), + ), ), ), ), ), controller.bottomSheetType.value == "location" - ? searchLocationBottomSheet(context, controller, isDark) - : controller.bottomSheetType.value == "vehicleSelection" + ? searchLocationBottomSheet( + context, + controller, + isDark, + ) + : controller.bottomSheetType.value == + "vehicleSelection" ? vehicleSelection(context, controller, isDark) : controller.bottomSheetType.value == "payment" ? paymentBottomSheet(context, controller, isDark) : controller.bottomSheetType.value == "conformRide" ? conformBottomSheet(context, isDark) - : controller.bottomSheetType.value == "waitingForDriver" + : controller.bottomSheetType.value == + "waitingForDriver" ? waitingDialog(context, controller, isDark) : controller.bottomSheetType.value == "driverDetails" ? driverDialog(context, controller, isDark) @@ -138,7 +211,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget searchLocationBottomSheet(BuildContext context, CabBookingController controller, bool isDark) { + Widget searchLocationBottomSheet( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.30, @@ -151,16 +228,29 @@ class CabBookingScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.all(16), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(35))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(35)), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 10), Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -168,40 +258,87 @@ class CabBookingScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.sourceTextEditController.value.text = ''; + controller + .sourceTextEditController + .value + .text = ''; final firstPlace = result; - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); + controller + .sourceTextEditController + .value + .text = address.toString(); controller.setDepartureMarker(lat, lng); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + if (Constant.checkZoneCheck( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ) == + true) { + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, + controller: + controller.sourceTextEditController.value, + // backgroundColor: AppThemeData.cardColor, hintText: "Pickup Location".tr, enable: false, - prefix: Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Image.asset("assets/icons/pickup.png", height: 22, width: 22)), + prefix: Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Image.asset( + "assets/icons/pickup.png", + height: 22, + width: 22, + ), + ), ), ), const SizedBox(height: 10), @@ -209,34 +346,63 @@ class CabBookingScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; final lat = firstPlace.coordinates.latitude; final lng = firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); + controller + .destinationTextEditController + .value + .text = address.toString(); controller.setDestinationMarker(lat, lng); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, hintText: "Destination Location".tr, + // backgroundColor: AppThemeData.cardColor, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -265,16 +431,28 @@ class CabBookingScreen extends StatelessWidget { RoundedButtonFill( title: "Continue".tr, onPress: () { - if (controller.sourceTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select source location".tr); - } else if (controller.destinationTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select destination location".tr); + if (controller + .sourceTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + "Please select source location".tr, + ); + } else if (controller + .destinationTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + "Please select destination location".tr, + ); } else { controller.bottomSheetType.value = "vehicleSelection"; } }, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, ), ], ), @@ -284,7 +462,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget vehicleSelection(BuildContext context, CabBookingController controller, bool isDark) { + Widget vehicleSelection( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.40, @@ -293,20 +475,42 @@ class CabBookingScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(24), + topRight: Radius.circular(24), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Align( alignment: Alignment.topLeft, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Text( "Select Your Vehicle Type".tr, - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), textAlign: TextAlign.start, ), ), @@ -319,11 +523,13 @@ class CabBookingScreen extends StatelessWidget { controller: scrollController, scrollDirection: Axis.vertical, itemBuilder: (context, index) { - VehicleType vehicleType = controller.vehicleTypes[index]; + VehicleType vehicleType = + controller.vehicleTypes[index]; return Obx( () => InkWell( onTap: () { - controller.selectedVehicleType.value = controller.vehicleTypes[index]; + controller.selectedVehicleType.value = + controller.vehicleTypes[index]; }, child: Padding( padding: const EdgeInsets.only(bottom: 10), @@ -333,60 +539,130 @@ class CabBookingScreen extends StatelessWidget { border: Border.all( color: isDark - ? controller.selectedVehicleType.value.id == vehicleType.id + ? controller + .selectedVehicleType + .value + .id == + vehicleType.id ? Colors.white : AppThemeData.grey500 - : controller.selectedVehicleType.value.id == vehicleType.id + : controller + .selectedVehicleType + .value + .id == + vehicleType.id ? AppThemeData.grey300 : Colors.transparent, width: 1, ), color: - controller.selectedVehicleType.value.id == vehicleType.id + controller.selectedVehicleType.value.id == + vehicleType.id ? AppThemeData.grey50 : isDark ? AppThemeData.grey300 : Colors.white, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: Row( children: [ ClipRRect( //borderRadius: BorderRadius.circular(10), child: CachedNetworkImage( - imageUrl: vehicleType.vehicleIcon.toString(), + imageUrl: + vehicleType.vehicleIcon + .toString(), height: 60, width: 60, imageBuilder: (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => ClipRRect(borderRadius: BorderRadius.circular(20), child: Image.network(Constant.placeHolderImage, fit: BoxFit.cover)), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: + CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + (context, url, error) => + ClipRRect( + borderRadius: + BorderRadius.circular( + 20, + ), + child: Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, + ), + ), fit: BoxFit.cover, ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${vehicleType.name} | ${controller.distance.toStringAsFixed(2)}${'km'.tr}", - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + letterSpacing: 1, + ), ), Padding( - padding: const EdgeInsets.only(top: 2.0), - child: Text(controller.duration.value, style: const TextStyle(fontWeight: FontWeight.w400, letterSpacing: 1)), + padding: const EdgeInsets.only( + top: 2.0, + ), + child: Text( + controller.duration.value, + style: const TextStyle( + fontWeight: FontWeight.w400, + letterSpacing: 1, + ), + ), ), ], ), ), ), Text( - Constant.amountShow(amount: controller.getAmount(vehicleType).toString()), - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), + Constant.amountShow( + amount: + controller + .getAmount(vehicleType) + .toString(), + ), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + letterSpacing: 1, + ), ), ], ), @@ -404,14 +680,25 @@ class CabBookingScreen extends StatelessWidget { 'amount': controller.selectedVehicleType.value.id == null ? Constant.amountShow(amount: "0.0") - : Constant.amountShow(amount: controller.getAmount(controller.selectedVehicleType.value).toString()), + : Constant.amountShow( + amount: + controller + .getAmount( + controller + .selectedVehicleType + .value, + ) + .toString(), + ), }), onPress: () async { if (controller.selectedVehicleType.value.id != null) { controller.calculateTotalAmount(); controller.bottomSheetType.value = "payment"; } else { - ShowToastDialog.showToast("Please select a vehicle type first.".tr); + ShowToastDialog.showToast( + "Please select a vehicle type first.".tr, + ); } }, color: AppThemeData.primary300, @@ -427,7 +714,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget paymentBottomSheet(BuildContext context, CabBookingController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.70, @@ -437,19 +728,37 @@ class CabBookingScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Select Payment Method".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), GestureDetector( onTap: () { Get.back(); }, - child: Icon(Icons.close, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + child: Icon( + Icons.close, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -459,32 +768,82 @@ class CabBookingScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Preferred Payment".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -492,7 +851,13 @@ class CabBookingScreen extends StatelessWidget { Text( "Other Payment Options".tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), const SizedBox(height: 10), ], @@ -500,32 +865,136 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller + .mercadoPagoModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller + .flutterWaveModel + .value + .isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -540,13 +1009,19 @@ class CabBookingScreen extends StatelessWidget { textColor: AppThemeData.grey900, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + "Please select a payment method".tr, + ); return; } if (controller.selectedPaymentMethod.value == "wallet") { - num walletAmount = controller.userModel.value.walletAmount ?? 0; + num walletAmount = + controller.userModel.value.walletAmount ?? 0; if (walletAmount <= 0) { - ShowToastDialog.showToast("Insufficient wallet balance. Please select another payment method.".tr); + ShowToastDialog.showToast( + "Insufficient wallet balance. Please select another payment method." + .tr, + ); return; } } @@ -577,13 +1052,29 @@ class CabBookingScreen extends StatelessWidget { init: CabBookingController(), builder: (controller) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -593,75 +1084,175 @@ class CabBookingScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark + ? Colors.transparent + : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Pickup Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.sourceTextEditController.value.text = ''; + controller + .sourceTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); - controller.setDepartureMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .sourceTextEditController + .value + .text = address.toString(); + controller.setDepartureMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, + controller: + controller + .sourceTextEditController + .value, hintText: "Pickup Location".tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), // Destination Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); - controller.setDestinationMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .destinationTextEditController + .value + .text = address.toString(); + controller.setDestinationMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, hintText: "Destination Location".tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -679,9 +1270,15 @@ class CabBookingScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 40, ), - child: const SizedBox(width: 20, height: 40), ), ), ], @@ -689,25 +1286,59 @@ class CabBookingScreen extends StatelessWidget { const SizedBox(height: 10), Row( children: [ - Expanded(child: Text("Promo code".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Expanded( + child: Text( + "Promo code".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { - Get.to(CabCouponCodeScreen())!.then((value) { + Get.to(CabCouponCodeScreen())!.then(( + value, + ) { if (value != null) { - controller.couponCodeTextEditController.value.text = value.code ?? ''; - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: value); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = value; + controller + .couponCodeTextEditController + .value + .text = value.code ?? ''; + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: value, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + value; controller.calculateTotalAmount(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } }); }, child: Text( "View All".tr, - style: AppThemeData.boldTextStyle(decoration: TextDecoration.underline, fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.boldTextStyle( + decoration: TextDecoration.underline, + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], @@ -720,25 +1351,57 @@ class CabBookingScreen extends StatelessWidget { height: Responsive.height(6, context), color: AppThemeData.carRent50, child: DottedBorder( - options: RectDottedBorderOptions(dashPattern: [10, 5], strokeWidth: 1, padding: EdgeInsets.all(0), color: AppThemeData.carRent400), + options: RectDottedBorderOptions( + dashPattern: [10, 5], + strokeWidth: 1, + padding: EdgeInsets.all(0), + color: AppThemeData.carRent400, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_coupon.svg"), + SvgPicture.asset( + "assets/icons/ic_coupon.svg", + ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: TextFormField( - controller: controller.couponCodeTextEditController.value, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + controller: + controller + .couponCodeTextEditController + .value, + style: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), decoration: InputDecoration( border: InputBorder.none, - hintText: 'Write coupon Code'.tr, - contentPadding: EdgeInsets.only(bottom: 10), - hintStyle: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + hintText: + 'Write coupon Code'.tr, + contentPadding: EdgeInsets.only( + bottom: 10, + ), + hintStyle: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), ), ), ), @@ -749,36 +1412,85 @@ class CabBookingScreen extends StatelessWidget { borderRadius: 10, fontSizes: 14, onPress: () async { - if (controller.couponCodeTextEditController.value.text.trim().isEmpty) { - ShowToastDialog.showToast("Please enter a coupon code".tr); + if (controller + .couponCodeTextEditController + .value + .text + .trim() + .isEmpty) { + ShowToastDialog.showToast( + "Please enter a coupon code".tr, + ); return; } List matchedCoupons = controller.cabCouponList - .where((element) => element.code!.toLowerCase().trim() == controller.couponCodeTextEditController.value.text.toLowerCase().trim()) + .where( + (element) => + element.code! + .toLowerCase() + .trim() == + controller + .couponCodeTextEditController + .value + .text + .toLowerCase() + .trim(), + ) .toList(); if (matchedCoupons.isNotEmpty) { - CouponModel couponModel = matchedCoupons.first; + CouponModel couponModel = + matchedCoupons.first; - if (couponModel.expiresAt != null && couponModel.expiresAt!.toDate().isAfter(DateTime.now())) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); + if (couponModel.expiresAt != + null && + couponModel.expiresAt! + .toDate() + .isAfter( + DateTime.now(), + )) { + double couponAmount = + Constant.calculateDiscount( + amount: + controller + .subTotal + .value + .toString(), + offerModel: couponModel, + ); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; - controller.discount.value = couponAmount; - controller.calculateTotalAmount(); - ShowToastDialog.showToast("Coupon applied successfully".tr); + if (couponAmount < + controller.subTotal.value) { + controller + .selectedCouponModel + .value = couponModel; + controller.discount.value = + couponAmount; + controller + .calculateTotalAmount(); + ShowToastDialog.showToast( + "Coupon applied successfully" + .tr, + ); controller.update(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } else { - ShowToastDialog.showToast("This coupon code has been expired".tr); + ShowToastDialog.showToast( + "This coupon code has been expired" + .tr, + ); } } else { - ShowToastDialog.showToast("Invalid coupon code".tr); + ShowToastDialog.showToast( + "Invalid coupon code".tr, + ); } }, color: AppThemeData.parcelService300, @@ -795,46 +1507,121 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + "Subtotal".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Row( children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Discount".tr, + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), SizedBox(width: 5), Text( - controller.selectedCouponModel.value.id == null ? "" : "(${controller.selectedCouponModel.value.code})", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.primary300), + controller + .selectedCouponModel + .value + .id == + null + ? "" + : "(${controller.selectedCouponModel.value.code})", + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + AppThemeData.primary300, + ), ), ], ), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -846,24 +1633,57 @@ class CabBookingScreen extends StatelessWidget { physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { - TaxModel taxModel = Constant.taxList[index]; + TaxModel taxModel = + Constant.taxList[index]; return Padding( - padding: const EdgeInsets.only(bottom: 5), + padding: const EdgeInsets.only( + bottom: 5, + ), child: Row( children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})' + .tr, textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark800 + : AppThemeData + .grey800, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), ).tr, textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -873,14 +1693,36 @@ class CabBookingScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + "Order Total".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -892,42 +1734,154 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: Row( children: [ controller.selectedPaymentMethod.value == '' - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "") - : controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), SizedBox(width: 22), Text( controller.selectedPaymentMethod.value.tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -954,7 +1908,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget waitingDialog(BuildContext context, CabBookingController controller, bool isDark) { + Widget waitingDialog( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.4, @@ -963,15 +1921,37 @@ class CabBookingScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 30), - Text("Waiting for driver....".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Waiting for driver....".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), Image.asset('assets/loader.gif', width: 250), RoundedButtonFill( title: "Cancel Ride".tr, @@ -986,7 +1966,9 @@ class CabBookingScreen extends StatelessWidget { }); if (controller.currentOrder.value.id != null) { - await FireStoreUtils.updateCabOrder(controller.currentOrder.value); + await FireStoreUtils.updateCabOrder( + controller.currentOrder.value, + ); } controller.bottomSheetType.value = ""; @@ -996,20 +1978,36 @@ class CabBookingScreen extends StatelessWidget { controller.routePoints.clear(); controller.sourceTextEditController.value.clear(); controller.destinationTextEditController.value.clear(); - controller.departureLatLong.value = const LatLng(0.0, 0.0); - controller.destinationLatLong.value = const LatLng(0.0, 0.0); - controller.departureLatLongOsm.value = latlong.LatLng(0.0, 0.0); - controller.destinationLatLongOsm.value = latlong.LatLng(0.0, 0.0); + controller.departureLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.departureLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); // 4. Reset user’s in-progress order if (Constant.userModel != null) { Constant.userModel!.inProgressOrderID = null; await FireStoreUtils.updateUser(Constant.userModel!); } - ShowToastDialog.showToast("Ride cancelled successfully".tr); + ShowToastDialog.showToast( + "Ride cancelled successfully".tr, + ); // Get.offAll(const CabDashboardScreen()); Get.back(); - CabDashboardController cabDashboardController = Get.put(CabDashboardController()); + CabDashboardController cabDashboardController = Get.put( + CabDashboardController(), + ); cabDashboardController.selectedIndex.value = 0; } catch (e) { ShowToastDialog.showToast("Failed to cancel ride".tr); @@ -1025,7 +2023,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget driverDialog(BuildContext context, CabBookingController controller, bool isDark) { + Widget driverDialog( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.7, @@ -1034,13 +2036,29 @@ class CabBookingScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -1050,7 +2068,11 @@ class CabBookingScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark ? Colors.transparent : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -1079,11 +2101,23 @@ class CabBookingScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, + controller: + controller + .sourceTextEditController + .value, hintText: "Pickup Location".tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), @@ -1112,13 +2146,25 @@ class CabBookingScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, hintText: "Destination Location".tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -1136,7 +2182,10 @@ class CabBookingScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), ), child: const SizedBox(width: 20, height: 40), ), @@ -1149,19 +2198,36 @@ class CabBookingScreen extends StatelessWidget { ? Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Otp :".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Otp :".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), Text( controller.currentOrder.value.otpCode ?? '', - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ) : SizedBox.shrink(), - if (Constant.isEnableOTPTripStart == true) SizedBox(height: 14), + if (Constant.isEnableOTPTripStart == true) + SizedBox(height: 14), controller.currentOrder.value.driver != null ? Row( @@ -1169,26 +2235,66 @@ class CabBookingScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.currentOrder.value.driver?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + borderRadius: BorderRadiusGeometry.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .currentOrder + .value + .driver + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), SizedBox(width: 10), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.currentOrder.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller.currentOrder.value.driver + ?.fullName() ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 18, + ), ), Text( "${controller.currentOrder.value.driver?.vehicleType ?? ''} | ${controller.currentOrder.value.driver?.carMakes.toString()}", - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 14, + ), ), Text( - controller.currentOrder.value.driver?.carNumber ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 16), + controller + .currentOrder + .value + .driver + ?.carNumber ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 16, + ), ), ], ), @@ -1196,7 +2302,13 @@ class CabBookingScreen extends StatelessWidget { Column( children: [ RoundedButtonBorder( - title: controller.driverModel.value.averageRating.toStringAsFixed(1) ?? '', + title: + controller + .driverModel + .value + .averageRating + .toStringAsFixed(1) ?? + '', width: 20, height: 3.5, radius: 10, @@ -1205,7 +2317,9 @@ class CabBookingScreen extends StatelessWidget { textColor: AppThemeData.warning400, borderColor: AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), SizedBox(height: 10), @@ -1213,40 +2327,87 @@ class CabBookingScreen extends StatelessWidget { children: [ InkWell( onTap: () { - Constant.makePhoneCall(controller.currentOrder.value.driver!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .currentOrder + .value + .driver! + .phoneNumber + .toString(), + ); }, child: Container( width: 38, height: 38, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey200 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular(120), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + "Please wait...".tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.currentOrder.value.authorID ?? ''); - UserModel? driverUser = await FireStoreUtils.getUserProfile(controller.currentOrder.value.driverId ?? ''); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .currentOrder + .value + .authorID ?? + '', + ); + UserModel? driverUser = + await FireStoreUtils.getUserProfile( + controller + .currentOrder + .value + .driverId ?? + '', + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer?.fullName(), - "restaurantName": driverUser?.fullName(), - "orderId": controller.currentOrder.value.id, + "customerName": + customer?.fullName(), + "restaurantName": + driverUser?.fullName(), + "orderId": + controller + .currentOrder + .value + .id, "restaurantId": driverUser?.id, "customerId": customer?.id, - "customerProfileImage": customer?.profilePictureURL, - "restaurantProfileImage": driverUser?.profilePictureURL, + "customerProfileImage": + customer?.profilePictureURL, + "restaurantProfileImage": + driverUser + ?.profilePictureURL, "token": driverUser?.fcmToken, "chatType": "Driver", }, @@ -1257,11 +2418,26 @@ class CabBookingScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey200 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular(120), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -1275,8 +2451,16 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: InkWell( @@ -1285,38 +2469,125 @@ class CabBookingScreen extends StatelessWidget { }, child: Row( children: [ - controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), SizedBox(width: 22), Expanded( child: Text( controller.selectedPaymentMethod.value.tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), + Text( + "Change".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, ), ), - Text("Change".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300)), ], ), ), @@ -1325,37 +2596,98 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + "Subtotal".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + "Discount".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -1374,17 +2706,41 @@ class CabBookingScreen extends StatelessWidget { children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})' + .tr, textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), ).tr, textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1394,14 +2750,36 @@ class CabBookingScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + "Order Total".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1415,7 +2793,8 @@ class CabBookingScreen extends StatelessWidget { ), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit) { + if (controller.currentOrder.value.status == + Constant.orderInTransit) { return Column( children: [ RoundedButtonFill( @@ -1427,21 +2806,45 @@ class CabBookingScreen extends StatelessWidget { onPress: () async { ShowToastDialog.showLoader("Please wait...".tr); - LocationData location = await controller.currentLocation.value.getLocation(); + LocationData location = + await controller.currentLocation.value + .getLocation(); - await FireStoreUtils.getSOS(controller.currentOrder.value.id ?? '').then((value) async { + await FireStoreUtils.getSOS( + controller.currentOrder.value.id ?? '', + ).then((value) async { if (value == false) { - await FireStoreUtils.setSos(controller.currentOrder.value.id ?? '', UserLocation(latitude: location.latitude!, longitude: location.longitude!)).then((_) { + await FireStoreUtils.setSos( + controller.currentOrder.value.id ?? '', + UserLocation( + latitude: location.latitude!, + longitude: location.longitude!, + ), + ).then((_) { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text("Your SOS request has been submitted to admin".tr), backgroundColor: Colors.green, duration: Duration(seconds: 3))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + "Your SOS request has been submitted to admin" + .tr, + ), + backgroundColor: Colors.green, + duration: Duration(seconds: 3), + ), + ); }); } else { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text("Your SOS request is already submitted".tr), backgroundColor: Colors.red, duration: Duration(seconds: 3))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + "Your SOS request is already submitted" + .tr, + ), + backgroundColor: Colors.red, + duration: Duration(seconds: 3), + ), + ); } }); }, @@ -1454,48 +2857,108 @@ class CabBookingScreen extends StatelessWidget { } }), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit && controller.currentOrder.value.paymentStatus == false) { + if (controller.currentOrder.value.status == + Constant.orderInTransit && + controller.currentOrder.value.paymentStatus == false) { return RoundedButtonFill( title: "Pay Now".tr, onPress: () async { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (Constant.userModel!.walletAmount == null || Constant.userModel!.walletAmount! < controller.totalAmount.value) { - ShowToastDialog.showToast("You do not have sufficient wallet balance".tr); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { + if (Constant.userModel!.walletAmount == null || + Constant.userModel!.walletAmount! < + controller.totalAmount.value) { + ShowToastDialog.showToast( + "You do not have sufficient wallet balance".tr, + ); } else { controller.completeOrder(); } - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin." + .tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: + controller.totalAmount.value + .toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } }, color: AppThemeData.primary300, @@ -1514,19 +2977,42 @@ class CabBookingScreen extends StatelessWidget { ); } - Padding cardDecorationScreen(CabBookingController controller, PaymentGateway value, isDark, String image) { + Padding cardDecorationScreen( + CabBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( width: 40, height: 40, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: image == '' ? Container(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100) : Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: + image == '' + ? Container( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + ) + : Image.asset(image), + ), ), ); } - Obx cardDecoration(CabBookingController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + CabBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -1541,8 +3027,21 @@ class CabBookingScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -1553,12 +3052,34 @@ class CabBookingScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == + null + ? '0.0' + : controller + .userModel + .value + .walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -1567,14 +3088,23 @@ class CabBookingScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); },