import 'package:flutter/material.dart';

class MoneyText extends StatelessWidget {
  final String text;
  final double size;
  final double? secondarySize;
  final Color color;
  final double height;

  const MoneyText({
    super.key,
    required this.text,
    required this.size,
    this.secondarySize,
    required this.color,
    this.height = 1,
  });

  @override
  Widget build(BuildContext context) {
    final split = text.contains(".") ? text.split(".") : text.split("€");
    final mainText = split[0];
    var secondaryText = text.contains(".") ? ",${split[1]}" : "€${split[1]}";

    return Text.rich(TextSpan(
      text: mainText,
      style: TextStyle(
        fontWeight: FontWeight.bold,
        fontSize: size,
        color: color,
        height: height
      ),
      children: [
        TextSpan(
          text: secondaryText,
          style: TextStyle(
            fontWeight: FontWeight.normal,
            fontSize: secondarySize ?? size,
          )
        )
      ]
    ));
  }
}