import 'package:flutter/material.dart';

import 'package:provider/provider.dart';
import 'package:pweb/pages/dashboard/buttons/balance/config.dart';

import 'package:pweb/providers/carousel.dart';


class CarouselIndicator extends StatelessWidget {
  final int itemCount;

  const CarouselIndicator({
    super.key,
    required this.itemCount,
  });

  @override
  Widget build(BuildContext context) {
    final currentIndex = context.watch<CarouselIndexProvider>().currentIndex;
    
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: List.generate(
        itemCount,
        (index) => _Dot(isActive: currentIndex == index),
      ),
    );
  }
}

class _Dot extends StatelessWidget {
  final bool isActive;

  const _Dot({required this.isActive});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: WalletCardConfig.dotSize,
      height: WalletCardConfig.dotSize,
      margin: WalletCardConfig.dotMargin,
      decoration: BoxDecoration(
        shape: BoxShape.circle,
        color: isActive
            ? Theme.of(context).colorScheme.primary
            : Theme.of(context).colorScheme.primary.withAlpha(60),
      ),
    );
  }
}
