import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../../enums/video_stream_mode_enum.dart';

/// P2P/WebRTC 模式切换控件
///
/// 显示当前传输模式（P2P / RTC），点击切换至另一种模式。
/// 位置：视频容器右下角，全屏按钮左侧。
///
/// 涉及页面：监控页 - 监控画面
class VideoStreamSwitch extends StatelessWidget {
  /// 当前视频传输模式
  final VideoStreamMode currentMode;

  /// 点击切换回调
  final VoidCallback onToggle;

  const VideoStreamSwitch({
    super.key,
    required this.currentMode,
    required this.onToggle,
  });

  @override
  Widget build(BuildContext context) {
    final isP2p = currentMode == VideoStreamMode.p2p;

    return GestureDetector(
      onTap: onToggle,
      child: Container(
        width: 60.w,
        height: 60.w,
        decoration: BoxDecoration(
          color: isP2p
              ? const Color(0xFF3A87FF).withValues(alpha: 0.6)
              : Colors.black38,
          borderRadius: BorderRadius.circular(8.r),
          border: Border.all(
            color: isP2p ? Colors.white54 : Colors.white24,
            width: 1,
          ),
        ),
        child: Center(
          child: Text(
            isP2p ? 'P2P' : 'RTC',
            style: TextStyle(
              fontSize: 10.sp,
              color: Colors.white,
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ),
    );
  }
}
