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); + }); }