import 'package:flutter/material.dart';

class MoneyText extends StatelessWidget {
  final String text;
  final double size;
  final bool resize;
  final Color color;

  const MoneyText({super.key, required this.text, required this.size, required this.resize, required this.color});

  @override
  Widget build(BuildContext context) {
    final units = text.split(".")[0];
    final cents = ",${text.split(".")[1]}";

    return Text.rich(TextSpan(
      text: units,
      style: TextStyle(
        fontWeight: FontWeight.bold,
        fontSize: size,
        color: color
      ),
      children: [
        TextSpan(
          text: cents,
          style: TextStyle(
            fontWeight: FontWeight.normal,
            fontSize: resize ? size/2 : size
          )
        )
      ]
    ));
  }

}