import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import '../constants/app_constants.dart';

class TokenStorage {
  static const _storage = FlutterSecureStorage(
    aOptions: AndroidOptions(encryptedSharedPreferences: true),
  );

  static Future<void> saveToken(String token) =>
      _storage.write(key: AppConstants.tokenKey, value: token);

  static Future<String?> getToken() =>
      _storage.read(key: AppConstants.tokenKey);

  static Future<void> saveUserType(String type) =>
      _storage.write(key: AppConstants.userTypeKey, value: type);

  static Future<String?> getUserType() =>
      _storage.read(key: AppConstants.userTypeKey);

  static Future<void> clear() => _storage.deleteAll();
}
