diff --git a/android/app/.gradle/config.properties b/android/app/.gradle/config.properties deleted file mode 100644 index 219c1d1..0000000 --- a/android/app/.gradle/config.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Sun Oct 27 00:29:01 HKT 2024 -java.home=E\:\\Program Files\\Android\\Android Studio\\jbr diff --git a/android/app/local.properties b/android/app/local.properties deleted file mode 100644 index 4ed58b9..0000000 --- a/android/app/local.properties +++ /dev/null @@ -1,8 +0,0 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Sun Oct 27 00:29:01 HKT 2024 -sdk.dir=E\:\\Android\\Sdk diff --git a/android/build.gradle b/android/build.gradle index 74dc16a..96db78a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,18 +1,11 @@ buildscript { ext.kotlin_version = '1.7.10' repositories { - maven { url 'https://maven.aliyun.com/repository/public/' } - maven { url 'https://maven.aliyun.com/repository/central'} - maven { url 'https://maven.aliyun.com/repository/google' } - maven { url 'https://maven.aliyun.com/repository/spring'} - maven { url 'https://maven.aliyun.com/repository/gradle-plugin'} - maven { url 'https://maven.aliyun.com/repository/apache-snapshots'} google() mavenCentral() } dependencies { - // 保留原来的依赖配置 classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -20,13 +13,6 @@ buildscript { allprojects { repositories { - // 使用阿里云的Maven镜像源 - maven { url 'https://maven.aliyun.com/repository/public/' } - maven { url 'https://maven.aliyun.com/repository/central'} - maven { url 'https://maven.aliyun.com/repository/google' } - maven { url 'https://maven.aliyun.com/repository/spring'} - maven { url 'https://maven.aliyun.com/repository/gradle-plugin'} - maven { url 'https://maven.aliyun.com/repository/apache-snapshots'} google() mavenCentral() mavenCentral() diff --git a/android/gradle/wrapper/gradle-7.3-all.zip b/android/gradle/wrapper/gradle-7.3-all.zip deleted file mode 100644 index 626a4f5..0000000 Binary files a/android/gradle/wrapper/gradle-7.3-all.zip and /dev/null differ diff --git a/android/gradle/wrapper/gradle-7.5-all.zip b/android/gradle/wrapper/gradle-7.5-all.zip deleted file mode 100644 index 097160c..0000000 Binary files a/android/gradle/wrapper/gradle-7.5-all.zip and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 24a2849..3c472b9 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=file:///E:/Flutter/MusicAPP/android/gradle/wrapper/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/lib/view/home_view.dart b/lib/view/home_view.dart index 9ed5576..f8f54f6 100644 --- a/lib/view/home_view.dart +++ b/lib/view/home_view.dart @@ -12,8 +12,6 @@ import '../common_widget/Song_widegt.dart'; import '../common_widget/list_cell.dart'; import '../models/getMusicList_bean.dart'; import 'music_view.dart'; -import '../api/api_music_likes.dart'; // 导入点赞API文件 -import '../models/universal_bean.dart'; class HomeView extends StatefulWidget { const HomeView({super.key}); @@ -44,6 +42,15 @@ class _HomeViewState extends State { setState(() { songs = [ + Song( + artistPic: bean1.coverPath!, + title: bean1.name!, + artist: bean1.singerName!, + musicurl: bean1.musicPath!, + pic: bean1.coverPath!, + id: bean1.id!, + likes: bean1.likeOrNot!, + collection: bean1.collectOrNot!), Song( artistPic: bean2.coverPath!, title: bean2.name!, @@ -340,7 +347,7 @@ class _HomeViewState extends State { bool likesnot = false; // 初始状态,假设未点赞 return Container( - height: 210, + height: 150, padding: const EdgeInsets.only(top: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -404,49 +411,6 @@ class _HomeViewState extends State { ), ], ), - const SizedBox( - height: 10, - ), - ElevatedButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => MusicView( - song: songs[index], - initialSongIndex: index, - ), - ), - ); - }, - child: const Text( - "查看详情页", - style: TextStyle(color: Colors.black, fontSize: 18), - ), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xffE6F4F1), - padding: const EdgeInsets.symmetric(vertical: 8), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - ), - ), - ElevatedButton( - onPressed: () => Navigator.pop(context), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xff429482), - padding: const EdgeInsets.symmetric(vertical: 8), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - ), - child: const Text( - "取消", - style: TextStyle(color: Colors.black, fontSize: 18), - ), - ), ], ), ); diff --git a/lib/view/main_tab_view/main_tab_view.dart b/lib/view/main_tab_view/main_tab_view.dart index ec7d82b..cc02bdd 100644 --- a/lib/view/main_tab_view/main_tab_view.dart +++ b/lib/view/main_tab_view/main_tab_view.dart @@ -5,38 +5,34 @@ import 'package:music_player_miao/view/user/user_view.dart'; import '../home_view.dart'; import '../release_view.dart'; - class MainTabView extends StatefulWidget { const MainTabView({super.key}); @override State createState() => _MainTabViewState(); } -class _MainTabViewState extends State with SingleTickerProviderStateMixin{ +class _MainTabViewState extends State with SingleTickerProviderStateMixin { TabController? controller; int selectTab = 0; final GlobalKey scaffoldKey = GlobalKey(); @override void initState() { - // TODO: implement initState super.initState(); controller = TabController(length: 4, vsync: this); controller?.addListener(() { selectTab = controller?.index ?? 0; - setState(() { - - }); + setState(() {}); }); } @override void dispose() { - // TODO: implement dispose super.dispose(); controller?.dispose(); } + @override Widget build(BuildContext context) { return Scaffold( @@ -51,55 +47,55 @@ class _MainTabViewState extends State with SingleTickerProviderStat UserView() ], ), - bottomNavigationBar: BottomAppBar( + bottomNavigationBar: Container( color: Colors.white, - elevation: 0, child: TabBar( controller: controller, indicatorColor: Colors.transparent, - indicatorWeight: 3, labelColor: Colors.black, - labelStyle: const TextStyle( - fontSize: 12 - ), + labelStyle: const TextStyle(fontSize: 12), // 减小文字大小 unselectedLabelColor: const Color(0xffCDCDCD), - unselectedLabelStyle: const TextStyle( - fontSize: 12 - ), + unselectedLabelStyle: const TextStyle(fontSize: 12), // 减小文字大小 tabs: [ Tab( - text: - "首页", - icon:Image.asset( - selectTab == 0?"assets/img/home_tab.png":"assets/img/home_tab_un.png", - width: 45,height: 45,), - + height: 60, // 明确指定高度 + icon: Image.asset( + selectTab == 0 ? "assets/img/home_tab.png" : "assets/img/home_tab_un.png", + width: 32, // 减小图标大小 + height: 32, + ), + text: "首页", ), Tab( - text: - "排行榜", - icon:Image.asset( - selectTab == 1?"assets/img/list_tab.png":"assets/img/list_tab_un.png", - width: 45,height: 45,), - + height: 60, + icon: Image.asset( + selectTab == 1 ? "assets/img/list_tab.png" : "assets/img/list_tab_un.png", + width: 32, + height: 32, + ), + text: "排行榜", ), Tab( - text: - "发布", - icon:Image.asset(selectTab == 2?"assets/img/music_tab.png":"assets/img/music_tab_un.png", - width: 45,height: 45,), - + height: 60, + icon: Image.asset( + selectTab == 2 ? "assets/img/music_tab.png" : "assets/img/music_tab_un.png", + width: 32, + height: 32, + ), + text: "发布", ), Tab( - text: - "个人", - icon:Image.asset(selectTab == 3?"assets/img/user_tab.png":"assets/img/user_tab_un.png", - width: 45,height: 45,), - + height: 60, + icon: Image.asset( + selectTab == 3 ? "assets/img/user_tab.png" : "assets/img/user_tab_un.png", + width: 32, + height: 32, + ), + text: "个人", ), ], ), ), ); } -} +} \ No newline at end of file diff --git a/lib/view/rank_view.dart b/lib/view/rank_view.dart index 9be84eb..25f04a8 100644 --- a/lib/view/rank_view.dart +++ b/lib/view/rank_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:music_player_miao/common_widget/app_data.dart'; import '../api/api_music_rank.dart'; -import '../common_widget/rank_song_row.dart'; +import '../common/download_manager.dart'; import '../models/getRank_bean.dart'; import '../view_model/rank_view_model.dart'; import 'music_view.dart'; @@ -23,6 +23,8 @@ class _RankViewState extends State { List rankMusicPath = []; List songs = []; + final downloadManager = Get.put(DownloadManager()); + void initState() { super.initState(); _fetchSonglistData(); @@ -158,8 +160,16 @@ class _RankViewState extends State { context, MaterialPageRoute( builder: (context) => MusicView( - song: songs[index], + songList: songs, initialSongIndex: index, + onSongStatusChanged: (index, isCollected, isLiked) { + setState(() { + // 更新父组件中的数据 + songs[index].collection = isCollected; + songs[index].likes = isLiked; + downloadManager.updateSongInfo(songs[index].id, isCollected, isLiked); + }); + }, ), ), ); @@ -228,7 +238,7 @@ class _RankViewState extends State { ), ), const SizedBox( - width: 20, + width: 18, ), ], ), @@ -273,7 +283,7 @@ class _RankViewState extends State { backgroundColor: Colors.white, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))), builder: (context) =>Container( - height: 210, + height: 150, padding: const EdgeInsets.only(top: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -333,49 +343,6 @@ class _RankViewState extends State { ), ], ), - const SizedBox(height: 10,), - ElevatedButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => MusicView( - song: songs[index], - initialSongIndex: index, - ), - ), - ); - }, - child: Text( - "查看详情页", - style: const TextStyle(color:Colors.black,fontSize: 18), - ), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xffE6F4F1), - padding: const EdgeInsets.symmetric(vertical: 8), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - ), - - ), - ElevatedButton( - onPressed: () =>Navigator.pop(context), - child: Text( - "取消", - style: const TextStyle(color:Colors.black,fontSize: 18), - ), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xff429482), - padding: const EdgeInsets.symmetric(vertical: 8), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - ), - - ), ], ), ) diff --git a/lib/view/user/my_download_view.dart b/lib/view/user/my_download_view.dart index 78451b5..95bf705 100644 --- a/lib/view/user/my_download_view.dart +++ b/lib/view/user/my_download_view.dart @@ -446,7 +446,7 @@ class _MyDownloadViewState extends State { shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(30))), builder: (context) => Container( - height: 180, + height: 150, padding: const EdgeInsets.only(top: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -499,24 +499,6 @@ class _MyDownloadViewState extends State { ), ], ), - const SizedBox( - height: 22, - ), - ElevatedButton( - onPressed: () => Navigator.pop(context), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xff429482), - padding: const EdgeInsets.symmetric(vertical: 8), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - ), - child: const Text( - "取消", - style: TextStyle(color: Colors.black, fontSize: 18), - ), - ), ], ), ));