mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-29 07:34:13 +01:00
fix(album): start the description right under the sheet's round edge
On a Material phone the list under an album header rises as a sheet with a 28 dp round edge. Song rows start right below that edge, but an album description added 8 dp of its own and the space a 1.4 line height puts above the first line, so its text sat about 12 dp lower than the rows do and the sheet looked empty at the top. As the first thing on that sheet the description now adds no space above itself: no padding, and the first line without its extra ascent. Mornye and the desktop, which have no round edge, keep the 8 dp.
This commit is contained in:
1 parent
23d151e4e6
commit
b6bdaf8db4
3 files changed
+52
-1
No files matched your search
@@ -495,6 +495,7 @@ class _AlbumScreenState extends ConsumerState<AlbumScreen>
|
||||
child: AlbumDescription(
|
||||
title: widget.albumName,
|
||||
description: _description!,
|
||||
underSheetEdge: !context.isMornye && !isDesktopPlatform,
|
||||
),
|
||||
),
|
||||
if (_isLoading || (_error == null && tracks.isNotEmpty))
|
||||
|
||||
@@ -12,11 +12,16 @@ class AlbumDescription extends StatefulWidget {
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
this.underSheetEdge = false,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String description;
|
||||
|
||||
/// Whether it is the first thing on the sheet a Material header rounds
|
||||
/// off. The round edge is its space above, so it adds none of its own.
|
||||
final bool underSheetEdge;
|
||||
|
||||
@override
|
||||
State<AlbumDescription> createState() => _AlbumDescriptionState();
|
||||
}
|
||||
@@ -222,7 +227,10 @@ class _AlbumDescriptionState extends State<AlbumDescription> {
|
||||
? () => _showFullDescription(context, text)
|
||||
: null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
padding: EdgeInsets.only(
|
||||
top: widget.underSheetEdge ? 0 : 8,
|
||||
bottom: 8,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
@@ -232,6 +240,12 @@ class _AlbumDescriptionState extends State<AlbumDescription> {
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: previewStyle,
|
||||
// The line's own space above would add to the edge.
|
||||
textHeightBehavior: widget.underSheetEdge
|
||||
? const TextHeightBehavior(
|
||||
applyHeightToFirstAscent: false,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
if (hasMore) ...[
|
||||
|
||||
@@ -226,4 +226,40 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('under a sheet edge the text adds no space above itself', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(393, 700);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
Future<({double top, double height})> text({required bool edge}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(),
|
||||
home: Scaffold(
|
||||
body: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: AlbumDescription(
|
||||
title: 'Album',
|
||||
description: 'A short description.',
|
||||
underSheetEdge: edge,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final rect = tester.getRect(find.text('A short description.'));
|
||||
return (top: rect.top, height: rect.height);
|
||||
}
|
||||
|
||||
final plain = await text(edge: false);
|
||||
final tight = await text(edge: true);
|
||||
expect(plain.top, 8);
|
||||
// No padding above, and the first line gives up its own space above.
|
||||
expect(tight.top, 0);
|
||||
expect(tight.height, lessThan(plain.height));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user