Skip to content

Commit

Permalink
Fix toggle Lyrics
Browse files Browse the repository at this point in the history
  • Loading branch information
up2code committed Mar 14, 2024
1 parent cdd6648 commit 18d31dc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/wi
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_hero_image.dart';

class SongDetailScreen extends ConsumerStatefulWidget {

const SongDetailScreen({super.key, required this.song, this.pvPlayerWidget});

final Song song;
Expand All @@ -43,6 +42,12 @@ class SongDetailScreen extends ConsumerStatefulWidget {
}

class _SongDetailScreenState extends ConsumerState<SongDetailScreen> {
_toggleShowLyric() {
ref
.read(songDetailScreenControllerProvider(widget.song.id).notifier)
.toggleLyricContent();
}

@override
Widget build(BuildContext context) {
final state = ref.watch(songDetailScreenControllerProvider(widget.song.id));
Expand All @@ -52,9 +57,23 @@ class _SongDetailScreenState extends ConsumerState<SongDetailScreen> {
data: (song) => SafeArea(
child: Scaffold(
appBar: GlobalAppBar(title: Text(song.name ?? 'Song detail')),
body: (song.hasYoutubePV)
? SongDetailWithPV(song: song, pvPlayerWidget: widget.pvPlayerWidget, onTapLyricButton: () {},)
: SongDetailWithoutPV(song: song, onTapLyricButton: () {},),
body: Column(children: [
// PV or thumbnail
(song.hasYoutubePV)
? widget.pvPlayerWidget ?? SongDetailPVPlayer(song: song)
: SongHeroImage(imageUrl: song.imageUrl!),

// Lyrics or Song detail content
(state.showLyricContent)
? LyricContent(
lyrics: song.lyrics,
onTapClose: _toggleShowLyric,
)
: SongDetailContent(
song: song,
onTapLyricButton: _toggleShowLyric,
),
]),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class SongDetailContent extends StatelessWidget {
child: ListView(
key: SongDetailScreen.songDetailScrollKey,
children: [
SongDetailButtonBar(song: song, onTapLyricButton: onTapLyricButton),
SongDetailButtonBar(
song: song,
onTapLyricButton: onTapLyricButton,
),
SongDetailInfoSection(song: song),
SongDetailTagsSection(song: song),
SongDetailArtistsSection(song: song),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:vocadb_app/src/features/songs/domain/song.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_albums_section.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_artists_section.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_button_bar.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_content.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_derived_section.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_info_section.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_pv_player.dart';
Expand All @@ -25,21 +26,7 @@ class SongDetailWithPV extends StatelessWidget {
Widget build(BuildContext context) {
return Column(children: [
pvPlayerWidget ?? SongDetailPVPlayer(song: song),
Expanded(
child: ListView(
children: [
SongDetailButtonBar(song: song, onTapLyricButton: onTapLyricButton),
SongDetailInfoSection(song: song),
SongDetailTagsSection(song: song),
SongDetailArtistsSection(song: song),
SongDetailPVsSection(song: song),
SongDetailAlbumsSection(song: song),
SongDetailDerivedSongsSection(song: song),
SongDetailRelatedSection(song: song),
SongDetailWebLinksSection(song: song),
],
),
),
SongDetailContent(song: song, onTapLyricButton: onTapLyricButton),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ void main() {
verify(callFetchSongRelated).called(1);

// /// Verify before tap lyric button
// await r.expectSongInfoContentVisible(true);
await r.expectSongInfoContentVisible(true);
await r.expectSongLyricContentVisible(false);
await r.expectLyricButtonVisible(true);

// /// Verify after tap lyric button
await r.tapLyricButton();
// await r.expectSongInfoContentVisible(false);
// await r.expectSongLyricContentVisible(true);
await r.expectSongInfoContentVisible(false);
await r.expectSongLyricContentVisible(true);

// /// Verify after tap close lyric button
// await r.tapCloseLyricButton();
// await r.expectSongInfoContentVisible(true);
// await r.expectSongLyricContentVisible(false);
/// Verify after tap close lyric button
await r.tapCloseLyricButton();
await r.expectSongInfoContentVisible(true);
await r.expectSongLyricContentVisible(false);
});
}

0 comments on commit 18d31dc

Please sign in to comment.