forked from piaocbn2j/MTMusic
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
939 B
42 lines
939 B
// home_view_model.dart
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'Song_widegt.dart';
|
|
|
|
class TryRow extends GetxController {
|
|
final RxString txtSearch = ''.obs;
|
|
|
|
final List<Song> allSongs = [
|
|
Song(
|
|
artistPic: 'assets/img/music_artist.png',
|
|
title: '背对背拥抱1',
|
|
artist: '林俊杰 1',
|
|
musicurl: 'audio/MAMAMOO.mp3',
|
|
pic: 'assets/img/artist_pic.png',
|
|
),
|
|
// Add more songs here
|
|
];
|
|
|
|
RxList<Song> filteredSongs = <Song>[].obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
filteredSongs.assignAll(allSongs);
|
|
super.onInit();
|
|
}
|
|
|
|
void updateSearchResults() {
|
|
final String query = txtSearch.value.toLowerCase();
|
|
if (query.isEmpty) {
|
|
filteredSongs.assignAll(allSongs);
|
|
} else {
|
|
filteredSongs.assignAll(allSongs
|
|
.where((song) =>
|
|
song.title.toLowerCase().contains(query) ||
|
|
song.artist.toLowerCase().contains(query))
|
|
.toList());
|
|
}
|
|
}
|
|
}
|