import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/basic.dart';
import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/colors.dart';
import 'package:ride/constant/links.dart';
import 'package:ride/controller/functions/crud.dart';
import 'package:ride/main.dart';
import 'package:ride/views/lang/languages.dart';
import 'package:ride/views/widgets/elevated_btn.dart';

import '../../constant/style.dart';

class LogOut {
  Future deleteMyAccount(String id) async {
    await CRUD().post(link: AppLink.removeUser, payload: {'id': id}).then(
        (value) => Get.snackbar('Deleted', 'Your Account is Deleted',
            backgroundColor: AppColor.redColor));
  }

  Future logOut() async {
    Get.defaultDialog(
        title: 'Are you Sure to LogOut?'.tr,
        content: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            MyElevatedButton(
              title: 'Cancel'.tr,
              onPressed: () => Get.back(),
            ),
            ElevatedButton(
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(AppColor.redColor),
                ),
                onPressed: () {
                  // box.remove(BoxName.agreeTerms);
                  box.remove(BoxName.driverID);
                  box.remove(BoxName.email);
                  box.remove(BoxName.lang);
                  box.remove(BoxName.name);
                  box.remove(BoxName.passengerID);
                  box.remove(BoxName.phone);
                  box.remove(BoxName.tokenFCM);
                  box.remove(BoxName.tokens);
                  Get.offAll(const Language());
                },
                child: Text(
                  'Sign Out'.tr,
                  style:
                      AppStyle.title.copyWith(color: AppColor.secondaryColor),
                ))
          ],
        ));
  }
}
