-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Primitives] - Create a Text widget #2
Comments
@Maatteogekko @vincevargadev - Can you two take a look at the API design at the bottom of the Wiki for Text? I've described an API that I think should cover the bases for Accessibility and Localization. Can you look for any holes in that API? |
The Localization part seems fine. Just a couple of considerations. Another thing. I noticed there is no property for |
Is there a purpose for a
Can you specify where exactly you expected that to appear in the API? |
Sure, but I expect it to be optional. If not provided it should be resolved at runtime, from the context of the Text widget.
|
@Maatteogekko - But what's the purpose of a |
To bundle all the localization parameters for the Text widget in a single object. This is a use case that the SwiftUI API allows, so I think it's important to include. |
The |
Ok, so |
There is |
The proposed text accessibility configuration looks good, the only thing I might do differently are the nullability of the |
@vincevargadev do we need a whole proposal for that? It sounds like there's just one category of issue there. Can you describe why you'd change the nullability? Can you also specify which fields? |
This is what I'd propose: class TextAccessibility {
const TextAccessibility({/*...*/});
/// This could either default to `speechAdjustedPitch = 1`,
/// or we "do nothing" by default with a `speechAdjustedPitch = null`.
final double speechAdjustedPitch;
/// Punctuation needs to handle three states:
/// * "default" punctuation with `null` to let VoiceOver decide based on context
/// * on and off with `true` and `false
final bool? speechAlwaysIncludesPunctuation;
/// Doesn't need to be nullable as the default behavior matches the
/// `speechSpellsOutCharacters = false` case.
final bool speechSpellsOutCharacters;
/// Make it nullable, as it's optional and not needed in most cases.
final AccessibilityHeading? accessibilityHeading;
/// Make it nullable, as it's optional and not needed in most cases.
final Set<AccessibilityTrait>? accessibilityTraits;
/// Make it nullable, as by default, the text content is spoken by VoiceOver,
/// and `accessibilityLabel` is only needed if the text content needs to be overridden.
final String? accessibilityLabel;
// DIRECTION: Include equality override to avoid needless widget rebuilds
} |
I opened a PR #20 tldr: Text accessibility labels can be localized, and we should handle that case, too. Do you have any suggestions, @Maatteogekko, about how to handle this case? If I see it right, we need to handle two cases for the accessibility label (either translated or not): class TextAccessibility {
/// Make it nullable, as by default, the text content is spoken by VoiceOver,
/// and `accessibilityLabel` is only needed if the text content needs to be overridden.
final AccessibilityLabel? accessibilityLabel;
}
// A couple of ways to represent it internally, so I only specify the constructors for clarity.
class AccessibilityLabel {
AccessibilityLabel.verbatim(String value);
AccessibilityLabel.localized(String value);
/// ...
} |
@vincevargadev the most important thing is to keep it consistent with the AccessibilityLabel(this.localizedAccessibilityLabelKey);
AccessibilityLabel.verbatim(String text) I admit that |
As mentioned, consistency with existing Swift UI APIs is one of the most important things. We want to avoid developers needing to remember the "Flutter" version of the same capability. |
Create a widget that matches Swift UI's
Text
view.Swift UI Docs: https://developer.apple.com/documentation/swiftui/text
The text was updated successfully, but these errors were encountered: