Repository navigation
Update InputDecorator et al - #13734
Conversation
There was a problem hiding this comment.
trivial nit: vertically align the subexpressions (i.e. indent by 3 more)
There was a problem hiding this comment.
convert into a TODO() or fix or remove as appropriate
There was a problem hiding this comment.
should we just fill if fillColor is non-null, and not fill if it's null?
There was a problem hiding this comment.
Most apps will not want to actually specify a fill color, they'll just the default one that's based on the theme's brightness.
There was a problem hiding this comment.
(that would work better in a world where there's a way to configure the fill color in the theme explicitly)
There was a problem hiding this comment.
I agree. What might work best here is an InputDecoratorTheme which would be part of ThemeData like IconTheme and textTheme. I will add that in a follow-up PR.
There was a problem hiding this comment.
it'd be mildly more efficient to do hashValues(..., hashValues(...))
There was a problem hiding this comment.
looks like you don't actually use the textDirection in _precache?
|
My main feedback is that instead of an enum for the borderType, I would just define an abstract subclass of ShapeBorder (similar to what you have), and then have people provide instances of subclasses of that subclass as the borderType (call it just |
There was a problem hiding this comment.
you should also check the animation is the same
There was a problem hiding this comment.
i think this whole method can just assert false, not reachable
There was a problem hiding this comment.
if you skip the default case, then the analyzer will catch cases where you have an unrecognized one for you
There was a problem hiding this comment.
I think the gapAnimation should probably be an argument to the paint method. You don't use it anywhere else as far as I can tell, and passing in a Listenable to a class without a lifecycle is a little scary (is it going to listen to it? i don't know!).
There was a problem hiding this comment.
Yes, that seems reasonable.
There was a problem hiding this comment.
I replaced gapAnimation with gapPercentage, which is just the animation's value.
There was a problem hiding this comment.
can you elaborate on why it's important that they be circular?
There was a problem hiding this comment.
The label text's gap can extend into the corners (even both the top left and top right corners) and I didn't want to bother with the more complicated problem of finding how far the gap penetrated into an elliptical corner. It didn't seem to be an important feature to support now. I suppose the summary rationale is: sloth.
a6c930b to
849dc93
Compare
|
Those outline animations are beautiful! |
849dc93 to
a80b01f
Compare
|
|
There was a problem hiding this comment.
I think we should add the following to this class, to avoid needing to hard-code any knowledge about InputBorder's subclasses in any of the other classes, thus allowing people to implement custom InputBorders that are crazier than currently allowed, while also simplifying the rest of the code:
- add an abstract paint() method that has the arguments that OutlineInputBorder has.
- add a property that returns an enum that describes how the padding/baseline should be applied (also covers the isOutlineBorder logic in the paint method).
We should also document in the class docs for InputBorder all the ways that this class differs from ShapeBorder, in particular:
- That it always has a single side style,
borderSide. - That copies of the class can be made, applying a different style, using
copyWith. - That the
paintmethod has additional arguments. - What the enum property described above is about.
There was a problem hiding this comment.
InputBorder now has an abstract isOutline getter that's used by the renderer to configure the layout. The renderer tests this boolean instead of testing the border's type.
I updated the abstract methods and docs as you suggested.
There was a problem hiding this comment.
for completeness, also add borderRadius and gapPad
There was a problem hiding this comment.
Yes, that's better.
There was a problem hiding this comment.
we just say "logical pixels", not "dps", in the Flutter documentation
There was a problem hiding this comment.
where is the default of 4px implemented? oh, i see, in the getter.
For efficiency it'd be better if that was done in the constructor.
There was a problem hiding this comment.
why must the radii be circular?
There was a problem hiding this comment.
This came up before: #13734 (comment)
I added a comment with the explanation.
There was a problem hiding this comment.
Now checked at the top of CircularInputBorder.paint().
There was a problem hiding this comment.
This code isn't used so for now it's assert(false, 'not implemented').
There was a problem hiding this comment.
prefer switch instead of if when checking an enum value
33917c9 to
6a866f1
Compare
| final double t = decoration.floatingLabelProgress; | ||
| // The center of the outline border label ends up a little below the | ||
| // center of the top border line. | ||
| final double floatingY = decoration.border.isOutline ? -labelHeight * 0.25 : contentPadding.top; |
There was a problem hiding this comment.
this line throws an exception if border: null and a labelText is used
There was a problem hiding this comment.
jup, can confirm.
https://gist.github.com/BenSower/e4bda931033a0fa306722e3da3b02fc9
There was a problem hiding this comment.
Sorry to have missed this. I've filed and issue and will fix:
#14165
Updates the appearance of InputDecorator which updates the appearance of most TextFields.
There's a short video of the new InputDecorator in action on YouTube. The screenshot below shows some of the new InputDecorator configurations.
InputDecorator "container"
In the descriptions of the new input decorator's features that follow the term 'container' is often used to refer to the areas highlighted in the screenshots below:
New Features
This version of InputDecorator is largely API compatible with the current one. Some new visual elements have been added and the internal layout has changed a bit.
The
prefixIconandsuffixIconappear at the leading or trailing edge of the input. Unlike theicon, they appear within the decorator's container.In the screenshot below the
suffixIconappears on the right (because the prevailing text direction is LTR):This screenshot shows an input decorator with
iconandcontentPaddingthat eliminates the default horizontal 12dps padding with the decorator's container.The container part of the decorator can be filled with
filled: trueand the color can be specified withfillColor: color.What was called the "divider" is now a configurable border. Specifying
border: const OutlineInputBorder()draw's an outline around the decorator's container,border: const UnderlineInputBorder()underlines the input as before, andborder: nulldoesn't draw anything (same ashideDivider: truein the previous version).When the decorator is outlined, the floating label animates into a gap in the border.
The screenshots below show the decorator's label when the text field lacks the focus, and the floating label when it gains the focus.
When the
errorTextfirst appears it "shakes" left and right to get the user's attention.The default padding of the decorator's content can be overridden with
contentPadding: edgeInsets. For example to generate a layout that's similar to the current Input decorator:contentPadding: const EdgeInsets.only(bottom: 8.0, top: 16.0).Incompatible Changes
hideDividerproperty has been replaced byborder: null.filledis true. The vertical padding is also different: previously there was 16dps above the floating label, and 8dps below the inline elements, now its 12dps above and below.labelText's location is a little different. It's vertically centered within the input decorator's container whenisFocusis true orisEmptyis false. When thelabelTextis "floating"it appears within a gap within the
InputBorderType.outlineor just a little lower than before forInputBorderType.underline.