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

import '../../../../constant/box_name.dart';
import '../../../../constant/colors.dart';
import '../../../../constant/style.dart';
import '../../../../controller/functions/launch.dart';
import '../../../../controller/home/captin/map_driver_controller.dart';
import '../../../../main.dart';

class SosConnect extends StatelessWidget {
  const SosConnect({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MapDriverController>(
        builder: (mapDriverController) => mapDriverController.isRideStarted
            ? Positioned(
                left: 5,
                top: Get.height * .3,
                child: Container(
                  decoration: AppStyle.boxDecoration,
                  height: 100,
                  width: 70,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      InkWell(
                        onTap: () {
                          launchCommunication('phone', '911', '');
                        },
                        child: const Icon(
                          Icons.sos_sharp,
                          color: AppColor.redColor,
                        ),
                      ),
                      InkWell(
                        onTap: () {
                          launchCommunication(
                              'whatsapp',
                              '0798583052', //todo  add number from driver
                              'Hello this is Captain'.tr +
                                  ' ${box.read(BoxName.nameDriver)}');
                        },
                        child: const Icon(
                          FontAwesome.whatsapp,
                          color: AppColor.greenColor,
                        ),
                      ),
                    ],
                  ),
                ))
            : const SizedBox());
  }
}
