import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/date_uitl.dart';
import 'package:mohem_flutter_app/classes/decorations_helper.dart';
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart';
import 'package:mohem_flutter_app/ui/marathon/widgets/countdown_timer.dart';


class MarathonTimerCard extends StatelessWidget {
  final int timeToMarathon;
  final MarathonProvider provider;

  const MarathonTimerCard({
    Key? key,
    required this.provider,
    required this.timeToMarathon,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      decoration: MyDecorations.shadowDecoration,
      padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 14),
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              "${LocaleKeys.gameDate.tr()} ".toText16(color: MyColors.grey77Color),
              DateUtil.getMonthDayYearDateFormatted(DateTime.parse(provider.marathonDetailModel.startTime!)).toText16(color: MyColors.darkTextColor, isBold: true),
            ],
          ),
          Row(
            children: <Widget>[
              "${LocaleKeys.gameTime.tr()} ".toText16(color: MyColors.grey77Color),
              DateUtil.formatDateToTimeLang(DateTime.parse(provider.marathonDetailModel.startTime!), AppState().isArabic(context)).toText16(color: MyColors.darkTextColor, isBold: true),
            ],
          ),
          Lottie.asset(MyLottieConsts.hourGlassLottie, height: 200),
          BuildCountdownTimer(timeToMarathon: timeToMarathon, provider: provider, screenFlag: 1),
        ],
      ),
    );
  }
}
