Skip to content

Commit

Permalink
chore: lyrics search improvements
Browse files Browse the repository at this point in the history
ref #174
  • Loading branch information
MSOB7YY committed May 10, 2024
1 parent ae6c2c3 commit bb27bf3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
54 changes: 37 additions & 17 deletions lib/ui/dialogs/set_lrc_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import 'package:namida/ui/dialogs/edit_tags_dialog.dart';
import 'package:namida/ui/widgets/custom_widgets.dart';

void showLRCSetDialog(Track track, Color colorScheme) async {
final fetchingFromInternet = false.obs;
final fetchingFromInternet = Rxn<bool>();
final availableLyrics = <LyricsModel>[].obs;
final fetchedLyrics = <LyricsModel>[].obs;

Expand Down Expand Up @@ -278,6 +278,8 @@ void showLRCSetDialog(Track track, Color colorScheme) async {

final searchController = TextEditingController();

final initialSearchTextHint = '${track.originalArtist} - ${track.title}';

void onSearchTrigger([String? query]) async {
fetchingFromInternet.value = true;
fetchedLyrics.clear();
Expand Down Expand Up @@ -335,20 +337,46 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
height: Get.height * 0.6,
child: Column(
children: [
CustomTagTextField(
borderRadius: 12.0,
controller: searchController,
hintText: '${track.originalArtist} - ${track.title}',
labelText: '',
onFieldSubmitted: (value) {
onSearchTrigger(value);
},
Row(
children: [
Expanded(
child: CustomTagTextField(
borderRadius: 12.0,
controller: searchController,
hintText: initialSearchTextHint,
keyboardType: TextInputType.text, // no next line
labelText: '',
onFieldSubmitted: (value) {
onSearchTrigger(value);
},
),
),
NamidaIconButton(
icon: Broken.received,
iconSize: 22.0,
onPressed: () {
searchController.text = initialSearchTextHint;
},
)
],
),
const SizedBox(height: 6.0),
Expanded(
child: Obx(
() {
if (fetchingFromInternet.value == true) {
return ThreeArchedCircle(
color: Get.theme.cardColor,
size: 58.0,
);
}
final both = [...availableLyrics, ...fetchedLyrics];
if (both.isEmpty && fetchingFromInternet.value != null) {
return const Icon(
Broken.emoji_sad,
size: 48.0,
);
}
return ListView.builder(
padding: EdgeInsets.zero,
itemCount: both.length,
Expand Down Expand Up @@ -494,14 +522,6 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
},
),
),
Obx(
() => fetchingFromInternet.value
? ThreeArchedCircle(
color: Get.theme.cardColor,
size: 58.0,
)
: const SizedBox(),
),
const SizedBox(height: 8.0),
Obx(
() => CustomListTile(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.2.3-beta+240510198
version: 2.2.4-beta+240510198

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit bb27bf3

Please sign in to comment.