Skip to content

Commit

Permalink
#59 showing songbook name in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
Paprikadobi committed Jul 19, 2022
1 parent 5bdf151 commit 1a16768
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/components/song_lyric/song_lyric_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import 'package:zpevnik/components/highlightable.dart';
import 'package:zpevnik/constants.dart';
import 'package:zpevnik/models/song_lyric.dart';
import 'package:zpevnik/models/songbook_record.dart';
import 'package:zpevnik/providers/navigation.dart';
import 'package:zpevnik/providers/song_lyrics.dart';
import 'package:zpevnik/routes/arguments/search.dart';
Expand Down Expand Up @@ -34,6 +35,22 @@ class SongLyricRow extends StatelessWidget {

final dragIndicatorKey = GlobalKey();

String? songbookName;

final searchText = context.read<AllSongLyricsProvider?>()?.searchText;

if (searchText != null && searchText.isNotEmpty) {
for (final songbookRecord in songLyric.songbookRecords) {
if (searchText == songbookRecord.number) {
songbookName = songbookRecord.songbook.target!.name;

break;
}
}
}

const textMargin = EdgeInsets.only(top: 2);

final row = Highlightable(
highlightBackground: true,
highlightableChildKeys: [dragIndicatorKey],
Expand Down Expand Up @@ -62,8 +79,12 @@ class SongLyricRow extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(songLyric.name, style: textTheme.bodyMedium),
if (songLyric.secondaryName1 != null) Text(songLyric.secondaryName1!, style: textTheme.bodySmall),
if (songLyric.secondaryName2 != null) Text(songLyric.secondaryName2!, style: textTheme.bodySmall),
if (songbookName != null)
Container(margin: textMargin, child: Text(songbookName, style: textTheme.bodySmall)),
if (songLyric.secondaryName1 != null)
Container(margin: textMargin, child: Text(songLyric.secondaryName1!, style: textTheme.bodySmall)),
if (songLyric.secondaryName2 != null)
Container(margin: textMargin, child: Text(songLyric.secondaryName2!, style: textTheme.bodySmall)),
],
),
),
Expand Down

0 comments on commit 1a16768

Please sign in to comment.