Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
17 kB
2
Indexable
Never
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:mobile/app/models/responses/edit_request_service.dart';
import 'package:mobile/app/modules/home/controllers/home_controller.dart';
import 'package:mobile/app/modules/home/controllers/service_decision_controller.dart';
import 'package:mobile/app/modules/home/widgets/provider_rating.dart';
import 'package:mobile/app/modules/home/widgets/provider_report.dart';
import 'package:mobile/app/providers/api_provider.dart';
import 'package:mobile/app/routes/app_pages.dart';
import 'package:mobile/app/services/auth_service.dart';
import 'package:mobile/common/ui.dart';

class ProviderEndService extends GetView<ServiceDecisionController> {
  final HomeController homeController = Get.put(HomeController());
  final GlobalKey<FormState> _bidForm = new GlobalKey<FormState>();
  final GlobalKey<FormState> _amountForm = new GlobalKey<FormState>();

  var currentUser = Get.find<AuthService>();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        padding: EdgeInsets.zero,
        physics: NeverScrollableScrollPhysics(),
        children: [
          Stack(
            children: [
              //map
              Column(
                children: [
                  Container(
                    height: Get.height * 0.5,
                    width: Get.width,
                    color: Colors.amber,
                    child: GoogleMap(
                      onMapCreated: controller.onMapCreated,
                      markers: Set<Marker>.of(controller.markers.values),
                      circles: controller.circles,
                      mapToolbarEnabled: false,
                      myLocationButtonEnabled: false,
                      myLocationEnabled: true,
                      // zoomGesturesEnabled: true,
                      zoomControlsEnabled: false,
                      compassEnabled: true,
                      //  scrollGesturesEnabled: true,
                      rotateGesturesEnabled: true,
                      tiltGesturesEnabled: false,
                      initialCameraPosition: CameraPosition(
                          target: LatLng(controller.pos.value.latitude,
                              controller.pos.value.longitude),
                          zoom: 15.0,
                          bearing: 30.0),
                      onCameraMove: (CameraPosition position) {
                        if (controller.markers.length > 0) {
                          MarkerId markerId =
                              MarkerId(controller.markerIdVal());
                          Marker marker = controller.markers[markerId];
                          Marker updatedMarker =
                              marker.copyWith(positionParam: position.target);
                          controller.markers[markerId] = updatedMarker;
                          controller.startLocation = LatLng(
                              position.target.latitude,
                              position.target.longitude);
                        }
                      },
                    ),
                  )
                ],
              ),
              //map
              Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.only(top: 32, left: 8, right: 8),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        IconButton(
                          onPressed: () {
                            Get.offAllNamed(Routes.ROOT);
                            controller.tc.clear();
                            controller.dc.clear();
                          },
                          icon: Icon(
                            Icons.arrow_back_ios,
                            color: Get.theme.hoverColor,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 200),
                    width: Get.width,
                    height: Get.height * 0.65,
                    decoration: BoxDecoration(
                      color: Get.theme.primaryColor,
                      borderRadius: BorderRadius.only(
                        topRight: Radius.circular(25),
                        topLeft: Radius.circular(25),
                      ),
                    ),
                    child: ListView(
                      padding: EdgeInsets.zero,
                      children: [
                        SizedBox(height: 10),
                        Container(
                          margin: EdgeInsets.symmetric(horizontal: 175),
                          height: 5,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(4),
                            color: Ui.parseColor("#CCCCCC"),
                          ),
                        ),
                        SizedBox(height: 12),
                        Container(
                          margin: EdgeInsets.symmetric(
                            horizontal: 18,
                          ),
                          decoration: BoxDecoration(
                            color: Ui.parseColor("#F6F6F6"),
                            borderRadius: BorderRadius.circular(10),
                            boxShadow: [
                              BoxShadow(
                                offset: Offset(0, 3),
                                blurRadius: 10,
                                color: Colors.black.withOpacity(0.3),
                              ),
                            ],
                          ),
                          child: Padding(
                            padding: EdgeInsetsDirectional.only(
                              start: 26,
                              top: 16,
                              bottom: 16,
                            ),
                            child: Row(
                              children: [
                                Container(
                                  width: 67,
                                  height: 67,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(48),
                                    image: DecorationImage(
                                      fit: BoxFit.fill,
                                      image: NetworkImage(
                                          controller.myData.toUserUrl),
                                    ),
                                  ),
                                ),
                                SizedBox(width: 12.5),
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      controller.myData.providerName,
                                      style: GoogleFonts.poppins(
                                        fontSize: 15,
                                        fontWeight: FontWeight.w500,
                                        color: Colors.black,
                                      ),
                                    ),
                                    SizedBox(height: 7),
                                    Text(
                                      controller.myData.createdDate
                                          .split(" ")[0],
                                      style: GoogleFonts.poppins(
                                        fontSize: 10,
                                        fontWeight: FontWeight.w400,
                                        color: Colors.black,
                                      ),
                                    ),
                                    SizedBox(height: 7),
                                    Text(
                                      Get.locale == Locale("ar")
                                          ? controller.myData.specialityNameAr
                                          : controller.myData.specialityNameEn,
                                      style: GoogleFonts.poppins(
                                        fontSize: 15,
                                        fontWeight: FontWeight.w500,
                                        color: Colors.black,
                                      ),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                          ),
                        ),
                        SizedBox(height: 22),
                        Container(
                          padding: EdgeInsets.symmetric(
                            horizontal: 40,
                          ),
                          child: Column(
                            children: [
                              Row(
                                children: [
                                  Text(
                                    'Customer Name'.tr,
                                    style: _leadingStyle(),
                                  ),
                                  Spacer(),
                                  Text(
                                    controller.myData.requesterName,
                                    style: _trailingStyle(),
                                  ),
                                  SizedBox(width: 15),
                                  Container(
                                    width: 33,
                                    height: 32,
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(48),
                                      image: DecorationImage(
                                        fit: BoxFit.fill,
                                        image: NetworkImage(
                                            controller.myData.fromUserUrl),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              SizedBox(height: 15),
                              _data(
                                  'Customer Address'.tr,
                                  controller.myData.address != null
                                      ? '${controller.myData.address.city}'
                                      : "N/A"),
                              SizedBox(height: 15),
                              _data('Service Status'.tr, 'InProgress'.tr),
                              SizedBox(height: 15),
                              Row(
                                children: [
                                  Text(
                                    'Total Amount'.tr,
                                    style: _leadingStyle(),
                                  ),
                                  Spacer(),
                                  Text(
                                    "${controller.myData.bid}",
                                    style: _leadingStyle(),
                                  ),
                                  Text(
                                    "SAR ".tr,
                                    style: _leadingStyle(),
                                  )
                                ],
                              ),
                              SizedBox(height: 15),
                              _data('Payment Type'.tr, 'Electronic Payment'.tr),
                            ],
                          ),
                        ),
                        controller.myData.status == 3
                            ? SizedBox()
                            : Column(
                                children: [
                                  SizedBox(height: 30),
                                  InkWell(
                                    onTap: () async {
                                      EditRequestService param =
                                          EditRequestService(
                                        id: controller.myData.id,
                                        status: 3,
                                        fromUser: controller.myData.providerId,
                                        toUser: controller.myData.requesterId,
                                      );
                                      ApiProvider(httpClient: Dio())
                                          .editRequestService(param)
                                          .then((value) => {
                                                homeController.getAll(),
                                              });

                                      Get.to(ProviderRating());
                                    },
                                    child: Container(
                                      height: 40,
                                      width: 228,
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 75),
                                      decoration: BoxDecoration(
                                        color: Ui.parseColor("#37915D"),
                                        borderRadius: BorderRadius.circular(28),
                                      ),
                                      child: Center(
                                        child: Text(
                                          'Finished Service'.tr,
                                          style: GoogleFonts.poppins(
                                            fontSize: 13,
                                            fontWeight: FontWeight.w400,
                                            color: Colors.white,
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                  SizedBox(height: 10),
                                  InkWell(
                                    onTap: () {
                                      Get.to(ProviderReport());
                                    },
                                    child: Container(
                                      height: 40,
                                      width: 228,
                                      margin:
                                          EdgeInsets.symmetric(horizontal: 75),
                                      decoration: BoxDecoration(
                                        color: Colors.white,
                                        borderRadius: BorderRadius.circular(28),
                                        border: Border.all(
                                          color: Ui.parseColor("#707070"),
                                          width: 1,
                                        ),
                                      ),
                                      child: Center(
                                        child: Text(
                                          'Report'.tr,
                                          style: GoogleFonts.poppins(
                                            fontSize: 13,
                                            fontWeight: FontWeight.w400,
                                            color: Ui.parseColor("#707070"),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                  SizedBox(height: 42),
                                ],
                              ),
                      ],
                    ),
                  )
                ],
              )
            ],
          ),
        ],
      ),
    );
  }

  Row _data(String leadingText, String trailingText) {
    return Row(
      children: [
        Text(
          leadingText,
          style: _leadingStyle(),
        ),
        Spacer(),
        Text(
          trailingText,
          style: _trailingStyle(),
        )
      ],
    );
  }

  TextStyle _leadingStyle() {
    return GoogleFonts.poppins(
      color: Ui.parseColor("#339A58"),
      fontSize: 14,
      fontWeight: FontWeight.w500,
    );
  }
}

TextStyle _trailingStyle() {
  return GoogleFonts.poppins(
    fontSize: 14,
    fontWeight: FontWeight.w500,
    color: Colors.black,
  );
}