show method

void show()

Displays the week picker dialog.

Implementation

void show() {
  _dateRangePickerValue = [startDate, endDate];

  final textStyle =
      TextStyle(color: primaryColor, fontWeight: FontWeight.w700);
  final config = CalendarDatePicker2WithActionButtonsConfig(
    dayTextStyle: textStyle,
    calendarType: CalendarDatePicker2Type.range,
    selectedDayHighlightColor: primaryColor,
    closeDialogOnCancelTapped: true,
    firstDayOfWeek: 1,
    weekdayLabelTextStyle: TextStyle(
      color: primaryColor,
      fontWeight: FontWeight.bold,
    ),
    controlsTextStyle: TextStyle(
      color: primaryColor,
      fontSize: 15.sp,
      fontWeight: FontWeight.bold,
    ),
    lastMonthIcon: Icon(
      Icons.arrow_back_ios,
      color: primaryColor,
      size: 16.sp,
    ),
    nextMonthIcon: Icon(
      Icons.arrow_forward_ios,
      color: primaryColor,
      size: 16.sp,
    ),
    centerAlignModePicker: true,
    customModePickerIcon: const SizedBox(),
    selectedDayTextStyle: textStyle.copyWith(
      color: secondaryColor,
    ),
    selectedMonthTextStyle: textStyle.copyWith(
      color: secondaryColor,
    ),
    selectedYearTextStyle: textStyle.copyWith(
      color: secondaryColor,
    ),
  );

  showGeneralDialog(
    barrierLabel: "WeekPicker",
    context: context,
    pageBuilder: (_, __, ___) {
      return Align(
        alignment: Alignment.topCenter,
        child: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                color: secondaryColor,
                height: 86.h,
                child: Column(
                  children: [
                    SizedBox(height: 40.h),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        IconButton(
                          onPressed: () {
                            Navigator.of(context).pop();
                          },
                          icon: Icon(
                            Icons.arrow_back,
                            color: primaryColor,
                          ),
                        ),
                        Text(
                          'Week Picker',
                          style: TextStyle(
                            fontSize: 18.sp,
                            color: primaryColor,
                            decoration: TextDecoration.none,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                        IconButton(
                          onPressed: () {
                            if (_dateRangePickerValue[0] != null &&
                                _dateRangePickerValue[1] != null) {
                              onConfirm(
                                _dateRangePickerValue[0]!,
                                _dateRangePickerValue[1]!,
                              );
                            }
                            Navigator.of(context).pop();
                          },
                          icon: Icon(Icons.check, color: primaryColor),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
              Container(
                height: 1.h,
                decoration: BoxDecoration(
                  color: primaryColor,
                ),
              ),
              SizedBox(
                height: 290.h,
                child: Material(
                  color: secondaryColor,
                  borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(10.sp),
                    bottomRight: Radius.circular(10.sp),
                  ),
                  child: StatefulBuilder(
                    builder:
                        (BuildContext context, StateSetter dialogSetState) {
                      return Column(
                        children: [
                          CalendarDatePicker2(
                            config: config,
                            value: _dateRangePickerValue,
                            onValueChanged: (value) {
                              dialogSetState(() {
                                _dateRangePickerValue = value;
                              });
                            },
                          ),
                        ],
                      );
                    },
                  ),
                ),
              ),
            ],
          ),
        ),
      );
    },
  );
}