import 'package:get/get.dart';

import '../../../../config/translations/strings_enum.dart';

/// 流媒体服务数据模型
class StreamingService {
  final String name;
  final String description;
  final String logoUrl;

  StreamingService({
    required this.name,
    required this.description,
    required this.logoUrl,
  });
}

class MedialocationController extends GetxController {
  // VPN连接状态
  final isConnected = false.obs;
  final isConnecting = false.obs;

  // 流媒体服务列表
  List<StreamingService> get streamingServices => [
    StreamingService(
      name: Strings.netflix.tr,
      description: Strings.niftyStreaming.tr,
      logoUrl: 'assets/images/netflix_logo.png',
    ),
    StreamingService(
      name: Strings.youtube.tr,
      description: Strings.youtubeStreaming.tr,
      logoUrl: 'assets/images/youtube_logo.png',
    ),
    StreamingService(
      name: Strings.hulu.tr,
      description: Strings.huluStreaming.tr,
      logoUrl: 'assets/images/hulu_logo.png',
    ),
    StreamingService(
      name: Strings.amazon.tr,
      description: Strings.amazonStreaming.tr,
      logoUrl: 'assets/images/amazon_logo.png',
    ),
  ];

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  /// 打开流媒体服务
  void openStreamingService(StreamingService service) {
    Get.snackbar(
      Strings.opening.tr,
      '${service.name} ${Strings.willOpenSoon.tr}',
    );
  }

  /// 连接VPN
  void connect() {
    if (isConnecting.value) return;
    
    isConnecting.value = true;
    
    // 模拟连接过程
    Future.delayed(const Duration(seconds: 2), () {
      isConnecting.value = false;
      isConnected.value = true;
      Get.snackbar(
        Strings.success.tr,
        Strings.connectedSuccessfully.tr,
      );
    });
  }

  /// 断开VPN
  void disconnect() {
    isConnected.value = false;
    isConnecting.value = false;
  }
}
