fix(ui): align metadata and wrap track badges

This commit is contained in:
zarzet
2026-08-18 20:50:31 +07:00
parent 2cb5993d6e
commit 6d97151ee7
6 changed files with 132 additions and 50 deletions
+51
View File
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:spotiflac_android/l10n/app_localizations.dart';
import 'package:spotiflac_android/widgets/audio_quality_badges.dart';
import 'package:spotiflac_android/widgets/in_library_badge.dart';
void main() {
testWidgets('track metadata badges wrap on a narrow result row', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Align(
child: SizedBox(
width: 180,
child: Builder(
builder: (context) {
final colorScheme = Theme.of(context).colorScheme;
return TrackMetadataBadgesLine(
primary: const Text(
'RADWIMPS',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
badges: [
AudioQualityBadge(
label: '16-bit',
colorScheme: colorScheme,
),
DolbyAtmosBadge(colorScheme: colorScheme),
const InLibraryBadge(),
],
);
},
),
),
),
),
),
);
expect(tester.takeException(), isNull);
expect(
tester.getTopLeft(find.byType(InLibraryBadge)).dy,
greaterThan(tester.getTopLeft(find.text('RADWIMPS')).dy),
);
});
}
@@ -56,5 +56,14 @@ void main() {
separators.every((text) => text.style?.color == Colors.white70),
isTrue,
);
final durationLabel = find.text('Duration');
final metadataRow = find
.ancestor(of: durationLabel, matching: find.byType(Row))
.first;
final row = tester.widget<Row>(metadataRow);
expect(row.crossAxisAlignment, CrossAxisAlignment.baseline);
expect(row.textBaseline, TextBaseline.alphabetic);
});
}