Merge pull request #458 from orz12/mod-add-time-in-rcmd-and-search
mod: 搜索和推荐页增加时间
This commit is contained in:
@ -3,7 +3,7 @@ import 'package:pilipala/utils/utils.dart';
|
|||||||
|
|
||||||
class StatDanMu extends StatelessWidget {
|
class StatDanMu extends StatelessWidget {
|
||||||
final String? theme;
|
final String? theme;
|
||||||
final int? danmu;
|
final dynamic danmu;
|
||||||
final String? size;
|
final String? size;
|
||||||
|
|
||||||
const StatDanMu({Key? key, this.theme, this.danmu, this.size})
|
const StatDanMu({Key? key, this.theme, this.danmu, this.size})
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import 'package:pilipala/utils/utils.dart';
|
|||||||
|
|
||||||
class StatView extends StatelessWidget {
|
class StatView extends StatelessWidget {
|
||||||
final String? theme;
|
final String? theme;
|
||||||
final int? view;
|
final dynamic view;
|
||||||
final String? size;
|
final String? size;
|
||||||
|
|
||||||
const StatView({Key? key, this.theme, this.view, this.size})
|
const StatView({Key? key, this.theme, this.view, this.size})
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import '../../models/model_rec_video_item.dart';
|
||||||
|
import 'stat/danmu.dart';
|
||||||
|
import 'stat/view.dart';
|
||||||
import '../../http/dynamics.dart';
|
import '../../http/dynamics.dart';
|
||||||
import '../../http/search.dart';
|
import '../../http/search.dart';
|
||||||
import '../../http/user.dart';
|
import '../../http/user.dart';
|
||||||
@ -322,19 +325,31 @@ class VideoStat extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RichText(
|
return Row(
|
||||||
|
children: [
|
||||||
|
StatView(
|
||||||
|
theme: 'gray',
|
||||||
|
view: videoItem.stat.view,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
StatDanMu(
|
||||||
|
theme: 'gray',
|
||||||
|
danmu: videoItem.stat.danmu,
|
||||||
|
),
|
||||||
|
if (videoItem is RecVideoItemModel) ...<Widget>[
|
||||||
|
const Spacer(),
|
||||||
|
RichText(
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: MediaQuery.textScalerOf(context)
|
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||||
.scale(Theme.of(context).textTheme.labelSmall!.fontSize!),
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
children: [
|
text: Utils.formatTimestampToRelativeTime(videoItem.pubdate)),
|
||||||
TextSpan(text: '${Utils.numFormat(videoItem.stat.view)}观看'),
|
|
||||||
TextSpan(text: ' • ${Utils.numFormat(videoItem.stat.danmu)}弹幕'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
]
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class SearchVideoPanel extends StatelessWidget {
|
|||||||
padding: index == 0
|
padding: index == 0
|
||||||
? const EdgeInsets.only(top: 2)
|
? const EdgeInsets.only(top: 2)
|
||||||
: EdgeInsets.zero,
|
: 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'];
|
controller.selectedType.value = i['type'];
|
||||||
ctr!.order.value =
|
ctr!.order.value =
|
||||||
i['type'].toString().split('.').last;
|
i['type'].toString().split('.').last;
|
||||||
SmartDialog.showLoading(msg: 'loooad');
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
await ctr!.onRefresh();
|
await ctr!.onRefresh();
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
},
|
||||||
@ -202,7 +202,7 @@ class VideoPanelController extends GetxController {
|
|||||||
Get.find<SearchPanelController>(
|
Get.find<SearchPanelController>(
|
||||||
tag: 'video${searchPanelCtr.keyword!}');
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
ctr.duration.value = i['value'];
|
ctr.duration.value = i['value'];
|
||||||
SmartDialog.showLoading(msg: 'loooad');
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
await ctr.onRefresh();
|
await ctr.onRefresh();
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String numFormat(dynamic number) {
|
static String numFormat(dynamic number) {
|
||||||
if (number == null){
|
if (number == null) {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
if (number is String) {
|
if (number is String) {
|
||||||
@ -63,6 +63,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分钟前
|
// 时间显示,刚刚,x分钟前
|
||||||
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
||||||
// 当前时间
|
// 当前时间
|
||||||
|
|||||||
Reference in New Issue
Block a user