import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../constant/colors.dart';
import '../../../../constant/style.dart';
import '../../../../controller/home/captin/map_driver_controller.dart';
import '../../../widgets/elevated_btn.dart';

GetBuilder<MapDriverController> driverEndRideBar() {
  return GetBuilder<MapDriverController>(
      builder: (mapDriverController) => mapDriverController.isRideStarted
          ? Positioned(
              left: 5,
              top: 5,
              right: 5,
              child: Container(
                decoration: AppStyle.boxDecoration,
                height: 100,
                width: 200,
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: [
                        Column(
                          children: [
                            const Icon(Icons.social_distance),
                            Text(
                              mapDriverController.distance.toString() +
                                  '  ' +
                                  'KM'.tr,
                              style: AppStyle.title,
                            ),
                          ],
                        ),
                        mapDriverController.remainingTimeTimerRideBegin < 60
                            ? MyElevatedButton(
                                title: 'End Ride'.tr,
                                onPressed: () {
                                  mapDriverController.finishRideFromDriver();
                                },
                                kolor: AppColor.redColor,
                              )
                            : const SizedBox(),
                        Column(
                          children: [
                            const Icon(Icons.timelapse),
                            Text(
                                mapDriverController.duration.toString() +
                                    '  ' +
                                    'Minute'.tr,
                                style: AppStyle.title),
                          ],
                        ),
                      ],
                    ),
                    Stack(
                      children: [
                        LinearProgressIndicator(
                          backgroundColor: AppColor.accentColor,
                          color:
                              mapDriverController.remainingTimeTimerRideBegin <
                                      60
                                  ? AppColor.redColor
                                  : AppColor.greenColor,
                          minHeight: 40,
                          borderRadius: BorderRadius.circular(15),
                          value: mapDriverController.progressTimerRideBegin
                              .toDouble(),
                        ),
                        Center(
                          child: Text(
                            mapDriverController.stringRemainingTimeRideBegin,
                            style: AppStyle.title,
                          ),
                        )
                      ],
                    ),
                  ],
                ),
              ))
          : const SizedBox());
}
