fix: 增加创建歌单空值检查和错误提示

chen
Spark 3 months ago
parent df99a8c949
commit d539bf88d2

File diff suppressed because one or more lines are too long

@ -456,7 +456,7 @@ class _ReleaseViewState extends State<ReleaseView> with AutomaticKeepAliveClient
String artistName,
) {
if (musicFile == null) {
_showErrorMessage('请选择音文件');
_showErrorMessage('请选择音文件');
return false;
}
if (coverFile == null) {

@ -318,13 +318,6 @@ class _UserViewState extends State<UserView>
color: const Color(0xff404040),
)
),
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/user_export.png",
width: 31
)
)
],
)
],
@ -530,11 +523,9 @@ class _UserViewState extends State<UserView>
_controller.clear();
showDialog(
context: context,
barrierDismissible: false, //
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
title: const Center(
child: Text(
"新建歌单",
@ -550,16 +541,8 @@ class _UserViewState extends State<UserView>
onPressed: () {
Navigator.of(context).pop();
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(0, 50), //
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.white),
),
),
),
@ -567,42 +550,32 @@ class _UserViewState extends State<UserView>
Expanded(
child: TextButton(
onPressed: () async {
Navigator.of(context).pop();
if (_controller.text.trim().isEmpty) {
_showErrorMessage("歌单名称不能为空");
return;
}
String enteredSongName = _controller.text;
SonglistBean bean = await SonglistApi().addSonglist(
songlistName: enteredSongName,
Authorization: AppData().currentToken);
if (bean.code == 200) {
print('添加成功');
setState(() {
// print('当前歌单数量: $playlistCount');
// print('playlistNames长度: ${playlistNames.length}');
// print('playlistid长度: ${playlistid.length}');
// print('playListSongsNum长度: ${playListSongsNum.length}');
playlistCount++;
// TODO id
playlistid.add(playlistid.length + 1);
playlistNames.add(enteredSongName);
playListSongsNum.add(0);
// print('添加后 - 歌单数量: $playlistCount');
// print('添加后 - playlistNames长度: ${playlistNames.length}');
// print('添加后 - playlistid长度: ${playlistid.length}');
// print('添加后 - playListSongsNum长度: ${playListSongsNum.length}');
});
Navigator.of(context).pop();
_showErrorMessage("创建成功");
} else {
_showErrorMessage(bean.msg == "重复添加歌单" ? "已存在,请不要重复添加" : "创建歌单失败");
}
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(0, 50), //
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"确认",
style: TextStyle(color: Colors.white),
),
),
),
@ -614,6 +587,26 @@ class _UserViewState extends State<UserView>
);
}
void _showErrorMessage(String message) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('提示'),
content: Text(message),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('确定'),
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
foregroundColor: Colors.white,
),
),
],
),
);
}
///
Future<bool> _showDeleteConfirmationDialog(
BuildContext context, int index) async {

Loading…
Cancel
Save