mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: app端推荐添加时间显示(测试)
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../models/home/rcmd/result.dart';
|
||||
import '../../models/model_rec_video_item.dart';
|
||||
import 'stat/danmu.dart';
|
||||
import 'stat/view.dart';
|
||||
@@ -332,6 +333,27 @@ class VideoStat extends StatelessWidget {
|
||||
Utils.formatTimestampToRelativeTime(videoItem.pubdate)),
|
||||
)),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
if (videoItem is RecVideoItemAppModel &&
|
||||
videoItem.desc != null &&
|
||||
videoItem.desc.contains(' · ')) ...<Widget>[
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 0,
|
||||
child: RichText(
|
||||
maxLines: 1,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.8),
|
||||
),
|
||||
text: Utils.shortenChineseDateString(videoItem.desc.split(' · ').last)),
|
||||
)),
|
||||
const SizedBox(width: 2),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@ class RecVideoItemAppModel {
|
||||
this.cardType,
|
||||
this.adInfo,
|
||||
this.threePoint,
|
||||
this.desc,
|
||||
});
|
||||
|
||||
int? id;
|
||||
@@ -48,6 +49,7 @@ class RecVideoItemAppModel {
|
||||
String? cardType;
|
||||
Map? adInfo;
|
||||
ThreePoint? threePoint;
|
||||
String? desc;
|
||||
|
||||
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['player_args'] != null
|
||||
@@ -90,6 +92,7 @@ class RecVideoItemAppModel {
|
||||
threePoint = json['three_point'] != null
|
||||
? ThreePoint.fromJson(json['three_point'])
|
||||
: null;
|
||||
desc = json['desc'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,11 @@ class Utils {
|
||||
return '${hour > 0 ? "${paddingStr(hour)}:" : ""}${paddingStr(minute)}:${paddingStr(second)}';
|
||||
}
|
||||
|
||||
static String shortenChineseDateString(String date) {
|
||||
if (date.contains("年")) return '${date.split("年").first}年';
|
||||
return date;
|
||||
}
|
||||
|
||||
// 完全相对时间显示
|
||||
static String formatTimestampToRelativeTime(timeStamp) {
|
||||
var difference = DateTime.now()
|
||||
|
||||
Reference in New Issue
Block a user