diff --git a/README.md b/README.md index b5f0dab..8f20864 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,4 @@ It's a music player for Android platform. It's a Flutter project and under devel - [freepik.com](https://www.freepik.com/) - [flutter-action](https://github.com/marketplace/actions/flutter-action) - [supported-formats](https://developer.android.com/media/platform/supported-formats) +- [music_api](https://github.com/yhsj0919/music_api) diff --git a/lib/lang/en.dart b/lib/lang/en.dart index 3e5b9ff..f1ea3d8 100644 --- a/lib/lang/en.dart +++ b/lib/lang/en.dart @@ -110,4 +110,5 @@ const Map en = { "正在发送...": "Sending...", "文件已存在,是否覆盖": "File has existed, do you want to cover it", "删除": "Delete", + "没有歌词": "No found lyric", }; diff --git a/lib/lang/zh.dart b/lib/lang/zh.dart index 6dcee69..b3e6db1 100644 --- a/lib/lang/zh.dart +++ b/lib/lang/zh.dart @@ -110,4 +110,5 @@ const Map zh = { "Sending...": "正在发送...", "File has existed, do you want to cover it": "文件已存在,是否覆盖", "Delete": "删除", + "No found lyric": "没有歌词", }; diff --git a/lib/models/find_controller.dart b/lib/models/find_controller.dart index 5f07be3..a9139ed 100644 --- a/lib/models/find_controller.dart +++ b/lib/models/find_controller.dart @@ -217,19 +217,21 @@ class FindController extends GetxController { } final pname = (await PackageInfo.fromPlatform()).packageName; - final d = Directory("/storage/emulated/0/$pname"); + final d = Directory("/storage/emulated/0/$pname/music"); if (!(await d.exists())) { - await d.create(); + await d.create(recursive: true); } downloadDir = d.path; } else { - final d = await getDownloadsDirectory() ?? + final tmpDir = await getDownloadsDirectory() ?? await getApplicationCacheDirectory(); + final d = Directory("${tmpDir.path}/music"); + if (!(await d.exists())) { - await d.create(); + await d.create(recursive: true); } downloadDir = d.path; diff --git a/lib/models/lyric_controller.dart b/lib/models/lyric_controller.dart index b82ac8c..c8138a3 100644 --- a/lib/models/lyric_controller.dart +++ b/lib/models/lyric_controller.dart @@ -13,7 +13,7 @@ class SongLyricController extends GetxController { bool get isShow => _isShow.value; set isShow(bool v) => _isShow.value = v; - final _lyric = testSongLyric.obs; + final _lyric = "".obs; //testSongLyric.obs; String get lyric => _lyric.value; set lyric(String v) => _lyric.value = v; diff --git a/lib/pages/find.dart b/lib/pages/find.dart index bce74ca..41d9838 100644 --- a/lib/pages/find.dart +++ b/lib/pages/find.dart @@ -117,6 +117,7 @@ class _FindPageState extends State { } void search(String text) async { + focusNodeSearch.unfocus(); if (!settingController.find.enableYoutubeSearch && !settingController.find.enableBilibiliSearch) { Get.snackbar("提 示".tr, "没有启用Youtube或Bilibili搜索".tr, @@ -479,7 +480,6 @@ class _FindPageState extends State { GestureDetector( onTap: () { if (!findController.isSearching) { - focusNodeSearch.unfocus(); search(controllerSearch.text); } else { findController.isSearching = false; @@ -591,7 +591,7 @@ class _FindPageState extends State { color: CTheme.primary, size: size.width * 0.2, ) - : const NoData()); + : NoData()); } @override diff --git a/lib/pages/home.dart b/lib/pages/home.dart index d2f76c0..a346452 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -181,7 +181,7 @@ class _HomePageState extends State { Expanded( child: playlistController.playlist.isNotEmpty ? _buildBodyPlaylist(context) - : const NoData(), + : NoData(), ), _buildBottomPlayer(context), ], diff --git a/lib/pages/manage.dart b/lib/pages/manage.dart index 6256d6d..0ffffa9 100644 --- a/lib/pages/manage.dart +++ b/lib/pages/manage.dart @@ -80,7 +80,7 @@ class _ManagePageState extends State { }, ), ) - : const NoData()); + : NoData()); } @override diff --git a/lib/pages/search.dart b/lib/pages/search.dart index 8d75224..2dd0ab9 100644 --- a/lib/pages/search.dart +++ b/lib/pages/search.dart @@ -29,6 +29,7 @@ class _SearchPageState extends State { } void search(String text) { + _focusNodeSearch.unfocus(); var items = playlistController.searchByKeyword(text.trim()); if (items.isEmpty) { @@ -64,7 +65,7 @@ class _SearchPageState extends State { } Widget _buildBody(BuildContext context) { - return playlistController.playlist.isNotEmpty + return songs.isNotEmpty ? Obx( () => Container( color: CTheme.background, @@ -98,7 +99,7 @@ class _SearchPageState extends State { ), ), ) - : const NoData(); + : NoData(); } @override diff --git a/lib/pages/song.dart b/lib/pages/song.dart index 8b14802..ab86de4 100644 --- a/lib/pages/song.dart +++ b/lib/pages/song.dart @@ -6,6 +6,7 @@ import 'package:mmoo_lyric/lyric_widget.dart'; import '../theme/theme.dart'; import '../theme/controller.dart'; +import '../widgets/nodata.dart'; import '../widgets/neubox.dart'; import '../widgets/vslider.dart'; import '../widgets/track_shape.dart'; @@ -106,6 +107,8 @@ class _SongPageState extends State { Widget buildLyric(BuildContext context) { songLyricController.updateController(); + final innerHeight = min(450.0, Get.height * 0.8); + return GestureDetector( onTap: () { songLyricController.isShow = !songLyricController.isShow; @@ -114,13 +117,18 @@ class _SongPageState extends State { child: Padding( padding: const EdgeInsets.all(CTheme.padding * 5), child: Center( - child: LyricWidget( - enableDrag: false, - lyrics: LyricUtil.formatLyric(songLyricController.lyric), - size: Size(double.infinity, min(450, Get.height * 0.8)), - controller: songLyricController.controller, - currLyricStyle: TextStyle(color: CTheme.secondaryBrand), - ), + child: songLyricController.lyric.isNotEmpty + ? LyricWidget( + enableDrag: false, + lyrics: LyricUtil.formatLyric(songLyricController.lyric), + size: Size(double.infinity, innerHeight), + controller: songLyricController.controller, + currLyricStyle: TextStyle(color: CTheme.secondaryBrand), + ) + : SizedBox( + height: innerHeight, + child: NoData(text: "没有歌词".tr), + ), ), ), ); diff --git a/lib/widgets/nodata.dart b/lib/widgets/nodata.dart index c39aa35..d42dd9a 100644 --- a/lib/widgets/nodata.dart +++ b/lib/widgets/nodata.dart @@ -5,7 +5,9 @@ import 'package:flutter/material.dart'; import '../theme/theme.dart'; class NoData extends StatelessWidget { - const NoData({super.key}); + NoData({super.key, String? text}) : text = text ?? "没有数据".tr; + + final String text; @override Widget build(BuildContext context) { @@ -29,9 +31,9 @@ class NoData extends StatelessWidget { ), ), ), - SizedBox(height: CTheme.padding * 2), + const SizedBox(height: CTheme.padding * 2), Text( - "没有数据".tr, + text, style: Theme.of(context).textTheme.titleMedium, ), ],