feat(ui): add favorite heart toggle, wire into song list
- Filled heart when favorited, outline when not (reactive via watchIsFavorite) - Wired into every song list tile (library, search, playlists) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
5c8796d353
commit
db99e2b1f7
@@ -0,0 +1,39 @@
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:melo/library/database.dart';
|
||||
import 'package:melo/library/playlist_service.dart';
|
||||
import 'package:melo/shared/favorite_button.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('shows outlined heart when not favorite, fills on tap', (tester) async {
|
||||
final db = MeloDb(NativeDatabase.memory());
|
||||
final service = PlaylistService(db);
|
||||
await db.into(db.songs).insert(SongsCompanion.insert(
|
||||
id: 'song-1', path: '/a.mp3', title: 'A', dateAddedMs: 0, updatedAtMs: 0,
|
||||
));
|
||||
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
Provider<MeloDb>.value(value: db),
|
||||
ChangeNotifierProvider<PlaylistService>.value(value: service),
|
||||
],
|
||||
child: MaterialApp(
|
||||
home: Scaffold(body: FavoriteButton(songId: 'song-1')),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byIcon(Icons.favorite_border), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.favorite_border));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byIcon(Icons.favorite), findsOneWidget);
|
||||
|
||||
await db.close();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user