From bbf70c81c6a1dbf3daa8753a899992b0039996c2 Mon Sep 17 00:00:00 2001 From: Spark <2666652@gmail.com> Date: Fri, 15 Nov 2024 00:51:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=B8=80=E4=BA=9B=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8F=91=E9=80=81=E5=80=92?= =?UTF-8?q?=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/password_manager.dart | 65 ++++ lib/view/begin/begin_view.dart | 116 +++---- lib/view/begin/login_v.dart | 59 +++- lib/view/begin/setup_view.dart | 150 +++++++-- lib/view/user/my_download_view.dart | 78 +++-- lib/view/user/my_music_view.dart | 481 ++++++++++++++-------------- lib/view/user/user_view.dart | 4 +- 7 files changed, 577 insertions(+), 376 deletions(-) create mode 100644 lib/common/password_manager.dart diff --git a/lib/common/password_manager.dart b/lib/common/password_manager.dart new file mode 100644 index 0000000..af017d6 --- /dev/null +++ b/lib/common/password_manager.dart @@ -0,0 +1,65 @@ +import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; + +class PasswordManager { + static const String PREFS_KEY = 'stored_password'; + late SharedPreferences _prefs; + + // 单例模式 + static final PasswordManager _instance = PasswordManager._internal(); + + factory PasswordManager() { + return _instance; + } + + PasswordManager._internal(); + + // 初始化 + Future init() async { + _prefs = await SharedPreferences.getInstance(); + } + + // 存储账号密码 + Future savePassword(String username, String password) async { + final Map credentials = { + 'username': username, + 'password': password, + }; + await _prefs.setString(PREFS_KEY, json.encode(credentials)); + } + + // 获取存储的账号密码 + Map? getStoredCredentials() { + final String? storedData = _prefs.getString(PREFS_KEY); + if (storedData != null) { + final Map decoded = json.decode(storedData); + return { + 'username': decoded['username'] as String, + 'password': decoded['password'] as String, + }; + } + return null; + } + + // 检查是否有存储的密码 + bool hasStoredPassword() { + return _prefs.containsKey(PREFS_KEY); + } + + // 移除存储的账号密码 + Future removePassword() async { + await _prefs.remove(PREFS_KEY); + } + + // 获取存储的用户名 + String? getStoredUsername() { + final credentials = getStoredCredentials(); + return credentials?['username']; + } + + // 获取存储的密码 + String? getStoredPassword() { + final credentials = getStoredCredentials(); + return credentials?['password']; + } +} \ No newline at end of file diff --git a/lib/view/begin/begin_view.dart b/lib/view/begin/begin_view.dart index 9d3ceab..65ffff3 100644 --- a/lib/view/begin/begin_view.dart +++ b/lib/view/begin/begin_view.dart @@ -29,7 +29,7 @@ class _BeginViewState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { return Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( image: DecorationImage( image: AssetImage("assets/img/app_bg.png"), fit: BoxFit.cover, @@ -37,11 +37,16 @@ class _BeginViewState extends State with TickerProviderStateMixin { ), child: Scaffold( backgroundColor: Colors.transparent, - body: SingleChildScrollView( + resizeToAvoidBottomInset: false, + body: ScrollConfiguration( + behavior: ScrollBehavior().copyWith( + physics: const NeverScrollableScrollPhysics(), + ), child: Column( children: [ + // 顶部欢迎部分 Padding( - padding: const EdgeInsets.only(top: 110,left: 40,right: 40), + padding: const EdgeInsets.only(top: 110, left: 40, right: 40), child: Row( children: [ const Column( @@ -76,71 +81,68 @@ class _BeginViewState extends State with TickerProviderStateMixin { ), ], ), - const SizedBox(width: 25,), + const SizedBox(width: 25), Image.asset("assets/img/app_logo.png", width: 80), ], ), ), - SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - Align( - child: SizedBox( - height: MediaQuery.of(context).size.height/1.06, - child: Column( - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 30.0), - child: Material( - color: Colors.white, - elevation: 3, - borderRadius: BorderRadius.circular(10), - child: TabBar( - controller: tabController, - unselectedLabelColor: Color(0xffCDCDCD), - labelColor: Colors.black, - indicator:BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: MColor.LGreen - ), - tabs: [ - Container( - padding: EdgeInsets.all(8.0), - // color: Colors.pink, - child: Text( - '登录', - style: TextStyle( - fontSize: 20, - ), - ), - ), - Container( - padding: EdgeInsets.all(8.0), - child: Text( - '注册', - style: TextStyle( - fontSize: 20, - ), - ), - ), - ], + const SizedBox(height: 20), // 添加一些间距 + + // 剩余部分使用 Expanded + Expanded( + child: Column( + children: [ + // TabBar部分 + Padding( + padding: const EdgeInsets.symmetric(horizontal: 30.0), + child: Material( + color: Colors.white, + elevation: 3, + borderRadius: BorderRadius.circular(10), + child: TabBar( + controller: tabController, + unselectedLabelColor: const Color(0xffCDCDCD), + labelColor: Colors.black, + indicatorSize: TabBarIndicatorSize.tab, + indicator: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: MColor.LGreen + ), + tabs: [ + Container( + padding: const EdgeInsets.all(8.0), + child: const Text( + '登录', + style: TextStyle( + fontSize: 20, + ), + ), + ), + Container( + padding: const EdgeInsets.all(8.0), + child: const Text( + '注册', + style: TextStyle( + fontSize: 20, ), ), ), - Expanded( - child: TabBarView( - controller: tabController, - children: [ - LoginV(), - SignUpView(), - ], - ) - ) ], ), ), + ), + + // TabBarView部分 + Expanded( + child: TabBarView( + controller: tabController, + physics: const NeverScrollableScrollPhysics(), + children: const [ + LoginV(), + SignUpView(), + ], + ), ) ], ), diff --git a/lib/view/begin/login_v.dart b/lib/view/begin/login_v.dart index 7fb54ee..4c67795 100644 --- a/lib/view/begin/login_v.dart +++ b/lib/view/begin/login_v.dart @@ -4,15 +4,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:music_player_miao/common_widget/app_data.dart'; -import 'package:music_player_miao/models/search_bean.dart'; import 'package:music_player_miao/view/main_tab_view/main_tab_view.dart'; import '../../api/api_client.dart'; -import '../../api/api_songlist.dart'; import '../../common/color_extension.dart'; +import '../../common/password_manager.dart'; import '../../models/getInfo_bean.dart'; import '../../models/login_bean.dart'; -import '../../models/songlist_bean.dart'; import '../../widget/my_text_field.dart'; class LoginV extends StatefulWidget { @@ -29,6 +27,7 @@ class _LoginVState extends State { bool signInRequired = false; IconData iconPassword = CupertinoIcons.eye_fill; bool obscurePassword = true; + final passwordManager = Get.put(PasswordManager()); @override Widget build(BuildContext context) { @@ -86,19 +85,59 @@ class _LoginVState extends State { password: passwordController.text, ); if (bean.code == 200) { + passwordManager.savePassword(nameController.text, passwordController.text); Get.to(() => const MainTabView()); - _showDialog(context, - title: 'assets/img/correct.png', - message: '登录成功!'); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Center( + child: Text( + '登录成功!', + style: TextStyle( + color: Colors.black, + fontSize: 16.0, // 设置字体大小 + fontWeight: FontWeight.w500, // 可选:设置字体粗细 + ), + ), + ), + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.white, + elevation: 3, + width: 200, // 设置固定宽度 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + ); GetInfoBean bean1 = await GetInfoApiClient() .getInfo( Authorization: AppData().currentToken); + } else { + throw Exception("账号或密码错误"); } } catch (error) { - String errorMessage = error.toString(); - _showDialog(context, - title: 'assets/img/warning.png', - message: errorMessage); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Center( + child: Text( + '${error.toString().replaceAll ('Exception: ', '')} !', + style: TextStyle( + color: Colors.red, + fontSize: 16.0, // 设置字体大小 + fontWeight: FontWeight.w500, // 可选:设置字体粗细 + ), + ), + ), + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.white, + elevation: 3, + width: 200, // 设置固定宽度 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + ); } }, style: TextButton.styleFrom( diff --git a/lib/view/begin/setup_view.dart b/lib/view/begin/setup_view.dart index 34c1050..b9a4339 100644 --- a/lib/view/begin/setup_view.dart +++ b/lib/view/begin/setup_view.dart @@ -1,5 +1,7 @@ // ignore_for_file: use_build_context_synchronously +import 'dart:async'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -28,6 +30,38 @@ class _SignUpViewState extends State { bool obscurePassword = true; bool signUpRequired = false; + // 添加计时器相关变量 + Timer? _timer; + int _countDown = 60; + bool _canSendCode = true; + + @override + void dispose() { + _timer?.cancel(); // 页面销毁时取消计时器 + super.dispose(); + } + + // 开始倒计时 + void startTimer() { + setState(() { + _canSendCode = false; + _countDown = 60; + }); + + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { + if (_countDown == 0) { + setState(() { + _canSendCode = true; + timer.cancel(); + }); + } else { + setState(() { + _countDown--; + }); + } + }); + } + @override Widget build(BuildContext context) { return Form( @@ -160,27 +194,75 @@ class _SignUpViewState extends State { }), ), SizedBox( - width: MediaQuery.of(context).size.width * 0.3, + width: MediaQuery.of(context).size.width * 0.313, height: MediaQuery.of(context).size.width * 0.13, child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: MColor.LGreen), - onPressed: () async { - UniversalBean bean = - await SetupApiClient().verification( - email: emailController.text, + style: ElevatedButton.styleFrom( + backgroundColor: _canSendCode ? MColor.LGreen : Colors.grey[300], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + ), + ), + onPressed: _canSendCode + ? () async { + UniversalBean bean = await SetupApiClient().verification( + email: emailController.text, + ); + + if (bean.code == 200) { + startTimer(); // 发送成功后开始倒计时 + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Center( + child: Text( + '验证码已成功发送!', + style: TextStyle(color: Colors.black), + ), + ), + duration: const Duration(seconds: 2), + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.white, + elevation: 3, + width: 200, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Center( + child: Text( + '邮箱为空或格式不正确!', + style: TextStyle( + color: Colors.black, + fontSize: 16.0, // 设置字体大小 + fontWeight: FontWeight.w500, // 可选:设置字体粗细 + ), + ), + ), + duration: const Duration(seconds: 2), + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.white, + elevation: 3, + width: 220, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), ); - _showSuccessDialog(context, - title: bean.code == 200 - ? 'assets/img/correct.png' - : 'assets/img/warning.png', - errorMessage: - bean.code == 200 ? '验证码已成功发送!' : '邮箱格式不正确!'); - }, - child: const Text( - "获取验证码", - style: TextStyle(color: Colors.black45, fontSize: 16), - )), + } + } + : null, + child: Text( + _canSendCode ? "获取验证码" : "${_countDown}s后重试", + style: TextStyle( + color: _canSendCode ? Colors.black45 : Colors.grey, + fontSize: 16, + ), + ), + ), ), ], ), @@ -198,18 +280,26 @@ class _SignUpViewState extends State { ), ); } - UniversalBean bean = await SetupApiClient().register( - email: emailController.text, - password: passwordController.text, - username: nameController.text, - verificationCode: confirmController.text); - _showSuccessDialog(context, - title: bean.code == 200 - ? 'assets/img/correct.png' - : 'assets/img/warning.png', - errorMessage: - bean.code == 200 ? '注册成功,一键登录' : '登录失败,验证码错误'); - if (bean.code == 200) Get.to(const MainTabView()); + if (nameController.text.isNotEmpty && + emailController.text.isNotEmpty && + passwordController.text.isNotEmpty && + confirmPSWController.text.isNotEmpty && + confirmController.text.isNotEmpty) { + UniversalBean bean = await SetupApiClient().register( + email: emailController.text, + password: passwordController.text, + username: nameController.text, + verificationCode: confirmController.text); + _showSuccessDialog(context, + title: bean.code == 200 + ? 'assets/img/correct.png' + : 'assets/img/warning.png', + errorMessage: + bean.code == 200 + ? '注册成功,一键登录' + : '注册失败,验证码错误'); + if (bean.code == 200) Get.to(const MainTabView()); + } }, style: TextButton.styleFrom( elevation: 3.0, diff --git a/lib/view/user/my_download_view.dart b/lib/view/user/my_download_view.dart index 95bf705..c9d4169 100644 --- a/lib/view/user/my_download_view.dart +++ b/lib/view/user/my_download_view.dart @@ -209,7 +209,8 @@ class _MyDownloadViewState extends State { onPressed: () { setState(() { _isSelectMode = false; - _selectedItems = List.generate(_songs.length, (index) => false); + _selectedItems = + List.generate(_songs.length, (index) => false); }); }, child: const Text( @@ -232,25 +233,32 @@ class _MyDownloadViewState extends State { Row( children: [ IconButton( - onPressed: _songs.isEmpty ? null : () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => MusicView( - songList: _songs, - initialSongIndex: 0, - onSongStatusChanged: (index, isCollected, isLiked) { - setState(() { - // 更新父组件中的数据 - _songs[index].collection = isCollected; - _songs[index].likes = isLiked; - downloadManager.updateSongInfo(_songs[index].id, isCollected, isLiked); - }); - }, - ), - ), - ); - }, + onPressed: _songs.isEmpty + ? null + : () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MusicView( + songList: _songs, + initialSongIndex: 0, + onSongStatusChanged: + (index, isCollected, isLiked) { + setState(() { + // 更新父组件中的数据 + _songs[index].collection = + isCollected; + _songs[index].likes = isLiked; + downloadManager.updateSongInfo( + _songs[index].id, + isCollected, + isLiked); + }); + }, + ), + ), + ); + }, icon: Image.asset( "assets/img/button_play.png", width: 20, @@ -320,20 +328,22 @@ class _MyDownloadViewState extends State { } : () { // 非选择模式下跳转到播放页面 - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => MusicView( - songList: _songs, - initialSongIndex: index, - onSongStatusChanged: (index, isCollected, isLiked) { - setState(() { - // 更新父组件中的数据 - _songs[index].collection = isCollected; - _songs[index].likes = isLiked; - }); - }, - ), + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MusicView( + songList: _songs, + initialSongIndex: index, + onSongStatusChanged: + (index, isCollected, isLiked) { + setState(() { + // 更新父组件中的数据 + _songs[index].collection = + isCollected; + _songs[index].likes = isLiked; + }); + }, + ), ), ); }, diff --git a/lib/view/user/my_music_view.dart b/lib/view/user/my_music_view.dart index 099d53c..ee46c48 100644 --- a/lib/view/user/my_music_view.dart +++ b/lib/view/user/my_music_view.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../common_widget/app_data.dart'; @@ -13,20 +12,21 @@ List flatten(Iterable> iterable) { class MyMusicView extends StatefulWidget { final int? songlistIdd; + const MyMusicView({Key? key, this.songlistIdd}) : super(key: key); + @override State createState() => _MyMusicViewState(); } class _MyMusicViewState extends State { - int songsNum = 0; - List songlistId =[]; + List songlistId = []; List musicDetail = []; List name = []; List coverPath = []; List musicPath = []; - List singerName =[]; + List singerName = []; List uploadUserName = []; final listVM = Get.put(HomeViewModel()); @@ -34,7 +34,6 @@ class _MyMusicViewState extends State { final List _mySongListSelections = List.generate(2, (index) => false); List _selectedItems = List.generate(10, (index) => false); - //修改从这开始 @override void initState() { @@ -86,8 +85,8 @@ class _MyMusicViewState extends State { print('Error fetching myworks data: $error'); } } - //在这里结束 + //在这里结束 void _toggleSelectMode() { setState(() { @@ -110,21 +109,20 @@ class _MyMusicViewState extends State { builder: (BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder( - borderRadius:BorderRadius.circular(10), + borderRadius: BorderRadius.circular(10), ), title: Row( children: [ - const Text("添加到",), + const Text( + "添加到", + ), Text( - '(${_selectedItems.where((item) => item).length} 首)', - style: const TextStyle( - color: Color(0xff429482), - fontSize: 16 - ), + '(${_selectedItems.where((item) => item).length} 首)', + style: const TextStyle(color: Color(0xff429482), fontSize: 16), ) ], ), - content:SingleChildScrollView( + content: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( children: [ @@ -151,8 +149,7 @@ class _MyMusicViewState extends State { ), ), TextButton( - onPressed: () { - }, + onPressed: () {}, style: TextButton.styleFrom( backgroundColor: const Color(0xff429482), minimumSize: const Size(130, 50), @@ -192,7 +189,6 @@ class _MyMusicViewState extends State { ); } - @override Widget build(BuildContext context) { return Container( @@ -209,52 +205,54 @@ class _MyMusicViewState extends State { centerTitle: true, elevation: 0, leading: !_isSelectMode - ?IconButton( - onPressed: () { - Get.back(result: true); - }, - icon: Image.asset( - "assets/img/back.png", - width: 25, - height: 25, - fit: BoxFit.contain, - ), - ) + ? IconButton( + onPressed: () { + Get.back(result: true); + }, + icon: Image.asset( + "assets/img/back.png", + width: 25, + height: 25, + fit: BoxFit.contain, + ), + ) : TextButton( - onPressed: _selectAll, - style: TextButton.styleFrom( - foregroundColor: Colors.black, - ), - child: const Text('全选',style: TextStyle(fontSize: 18),), - ), + onPressed: _selectAll, + style: TextButton.styleFrom( + foregroundColor: Colors.black, + minimumSize: const Size(50, 40), // 设置最小宽度,确保文字有足够空间 + padding: + const EdgeInsets.symmetric(horizontal: 8), // 添加水平内边距 + ), + child: const Text( + '全选', + style: TextStyle(fontSize: 18), + ), + ), title: _isSelectMode ? Text( - '已选中 ${_selectedItems.where((item) => item).length} 首歌曲', - style: const TextStyle( - color: Colors.black, - ), - ) + '已选中 ${_selectedItems.where((item) => item).length} 首歌曲', + style: const TextStyle( + color: Colors.black, + ), + ) : const Text( - '我的歌单', - style: TextStyle(color: Colors.black), - ), + '我的歌单', + style: TextStyle(color: Colors.black), + ), actions: [ if (_isSelectMode) TextButton( - onPressed: (){ + onPressed: () { setState(() { _isSelectMode = false; _selectedItems = List.generate(10, (index) => false); }); }, child: const Text( - "完成", - style: TextStyle( - color: Colors.black, - fontSize: 18 - ), - ) - ) + "完成", + style: TextStyle(color: Colors.black, fontSize: 18), + )) ], ), body: Container( @@ -271,7 +269,7 @@ class _MyMusicViewState extends State { Row( children: [ IconButton( - onPressed: (){}, + onPressed: () {}, icon: Image.asset( "assets/img/button_play.png", width: 20, @@ -280,16 +278,14 @@ class _MyMusicViewState extends State { ), const Text( '播放全部', - style: TextStyle( - fontSize: 16 - ), + style: TextStyle(fontSize: 16), + ), + const SizedBox( + width: 5, ), - const SizedBox(width: 5,), const Text( '50', - style: TextStyle( - fontSize: 16 - ), + style: TextStyle(fontSize: 16), ), ], ), @@ -307,220 +303,221 @@ class _MyMusicViewState extends State { child: songsNum == 0 ? Center(child: Text('该歌单为空')) // 如果没有作品,显示提示文本 : ListView.builder( - itemCount: songsNum, - itemBuilder: (BuildContext context, int index) { - return Container( - padding: const EdgeInsets.symmetric(vertical: 5.0), - child: ListTile( - leading: _isSelectMode - ? Checkbox( - value: _selectedItems[index], - onChanged: (value) { - setState(() { - _selectedItems[index] = value!; - }); - }, - shape: const CircleBorder(), - activeColor: const Color(0xff429482), - ) - : CircleAvatar( - backgroundImage: NetworkImage(coverPath[index]), // 假设封面路径是网络资源 - radius: 25, - ), - title: Text('${name[index]} - ${singerName[index]}'), // 显示歌曲名和歌手名 - trailing: _isSelectMode - ? null - : IconButton( - icon: const Icon(Icons.more_vert), - onPressed: () { - _bottomSheet(context); - }, - ), + itemCount: songsNum, + itemBuilder: (BuildContext context, int index) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 5.0), + child: ListTile( + leading: _isSelectMode + ? Checkbox( + value: _selectedItems[index], + onChanged: (value) { + setState(() { + _selectedItems[index] = value!; + }); + }, + shape: const CircleBorder(), + activeColor: const Color(0xff429482), + ) + : CircleAvatar( + backgroundImage: + NetworkImage(coverPath[index]), + // 假设封面路径是网络资源 + radius: 25, + ), + title: + Text('${name[index]} - ${singerName[index]}'), + // 显示歌曲名和歌手名 + trailing: _isSelectMode + ? null + : IconButton( + icon: const Icon(Icons.more_vert), + onPressed: () { + _bottomSheet(context); + }, + ), + ), + ); + }, ), - ); - }, - ), ), ], ), ), - bottomNavigationBar: _isSelectMode ? BottomAppBar( - child: SizedBox( - height: 127.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Row( - children: [ - IconButton( - onPressed: (){ - _showSelectionDialog(); - }, - icon: Image.asset("assets/img/list_add.png"), - iconSize: 60, + child: SizedBox( + height: 127.0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + IconButton( + onPressed: () { + _showSelectionDialog(); + }, + icon: Image.asset("assets/img/list_add.png"), + iconSize: 60, + ), + const Text("添加到"), + ], + ), + Container( + height: 50, + width: 2, + color: const Color(0xff429482), + ), + Row( + children: [ + IconButton( + onPressed: () {}, + icon: + Image.asset("assets/img/list_download.png"), + iconSize: 60, + ), + const Text("下载"), + ], + ), + ], + ), + ElevatedButton( + onPressed: () { + setState(() { + _isSelectMode = false; + _selectedItems = + List.generate(10, (index) => false); + }); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xff429482), + padding: const EdgeInsets.symmetric(vertical: 14), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero, + ), ), - const Text("添加到"), - ], - ), - Container( - height: 50, - width: 2, - color: const Color(0xff429482), - ), - Row( - children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_download.png"), - iconSize: 60, + child: const Text( + '取消', + style: TextStyle(color: Colors.black, fontSize: 16), ), - const Text("下载"), - ], - ), - ], - ), - ElevatedButton( - onPressed: () { - setState(() { - _isSelectMode = false; - _selectedItems = List.generate(10, (index) => false); - }); - }, - 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: 16 - ),), ), - ], - ), - ), - ) + ) : null, ), ); } - Future _bottomSheet(BuildContext context){ + + 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: 210, - padding: const EdgeInsets.only(top: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + 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: [ - Column( + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_remove.png"), - iconSize: 60, + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_remove.png"), + iconSize: 60, + ), + const Text("从歌单移除") + ], ), - const Text("从歌单移除") - ], - ), - Column( - children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_download.png"), - iconSize: 60, + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_download.png"), + iconSize: 60, + ), + const Text("下载") + ], ), - const Text("下载") - ], - ), - Column( - children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_collection.png"), - iconSize: 60, + 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, + ), + const Text("点赞") + ], + ), + Column( + children: [ + IconButton( + onPressed: () {}, + icon: Image.asset("assets/img/list_comment.png"), + iconSize: 60, + ), + const Text("评论") + ], ), - const Text("收藏") ], ), - Column( - children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_good.png"), - iconSize: 60, + const SizedBox( + height: 10, + ), + ElevatedButton( + onPressed: () { + // Get.to(()=>const MusicView()); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xffE6F4F1), + padding: const EdgeInsets.symmetric(vertical: 8), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero, ), - const Text("点赞") - ], + ), + child: const Text( + "查看详情页", + style: TextStyle(color: Colors.black, fontSize: 18), + ), ), - Column( - children: [ - IconButton( - onPressed: (){}, - icon: Image.asset("assets/img/list_comment.png"), - iconSize: 60, + 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, ), - const Text("评论") - ], + ), + child: const Text( + "取消", + style: TextStyle(color: Colors.black, fontSize: 18), + ), ), ], ), - const SizedBox(height: 10,), - ElevatedButton( - onPressed: () { - // Get.to(()=>const MusicView()); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xffE6F4F1), - 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), - ), - - ), - 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/user/user_view.dart b/lib/view/user/user_view.dart index efba12f..08ad44b 100644 --- a/lib/view/user/user_view.dart +++ b/lib/view/user/user_view.dart @@ -384,12 +384,10 @@ class _UserViewState extends State { IconButton( onPressed: () async { Navigator.pop(context); + Get.to(const BeginView()); 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,