diff --git a/android/app/.gradle/config.properties b/android/app/.gradle/config.properties new file mode 100644 index 0000000..219c1d1 --- /dev/null +++ b/android/app/.gradle/config.properties @@ -0,0 +1,2 @@ +#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 new file mode 100644 index 0000000..4ed58b9 --- /dev/null +++ b/android/app/local.properties @@ -0,0 +1,8 @@ +## 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 f7eb7f6..74dc16a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,11 +1,18 @@ 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" } @@ -13,8 +20,16 @@ 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 new file mode 100644 index 0000000..626a4f5 Binary files /dev/null and b/android/gradle/wrapper/gradle-7.3-all.zip differ diff --git a/android/gradle/wrapper/gradle-7.5-all.zip b/android/gradle/wrapper/gradle-7.5-all.zip new file mode 100644 index 0000000..097160c Binary files /dev/null and b/android/gradle/wrapper/gradle-7.5-all.zip differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..24a2849 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=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=file:///E:/Flutter/MusicAPP/android/gradle/wrapper/gradle-7.5-all.zip diff --git a/assets/img/list_good_act.png b/assets/img/list_good_act.png new file mode 100644 index 0000000..5dca998 Binary files /dev/null and b/assets/img/list_good_act.png differ diff --git a/lib/view/home_view.dart b/lib/view/home_view.dart index cf0db6e..9ed5576 100644 --- a/lib/view/home_view.dart +++ b/lib/view/home_view.dart @@ -12,6 +12,8 @@ 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}); @@ -42,15 +44,6 @@ 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!, @@ -337,110 +330,128 @@ class _HomeViewState extends State { Future _bottomSheet(BuildContext context, int index) { return showModalBottomSheet( - context: context, - backgroundColor: Colors.white, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(30))), - builder: (context) => Container( - height: 210, - padding: const EdgeInsets.only(top: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - children: [ - IconButton( - onPressed: () {}, - icon: Image.asset("assets/img/list_add.png"), - iconSize: 60, - ), - const Text("加入歌单") - ], - ), - Column( - children: [ - IconButton( - onPressed: () {}, - icon: Image.asset("assets/img/list_download.png"), - iconSize: 60, - ), - const Text("下载") - ], - ), - Column( - children: [ - IconButton( - onPressed: () {}, - icon: Image.asset("assets/img/list_collection.png"), - iconSize: 60, - ), - const Text("收藏") - ], - ), - Column( - children: [ - IconButton( - onPressed: () {}, - icon: Image.asset("assets/img/list_good.png"), - iconSize: 60, + context: context, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), + builder: (context) => StatefulBuilder( // 使用StatefulBuilder以便动态修改状态 + builder: (context, setState) { + bool likesnot = false; // 初始状态,假设未点赞 + + return Container( + height: 210, + padding: const EdgeInsets.only(top: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_add.png"), + iconSize: 60, + ), + const Text("加入歌单"), + ], + ), + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_download.png"), + iconSize: 60, + ), + const Text("下载"), + ], + ), + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_collection.png"), + iconSize: 60, + ), + const Text("收藏"), + ], + ), + Column( + children: [ + IconButton( + onPressed: (){}, + icon: Image.asset("assets/img/list_good.png"), + iconSize: 60, + ), + Text("点赞") + ], + ), + Column( + children: [ + IconButton( + onPressed: () { + Get.to(() => CommentView( + initialSongIndex: index, + )); + }, + icon: Image.asset("assets/img/list_comment.png"), + iconSize: 60, + ), + const Text("评论"), + ], + ), + ], + ), + const SizedBox( + height: 10, + ), + ElevatedButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MusicView( + song: songs[index], + initialSongIndex: index, + ), ), - const Text("点赞") - ], + ); + }, + child: const Text( + "查看详情页", + style: TextStyle(color: Colors.black, fontSize: 18), ), - Column( - children: [ - IconButton( - onPressed: () { - Get.to(() => CommentView( - initialSongIndex: index, - )); - }, - icon: Image.asset("assets/img/list_comment.png"), - iconSize: 60, - ), - const Text("评论") - ], + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xffE6F4F1), + padding: const EdgeInsets.symmetric(vertical: 8), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero, + ), ), - ], - ), - const SizedBox( - height: 10, - ), - ElevatedButton( - onPressed: () {}, - 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, + ), ), - ), - ), - 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), ), ), - child: const Text( - "取消", - style: TextStyle(color: Colors.black, fontSize: 18), - ), - ), - ], - ), - )); + ], + ), + ); + }, + ), + ); } } diff --git a/lib/view/rank_view.dart b/lib/view/rank_view.dart index 0666064..9be84eb 100644 --- a/lib/view/rank_view.dart +++ b/lib/view/rank_view.dart @@ -5,6 +5,8 @@ import '../api/api_music_rank.dart'; import '../common_widget/rank_song_row.dart'; import '../models/getRank_bean.dart'; import '../view_model/rank_view_model.dart'; +import 'music_view.dart'; +import '../common_widget/Song_widegt.dart'; class RankView extends StatefulWidget { const RankView({super.key}); @@ -19,6 +21,7 @@ class _RankViewState extends State { List rankSingerName = []; List rankCoverPath = []; List rankMusicPath = []; + List songs = []; void initState() { super.initState(); @@ -32,6 +35,24 @@ class _RankViewState extends State { rankSingerName = bean2.data!.map((data) => data.singerName!).toList(); rankCoverPath = bean2.data!.map((data) => data.coverPath!).toList(); rankMusicPath = bean2.data!.map((data) => data.musicPath!).toList(); + + if (rankNames.isNotEmpty && + rankNames.length == rankSingerName.length && + rankNames.length == rankCoverPath.length && + rankNames.length == rankMusicPath.length) { + for (int i = 0; i < rankNames.length; i++) { + songs.add(Song( + artistPic: rankCoverPath[i], + title: rankNames[i], + artist: rankSingerName[i], + musicurl: rankMusicPath[i], + pic: rankCoverPath[i], + id: i, + likes: false, + collection: false, + )); + } + } }); } @@ -132,6 +153,17 @@ class _RankViewState extends State { itemBuilder: (context, index) { int rankNum = index + 1; return ListTile( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MusicView( + song: songs[index], + initialSongIndex: index, + ), + ), + ); + }, title: Column( children: [ Row( @@ -202,12 +234,16 @@ class _RankViewState extends State { ), IconButton( onPressed: () { - _bottomSheet(context); + _bottomSheet(context, index); // 传递当前的 index }, icon: Image.asset( - "assets/img/More.png", + 'assets/img/More.png', width: 25, height: 25, + errorBuilder: (context, error, stackTrace) { + print('Error loading image: $error'); + return const Icon(Icons.error, size: 25); // 使用 const + }, ), ), const SizedBox( @@ -231,7 +267,7 @@ class _RankViewState extends State { ), ); } - Future _bottomSheet(BuildContext context){ + Future _bottomSheet(BuildContext context, int index){ return showModalBottomSheet( context: context, backgroundColor: Colors.white, @@ -300,7 +336,15 @@ class _RankViewState extends State { const SizedBox(height: 10,), ElevatedButton( onPressed: () { - // Get.to(()=>const MainTabView()); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MusicView( + song: songs[index], + initialSongIndex: index, + ), + ), + ); }, child: Text( "查看详情页", diff --git a/lib/view/user/user_view.dart b/lib/view/user/user_view.dart index aa46e31..b5d13b0 100644 --- a/lib/view/user/user_view.dart +++ b/lib/view/user/user_view.dart @@ -406,73 +406,75 @@ class _UserViewState extends State { ///下弹框--退出,个人信息修改 Future _bottomSheet(BuildContext context) { return showModalBottomSheet( - context: context, - backgroundColor: Colors.white, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(30))), - builder: (context) => Container( - height: 200, - padding: const EdgeInsets.only(top: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - children: [ - IconButton( - onPressed: () { - Get.to(const UserInfo()); - }, - icon: Image.asset("assets/img/user_infor.png"), - iconSize: 60, - ), - const Text("账户信息") - ], - ), - Column( - children: [ - IconButton( - onPressed: () async { - UniversalBean bean = await LogoutApiClient() - .logout( - Authorization: AppData().currentToken); - if (bean.code == 200) { - Get.to(const BeginView()); - } - }, - icon: Image.asset("assets/img/user_out.png"), - iconSize: 60, - ), - const Text("退出登录") - ], - ), - ], - ), - const SizedBox( - height: 30, - ), - ElevatedButton( - onPressed: () => Navigator.pop(context), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xff429482), - padding: const EdgeInsets.symmetric(vertical: 14), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), + context: context, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), + isScrollControlled: true, // 设置弹出框根据内容高度自适应 + builder: (context) => Padding( + padding: const EdgeInsets.only(top: 20), + child: Column( + mainAxisSize: MainAxisSize.min, // 使Column高度适应内容 + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + IconButton( + onPressed: () { + Get.to(const UserInfo()); + }, + icon: Image.asset("assets/img/user_infor.png"), + iconSize: 60, ), - child: const Text( - "取消", - style: TextStyle(color: Colors.black, fontSize: 18), + const Text("账户信息") + ], + ), + Column( + children: [ + IconButton( + onPressed: () async { + UniversalBean bean = await LogoutApiClient().logout( + Authorization: AppData().currentToken, + ); + if (bean.code == 200) { + Get.to(const BeginView()); + } + }, + icon: Image.asset("assets/img/user_out.png"), + iconSize: 60, ), - ), - ], + const Text("退出登录") + ], + ), + ], + ), + const SizedBox(height: 30), + ElevatedButton( + onPressed: () => Navigator.pop(context), + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xff429482), + padding: const EdgeInsets.symmetric(vertical: 14), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero, + ), ), - )); + child: const Text( + "取消", + style: TextStyle(color: Colors.black, fontSize: 18), + ), + ), + ], + ), + ), + ); } + ///弹出框--添加歌单 void _showAddPlaylistDialog() { _controller.clear();