import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_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/marathon_details_card.dart';
import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_footer.dart';
import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_timer_card.dart';
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
import 'package:provider/provider.dart';

class MarathonIntroScreen extends StatelessWidget {
  const MarathonIntroScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    MarathonProvider provider = context.watch<MarathonProvider>();
    return Scaffold(
      appBar: AppBarWidget(context, title: LocaleKeys.brainMarathon.tr()),
      body: Column(
        children: <Widget>[
          ListView(
            padding: const EdgeInsets.all(21),
            children: <Widget>[
              MarathonDetailsCard(marathonDetailModel: provider.isUpComingMarathon ? provider.marathonDetailModel : provider.demoMarathonDetailModel),
              20.height,
              provider.isUpComingMarathon
                  ? MarathonTimerCard(
                      provider: provider,
                      timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch,
                    )
                  : const SizedBox(),
            ],
          ).expanded,
          1.divider,
          MarathonFooter(provider: provider),
        ],
      ),
    );
  }
}
