opt: sys msg

This commit is contained in:
bggRGjQaUbCoE
2024-11-08 19:00:57 +08:00
parent 1fbd324a16
commit 03d405e197
3 changed files with 49 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
import 'package:PiliPalaX/utils/app_scheme.dart';
import 'package:PiliPalaX/utils/id_utils.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/gestures.dart';
@@ -170,11 +171,12 @@ class _SysMsgPageState extends State<SysMsgPage> {
InlineSpan _buildContent(String content) {
final List<InlineSpan> spanChildren = <InlineSpan>[];
RegExp urlRegExp = RegExp(
r'#\{([^}]*)\}\{([^}]*)\}|https?:\/\/[^\s/\$.?#].[^\s]*|www\.[^\s/\$.?#].[^\s]*');
r'#\{([^}]*)\}\{([^}]*)\}|https?:\/\/[^\s/\$.?#].[^\s]*|www\.[^\s/\$.?#].[^\s]*|\【(.*?)\】');
content.splitMapJoin(
urlRegExp,
onMatch: (Match match) {
if (match[0]!.startsWith('#')) {
String matchStr = match[0]!;
if (matchStr.startsWith('#')) {
spanChildren.add(
TextSpan(
text: match[1],
@@ -190,6 +192,37 @@ class _SysMsgPageState extends State<SysMsgPage> {
},
),
);
} else if (matchStr.startsWith('')) {
try {
bool isBV = match[3]?.startsWith('BV') == true;
// validate
if (isBV) {
IdUtils.bv2av(match[3]!);
} else {
IdUtils.av2bv(int.parse(match[3]!));
}
spanChildren.add(TextSpan(text: ''));
spanChildren.add(
TextSpan(
text: match[3],
style: TextStyle(color: Theme.of(context).colorScheme.primary),
recognizer: TapGestureRecognizer()
..onTap = () {
try {
Uri uri = Uri.parse(match[3]!);
PiliScheme.routePush(uri);
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
),
);
spanChildren.add(TextSpan(text: ''));
} catch (e) {
spanChildren.add(
TextSpan(text: match[0]),
);
}
} else {
spanChildren.add(
TextSpan(

View File

@@ -98,13 +98,13 @@ class _StyleSettingState extends State<StyleSetting> {
defaultVal: true,
needReboot: true,
),
const SetSwitchItem(
title: '首页背景渐变',
setKey: SettingBoxKey.enableGradientBg,
leading: Icon(Icons.gradient_outlined),
defaultVal: false,
needReboot: true,
),
// const SetSwitchItem(
// title: '首页背景渐变',
// setKey: SettingBoxKey.enableGradientBg,
// leading: Icon(Icons.gradient_outlined),
// defaultVal: false,
// needReboot: true,
// ),
ListTile(
onTap: () async {
double? result = await showDialog(

View File

@@ -71,13 +71,13 @@ class _VideoSettingState extends State<VideoSetting> {
setKey: SettingBoxKey.enableHA,
defaultVal: true,
),
const SetSwitchItem(
title: '亮度记忆',
subTitle: '返回时自动调整视频亮度',
leading: Icon(Icons.brightness_6_outlined),
setKey: SettingBoxKey.enableAutoBrightness,
defaultVal: true,
),
// const SetSwitchItem(
// title: '亮度记忆',
// subTitle: '返回时自动调整视频亮度',
// leading: Icon(Icons.brightness_6_outlined),
// setKey: SettingBoxKey.enableAutoBrightness,
// defaultVal: true,
// ),
const SetSwitchItem(
title: '免登录1080P',
subTitle: '免登录查看1080P视频',