//
//  PaginationDots.swift
//  vibes
//
//  Created by Claude Code on 1/6/25.
//

import SwiftUI

struct PaginationDots: View {
    let totalDots: Int
    let currentIndex: Int

    var body: some View {
        HStack(spacing: 4) {
            ForEach(0..<totalDots, id: \.self) { index in
                let isActive = index == currentIndex
                let width: CGFloat = isActive ? 12 : 6
                let height: CGFloat = 6
                let opacity: Double = isActive ? 1.0 : 0.5

                // Use Capsule for all dots so they can animate smoothly
                Capsule()
                    .fill(Constants.ForegroundPrimary.opacity(opacity))
                    .frame(width: width, height: height)
                    .animation(.spring(response: 0.4, dampingFraction: 0.75), value: isActive)
                    .id(index)
            }
        }
    }
}

#Preview {
    ZStack {
        Color.black
            .ignoresSafeArea()

        VStack(spacing: 20) {
            PaginationDots(totalDots: 5, currentIndex: 0)
            PaginationDots(totalDots: 5, currentIndex: 2)
            PaginationDots(totalDots: 3, currentIndex: 1)
        }
    }
}
