mod: 限制横版卡片内容高度,避免特定设备显示超出范围,修复更新弹窗

This commit is contained in:
orz12
2024-02-18 17:53:38 +08:00
parent 93df04c84e
commit d5fef6a7d9
2 changed files with 44 additions and 42 deletions

View File

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

View File

@@ -96,11 +96,21 @@ class Utils {
if (formatType == 'detail') {
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, // 为空则显示当前时间
static String CustomStamp_str({
int? timestamp, // 为空则显示当前时间
String? date, // 显示格式,比如:'YY年MM月DD日 hh:mm:ss'
bool toInt = true, // 去除0开头
String? formatType}) {
}) {
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<String>.generate(length, (index) => printable[random.nextInt(printable.length)]).join();
return List<String>.generate(
length, (index) => printable[random.nextInt(printable.length)]).join();
}
static String base64EncodeRandomString(int minLength, int maxLength) {