import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:taafee_mobile/features/card/data_layer/model/work_schedules.dart';
import 'package:taafee_mobile/features/card/data_layer/model/working_time.dart';

import '../../../../common/const/const.dart';
import '../../../../common/widgets/listview.dart';
import '../../../../common/widgets/text.dart';

class WorkingTimeWidget extends StatelessWidget {
  WorkScheduleModel? workScheduleModel;
  WorkingTimeWidget({super.key, this.workScheduleModel});

  @override
  Widget build(BuildContext context) {
    return workScheduleModel != null
        ? Container(
            width: Get.width * .89,
            // height: 270,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(10),
            ),
            child: SizedBox(
              width: Get.width * .89,
              child: ListViewWidget(
                  itemCount: workScheduleModel!.days.length,
                  physics: const BouncingScrollPhysics(),
                  childBuilder: (index) {
                    return Row(
                      children: [
                        SizedBox(
                          width: 90,
                          child: BoldTextWidget(workScheduleModel!.days[index].day),
                        ).paddingSymmetric(horizontal: 12),
                        Expanded(
                          child: SizedBox(
                            height: 50,
                            child: ListViewWidget(
                                physics: const BouncingScrollPhysics(),
                                scrollDirection: Axis.horizontal,
                                itemCount: workScheduleModel!.days[index].workTime.length,
                                childBuilder: (i) {
                                  return Container(
                                    alignment: Alignment.center,
                                    width: 125,
                                    decoration: BoxDecoration(
                                      color: workScheduleModel!.days[index].workTime[i].name == "عطلة"
                                          ? Colors.grey
                                          : AppColors.secondaryColor,
                                      borderRadius: BorderRadius.circular(10),
                                    ),
                                    margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 10),
                                    child: Row(
                                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                      children: [
                                        RegularTextWidget(workScheduleModel!.days[index].workTime[i].startTime),
                                        RegularTextWidget(workScheduleModel!.days[index].workTime[i].name),
                                        RegularTextWidget(workScheduleModel!.days[index].workTime[i].endTime),
                                      ],
                                    ).paddingSymmetric(horizontal: 10),
                                  );
                                }),
                          ),
                        )
                      ],
                    );
                  }),
            ),
          )
        : Container();
  }
}
