Status Update
Comments
ap...@google.com <ap...@google.com> #2
It would also be nice to be able to set different maxLines
for the large and small titles. For example, setting maxLines = 2
for the large title and maxLines = 1
for the small title.
This functionality is something that would also be possible with TwoRowsTopAppBar
being publicly exposed.
ap...@google.com <ap...@google.com> #3
@Nick - Having the app bar adjust to its content height is quite tricky here, mainly when there are other constraints that involve the scroll behavior.
What we did at maxLines
will still be applied to the Text
, however, the height set up is going to be done programmatically on the top app bar you chose.
na...@google.com <na...@google.com> #4
@sgibly We don't really need the app bar to adjust to its content height. What we are asking for is a way to configure the title based on expanded/collapsed state. TwoRowsTopAppBar
provides a way to handle this, but is a private composable.
Our goal:
- use a slightly larger font size than the current default when in the expanded state
- allow the title to wrap 2 lines when in the expanded state
- confine the tile to a single line when in the collapsed state
As a workaround we have forked ExtraLargeTopAppBar
composable that we use throughout our application:
Description
Some more details in b/388353336
Start of trace:
This happens because when we draw we use a shared ContentDrawScope implementation that we render all DrawModifierNodes in. We do this by mutating a property as we draw successive nodes. However, this means that if anyone captures a reference to this draw scope and tries to draw it later on, this will cause a NPE error as we don't know what the 'current node' that needs to be drawn in.
For the general case this is an error and scopes shouldn't be captured and stored outside the scope in this way, but for GraphicsLayer this is needed when recording drawContent to support some edge cases, such as when we need to draw a layer implementation that can't be drawn in software, within software rendering (such as drawing to a Bitmap). For this we just end up re-invoking the draw block we captured.
We considered some solutions where we would allocate a new draw scope instance per modifier, but this adds some overhead and 'storing' these draw scopes for future use is challenging. (we considered putting them on the node object, in a map on the node coordinator, or some other chain structure on the node coordinator, but none of these are really great)
Instead we can explicitly support the GraphicsLayer.record case by overriding the DrawScope#GraphicsLayer.record function and making it handle this case properly. This can still cause issues if using the non-DrawScope scoped record function, but developers should move to the DrawScope one instead.