feat: app端推荐添加时间显示(测试)

This commit is contained in:
orz12
2024-09-08 22:18:06 +08:00
committed by bggRGjQaUbCoE
parent be8b301473
commit a4a1cb1371
3 changed files with 30 additions and 0 deletions

View File

@@ -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),
]
],
);

View File

@@ -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'];
}
}

View File

@@ -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()