|
|
@ -6,11 +6,14 @@ import 'package:music_player_miao/common_widget/app_data.dart';
|
|
|
|
import 'package:music_player_miao/models/search_bean.dart';
|
|
|
|
import 'package:music_player_miao/models/search_bean.dart';
|
|
|
|
import 'package:music_player_miao/view/comment_view.dart';
|
|
|
|
import 'package:music_player_miao/view/comment_view.dart';
|
|
|
|
import '../../view_model/home_view_model.dart';
|
|
|
|
import '../../view_model/home_view_model.dart';
|
|
|
|
|
|
|
|
import '../api/api_music_likes.dart';
|
|
|
|
import '../api/api_music_list.dart';
|
|
|
|
import '../api/api_music_list.dart';
|
|
|
|
import '../common/download_manager.dart';
|
|
|
|
import '../common/download_manager.dart';
|
|
|
|
import '../common_widget/Song_widegt.dart';
|
|
|
|
import '../common_widget/Song_widegt.dart';
|
|
|
|
import '../common_widget/list_cell.dart';
|
|
|
|
import '../common_widget/list_cell.dart';
|
|
|
|
|
|
|
|
import '../models/MusicsListBean.dart';
|
|
|
|
import '../models/getMusicList_bean.dart';
|
|
|
|
import '../models/getMusicList_bean.dart';
|
|
|
|
|
|
|
|
import '../models/universal_bean.dart';
|
|
|
|
import 'music_view.dart';
|
|
|
|
import 'music_view.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class HomeView extends StatefulWidget {
|
|
|
|
class HomeView extends StatefulWidget {
|
|
|
@ -49,43 +52,22 @@ class _HomeViewState extends State<HomeView>
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _fetchSonglistData() async {
|
|
|
|
Future<void> _fetchSonglistData() async {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
MusicListBean bean1 =
|
|
|
|
MusicsListBean bean =
|
|
|
|
await GetMusic().getMusic1(Authorization: AppData().currentToken);
|
|
|
|
await GetMusic().getMusicList(Authorization: AppData().currentToken);
|
|
|
|
MusicListBean bean2 =
|
|
|
|
|
|
|
|
await GetMusic().getMusic2(Authorization: AppData().currentToken);
|
|
|
|
|
|
|
|
MusicListBean bean3 =
|
|
|
|
|
|
|
|
await GetMusic().getMusic3(Authorization: AppData().currentToken);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
selectedSongs = [
|
|
|
|
selectedSongs = [];
|
|
|
|
Song(
|
|
|
|
for (var data in bean.data!) {
|
|
|
|
artistPic: bean1.coverPath!,
|
|
|
|
selectedSongs.add(Song(
|
|
|
|
title: bean1.name!,
|
|
|
|
artistPic: data.coverPath!,
|
|
|
|
artist: bean1.singerName!,
|
|
|
|
title: data.name!,
|
|
|
|
musicurl: bean1.musicPath!,
|
|
|
|
artist: data.singerName!,
|
|
|
|
pic: bean1.coverPath!,
|
|
|
|
musicurl: data.musicPath!,
|
|
|
|
id: bean1.id!,
|
|
|
|
pic: data.coverPath!,
|
|
|
|
likes: bean1.likeOrNot!,
|
|
|
|
id: data.id!,
|
|
|
|
collection: bean1.collectOrNot!),
|
|
|
|
likes: data.likeOrNot!,
|
|
|
|
Song(
|
|
|
|
collection: data.collectOrNot!,
|
|
|
|
artistPic: bean2.coverPath!,
|
|
|
|
));
|
|
|
|
title: bean2.name!,
|
|
|
|
}
|
|
|
|
artist: bean2.singerName!,
|
|
|
|
|
|
|
|
musicurl: bean2.musicPath!,
|
|
|
|
|
|
|
|
pic: bean2.coverPath!,
|
|
|
|
|
|
|
|
id: bean2.id!,
|
|
|
|
|
|
|
|
likes: bean2.likeOrNot!,
|
|
|
|
|
|
|
|
collection: bean2.collectOrNot!),
|
|
|
|
|
|
|
|
Song(
|
|
|
|
|
|
|
|
artistPic: bean3.coverPath!,
|
|
|
|
|
|
|
|
title: bean3.name!,
|
|
|
|
|
|
|
|
artist: bean3.singerName!,
|
|
|
|
|
|
|
|
musicurl: bean3.musicPath!,
|
|
|
|
|
|
|
|
pic: bean3.coverPath!,
|
|
|
|
|
|
|
|
id: bean3.id!,
|
|
|
|
|
|
|
|
likes: bean3.likeOrNot!,
|
|
|
|
|
|
|
|
collection: bean3.collectOrNot!),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
print('Error occurred while fetching song list: $e');
|
|
|
|
print('Error occurred while fetching song list: $e');
|
|
|
@ -415,11 +397,46 @@ class _HomeViewState extends State<HomeView>
|
|
|
|
style: const TextStyle(
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16, color: Colors.black),
|
|
|
|
fontSize: 16, color: Colors.black),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
trailing: InkWell(
|
|
|
|
trailing: Padding(
|
|
|
|
onTap: () {
|
|
|
|
padding: const EdgeInsets.only(right: 16),
|
|
|
|
_bottomSheet(context, index);
|
|
|
|
child: InkWell(
|
|
|
|
|
|
|
|
onTap: () async {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
selectedSongs[index].likes =
|
|
|
|
|
|
|
|
!selectedSongs[index].likes!;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UniversalBean response = await LikesApiMusic()
|
|
|
|
|
|
|
|
.likesMusic(
|
|
|
|
|
|
|
|
musicId: selectedSongs[index].id,
|
|
|
|
|
|
|
|
Authorization:
|
|
|
|
|
|
|
|
AppData().currentToken);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (response.code != 200) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
selectedSongs[index].likes =
|
|
|
|
|
|
|
|
!selectedSongs[index].likes!;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Image.asset('assets/img/More.png'),
|
|
|
|
child: selectedSongs[index].likes!
|
|
|
|
|
|
|
|
? Image.asset(
|
|
|
|
|
|
|
|
'assets/img/like.png',
|
|
|
|
|
|
|
|
width: 24,
|
|
|
|
|
|
|
|
height: 24,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: ColorFiltered(
|
|
|
|
|
|
|
|
colorFilter: ColorFilter.mode(
|
|
|
|
|
|
|
|
Colors.grey[700]!,
|
|
|
|
|
|
|
|
BlendMode.srcIn,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
|
|
'assets/img/unlike.png',
|
|
|
|
|
|
|
|
width: 24,
|
|
|
|
|
|
|
|
height: 24,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
Navigator.push(
|
|
|
@ -451,36 +468,6 @@ class _HomeViewState extends State<HomeView>
|
|
|
|
const SizedBox(
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
///精选歌单
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
padding:
|
|
|
|
|
|
|
|
const EdgeInsets.only(left: 20, right: 20, top: 5),
|
|
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
|
|
'精选歌单',
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontSize: 20, fontWeight: FontWeight.w500),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 5,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 180,
|
|
|
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 20),
|
|
|
|
|
|
|
|
itemCount: homeVM.listArr.length,
|
|
|
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
var sObj = homeVM.listArr[index];
|
|
|
|
|
|
|
|
return ListRow(
|
|
|
|
|
|
|
|
sObj: sObj,
|
|
|
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
|
|
|
onPressedPlay: () {},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|