import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/controller/mh_controller/book_info_controller.dart';

class BookDateWidget extends GetView<BookInfoController> {
  int index;
  BookInfoController bookInfoController;

  BookDateWidget({required this.index, required this.bookInfoController}) {}

  @override
  Widget build(BuildContext context) {
    return InkWell(onTap: () {
      if (index == controller.model.datetimes_index) {
        return;
      }
      controller.model.datetimes_index = index;
      controller.time_periodChange();
      controller.updateAll();
    }, child: Obx(() {
      return Container(
        width: 144.rpx,
        height: 143.rpx,
        constraints: BoxConstraints(
          minHeight: 140.rpx,
        ),
        decoration: BoxDecoration(
          // color: FlutterFlowTheme.of(context).secondaryBackground,
          color: controller.model.datetimes_index == index
              ? Color(0XFF84F5FF)
              : Color(0xFF003058),
          borderRadius: BorderRadius.circular(13.rpx),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Flexible(
              child: Text(
                "${bookInfoController.model.datetimes![index]?['dayName']}",
                style: TextStyle(
                    fontFamily: 'Readex Pro',
                    letterSpacing: 0,
                    color: controller.model.datetimes_index == index
                        ? Color(0XFF011D33)
                        : Colors.white,
                    fontSize: 26.rpx),
              ),
            ),
            Flexible(
              child: Text(
                "${bookInfoController.model.datetimes![index]?['day']}",
                style: TextStyle(
                    fontFamily: 'Readex Pro',
                    letterSpacing: 0,
                    color: controller.model.datetimes_index == index
                        ? Color(0XFF011D33)
                        : Colors.white,
                    fontSize: 19.rpx),
              ),
            ),
            Flexible(
              child: Icon(
                Icons.keyboard_arrow_down_rounded,
                color: controller.model.datetimes_index == index
                    ? Color(0XFF011D33)
                    : Colors.white,
                size: 12,
              ),
            ),
          ],
        ),
      );
    }));
  }
}
