Untitled
unknown
dart
3 years ago
22 kB
1
Indexable
Never
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:iketfaa_delivery/App/Common/Utilities/Constants/AppColors.dart'; import 'package:iketfaa_delivery/App/Common/Utilities/Constants/Strings/Backend.dart'; import 'package:iketfaa_delivery/App/Common/Widgets/OpenSingleImageFromURL.dart'; import 'package:iketfaa_delivery/App/Delivery/Models/Main/ActiveOrder.dart'; import 'package:iketfaa_delivery/App/Delivery/Models/Main/DriverNewOffer.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/controller/delivery_customer_current_order_controller.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/widget/card_list.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/widget/card_location.dart'; import 'package:iketfaa_delivery/App/Common/Services/translation_service.dart'; import 'package:iketfaa_delivery/App/Common/Utilities/Constants/Strings/General.dart'; import 'package:iketfaa_delivery/App/Common/Widgets/primary_button.dart'; import 'package:iketfaa_delivery/App/Common/Widgets/secondary_button.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/binding/delivery_customer_current_order_binding.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/view/delivery_customer_current_order_map.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/widget/delivery_customer_current_without_order.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOrderBill/binding/delivery_order_bill_binding.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOrderBill/view/delivery_order_bill_view.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOrderChat/binding/DeliveryActiveOrderChatBinding.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOrderChat/views/DeliveryActiveOrderChatView.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryUser/DeliveryCustomer/DeliveryCustomerComplaint/Binding/delivery_customer_complaint_binding.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryUser/DeliveryCustomer/DeliveryCustomerComplaint/view/delivery_customer_complaint_view.dart'; import 'package:iketfaa_delivery/App/Delivery/Utilities/Widgets/customized_app_bar.dart'; import 'package:iketfaa_delivery/App/Delivery/Utilities/Widgets/delivery_fading_effect.dart'; import 'package:iketfaa_delivery/App/Delivery/Utilities/Widgets/delivery_fading_effect_map.dart'; import 'package:iketfaa_delivery/App/Delivery/Utilities/Widgets/listtile_icon.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/widget/order_details.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryCustomerCurrentOrder/widget/slider.dart'; import 'package:iketfaa_delivery/App/Delivery/Utilities/Widgets/primary_app_bar.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOffers/binding/delivery_offers_binding.dart'; import 'package:iketfaa_delivery/App/Delivery/Modules/DeliveryOffers/view/delivery_offers_view.dart'; import 'package:url_launcher/url_launcher.dart'; class DeliveryCustomerCurrentOrderView extends GetView<DeliveryCustomerCurrentOrderController> { @override Widget build(BuildContext context) { return SafeArea( top: false, child: Scaffold( backgroundColor: AppColors.white, body: StreamBuilder<DocumentSnapshot>( key: Key('MyOrder'), stream: FirebaseFirestore.instance .collection(DELIVERY_NEW_ORDERS_COLLECTION) .doc(controller.authManager.appUser.value.id) .snapshots(), builder: (context, snapshot) { if (snapshot.data == null) { return DeliveryCustomerCurrentWithoutOrderView(); } if (!snapshot.hasData) { return DeliveryCustomerCurrentWithoutOrderView(); } if (snapshot.data!.data() == null) { return DeliveryCustomerCurrentWithoutOrderView(); } controller.customerCurrentOrder.value = ActiveOrder.fromJson( snapshot.data!.data() as Map<String, dynamic>); controller.setUpAllMarkers(); if (controller.customerCurrentOrder.value.offerID != null) { print('ok'); return StreamBuilder<QuerySnapshot>( key: Key('DriverOffer'), stream: FirebaseFirestore.instance .collection(DELIVERY_NEW_OFFERS_COLLECTION) .where(OFFER_ID_FIELD, isEqualTo: controller.customerCurrentOrder.value.offerID) .limit(1) .snapshots(), builder: (context, offerSnapShot) { if (offerSnapShot.data != null) { if (offerSnapShot.data!.docs.isNotEmpty) { controller.driverOffer.value = DriverOffer.fromJson( offerSnapShot.data!.docs[0].data() as Map<String, dynamic>, ); if (controller.driverOffer.value.orderAddress != null) { Marker driverMarker = Marker( markerId: MarkerId('driverLocation'), position: LatLng( controller.driverOffer.value.orderAddress! .geoPoint!.latitude, controller.driverOffer.value.orderAddress! .geoPoint!.longitude, ), draggable: false, icon: controller .dashboardController.driverLocationMarker!); controller.markers[MarkerId('driverLocation')] = driverMarker; } } } if (controller.driverOffer.value.driverEstimateTime != null) return DeliveryCustomerCurrentWithOrderView(); return Container(); }, ); } return DeliveryCustomerCurrentWithOrderView(); }, ), ), ); } } class DeliveryCustomerCurrentWithOrderView extends GetView<DeliveryCustomerCurrentOrderController> { @override Widget build(BuildContext context) { return NestedScrollView( physics: BouncingScrollPhysics(), headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( title: Stack( children: [ Align( alignment: Alignment.topCenter, child: Container( width: Get.width, height: Get.height * 0.1, child: CustomPaint( foregroundPainter: DeliveryFadingEffectMap(), ), )), PrimaryAppBar( title: 'activeOrder', icon: "assets/svg/menu.svg", iconColor: AppColors.black, function: () => controller.deliveryHubController.openDrawer(), ), ], ), pinned: true, automaticallyImplyLeading: false, backgroundColor: Colors.white, flexibleSpace: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return FlexibleSpaceBar( titlePadding: EdgeInsets.zero, collapseMode: CollapseMode.pin, background: Stack( children: [ InkWell( onTap: () { print('object'); Get.to( () => DeliveryCustomerCurrentOrderMap( addMargin: false, map: GoogleMap( mapType: MapType.normal, onMapCreated: controller.onMapCreated, markers: Set<Marker>.of(controller.markers.values), mapToolbarEnabled: false, myLocationButtonEnabled: false, myLocationEnabled: false, zoomControlsEnabled: false, compassEnabled: false, rotateGesturesEnabled: true, tiltGesturesEnabled: false, initialCameraPosition: CameraPosition( target: LatLng( controller .customerCurrentOrder .value .customerAddress! .geoPoint! .latitude, controller .customerCurrentOrder .value .customerAddress! .geoPoint! .longitude), zoom: 12.0, bearing: 15.0, ), ), ), ); }, child: IgnorePointer( child: DeliveryCustomerCurrentOrderMap( addMargin: true, map: GoogleMap( mapType: MapType.normal, onMapCreated: controller.onMapCreated, markers: Set<Marker>.of(controller.markers.values), mapToolbarEnabled: false, myLocationButtonEnabled: false, myLocationEnabled: false, zoomControlsEnabled: false, compassEnabled: false, rotateGesturesEnabled: true, tiltGesturesEnabled: false, initialCameraPosition: CameraPosition( target: LatLng( controller.customerCurrentOrder.value .customerAddress!.geoPoint!.latitude, controller .customerCurrentOrder .value .customerAddress! .geoPoint! .longitude), zoom: 12.0, bearing: 15.0, ), ), ), )), ], ), ); }, ), expandedHeight: Get.height * 0.55, ), ]; }, body: Container( width: Get.width, height: Get.height * 0.55, padding: const EdgeInsets.all(10.0), decoration: BoxDecoration( color: AppColors.white, borderRadius: BorderRadius.only( topRight: Radius.circular(45), topLeft: Radius.circular(45), ), ), child: Padding( padding: EdgeInsets.only(left: 10, right: 10), child: ListView( physics: NeverScrollableScrollPhysics(), children: [ controller.customerCurrentOrder.value.offerID != null ? Container( color: AppColors.white, width: Get.width, child: Column( children: [ Text( 'Estimate Time'.tr, style: Get.textTheme.headline4!.copyWith( color: AppColors.grey.withOpacity(0.5)), ), const SizedBox(height: 15.0), Text( TranslationService().isLocaleArabic() ? controller .deliveryHubController .dashboardController .timeEstimatesDeliveryDriver .value .timeEstimateDeliveryDriver![controller .driverOffer .value .driverEstimateTime!] .nameAR! : controller .deliveryHubController .dashboardController .timeEstimatesDeliveryDriver .value .timeEstimateDeliveryDriver![controller .driverOffer .value .driverEstimateTime!] .nameEN!, style: Get.textTheme.headline2! .copyWith(fontSize: 22)), const SizedBox(height: 20), SliderLine( currentOrder: controller.customerCurrentOrder.value), const SizedBox(height: 20), ], ), ) : Container(), controller.driverOffer.value.offerID == null ? SizedBox( height: 25.0, ) : SizedBox(), CardLocation( arrived: controller.customerCurrentOrder.value.arrived, address: controller.customerCurrentOrder.value.customerAddress!, ), const SizedBox(height: 25), Divider( color: AppColors.grey.withOpacity(0.1), thickness: 2, ), const SizedBox(height: 25.0), ListView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { return CardList( storeOrder: controller.customerCurrentOrder.value.orders![index], lastStoreLine: controller.customerCurrentOrder.value.offerID != null || index != controller.customerCurrentOrder.value.orders! .length - 1, functionPhotos: controller.customerCurrentOrder.value .orders![index].images != null && controller.customerCurrentOrder.value.orders![index] .images!.length != 0 ? () { controller.authManager.commonTools .showCustomBottomSheet( context, 'photos'.tr, Container( alignment: Alignment.center, height: Get.width * 0.45, child: ListView.builder( shrinkWrap: true, scrollDirection: Axis.horizontal, itemCount: controller.customerCurrentOrder .value.orders![index].images!.length, itemBuilder: (context, imageIndex) { return GestureDetector( onTap: () { Get.to(() => OpenSingleImageFromURL( imageURL: controller .customerCurrentOrder .value .orders![index] .images![imageIndex], )); }, child: Container( margin: EdgeInsets.only( right: 10.0, left: 10.0), height: Get.width * 0.45, width: Get.width * 0.45, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), image: DecorationImage( image: NetworkImage(controller .customerCurrentOrder .value .orders![index] .images![imageIndex]), fit: BoxFit.cover)), ), ); }, ), ), ); } : null, ); }, itemCount: controller.customerCurrentOrder.value.orders!.length, ), controller.customerCurrentOrder.value.offerID == null ? const SizedBox() : SizedBox(height: Get.height * 0.05), controller.customerCurrentOrder.value.offerID != null ? PrimaryButton( text: 'chat'.tr, function: () { Get.to(() => DeliveryActiveOrderChatView(), binding: DeliveryActiveOrderChatBinding(), arguments: [ controller.customerCurrentOrder.value, controller.driverOffer.value ]); }, ) : const SizedBox(height: 25.0), controller.customerCurrentOrder.value.offerID != null ? SizedBox() : SecondaryButton( text: 'offers'.tr, function: () { Get.to(() => DeliveryOffersView(), binding: DeliveryOffersBinding()); }, ), controller.customerCurrentOrder.value.offerID != null ? SizedBox( height: 40.0, ) : SizedBox(height: 25.0), controller.customerCurrentOrder.value.offerID != null ? SecondaryButton( text: 'bill'.tr, function: () { Get.to( () => DeliveryOrderBillView( stores: controller .customerCurrentOrder.value.orders!, ), binding: DeliveryOrderBillBinding()); }, ) : SizedBox(), SizedBox(height: Get.height * 0.05), DeliveryActiveOrderDetails( customerCurrentOrder: controller.customerCurrentOrder.value, withBorder: true, ), controller.customerCurrentOrder.value.offerID != null ? SizedBox(height: 50.0) : SizedBox(height: 25.0), controller.customerCurrentOrder.value.offerID == null ? SizedBox(height: 25.0) : SizedBox(height: 25.0), PrimaryButton( text: 'cancelTrip'.tr, buttonColor: AppColors.red, function: () { print(controller.driverOffer.value.offerID); Get.to(() => DeliveryCustomerComplaintView(), binding: DeliveryCustomerComplaintBinding()); }, ), SizedBox(height: 35.0) ], ), ), ), ); } }