Skip to content

Commit

Permalink
[Fix] add divider in music_container_listitem mutiselect page
Browse files Browse the repository at this point in the history
[Fix] adjust musiclist image card desc
  • Loading branch information
canxin121 committed Jul 18, 2024
1 parent 528c463 commit 0a5e107
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 75 deletions.
52 changes: 28 additions & 24 deletions lib/comps/musiclist_comp/musiclist_image_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class MusicListImageCard extends StatelessWidget {
final bool online;
final GestureTapCallback? onTap;
final bool cachePic;
const MusicListImageCard({
super.key,
required this.musicListW,
required this.online,
this.onTap,
this.cachePic = false,
});
final bool showDesc;
const MusicListImageCard(
{super.key,
required this.musicListW,
required this.online,
this.onTap,
this.cachePic = false,
this.showDesc = true});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -75,28 +76,31 @@ class MusicListImageCard extends StatelessWidget {
musicListInfo.name,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: textCOlor).useSystemChineseFont(),
style: TextStyle(color: textCOlor, fontSize: 16)
.useSystemChineseFont(),
maxLines: 2,
),
),
),
const SizedBox(height: 4),
Flexible(
fit: FlexFit.loose,
child: Center(
child: Text(
musicListInfo.desc,
style: TextStyle(
color: isDarkMode
? CupertinoColors.systemGrey4
: CupertinoColors.systemGrey,
fontSize: 16,
).useSystemChineseFont(),
textAlign: TextAlign.center,
maxLines: 4,
overflow: TextOverflow.fade,
if (showDesc) const SizedBox(height: 4),
if (showDesc)
Flexible(
fit: FlexFit.loose,
child: Center(
child: Text(
musicListInfo.desc,
style: TextStyle(
color: isDarkMode
? CupertinoColors.systemGrey4
: CupertinoColors.systemGrey,
fontSize: 12,
).useSystemChineseFont(),
textAlign: TextAlign.center,
maxLines: 4,
overflow: TextOverflow.ellipsis,
),
),
),
),
],
);

