flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.97k stars 26.8k forks source link

CupertinoDatePicker should only display available days #149888

Open RomanNakonechnyi opened 2 weeks ago

RomanNakonechnyi commented 2 weeks ago

Steps to reproduce

  1. Just use CupertinoDatePicker

Expected results

Number of days is correct for each month.

Actual results

Number of days is always 31.

Code sample

Code sample https://dartpad.dev/?id=e93f41f8a269ea8c654cbad67c125c10

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console Flutter (Channel stable, 3.16.9, on macOS 14.5 23F79 darwin-arm64, locale en-UA) • Flutter version 3.16.9 on channel stable at /Users/romannakonechnyi/fvm/versions/3.16.9 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 41456452f2 (4 months ago), 2024-01-25 10:06:23 -0800 • Engine revision f40e976bed • Dart version 3.2.6 • DevTools version 2.28.5 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/romannakonechnyi/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode-15.4.0.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) [✓] VS Code (version 1.90.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.90.0 ```
huycozy commented 2 weeks ago

Hi @RomanNakonechnyi, I see days 30th and 31st are greyed out already and can't be selected, do you mean it should not displayed?

RomanNakonechnyi commented 2 weeks ago

Hi @huycozy, thanks for quick response. I expect date picker to show only real dates, it is strange to see fantom days like 29, 30, 31 for February even if they are greyed out. What's your opinion on that?)

jonmountjoy commented 2 weeks ago

@RomanNakonechnyi was does iOS do?

RomanNakonechnyi commented 2 weeks ago

@jonmountjoy reminders and zoom app examples, no redundant disabled days. IMG_3812 IMG_3813

huycozy commented 2 weeks ago

@RomanNakonechnyi That looks like a feature request instead. I will label this for other's thoughts. Thanks!

Sample code from dartpad above ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: Center( child: CupertinoDatePicker( initialDateTime: DateTime(2024, 2, 28), mode: CupertinoDatePickerMode.date, onDateTimeChanged: (DateTime value) {}, ), ), ), ); } } ```
MitchellGoodwin commented 2 weeks ago

This is a SwiftUI date picker wheel.

Screenshot 2024-06-12 at 9 48 10 AM

It will show unselectable dates that are grayed out the same way we do. In the format that we show time as well like the native version we don't show invalid dates the same as them. We do have the situation where you can have just the date with the day of week showing and we have weird invalid dates grayed out. It doesn't look like there's a way to show this specific date format by default in SwiftUI, so there's nothing to compare to, but it does look odd.

Screenshot 2024-06-12 at 10 17 23 AM
RomanNakonechnyi commented 1 week ago

@MitchellGoodwin thanks for checking, it definitely does look odd, and its one of places where Flutter can do better than swiftUI;)