mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-08-04 01:30:14 +08:00
committed by
GitHub
parent
84f7f14a29
commit
08a33d9ce5
41
lib/pages/music/controller.dart
Normal file
41
lib/pages/music/controller.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/music.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_detail.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MusicDetailController extends CommonDynController {
|
||||
@override
|
||||
late final int oid;
|
||||
@override
|
||||
late final int replyType;
|
||||
|
||||
@override
|
||||
dynamic get sourceId => oid.toString();
|
||||
|
||||
final infoState = LoadingState<MusicDetail>.loading().obs;
|
||||
|
||||
late final String musicId;
|
||||
|
||||
bool get showDynActionBar => Pref.showDynActionBar;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
musicId = Get.parameters['musicId']!;
|
||||
getMusicDetail();
|
||||
}
|
||||
|
||||
Future<void> getMusicDetail() async {
|
||||
final res = await MusicHttp.bgmDetail(musicId);
|
||||
if (res.isSuccess) {
|
||||
final comment = res.data.musicComment!;
|
||||
oid = comment.oid!;
|
||||
replyType = comment.pageType ?? 47;
|
||||
count.value = comment.nums ?? -1;
|
||||
queryData();
|
||||
}
|
||||
infoState.value = res;
|
||||
}
|
||||
}
|
||||
30
lib/pages/music/video/controller.dart
Normal file
30
lib/pages/music/video/controller.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/music.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_detail.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_recommend_list.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MusicRecommendController
|
||||
extends CommonListController<List<BgmRecommend>?, BgmRecommend> {
|
||||
late final String musicId;
|
||||
late final MusicDetail musicDetail;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
final Map<String, dynamic> args = Get.arguments;
|
||||
musicId = args['id'];
|
||||
musicDetail = args['detail'];
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
void checkIsEnd(int length) {
|
||||
isEnd = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<BgmRecommend>?>> customGetData() =>
|
||||
MusicHttp.bgmRecommend(musicId);
|
||||
}
|
||||
127
lib/pages/music/video/view.dart
Normal file
127
lib/pages/music/video/view.dart
Normal file
@@ -0,0 +1,127 @@
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_recommend_list.dart';
|
||||
import 'package:PiliPlus/pages/music/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/music/widget/music_video_card_h.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MusicRecommandPage extends StatefulWidget {
|
||||
const MusicRecommandPage({super.key});
|
||||
|
||||
@override
|
||||
State<MusicRecommandPage> createState() => _MusicRecommandPageState();
|
||||
}
|
||||
|
||||
class _MusicRecommandPageState extends State<MusicRecommandPage>
|
||||
with GridMixin, SingleTickerProviderStateMixin {
|
||||
late final _controller = Get.put(
|
||||
MusicRecommendController(),
|
||||
tag: Utils.generateRandomString(8),
|
||||
);
|
||||
|
||||
late final _animation = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 5),
|
||||
reverseDuration: const Duration(seconds: 5),
|
||||
)..repeat(reverse: true);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Material(
|
||||
color: theme.colorScheme.surface,
|
||||
child: refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: _controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
_buildAppBar(theme, padding),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
left: padding.left,
|
||||
right: padding.right,
|
||||
bottom: padding.bottom + 100,
|
||||
),
|
||||
sliver: Obx(
|
||||
() => _buildBody(_controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<BgmRecommend>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => gridSkeleton,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) => MusicVideoCardH(
|
||||
videoItem: response[index],
|
||||
animation: _animation,
|
||||
),
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _buildAppBar(ThemeData theme, EdgeInsets padding) {
|
||||
final info = _controller.musicDetail;
|
||||
return SliverAppBar(
|
||||
pinned: true,
|
||||
title: Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 40,
|
||||
height: 40,
|
||||
src: info.mvCover,
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
info.musicTitle!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Obx(() {
|
||||
final count = _controller.loadingState.value.dataOrNull?.length;
|
||||
return count == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
'共$count条视频',
|
||||
style: theme.textTheme.labelMedium,
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animation.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
667
lib/pages/music/view.dart
Normal file
667
lib/pages/music/view.dart
Normal file
@@ -0,0 +1,667 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/marquee.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/music.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_preview_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_detail.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_page.dart';
|
||||
import 'package:PiliPlus/pages/music/controller.dart';
|
||||
import 'package:PiliPlus/pages/music/video/view.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/date_util.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/num_util.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class MusicDetailPage extends StatefulWidget {
|
||||
const MusicDetailPage({super.key});
|
||||
|
||||
@override
|
||||
State<MusicDetailPage> createState() => _MusicDetailPageState();
|
||||
}
|
||||
|
||||
class _MusicDetailPageState extends CommonDynPageState<MusicDetailPage> {
|
||||
@override
|
||||
final MusicDetailController controller = Get.put(
|
||||
MusicDetailController(),
|
||||
tag: Utils.generateRandomString(8),
|
||||
);
|
||||
|
||||
@override
|
||||
dynamic get arguments => null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final size = MediaQuery.sizeOf(context);
|
||||
final maxWidth = size.width;
|
||||
isPortrait = size.height >= maxWidth;
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: _buildAppBar(isPortrait, maxWidth),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(left: padding.left, right: padding.right),
|
||||
child: isPortrait
|
||||
? refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: _buildBody(theme, isPortrait, maxWidth),
|
||||
)
|
||||
: _buildBody(theme, isPortrait, maxWidth),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar(bool isPortrait, double maxWidth) => AppBar(
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Obx(
|
||||
() {
|
||||
final info = controller.infoState.value;
|
||||
late final showTitle = controller.showTitle.value;
|
||||
return info.isSuccess
|
||||
? AnimatedOpacity(
|
||||
opacity: showTitle ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: IgnorePointer(
|
||||
ignoring: !showTitle,
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: info.data.mvCover,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
Text(info.data.musicTitle!),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox(height: 40);
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: isPortrait
|
||||
? null
|
||||
: [
|
||||
ratioWidget(maxWidth),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme,
|
||||
bool isPortrait,
|
||||
double maxWidth,
|
||||
) => Obx(() {
|
||||
switch (controller.infoState.value) {
|
||||
case Success(:final response):
|
||||
double padding = max(maxWidth / 2 - Grid.smallCardWidth, 0);
|
||||
final Widget child;
|
||||
if (isPortrait) {
|
||||
child = Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: padding),
|
||||
child: CustomScrollView(
|
||||
controller: controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: _buildCard(theme, response, maxWidth),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: _buildChart(theme, response, maxWidth),
|
||||
),
|
||||
buildReplyHeader(theme),
|
||||
Obx(() => replyList(theme, controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
padding = padding / 4;
|
||||
final flex = controller.ratio[0].toInt();
|
||||
final flex1 = controller.ratio[1].toInt();
|
||||
final leftWidth =
|
||||
(maxWidth - this.padding.horizontal) * (flex / (flex + flex1)) -
|
||||
padding;
|
||||
child = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: flex,
|
||||
child: CustomScrollView(
|
||||
controller: controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
left: padding,
|
||||
),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: _buildCard(theme, response, leftWidth),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
left: padding,
|
||||
bottom: this.padding.bottom + 100,
|
||||
),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: _buildChart(theme, response, leftWidth),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: flex1,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(right: padding),
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
backgroundColor: Colors.transparent,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: controller
|
||||
.scrollController, // debug: The provided ScrollController is attached to more than one ScrollPosition.
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
buildReplyHeader(theme),
|
||||
Obx(
|
||||
() =>
|
||||
replyList(theme, controller.loadingState.value),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
child,
|
||||
_buildBottom(theme, response),
|
||||
],
|
||||
);
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
});
|
||||
|
||||
Widget _buildBottom(ThemeData theme, MusicDetail item) {
|
||||
final outline = theme.colorScheme.outline;
|
||||
|
||||
Widget textIconButton({
|
||||
required IconData icon,
|
||||
required String text,
|
||||
int? count,
|
||||
bool status = false,
|
||||
required VoidCallback onPressed,
|
||||
IconData? activitedIcon,
|
||||
}) {
|
||||
final color = status ? theme.colorScheme.primary : outline;
|
||||
return TextButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: Icon(
|
||||
status ? activitedIcon : icon,
|
||||
size: 16,
|
||||
color: color,
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
foregroundColor: outline,
|
||||
),
|
||||
label: Text(
|
||||
count != null ? NumUtil.numFormat(count) : text,
|
||||
style: TextStyle(color: color),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: SlideTransition(
|
||||
position: controller.fabAnim,
|
||||
child: controller.showDynActionBar
|
||||
? Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: 14,
|
||||
bottom: padding.bottom + 14,
|
||||
),
|
||||
child: replyButton,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 14, bottom: 14),
|
||||
child: replyButton,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: theme.colorScheme.outline.withValues(
|
||||
alpha: 0.08,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.only(bottom: padding.bottom),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
// TODO
|
||||
// Expanded(
|
||||
// child: textIconButton(
|
||||
// icon: FontAwesomeIcons.shareFromSquare,
|
||||
// text: '转发',
|
||||
// count: item.musicShares,
|
||||
// onPressed: () {
|
||||
// final data = controller.infoState.value.dataOrNull;
|
||||
// if (data != null) {
|
||||
// showModalBottomSheet(
|
||||
// context: context,
|
||||
// isScrollControlled: true,
|
||||
// useSafeArea: true,
|
||||
// builder: (context) => RepostPanel(
|
||||
// rid: controller.oid,
|
||||
// dynType: null,
|
||||
// pic: data.mvCover,
|
||||
// title: data.musicTitle,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
Expanded(
|
||||
child: textIconButton(
|
||||
icon: CustomIcon.share_node,
|
||||
text: '分享',
|
||||
onPressed: () => Utils.shareText(
|
||||
'https://music.bilibili.com/h5/music-detail?music_id=${controller.musicId}',
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (context) => textIconButton(
|
||||
icon: FontAwesomeIcons.thumbsUp,
|
||||
activitedIcon: FontAwesomeIcons.solidThumbsUp,
|
||||
text: '点赞',
|
||||
count: item.wishCount,
|
||||
status: item.wishListen ?? false,
|
||||
onPressed: () async {
|
||||
if (!Accounts.main.isLogin) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
final hasLike = item.wishListen ?? false;
|
||||
final res = await MusicHttp.wishUpdate(
|
||||
controller.musicId,
|
||||
hasLike,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
if (hasLike) {
|
||||
item.wishCount--;
|
||||
} else {
|
||||
item.wishCount++;
|
||||
}
|
||||
item.wishListen = !hasLike;
|
||||
if (context.mounted) {
|
||||
(context as Element).markNeedsBuild();
|
||||
}
|
||||
} else {
|
||||
res.toast();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildArtist(Artist artist, TextStyle? style) {
|
||||
Widget child = Text('${artist.identity}: ${artist.name}', style: style);
|
||||
if (!artist.face.isNullOrEmpty) {
|
||||
child = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: artist.face,
|
||||
width: 15,
|
||||
height: 15,
|
||||
type: ImageType.avatar,
|
||||
),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
child = InkWell(
|
||||
borderRadius: StyleString.mdRadius,
|
||||
onTap: artist.mid == null || artist.mid == 0
|
||||
? () => Utils.copyText(artist.name!)
|
||||
: () => Get.toNamed(
|
||||
'/member',
|
||||
parameters: {'mid': artist.mid!.toString()},
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
return child;
|
||||
}
|
||||
|
||||
Widget _buildRank(
|
||||
int? rank,
|
||||
String name,
|
||||
TextTheme theme, [
|
||||
VoidCallback? onTap,
|
||||
]) {
|
||||
final child = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(NumUtil.numFormat(rank), style: theme.bodyLarge),
|
||||
Text(name, style: theme.bodySmall),
|
||||
],
|
||||
);
|
||||
return onTap == null
|
||||
? child
|
||||
: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Padding(padding: const EdgeInsets.all(4), child: child),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCard(ThemeData theme, MusicDetail item, double maxWidth) {
|
||||
final textTheme = theme.textTheme;
|
||||
return SizedBox(
|
||||
width: maxWidth,
|
||||
child: Card(
|
||||
margin: const EdgeInsets.all(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => PageUtils.imageView(
|
||||
imgList: [SourceModel(url: item.mvCover!)],
|
||||
),
|
||||
child: NetworkImgLayer(
|
||||
src: item.mvCover,
|
||||
width: 80,
|
||||
height: 80,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
spacing: 2,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
InkWell(
|
||||
borderRadius: StyleString.mdRadius,
|
||||
// TODO: android intent ACTION_MEDIA_SEARCH
|
||||
onTap: () => Utils.copyText(
|
||||
item.musicTitle!,
|
||||
),
|
||||
child: MarqueeText(
|
||||
item.musicTitle!,
|
||||
maxWidth: maxWidth - 136, // 80 + 16 + 32 + 8
|
||||
style: textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 2,
|
||||
alignment: WrapAlignment.spaceEvenly,
|
||||
children: [
|
||||
if (!item.artistsList.isNullOrEmpty)
|
||||
for (var artist in item.artistsList!)
|
||||
_buildArtist(artist, textTheme.bodySmall),
|
||||
if (!item.musicPublish.isNullOrEmpty)
|
||||
Text(
|
||||
'发行日期:${item.musicPublish}',
|
||||
style: textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
spacing: 16,
|
||||
children: [
|
||||
if (!item.musicRank.isNullOrEmpty)
|
||||
PBadge(
|
||||
text: item.musicRank,
|
||||
type: PBadgeType.secondary,
|
||||
isStack: false,
|
||||
fontSize: 11,
|
||||
),
|
||||
if (item.mvCid != null && item.mvCid != 0)
|
||||
InkWell(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
onTap: () => PageUtils.toVideoPage(
|
||||
bvid: item.mvBvid,
|
||||
cid: item.mvCid!,
|
||||
aid: item.mvAid,
|
||||
),
|
||||
child: ColoredBox(
|
||||
color: theme.colorScheme.secondaryContainer
|
||||
.withValues(alpha: 0.5),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.play_circle_outline,
|
||||
size: 11,
|
||||
color: theme
|
||||
.colorScheme
|
||||
.onSecondaryContainer,
|
||||
),
|
||||
Text(
|
||||
'看MV',
|
||||
style: TextStyle(
|
||||
color: theme
|
||||
.colorScheme
|
||||
.onSecondaryContainer,
|
||||
height: 1,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
strutStyle: const StrutStyle(
|
||||
leading: 0,
|
||||
height: 1,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SelectableText(
|
||||
[
|
||||
if (!(item.originArtist ?? item.originArtistList)
|
||||
.isNullOrEmpty)
|
||||
'原唱:${item.originArtist ?? item.originArtistList}',
|
||||
if (!item.album.isNullOrEmpty) '专辑:${item.album}',
|
||||
if (!item.musicSource.isNullOrEmpty) '出处:${item.musicSource}',
|
||||
].join('\n'),
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: 8,
|
||||
children: [
|
||||
const Text('热歌榜排名'),
|
||||
_buildRank(item.hotSongHeat?.lastHeat, '热度', textTheme),
|
||||
_buildRank(item.listenPv, '总播放量', textTheme),
|
||||
_buildRank(
|
||||
item.musicRelation,
|
||||
'使用稿件量',
|
||||
textTheme,
|
||||
() => Get.to(
|
||||
const MusicRecommandPage(),
|
||||
arguments: {'id': controller.musicId, 'detail': item},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _buildChart(ThemeData theme, MusicDetail item, double maxWidth) {
|
||||
final heat = item.hotSongHeat?.songHeat;
|
||||
if (heat == null || heat.isEmpty) return null;
|
||||
final colorScheme = theme.colorScheme;
|
||||
int maxHeat = heat.first.heat;
|
||||
int minHeat = heat.first.heat;
|
||||
for (int i = 1; i < heat.length; i++) {
|
||||
final h = heat[i].heat;
|
||||
if (h > maxHeat) maxHeat = h;
|
||||
if (h < minHeat) minHeat = h;
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Text('近${heat.length}日热度趋势', style: theme.textTheme.titleMedium),
|
||||
SizedBox(
|
||||
width: maxWidth,
|
||||
height: maxWidth * 0.5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsGeometry.only(top: 4, right: 22),
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
lineTouchData: const LineTouchData(enabled: false),
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
rightTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
topTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
leftTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
reservedSize: 55,
|
||||
showTitles: true,
|
||||
),
|
||||
),
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 30 * sqrt2,
|
||||
getTitlesWidget: (index, meta) {
|
||||
return SideTitleWidget(
|
||||
angle: -pi / 4,
|
||||
space: 8 * sqrt2,
|
||||
meta: meta,
|
||||
child: Text(
|
||||
DateUtil.shortFormat.format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
heat[index.toInt()].date * 1000,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(
|
||||
show: true,
|
||||
border: Border.all(color: colorScheme.onSurface),
|
||||
),
|
||||
minX: 0,
|
||||
maxX: (heat.length - 1).toDouble(),
|
||||
minY: minHeat.toDouble(),
|
||||
maxY: maxHeat.toDouble(),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: List.generate(
|
||||
heat.length,
|
||||
(index) => FlSpot(
|
||||
index.toDouble(),
|
||||
heat[index].heat.toDouble(),
|
||||
),
|
||||
),
|
||||
color: colorScheme.primary,
|
||||
barWidth: 1,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(
|
||||
show: true,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
colorScheme.primary.withValues(alpha: 0.5),
|
||||
colorScheme.onPrimary.withValues(alpha: 0.5),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
147
lib/pages/music/widget/music_video_card_h.dart
Normal file
147
lib/pages/music/widget/music_video_card_h.dart
Normal file
@@ -0,0 +1,147 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/marquee.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/stat_type.dart';
|
||||
import 'package:PiliPlus/models_new/music/bgm_recommend_list.dart';
|
||||
import 'package:PiliPlus/utils/duration_util.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MusicVideoCardH extends StatelessWidget {
|
||||
final BgmRecommend videoItem;
|
||||
final Animation<double> animation;
|
||||
|
||||
const MusicVideoCardH({
|
||||
super.key,
|
||||
required this.videoItem,
|
||||
required this.animation,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
int? cid =
|
||||
videoItem.cid ?? await SearchHttp.ab2c(bvid: videoItem.bvid);
|
||||
if (cid != null) {
|
||||
PageUtils.toVideoPage(
|
||||
bvid: videoItem.bvid,
|
||||
cid: cid,
|
||||
cover: videoItem.cover,
|
||||
title: videoItem.title,
|
||||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () => imageSaveDialog(
|
||||
title: videoItem.title,
|
||||
cover: videoItem.cover,
|
||||
bvid: videoItem.bvid,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, boxConstraints) {
|
||||
double maxWidth = boxConstraints.maxWidth;
|
||||
double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: videoItem.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
PBadge(
|
||||
text: DurationUtil.formatDuration(videoItem.duration),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
content(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget content(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
videoItem.title!,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
StatWidget(
|
||||
type: StatType.play,
|
||||
value: videoItem.play,
|
||||
),
|
||||
StatWidget(
|
||||
type: StatType.danmaku,
|
||||
value: videoItem.danmu,
|
||||
),
|
||||
],
|
||||
),
|
||||
BounceMarquee(
|
||||
animation: animation,
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (videoItem.labelList case final labelList?)
|
||||
for (final label in labelList)
|
||||
PBadge(
|
||||
text: label.name,
|
||||
isStack: false,
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.secondary,
|
||||
),
|
||||
Text(
|
||||
videoItem.upNickName!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user