import 'dart:io';

import 'package:permission_handler/permission_handler.dart';

/// 공용 권한 유틸리티
class PermissionService {
  static Future<bool> checkAndRequestBluetoothPermission() async {
    if (!Platform.isAndroid && !Platform.isIOS) {
      return true;
    }

    final permissions = <Permission>[
      Permission.bluetooth,
      Permission.bluetoothScan,
      Permission.bluetoothConnect,
      Permission.bluetoothAdvertise,
    ];

    for (final permission in permissions) {
      final status = await permission.status;
      if (status.isGranted) {
        continue;
      }
      final result = await permission.request();
      if (!result.isGranted) {
        return false;
      }
    }
    return true;
  }
}
