import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class ProgressBar extends ConsumerWidget{
  final double max;
  final double value;
  final double height;
  final double textSize;
  final double textSecondarySize;
  final Color backgroundColor;
  final Color foregroundColor;
  final Color textColor;

  const ProgressBar({
    required this.max,
    required this.value,
    required this.height,
    required this.textSize,
    required this.textSecondarySize,
    required this.backgroundColor,
    required this.foregroundColor,
    required this.textColor,}
  );

  @override
  Widget build(BuildContext context, WidgetRef ref) {

    return
      Stack(
        children: [
          LinearProgressIndicator(
          value: value / max,
          minHeight: height,
          borderRadius: BorderRadius.all(Radius.circular(24)),
          color: foregroundColor,
          backgroundColor: backgroundColor
        ),
        FractionallySizedBox(
          widthFactor: value / max,
          child: SizedBox(
            height: height,
            child: Center(
              child: MoneyText(
                text: "$value€",
                size: textSize,
                secondarySize: textSecondarySize,
                color: textColor,
              ),
            )
          ),
        ),
      ]
    );
  }
}