diff --git a/lib/common/widgets/video_card_h.dart b/lib/common/widgets/video_card_h.dart index 2a1bedf2..a94612e4 100644 --- a/lib/common/widgets/video_card_h.dart +++ b/lib/common/widgets/video_card_h.dart @@ -159,8 +159,11 @@ class VideoContent extends StatelessWidget { Text( videoItem.title as String, textAlign: TextAlign.start, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w500, + fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize, + height: 1.4, + letterSpacing: 0.3, ), maxLines: 2, overflow: TextOverflow.ellipsis, @@ -175,6 +178,8 @@ class VideoContent extends StatelessWidget { text: i['text'] as String, style: TextStyle( fontWeight: FontWeight.w500, + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize, letterSpacing: 0.3, color: i['type'] == 'em' ? Theme.of(context).colorScheme.primary @@ -204,24 +209,19 @@ class VideoContent extends StatelessWidget { // ), // ), // const SizedBox(height: 4), - if (showPubdate) - Text( - Utils.dateFormat(videoItem.pubdate!), - style: TextStyle( - fontSize: 11, color: Theme.of(context).colorScheme.outline), - ), - if (showOwner) - Row( - children: [ - Text( - videoItem.owner.name as String, - style: TextStyle( - fontSize: - Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), + if (showOwner || showPubdate) + Expanded( + flex: 0, + child: Text( + "${showPubdate ? Utils.dateFormat(videoItem.pubdate!, formatType: 'day') + ' ' : ''} ${showOwner ? videoItem.owner.name : ''}", + maxLines: 1, + style: TextStyle( + fontSize: 11, + height: 1, + color: Theme.of(context).colorScheme.outline, + overflow: TextOverflow.fade, ), - ], + ), ), Row( children: [ @@ -237,7 +237,6 @@ class VideoContent extends StatelessWidget { theme: 'gray', danmu: videoItem.stat.danmaku as int, ), - const Spacer(), if (source == 'normal') SizedBox( diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index e0a9434e..a24f9858 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -97,10 +97,20 @@ class Utils { currentYearStr = 'MM-DD hh:mm'; lastYearStr = 'YY-MM-DD hh:mm'; return CustomStamp_str( + timestamp: timeStamp, date: lastYearStr, toInt: false); + } else if (formatType == 'day') { + if (distance <= 43200) { + return CustomStamp_str( timestamp: timeStamp, - date: lastYearStr, - toInt: false, - formatType: formatType); + date: 'hh:mm', + toInt: true, + ); + } + return CustomStamp_str( + timestamp: timeStamp, + date: 'YY-MM-DD', + toInt: true, + ); } if (distance <= 60) { return '刚刚'; @@ -111,25 +121,19 @@ class Utils { } else if (DateTime.fromMillisecondsSinceEpoch(time * 1000).year == DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000).year) { return CustomStamp_str( - timestamp: timeStamp, - date: currentYearStr, - toInt: false, - formatType: formatType); + timestamp: timeStamp, date: currentYearStr, toInt: false); } else { return CustomStamp_str( - timestamp: timeStamp, - date: lastYearStr, - toInt: false, - formatType: formatType); + timestamp: timeStamp, date: lastYearStr, toInt: false); } } // 时间戳转时间 - static String CustomStamp_str( - {int? timestamp, // 为空则显示当前时间 - String? date, // 显示格式,比如:'YY年MM月DD日 hh:mm:ss' - bool toInt = true, // 去除0开头 - String? formatType}) { + static String CustomStamp_str({ + int? timestamp, // 为空则显示当前时间 + String? date, // 显示格式,比如:'YY年MM月DD日 hh:mm:ss' + bool toInt = true, // 去除0开头 + }) { timestamp ??= (DateTime.now().millisecondsSinceEpoch / 1000).round(); String timeStr = (DateTime.fromMillisecondsSinceEpoch(timestamp * 1000)).toString(); @@ -159,10 +163,6 @@ class Utils { return timeStr; } - // if (formatType == 'list' && int.parse(DD) > DateTime.now().day - 2) { - // return '昨天'; - // } - date = date .replaceAll('YY', YY) .replaceAll('MM', MM) @@ -229,7 +229,8 @@ class Utils { if (Platform.isAndroid) { buildNumber = buildNumber.substring(0, buildNumber.length - 1); } - bool isUpdate = Utils.needUpdate("v${currentInfo.version}+$buildNumber", data.tagName!); + bool isUpdate = + Utils.needUpdate("${currentInfo.version}+$buildNumber", data.tagName!); if (isUpdate) { SmartDialog.show( animationType: SmartAnimationType.centerFade_otherSlide, @@ -336,11 +337,13 @@ class Utils { } static String generateRandomString(int minLength, int maxLength) { - const String printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#\$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '; + const String printable = + '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#\$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '; var random = Random(); int length = minLength + random.nextInt(maxLength - minLength + 1); - return List.generate(length, (index) => printable[random.nextInt(printable.length)]).join(); + return List.generate( + length, (index) => printable[random.nextInt(printable.length)]).join(); } static String base64EncodeRandomString(int minLength, int maxLength) {