From b6bdaf8db44468e5609b9a00a55dc3cd799e6485 Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:52:05 +0700 Subject: [PATCH] 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. --- lib/screens/album_screen.dart | 1 + lib/widgets/album_description.dart | 16 ++++++++++++- test/album_description_test.dart | 36 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/lib/screens/album_screen.dart b/lib/screens/album_screen.dart index 167f37fd1..74725c026 100644 --- a/lib/screens/album_screen.dart +++ b/lib/screens/album_screen.dart @@ -495,6 +495,7 @@ class _AlbumScreenState extends ConsumerState child: AlbumDescription( title: widget.albumName, description: _description!, + underSheetEdge: !context.isMornye && !isDesktopPlatform, ), ), if (_isLoading || (_error == null && tracks.isNotEmpty)) diff --git a/lib/widgets/album_description.dart b/lib/widgets/album_description.dart index 8e16a3639..ee5f22c82 100644 --- a/lib/widgets/album_description.dart +++ b/lib/widgets/album_description.dart @@ -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 createState() => _AlbumDescriptionState(); } @@ -222,7 +227,10 @@ class _AlbumDescriptionState extends State { ? () => _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 { 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) ...[ diff --git a/test/album_description_test.dart b/test/album_description_test.dart index a639e6c01..1ebef106a 100644 --- a/test/album_description_test.dart +++ b/test/album_description_test.dart @@ -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); + }); }