//
//  ZoomControlView.swift
//  CameraTester
//
//  Created by Matt Bruce on 1/2/26.
//

import SwiftUI
import Bedrock

// MARK: - Zoom Control View

struct ZoomControlView: View {
    let zoomFactor: CGFloat
    var isCenterStageActive: Bool = false

    // Layout constants
    private let fontSize: CGFloat = 16
    private let iconSize: CGFloat = 14

    var body: some View {
        HStack {
            Spacer()
            if isCenterStageActive {
                // Show Center Stage indicator instead of zoom level
                // (pinch to zoom is disabled when Center Stage is active)
                HStack(spacing: Design.Spacing.xSmall) {
                    Image(systemName: "person.crop.rectangle.fill")
                        .font(.system(size: iconSize, weight: .medium))
                    Text("Center Stage")
                        .font(.system(size: fontSize, weight: .medium))
                }
                .foregroundStyle(Color.yellow)
                .padding(.horizontal, Design.Spacing.medium)
                .padding(.vertical, Design.Spacing.small)
                .background(
                    RoundedRectangle(cornerRadius: Design.CornerRadius.medium)
                        .fill(Color.black.opacity(Design.Opacity.medium))
                )
            } else {
                Text(String(format: "%.1fx", zoomFactor))
                    .font(.system(size: fontSize, weight: .medium))
                    .foregroundStyle(Color.white)
                    .padding(.horizontal, Design.Spacing.medium)
                    .padding(.vertical, Design.Spacing.small)
                    .background(
                        RoundedRectangle(cornerRadius: Design.CornerRadius.medium)
                            .fill(Color.black.opacity(Design.Opacity.medium))
                    )
            }
            Spacer()
        }
        .accessibilityLabel(isCenterStageActive ? "Center Stage active" : "Zoom \(String(format: "%.1f", zoomFactor)) times")
    }
}
