Skip to content

Commit

Permalink
[*] improve ui
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed May 21, 2024
1 parent f58e1af commit 7edff31
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/lang/en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ const Map<String, String> en = {
"正在发送...": "Sending...",
"文件已存在,是否覆盖": "File has existed, do you want to cover it",
"删除": "Delete",
"没有歌词": "No found lyric",
};
1 change: 1 addition & 0 deletions lib/lang/zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ const Map<String, String> zh = {
"Sending...": "正在发送...",
"File has existed, do you want to cover it": "文件已存在,是否覆盖",
"Delete": "删除",
"No found lyric": "没有歌词",
};
10 changes: 6 additions & 4 deletions lib/models/find_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/models/lyric_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/pages/find.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class _FindPageState extends State<FindPage> {
}

void search(String text) async {
focusNodeSearch.unfocus();
if (!settingController.find.enableYoutubeSearch &&
!settingController.find.enableBilibiliSearch) {
Get.snackbar("提 示".tr, "没有启用Youtube或Bilibili搜索".tr,
Expand Down Expand Up @@ -479,7 +480,6 @@ class _FindPageState extends State<FindPage> {
GestureDetector(
onTap: () {
if (!findController.isSearching) {
focusNodeSearch.unfocus();
search(controllerSearch.text);
} else {
findController.isSearching = false;
Expand Down Expand Up @@ -591,7 +591,7 @@ class _FindPageState extends State<FindPage> {
color: CTheme.primary,
size: size.width * 0.2,
)
: const NoData());
: NoData());
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class _HomePageState extends State<HomePage> {
Expanded(
child: playlistController.playlist.isNotEmpty
? _buildBodyPlaylist(context)
: const NoData(),
: NoData(),
),
_buildBottomPlayer(context),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/manage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _ManagePageState extends State<ManagePage> {
},
),
)
: const NoData());
: NoData());
}

@override
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _SearchPageState extends State<SearchPage> {
}

void search(String text) {
_focusNodeSearch.unfocus();
var items = playlistController.searchByKeyword(text.trim());

if (items.isEmpty) {
Expand Down Expand Up @@ -64,7 +65,7 @@ class _SearchPageState extends State<SearchPage> {
}

Widget _buildBody(BuildContext context) {
return playlistController.playlist.isNotEmpty
return songs.isNotEmpty
? Obx(
() => Container(
color: CTheme.background,
Expand Down Expand Up @@ -98,7 +99,7 @@ class _SearchPageState extends State<SearchPage> {
),
),
)
: const NoData();
: NoData();
}

@override
Expand Down
22 changes: 15 additions & 7 deletions lib/pages/song.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -106,6 +107,8 @@ class _SongPageState extends State<SongPage> {

Widget buildLyric(BuildContext context) {
songLyricController.updateController();
final innerHeight = min(450.0, Get.height * 0.8);

return GestureDetector(
onTap: () {
songLyricController.isShow = !songLyricController.isShow;
Expand All @@ -114,13 +117,18 @@ class _SongPageState extends State<SongPage> {
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),
),
),
),
);
Expand Down
8 changes: 5 additions & 3 deletions lib/widgets/nodata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
),
],
Expand Down

0 comments on commit 7edff31

Please sign in to comment.