import 'package:location/sdk/map/map_helper.dart';
import 'package:permission_handler/permission_handler.dart';

class PermissionUtil {
  PermissionUtil._();

  static Future<bool> requestLocationPermission() async {
    final status = await Permission.locationWhenInUse.request();
    if (status.isGranted) {
      MapHelper.startLocation();
      return true;
    } else {
      return false;
    }
  }

  static Future<bool> checkLocationPermission() async {
    final status = await Permission.locationWhenInUse.status;
    return status.isGranted;
  }

  static Future<bool> requestShowLocationAlways() async {
    final status = await Permission.locationAlways.request();
    if (status.isGranted) {
      MapHelper.startLocation();
      return true;
    } else {
      return false;
    }
  }

  static Future<bool> checkShowLocationAlways() async {
    final status = await Permission.locationAlways.status;
    if (status.isGranted) {
      return true;
    } else {
      return false;
    }
  }

  static Future<bool> checkPermission(Permission permission) async {
    final status = await permission.status;
    if (status.isGranted) {
      return true;
    } else {
      return false;
    }
  }

  static Future<bool> requestPermission(Permission permission) async {
    final status = await permission.request();
    if (status.isGranted) {
      return true;
    } else {
      return false;
    }
  }
}
