syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.46k stars 680 forks source link

[syncfusion_flutter_datepicker] "TODAY" button should say "THIS MONTH" #1777

Closed lukehutch closed 2 weeks ago

lukehutch commented 2 months ago

The "TODAY" button/link only shows the current month, it does not actually select today's date. Therefore, the button should have the text "THIS MONTH".

lukehutch commented 2 months ago

And/or, there should be an option to select today's date when you tap this button. Or maybe tapping it twice should select today's date.

Yuvaraj-Gajaraj commented 1 month ago

Hi @lukehutch ,

We would like to let you know that when tap the Today button in the SfDateRangePicker it will navigate to the current month, in that we have already marked today's date with a circular. If you have any further queries please get back to us, we are always happy to assist you.

Regards, Yuvaraj.

lukehutch commented 1 month ago

I understand what the button does. But the text on the button then has the wrong text on it. It shows the current month, it doesn't select the current day.

natrayansf commented 1 month ago

Hi @lukehutch,

You can achieve your requirement “option to select today's date when you tap this button” by utilizing the DateRangePickerController() provided by the SfDateRangePicker. Upon tapping the button, you can update the displayDate and selectedDate fields accordingly.

Code snippet:

class _MyHomePageState extends State<MyHomePage> {
  final DateRangePickerController controller = DateRangePickerController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: SfDateRangePicker(
              view: DateRangePickerView.month,
              controller: controller,
            ),
          ),
          Expanded(
            child: TextButton(
              onPressed: () {
                controller.displayDate = DateTime.now();
                controller.selectedDate = DateTime.now();
              },
              child: const Text('Today'),
            ),
          ),
        ],
      ),
    );
  }
}

We have attached a simple sample for reference. If you have any further queries please get back to us, we are always happy to assist you. Sample: 585642.zip

Regards, Natrayan

lukehutch commented 1 month ago

Thanks, sure, but I am only commenting on the fact that the text in the built-in button has the wrong label. It should say "This month", not "Today", because its function is to jump the view to the current month, not to select the current day.

Yuvaraj-Gajaraj commented 3 weeks ago

Hi @lukehutch ,

Previously we referred to Google and Microsoft Outlook calendar as a reference. In the Google Calendar (Mobile platform), the 'Today' button was recently changed to 'Jump to Today', and in the Microsoft Outlook calendar when we press the Today button in month view, it selects today's date, and the respected will also be highlighted. We have considered this as an improvement and logged an FR in our feedback portal, it will be included in any of our upcoming releases. You can also track the status of the feature with the feedback below.

Feedback, https://www.syncfusion.com/feedback/57067

However, you can be able to customize the Today button text with the help of overriding the required properties in the locale and replacing it with the required text value. We have prepared a class for the English locale by extending our SfLocalization, using it in the sample, modifying the Today text to This Month, and achieving the requirement. We have shared the sample below for your reference.

Screenshot: ScreenRecording2024-05-08at1 24 26AM-ezgif com-video-to-gif-converter

UG, https://help.syncfusion.com/flutter/globalization#custom-culture-support

Sample: i585642.zip

Regards, Yuvaraj.

lukehutch commented 3 weeks ago

Great, thanks for the detailed response.