feat: match info

opt dateformat

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-15 20:12:57 +08:00
parent 25f4ed6636
commit a2c24fb33c
108 changed files with 1703 additions and 877 deletions

View File

@@ -2,7 +2,7 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/http/user.dart';
import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/image_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -111,14 +111,14 @@ void imageSaveDialog({
tooltip: '分享',
onPressed: () {
SmartDialog.dismiss();
DownloadUtils.onShareImg(cover!);
ImageUtil.onShareImg(cover!);
},
icon: Icons.share,
),
iconBtn(
tooltip: '保存封面图',
onPressed: () async {
bool saveStatus = await DownloadUtils.downloadImg(
bool saveStatus = await ImageUtil.downloadImg(
context,
[cover!],
);

View File

@@ -1,14 +1,14 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/models/common/image_type.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:PiliPlus/utils/image_util.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class NetworkImgLayer extends StatelessWidget {
const NetworkImgLayer({
super.key,
this.src,
required this.src,
required this.width,
this.height,
this.type = ImageType.def,
@@ -64,7 +64,7 @@ class NetworkImgLayer extends StatelessWidget {
memCacheHeight = height.cacheSize(context);
}
return CachedNetworkImage(
imageUrl: Utils.thumbnailImgUrl(src, quality),
imageUrl: ImageUtil.thumbnailUrl(src, quality),
width: width,
height: height,
memCacheWidth: memCacheWidth,

View File

@@ -4,8 +4,8 @@ import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactive_vi
as custom;
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactive_viewer_boundary.dart';
import 'package:PiliPlus/models/common/image_preview_type.dart';
import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/image_util.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -248,7 +248,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
String _getActualUrl(String url) {
return _quality != 100
? Utils.thumbnailImgUrl(url, _quality)
? ImageUtil.thumbnailUrl(url, _quality)
: url.http2https;
}
@@ -367,7 +367,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
final item = widget.sources[currentIndex.value];
return [
PopupMenuItem(
onTap: () => DownloadUtils.onShareImg(item.url),
onTap: () => ImageUtil.onShareImg(item.url),
child: const Text("分享图片"),
),
PopupMenuItem(
@@ -375,7 +375,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
child: const Text("复制链接"),
),
PopupMenuItem(
onTap: () => DownloadUtils.downloadImg(
onTap: () => ImageUtil.downloadImg(
this.context,
[item.url],
),
@@ -383,7 +383,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
),
if (widget.sources.length > 1)
PopupMenuItem(
onTap: () => DownloadUtils.downloadImg(
onTap: () => ImageUtil.downloadImg(
this.context,
widget.sources.map((item) => item.url).toList(),
),
@@ -392,7 +392,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
if (item.sourceType == SourceType.livePhoto)
PopupMenuItem(
onTap: () {
DownloadUtils.downloadLivePhoto(
ImageUtil.downloadLivePhoto(
context: this.context,
url: item.url,
liveUrl: item.liveUrl!,
@@ -433,7 +433,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
return CachedNetworkImage(
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
imageUrl: Utils.thumbnailImgUrl(item.url, widget.quality),
imageUrl: ImageUtil.thumbnailUrl(item.url, widget.quality),
);
},
),
@@ -510,7 +510,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
ListTile(
onTap: () {
Get.back();
DownloadUtils.onShareImg(item.url);
ImageUtil.onShareImg(item.url);
},
dense: true,
title: const Text('分享', style: TextStyle(fontSize: 14)),
@@ -526,7 +526,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
ListTile(
onTap: () {
Get.back();
DownloadUtils.downloadImg(
ImageUtil.downloadImg(
this.context,
[item.url],
);
@@ -538,7 +538,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
ListTile(
onTap: () {
Get.back();
DownloadUtils.downloadImg(
ImageUtil.downloadImg(
this.context,
widget.sources.map((item) => item.url).toList(),
);
@@ -550,7 +550,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
ListTile(
onTap: () {
Get.back();
DownloadUtils.downloadLivePhoto(
ImageUtil.downloadLivePhoto(
context: this.context,
url: item.url,
liveUrl: item.liveUrl!,

View File

@@ -2,8 +2,8 @@ import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/models/common/avatar_badge_type.dart';
import 'package:PiliPlus/models/common/image_type.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/image_util.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -62,7 +62,7 @@ class PendantAvatar extends StatelessWidget {
child: CachedNetworkImage(
width: size * 1.75,
height: size * 1.75,
imageUrl: Utils.thumbnailImgUrl(garbPendantImage),
imageUrl: ImageUtil.thumbnailUrl(garbPendantImage),
),
),
),

View File

@@ -1,5 +1,5 @@
import 'package:PiliPlus/models/common/stat_type.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:PiliPlus/utils/num_util.dart';
import 'package:flutter/material.dart';
class StatWidget extends StatelessWidget {
@@ -39,7 +39,7 @@ class StatWidget extends StatelessWidget {
color: color,
),
Text(
Utils.numFormat(value),
NumUtil.numFormat(value),
style: TextStyle(fontSize: 12, color: color),
),
],

View File

@@ -11,6 +11,8 @@ import 'package:PiliPlus/models/common/stat_type.dart';
import 'package:PiliPlus/models/model_hot_video_item.dart';
import 'package:PiliPlus/models/model_video.dart';
import 'package:PiliPlus/models/search/result.dart';
import 'package:PiliPlus/utils/date_util.dart';
import 'package:PiliPlus/utils/duration_util.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
@@ -138,7 +140,7 @@ class VideoCardH extends StatelessWidget {
PBadge(
text: progress == -1
? '已看完'
: '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}',
: '${DurationUtil.formatDuration(progress)}/${DurationUtil.formatDuration(videoItem.duration)}',
right: 6,
bottom: 8,
type: PBadgeType.gray,
@@ -155,7 +157,8 @@ class VideoCardH extends StatelessWidget {
)
] else if (videoItem.duration > 0)
PBadge(
text: Utils.timeFormat(videoItem.duration),
text: DurationUtil.formatDuration(
videoItem.duration),
right: 6.0,
bottom: 6.0,
type: PBadgeType.gray,
@@ -194,9 +197,7 @@ class VideoCardH extends StatelessWidget {
Widget content(BuildContext context) {
final theme = Theme.of(context);
String pubdate = showPubdate
? Utils.dateFormat(videoItem.pubdate!, formatType: 'day')
: '';
String pubdate = showPubdate ? DateUtil.dateFormat(videoItem.pubdate!) : '';
if (pubdate != '') pubdate += ' ';
return Expanded(
child: Column(

View File

@@ -7,15 +7,17 @@ import 'package:PiliPlus/common/widgets/video_popup_menu.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/home/rcmd/result.dart';
import 'package:PiliPlus/models/model_rec_video_item.dart';
import 'package:PiliPlus/utils/app_scheme.dart';
import 'package:PiliPlus/utils/date_util.dart';
import 'package:PiliPlus/utils/duration_util.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
// 视频卡片 - 垂直布局
class VideoCardV extends StatelessWidget {
@@ -129,7 +131,8 @@ class VideoCardV extends StatelessWidget {
right: 7,
size: PBadgeSize.small,
type: PBadgeType.gray,
text: Utils.timeFormat(videoItem.duration),
text:
DurationUtil.formatDuration(videoItem.duration),
)
],
);
@@ -229,6 +232,9 @@ class VideoCardV extends StatelessWidget {
);
}
static final shortFormat = DateFormat('M-d');
static final longFormat = DateFormat('yy-M-d');
Widget videoStat(BuildContext context, ThemeData theme) {
return Row(
children: [
@@ -248,29 +254,36 @@ class VideoCardV extends StatelessWidget {
Text.rich(
maxLines: 1,
TextSpan(
style: TextStyle(
fontSize: theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline.withValues(alpha: 0.8),
),
text: Utils.formatTimestampToRelativeTime(videoItem.pubdate)),
),
const SizedBox(width: 2),
] else if (videoItem is RecVideoItemAppModel &&
videoItem.desc != null &&
videoItem.desc!.contains(' · ')) ...[
const Spacer(),
Text.rich(
maxLines: 1,
TextSpan(
style: TextStyle(
fontSize: theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline.withValues(alpha: 0.8),
),
text: Utils.shortenChineseDateString(
videoItem.desc!.split(' · ').last)),
style: TextStyle(
fontSize: theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline.withValues(alpha: 0.8),
),
text: DateUtil.dateFormat(
videoItem.pubdate,
shortFormat: shortFormat,
longFormat: longFormat,
),
),
),
const SizedBox(width: 2),
]
// deprecated
// else if (videoItem is RecVideoItemAppModel &&
// videoItem.desc != null &&
// videoItem.desc!.contains(' · ')) ...[
// const Spacer(),
// Text.rich(
// maxLines: 1,
// TextSpan(
// style: TextStyle(
// fontSize: theme.textTheme.labelSmall!.fontSize,
// color: theme.colorScheme.outline.withValues(alpha: 0.8),
// ),
// text: Utils.shortenChineseDateString(
// videoItem.desc!.split(' · ').last)),
// ),
// const SizedBox(width: 2),
// ]
],
);
}