From cbdad8db5b793aebf08ebffab530605e735f9dc1 Mon Sep 17 00:00:00 2001 From: Spark <2666652@gmail.com> Date: Thu, 14 Nov 2024 14:41:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=AD=8C=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/view/user/user_view.dart | 172 ++++++++++++++++++++--------------- pubspec.lock | 4 +- 2 files changed, 101 insertions(+), 75 deletions(-) diff --git a/lib/view/user/user_view.dart b/lib/view/user/user_view.dart index 26fbc70..efba12f 100644 --- a/lib/view/user/user_view.dart +++ b/lib/view/user/user_view.dart @@ -151,6 +151,7 @@ class _UserViewState extends State { ], ), ), + const SizedBox( height: 10, ), @@ -195,75 +196,100 @@ class _UserViewState extends State { ), ], )), + ///歌单 - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '歌单 $playlistCount', - style: const TextStyle( - fontSize: 20, fontWeight: FontWeight.w500), - ), - Row( - children: [ - IconButton( - onPressed: () { - _showAddPlaylistDialog(); - }, - icon: Image.asset( - "assets/img/user_add.png", - width: 31, - color: const Color(0xff404040), - )), - IconButton( - onPressed: () {}, - icon: Image.asset("assets/img/user_export.png", - width: 31)) - ], - ) - ], - ), Container( - padding: const EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 5), - child: ListView.builder( - shrinkWrap: true, // 使得ListView适应内容高度 - itemCount: playlistNames.length, // 根据歌单数量动态设置itemCount - itemBuilder: (context, index) { - return InkWell( - onTap: () { - print('点击成功'); - Get.to(MyMusicView(songlistIdd: playlistid[index])); - // 点击歌单时的回调,可以导航到歌单详情页 - //待添加 - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Image.asset("assets/img/artist_pic.png"), - Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 歌单标题行 + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '歌单 $playlistCount', + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500 + ), + ), + Row( + children: [ + IconButton( + onPressed: () { + _showAddPlaylistDialog(); + }, + icon: Image.asset( + "assets/img/user_add.png", + width: 31, + color: const Color(0xff404040), + ) + ), + IconButton( + onPressed: () {}, + icon: Image.asset( + "assets/img/user_export.png", + width: 31 + ) + ) + ], + ) + ], + ), + + const SizedBox( + height: 10, + ), + + // 歌单列表 + Padding( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: Column( + children: List.generate( + playlistNames.length, + (index) => Column( children: [ - Text( - playlistNames[index], // 动态显示歌单名称 - style: TextStyle(fontSize: 20), - ), - Text( - '$playlistCount首', // 动态显示歌曲数量 - style: TextStyle(fontSize: 16), + InkWell( + onTap: () { + print('点击成功'); + Get.to(MyMusicView(songlistIdd: playlistid[index])); + }, + child: Row( + children: [ + Image.asset("assets/img/artist_pic.png"), + const SizedBox(width: 25), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + playlistNames[index], + style: const TextStyle(fontSize: 20), + ), + Text( + '$playlistCount首', + style: const TextStyle(fontSize: 16), + ), + ], + ), + ), + Image.asset("assets/img/user_next.png"), + ], + ), ), + if (index < playlistNames.length - 1) + const SizedBox(height: 10), ], ), - const SizedBox(width: 80), - Image.asset("assets/img/user_next.png"), - ], + ), ), - ); - }, + ), + ], ), ), const SizedBox( - height: 20, + height: 30, ), const Text( @@ -399,8 +425,19 @@ class _UserViewState extends State { content: TextFieldColor(controller: _controller, hintText: '请输入歌单名称'), actions: [ TextButton( - onPressed: () { + onPressed: () async { Navigator.of(context).pop(); + String enteredSongName = _controller.text; + SonglistBean bean = await SonglistApi().addSonglist( + songlistName: enteredSongName, + Authorization: AppData().currentToken); + if (bean.code == 200) { + print('添加成功'); + setState(() { + playlistCount++; + playlistNames.add(enteredSongName); + }); + } }, style: TextButton.styleFrom( backgroundColor: const Color(0xff429482), @@ -410,24 +447,13 @@ class _UserViewState extends State { ), ), child: const Text( - "取消", + "确认", style: TextStyle(color: Colors.white), ), ), TextButton( - onPressed: () async { + onPressed: () { Navigator.of(context).pop(); - String enteredSongName = _controller.text; - //playlistCount++; - // Add the new playlist - setState(() { - //playlistNames.add(enteredSongName); - _fetchSonglistData(); - }); - // songlistName: _controller.text, - SonglistBean bean = await SonglistApi().addSonglist( - songlistName: enteredSongName, - Authorization: AppData().currentToken); }, style: TextButton.styleFrom( backgroundColor: const Color(0xff429482), @@ -437,7 +463,7 @@ class _UserViewState extends State { ), ), child: const Text( - "确认", + "取消", style: TextStyle(color: Colors.white), ), ), diff --git a/pubspec.lock b/pubspec.lock index 3430521..ced97e0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -181,10 +181,10 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2" + sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b url: "https://pub.dev" source: hosted - version: "0.9.3" + version: "0.9.3+1" file_selector_macos: dependency: transitive description: