mod: 推荐、搜索页添加时间,修复视频搜索页无法筛选和回顶
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'stat/danmu.dart';
|
||||
import 'stat/view.dart';
|
||||
import '../../http/dynamics.dart';
|
||||
import '../../http/search.dart';
|
||||
import '../../http/user.dart';
|
||||
@ -322,21 +324,30 @@ class VideoStat extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RichText(
|
||||
maxLines: 1,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: MediaQuery.textScalerOf(context)
|
||||
.scale(Theme.of(context).textTheme.labelSmall!.fontSize!),
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
return Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: videoItem.stat.view as int,
|
||||
),
|
||||
children: [
|
||||
if (videoItem.stat.view != '-')
|
||||
TextSpan(text: '${videoItem.stat.view}观看'),
|
||||
if (videoItem.stat.danmu != '-')
|
||||
TextSpan(text: ' • ${videoItem.stat.danmu}弹幕'),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: videoItem.stat.danmu as int,
|
||||
),
|
||||
const Spacer(),
|
||||
RichText(
|
||||
maxLines: 1,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
text: Utils.formatTimestampToRelativeTime(videoItem.pubdate)
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
keyword: widget.keyword,
|
||||
searchType: widget.searchType,
|
||||
),
|
||||
tag: widget.searchType!.type + widget.keyword!,
|
||||
tag: widget.searchType!.type,
|
||||
);
|
||||
scrollController = _searchPanelController.scrollController;
|
||||
scrollController.addListener(() async {
|
||||
|
@ -35,7 +35,7 @@ class SearchVideoPanel extends StatelessWidget {
|
||||
padding: index == 0
|
||||
? const EdgeInsets.only(top: 2)
|
||||
: EdgeInsets.zero,
|
||||
child: VideoCardH(videoItem: i),
|
||||
child: VideoCardH(videoItem: i, showPubdate: true),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -70,7 +70,7 @@ class SearchVideoPanel extends StatelessWidget {
|
||||
controller.selectedType.value = i['type'];
|
||||
ctr!.order.value =
|
||||
i['type'].toString().split('.').last;
|
||||
SmartDialog.showLoading(msg: 'loooad');
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr!.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
@ -201,7 +201,7 @@ class VideoPanelController extends GetxController {
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(tag: 'video');
|
||||
ctr.duration.value = i['value'];
|
||||
SmartDialog.showLoading(msg: 'loooad');
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
|
@ -28,7 +28,13 @@ class Utils {
|
||||
return tempPath;
|
||||
}
|
||||
|
||||
static String numFormat(int number) {
|
||||
static String numFormat(dynamic number) {
|
||||
if (number == null) {
|
||||
return '0';
|
||||
}
|
||||
if (number is String) {
|
||||
return number;
|
||||
}
|
||||
final String res = (number / 10000).toString();
|
||||
if (int.parse(res.split('.')[0]) >= 1) {
|
||||
return '${(number / 10000).toPrecision(1)}万';
|
||||
@ -58,6 +64,26 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
// 完全相对时间显示
|
||||
static String formatTimestampToRelativeTime(timeStamp) {
|
||||
var difference = DateTime.now()
|
||||
.difference(DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000));
|
||||
|
||||
if (difference.inDays > 365) {
|
||||
return '${difference.inDays ~/ 365}年前';
|
||||
} else if (difference.inDays > 30) {
|
||||
return '${difference.inDays ~/ 30}个月前';
|
||||
} else if (difference.inDays > 0) {
|
||||
return '${difference.inDays}天前';
|
||||
} else if (difference.inHours > 0) {
|
||||
return '${difference.inHours}小时前';
|
||||
} else if (difference.inMinutes > 0) {
|
||||
return '${difference.inMinutes}分钟前';
|
||||
} else {
|
||||
return '刚刚';
|
||||
}
|
||||
}
|
||||
|
||||
// 时间显示,刚刚,x分钟前
|
||||
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
||||
// 当前时间
|
||||
|
Reference in New Issue
Block a user