single method

Widget single({
  1. required CalendarInfo calendarInfo,
  2. required DateInfo date,
  3. required double width,
})

Implementation

Widget single({
  required CalendarInfo calendarInfo,
  required DateInfo date,
  required double width,
}) {
  return InkWell(
    onTap: () {
      if (date.date != null) {
        if (date.isSelected != SelectType.disabled) {
          setState(() {
            int bottomSelectedItemsIndex;
            if (date.isSelected == SelectType.selected) {
              selectedItems!.remove(selectedItems!
                  .singleWhere((element) => (element.day == date.date!)));
              removeBottomSelectedItems(date, calendarInfo);
              date.isSelected = SelectType.none;
              date.singleSelectedAniCtrl!.reverse();
            } else {
              DateTime selectedDate1 = DateTime(
                calendarInfo.year,
                calendarInfo.month,
                date.date!,
              );
              if (widget.limitCount <= selectedItems!.length) {
                // 날짜 삭제
                if (calendarInfo.year == selectedItems![0].year &&
                    calendarInfo.month == selectedItems![0].month) {
                  DateInfo selectedDate5 = calendarInfo.dates.singleWhere(
                      (element2) => element2.date == selectedItems![0].day);
                  selectedDate5.isSelected = SelectType.none;
                  selectedDate5.singleSelectedAniCtrl!.reverse();
                }
                selectedItems!.removeAt(0);
                removeBottomSelectedItemsXBtn(0);

                // 날짜 추가
                selectedItems!.add(selectedDate1);
                setBottomSelectedItems(selectedDate1);
                DateInfo selectedDate4 = calendarInfo.dates.singleWhere(
                    (element3) => element3.date == selectedDate1.day);
                selectedDate4.isSelected = SelectType.selected;
                selectedDate4.singleSelectedAniCtrl!.forward();

                bottomSelectedItemsIndex = bottomSelectedItems!
                    .indexWhere((element1) => element1.day == date.date!);
              } else {
                selectedItems!.add(selectedDate1);
                setBottomSelectedItems(selectedDate1);
                bottomSelectedItemsIndex = bottomSelectedItems!
                    .indexWhere((element1) => element1.day == date.date!);
                date.isSelected = SelectType.selected;
                date.singleSelectedAniCtrl!.forward();
              }
            }
          });
          // widget.onSelected(selectedItems);
          // widget.getSelectedItems(selectedItems);
        }
      }
    },
    child: Container(
      width: width / 7,
      height: width / 9,
      child: Stack(
        children: [
          Align(
            alignment: Alignment.center,
            child: ScaleTransition(
              scale: (date.singleScaleAnimation != null)
                  ? date.singleScaleAnimation!
                  : nullAnimation,
              child: Container(
                width: width / 12,
                height: width / 12,
                decoration: BoxDecoration(
                  color: widget.selectedCircleColor,
                  shape: BoxShape.circle,
                ),
              ),
            ),
          ),
          Align(
            alignment: Alignment.center,
            child: date.date != null
                ? Text(
                    date.date.toString(),
                    style: TextStyle(
                        fontSize: width * 0.033,
                        color: textColor(date.isSelected)),
                  )
                : Container(),
          )
        ],
      ),
    ),
  );
}