import 'package:get/get.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;

  // 流媒体服务列表
  final List<StreamingService> streamingServices = [
    StreamingService(
      name: 'Netflix',
      description: 'Nifty Streaming',
      logoUrl: 'assets/images/netflix_logo.png',
    ),
    StreamingService(
      name: 'YouTube',
      description: 'YouTube Streaming',
      logoUrl: 'assets/images/youtube_logo.png',
    ),
    StreamingService(
      name: 'hulu',
      description: 'hulu Streaming',
      logoUrl: 'assets/images/hulu_logo.png',
    ),
    StreamingService(
      name: 'Amazon',
      description: 'Amazon Streaming',
      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(
      'Opening',
      '${service.name} will open soon',
    );
  }

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

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