-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Create cupertino checkbox #122244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create cupertino checkbox #122244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not confident on the wording here. I would like to warn developers of Apple's guidance, without discouraging them from doing what they would like to do.
|
FYI for iOS it's in the HIG but only implicitly (e.g. in tables https://developer.apple.com/design/human-interface-guidelines/components/layout-and-organization/lists-and-tables/#platform-considerations) |
|
@GroovinChip might be the best person to give feedback on this, he made the macOS checkbox on Flutter. |
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made an initial pass. Mostly it looks pretty good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
| /// Note: in the Apple ecosystem, checkboxes are encouraged to only be used in | |
| /// macOS, not iOS. If a multi-selection component is needed, iOS encourages the | |
| /// developer to use Switches, or [CupertinoSwitch] instead, or find a creative | |
| /// custom solution. | |
| /// In the Apple Human Interface Guidelines (HIG), checkboxes are encouraged for use on macOS, but not on iOS. | |
| /// If a multi-selection component is needed on iOS, the HIG encourages the developer to use switches ([CupertinoSwitch] in Flutter) | |
| /// instead, or to find a creative custom solution. |
Does it actively discourage checkboxes on iOS? If not, then I'd just say that "but is silent about their use on iOS".
And probably link the appropriate HIG guidelines. Also note that (lol!) our style guide discourages empty prose like "Note" "Note that", etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it assert? If so, you should mention that it asserts in debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// true this callback cycle from false to true to null. | |
| /// true this callback cycle from false to true to null and back to false again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mention if it asserts in debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If this property is null, then the side will be width 1. | |
| /// If this property is null, then the side defaults to a width of 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't these use locations for this use CupertinoCheckbox.width directly? It is also a const, and would show where it comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These numbers in the offsets should be converted to constants to make it easier to read/understand them. Or you could comment on how the values are derived right here in a comment if this is the only instance of the number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// A mixin for [StatefulWidget]s that implement ios-themed toggleable | |
| /// A mixin for [StatefulWidget]s that implement iOS-themed toggleable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The mixin implements the logic for toggling the control (e.g. when tapped). | |
| /// The mixin implements the logic for toggling the control when tapped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// This mixin is used to implement the cupertino components for [Checkbox] | |
| /// This mixin is used to implement the Cupertino components for [Checkbox] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adaptive widgets don't need to be the same size, and I think it's probably better to have it conform to the standard interactive size for Cupertino, since that should fit better with other Cupertino widgets. It's not much different anyhow.
b501bdf to
9beffb6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The color used if the checkbox is inactive. By default, | |
| /// [CupertinoColors.inactiveGray] is used. | |
| /// The color used if the checkbox is inactive. | |
| /// | |
| /// By default, [CupertinoColors.inactiveGray] is used. |
The first paragraph is used as a short description in the docs, and should only be one sentence long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // The ratios for the offsets below where found from looking at the checkbox | |
| // The ratios for the offsets below were found from looking at the checkbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// A mixin for [StatefulWidget]s that implement iOS-themed toggleable | |
| /// A mixin for [StatefulWidget]s that implements iOS-themed toggleable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// controls (e.g.[Checkbox]es). | |
| /// controls (e.g. [CupertinoCheckbox]es). |
Or describe how this class relates to the Material Checkbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The mixin implements the logic for toggling the control when tapped. | |
| /// This mixin implements the logic for toggling the control when tapped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If value is true then the control "active" (checked, on, or selected). If | |
| /// If [value] is true then the control "active" (checked, on, or selected). If |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this entire function, since it's only calling super.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// the Toggleable. In their [paint] method subclasses may call | |
| /// the Toggleable. In their [paint] method, subclasses may call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to remove this sentence entirely, because I missed that I had deleted the method this is referring too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If true the checkbox's [value] can be true, false, or null. | |
| /// If true, the checkbox's [value] can be true, false, or null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If tristate is false (the default), [value] is asseted to not be null. | |
| /// If tristate is false (the default), [value] must not be null, and [onChanged] will only toggle between true and false. |
9beffb6 to
0810582
Compare
|
@gspencergoog this is ready for review again 👍 |
3916a7b to
9a5eec2
Compare
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe describe what this is a link to? (or make it into an actual Markdown link to the descriptive text?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Creates a macOS styled checkbox. | |
| /// Creates a macOS-style checkbox. |
Just a tiny nit: when I read this the first time, I read it as a "styled checkbox" for macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If this property is null, then the side defaults to a width of 1. | |
| /// If this property is null, then the side defaults to a one pixel wide | |
| /// black, solid border. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad we have to cast here (but we do). Someday we should add a asOffset to Size and a asSize to Offset.
9a5eec2 to
f084121
Compare
f084121 to
6ccacb8
Compare


Addresses: #61789.
Adds a macOS/iOS styled checkbox widget to Cupertino. Works with keyboard focus, and keyboard interactions. The goal is to make this widget adaptable with the Material Checkbox.
Notably SwiftUI does not provide checkboxes for iOS development, only macOS, so our comparison tool could not be used. So we have to compare with desktop checkboxes and the checkboxes in the Human Interface Guidelines.
Some screenshots of the checkbox in the macOS settings, and from the Human Interface Guidelines:




Here is the CupertinoCheckbox in action, both with mouse and keyboard interactions:
Screen.Recording.2023-03-08.at.3.06.53.PM.mov
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.