import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';

class AgeText extends FStatelessWidget {
  String? ageUnits;
  String? ageDay = '';
  String? ageWeek = '';
  String? ageMonth = '';
  String? ageYear = '';
  TextStyle? style = TextStyle();
  AgeText({
    Key? key,
    this.ageUnits,
    this.ageDay,
    this.ageMonth,
    this.ageWeek,
    this.ageYear,
    this.style,
  }) : super(key: key);

  String buildAgeText() {
    switch (ageUnits) {
      case 'Year':
        if (ageYear?.isEmpty ?? true) return i18nBook.remedical.notFill.t;
        return '$ageYear ${i18nBook.remedical.years.t}';
      case 'YearAndMonth':
        return '$ageYear ${i18nBook.remedical.years4display.t} $ageMonth ${i18nBook.remedical.month4display.t}';
      case 'MonthAndWeek':
        return '$ageMonth ${i18nBook.remedical.month4display.t} $ageWeek ${i18nBook.remedical.week4display.t}';
      case 'WeekAndDay':
        return '$ageWeek ${i18nBook.remedical.week4display.t} $ageDay ${i18nBook.remedical.day4display.t}';
      default:
        return i18nBook.remedical.notFill.t;
    }
  }

  @override
  FWidget build(BuildContext context) {
    return FText(
      buildAgeText(),
      style: style,
    );
  }
}