Expand Down
3 changes: 2 additions & 1 deletion lib/pages/local_music_list_gridview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class LocalMusicListGridPageState extends State<LocalMusicListGridPage>
key: ValueKey(musicList.getMusiclistInfo().id),
musicListW: musicList,
online: false,
showDesc: false,
onTap: () {
Navigator.push(
context,
Expand Down Expand Up @@ -207,7 +208,7 @@ class MusicListGridPageMenu extends StatelessWidget {
}
},
title: '打开歌单链接',
icon: CupertinoIcons.pencil,
icon: CupertinoIcons.link,
),
PullDownMenuItem(
itemTheme: PullDownMenuItemTheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ class MutiSelectLocalMusicListGridPageState
),
widget.musicLists.isEmpty
? Center(
child: Text("没有歌单", style: TextStyle(color: textColor).useSystemChineseFont()),
child: Text("没有歌单",
style:
TextStyle(color: textColor).useSystemChineseFont()),
)
: Expanded(
child: Align(
Expand All @@ -172,6 +174,7 @@ class MutiSelectLocalMusicListGridPageState
MusicListImageCard(
musicListW: musicList,
online: false,
showDesc: false,
cachePic: globalConfig.savePicWhenAddMusicList,
),
Align(
Expand All @@ -196,7 +199,7 @@ class MutiSelectLocalMusicListGridPageState
crossAxisCount: 2,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
childAspectRatio: 2 / 3,
childAspectRatio: 0.75,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:app_rhyme/comps/music_container_comp/music_container_list_item.d
import 'package:app_rhyme/src/rust/api/bind/type_bind.dart';
import 'package:app_rhyme/types/music_container.dart';
import 'package:app_rhyme/utils/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:pull_down_button/pull_down_button.dart';

Expand Down Expand Up @@ -109,6 +110,10 @@ class MutiSelectMusicContainerListPageState
final bool isDarkMode = brightness == Brightness.dark;
final Color backgroundColor =
isDarkMode ? CupertinoColors.black : CupertinoColors.white;
final Color dividerColor = isDarkMode
? const Color.fromARGB(255, 41, 41, 43)
: const Color.fromARGB(255, 245, 245, 246);
double screenWidth = MediaQuery.of(context).size.width;

return CupertinoPageScaffold(
backgroundColor: backgroundColor,
Expand Down Expand Up @@ -166,34 +171,46 @@ class MutiSelectMusicContainerListPageState
triggerSelectionOnTap: true,
itemBuilder: (context, index, selected) {
final musicContainer = widget.musicContainers[index];
return Row(
key:
ValueKey("${selected}_${musicContainer.info.id}"),
return Column(
children: [
Expanded(
child: MusicContainerListItem(
showMenu: false,
musicContainer: musicContainer,
musicListW: widget.musicList,
),
),
Icon(
selected
? CupertinoIcons.check_mark_circled
: CupertinoIcons.circle,
color: selected
? CupertinoColors.systemGreen
: CupertinoColors.systemGrey4,
Row(
key: ValueKey(
"${selected}_${musicContainer.info.id}"),
children: [
Expanded(
child: MusicContainerListItem(
showMenu: false,
musicContainer: musicContainer,
musicListW: widget.musicList,
),
),
Icon(
selected
? CupertinoIcons.check_mark_circled
: CupertinoIcons.circle,
color: selected
? CupertinoColors.systemGreen
: CupertinoColors.systemGrey4,
),
],
),
const Padding(padding: EdgeInsets.only(top: 10)),
SizedBox(
width: screenWidth * 0.85,
child: Divider(
color: dividerColor,
height: 0.5,
),
)
],
);
},
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
childAspectRatio: 8 / 1,
mainAxisSpacing: 0,
crossAxisSpacing: 0,
childAspectRatio: 6,
),
),
))
Expand Down Expand Up @@ -272,18 +289,21 @@ class MutiSelectLocalMusicContainerListChoiceMenu extends StatelessWidget {
textStyle: const TextStyle().useSystemChineseFont()),
onTap: handleCacheSelected,
title: '缓存选中音乐',
icon: CupertinoIcons.cloud_download,
),
PullDownMenuItem(
itemTheme: PullDownMenuItemTheme(
textStyle: const TextStyle().useSystemChineseFont()),
onTap: handleDeleteCacheSelected,
title: '删除音乐缓存',
icon: CupertinoIcons.delete,
),
PullDownMenuItem(
itemTheme: PullDownMenuItemTheme(
textStyle: const TextStyle().useSystemChineseFont()),
onTap: handleDeleteFromList,
title: '从歌单删除',
icon: CupertinoIcons.trash,
),
],
PullDownMenuItem(
Expand All @@ -293,6 +313,7 @@ class MutiSelectLocalMusicContainerListChoiceMenu extends StatelessWidget {
await addMusicsToMusicList(context, musicContainers);
},
title: '添加到歌单',
icon: CupertinoIcons.add,
),
PullDownMenuItem(
itemTheme: PullDownMenuItemTheme(
Expand All @@ -301,6 +322,7 @@ class MutiSelectLocalMusicContainerListChoiceMenu extends StatelessWidget {
await createNewMusicListFromMusics(context, musicContainers);
},
title: '创建新歌单',
icon: CupertinoIcons.add_circled,
),
PullDownMenuItem(
itemTheme: PullDownMenuItemTheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class _MutiSelectOnlineMusicListGridPageState
children: [
MusicListImageCard(
musicListW: musicList,
showDesc: false,
online: false,
cachePic: globalConfig.savePicWhenAddMusicList,
),
Expand All @@ -273,7 +274,7 @@ class _MutiSelectOnlineMusicListGridPageState
crossAxisCount: 2,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
childAspectRatio: 2 / 3,
childAspectRatio: 0.75,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class ReorderLocalMusicListGridPageState
return SizedBox(
width: screenWidth / 2 - 20,
child: MusicListImageCard(
showDesc: false,
key:
ValueKey(musicList.getMusiclistInfo().id),
musicListW: musicList,
Expand Down
21 changes: 9 additions & 12 deletions lib/pages/search_page/search_music_aggregator_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,15 @@ class _SearchMusicAggregatorPageState extends State<SearchMusicAggregatorPage>
trailing: SearchMusicAggregatroChoiceMenu(
musicAggregatorController: _pagingController,
builder:
(BuildContext context, Future<void> Function() showMenu) {
return GestureDetector(
child: Text(
'选项',
style: TextStyle(color: activeIconRed)
.useSystemChineseFont(),
),
onTapDown: (details) {
showMenu();
},
);
},
(BuildContext context, Future<void> Function() showMenu) =>
CupertinoButton(
padding: const EdgeInsets.all(0),
onPressed: showMenu,
child: Text(
'选项',
style: TextStyle(color: activeIconRed)
.useSystemChineseFont(),
)),
fetchAllMusicAggregators: _fetchAllMusicAggregators,
)),
// 搜索框和过滤按钮
Expand Down
27 changes: 12 additions & 15 deletions lib/pages/search_page/search_music_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,15 @@ class _SearchMusicListState extends State<SearchMusicListPage>
),
trailing: SearchMusicListChoiceMenu(
builder:
(BuildContext context, Future<void> Function() showMenu) {
return GestureDetector(
child: Text(
'选项',
style:
TextStyle(color: activeIconRed).useSystemChineseFont(),
),
onTapDown: (details) {
showMenu();
},
);
},
(BuildContext context, Future<void> Function() showMenu) =>
CupertinoButton(
padding: const EdgeInsets.all(0),
onPressed: showMenu,
child: Text(
'选项',
style: TextStyle(color: activeIconRed)
.useSystemChineseFont(),
)),
fetchAllMusicAggregators: _fetchAllMusicLists,
openShareMusicList: () async {
var url = await showInputPlaylistShareLinkDialog(context);
Expand Down Expand Up @@ -183,9 +180,9 @@ class _SearchMusicListState extends State<SearchMusicListPage>
);
}, itemBuilder: (context, musicListW, index) {
return Container(
padding:
const EdgeInsets.only(left: 10, right: 10, bottom: 20),
padding: const EdgeInsets.only(left: 10, right: 10),
child: MusicListImageCard(
showDesc: false,
musicListW: musicListW,
onTap: () {
Navigator.push(
Expand All @@ -200,7 +197,7 @@ class _SearchMusicListState extends State<SearchMusicListPage>
));
}),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, childAspectRatio: 0.7)),
crossAxisCount: 2, childAspectRatio: 0.8)),
),
],
));
Expand Down

0 comments on commit 0a5e107

Please sign in to comment.