Merge branch 'design' into alpha

This commit is contained in:
guozhigq
2023-09-20 23:53:57 +08:00
5 changed files with 73 additions and 5 deletions

View File

@ -14,6 +14,7 @@ class RcmdController extends GetxController {
Box recVideo = GStrorage.recVideo;
Box setting = GStrorage.setting;
RxInt crossAxisCount = 2.obs;
late bool enableSaveLastData;
@override
void onInit() {
@ -28,6 +29,8 @@ class RcmdController extends GetxController {
}
videoList.value = list;
}
enableSaveLastData =
setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
}
// 获取推荐
@ -49,7 +52,11 @@ class RcmdController extends GetxController {
videoList.value = res['data'];
}
} else if (type == 'onRefresh') {
videoList.value = res['data'];
if (enableSaveLastData) {
videoList.insertAll(0, res['data']);
} else {
videoList.value = res['data'];
}
} else if (type == 'onLoad') {
videoList.addAll(res['data']);
}

View File

@ -79,6 +79,12 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableWordRe,
defaultVal: false,
),
const SetSwitchItem(
title: '首页推荐刷新',
subTitle: '下拉刷新时保留上次内容',
setKey: SettingBoxKey.enableSaveLastData,
defaultVal: false,
),
ListTile(
dense: false,
title: Text('评论展示', style: titleStyle),

View File

@ -1,5 +1,6 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
@ -129,7 +130,50 @@ class IntroDetail extends StatelessWidget {
final currentDesc = descV2[index];
switch (currentDesc.type) {
case 1:
return TextSpan(text: currentDesc.rawText);
List<InlineSpan> spanChildren = [];
RegExp urlRegExp = RegExp(r'https?://\S+\b');
Iterable<Match> matches = urlRegExp.allMatches(currentDesc.rawText);
int previousEndIndex = 0;
for (Match match in matches) {
if (match.start > previousEndIndex) {
spanChildren.add(TextSpan(
text: currentDesc.rawText
.substring(previousEndIndex, match.start)));
}
spanChildren.add(
TextSpan(
text: match.group(0),
style: TextStyle(
color: Theme.of(context).colorScheme.primary), // 设置颜色为蓝色
recognizer: TapGestureRecognizer()
..onTap = () {
// 处理点击事件
try {
Get.toNamed(
'/webview',
parameters: {
'url': match.group(0)!,
'type': 'url',
'pageTitle': match.group(0)!,
},
);
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
),
);
previousEndIndex = match.end;
}
if (previousEndIndex < currentDesc.rawText.length) {
spanChildren.add(TextSpan(
text: currentDesc.rawText.substring(previousEndIndex)));
}
TextSpan result = TextSpan(children: spanChildren);
return result;
case 2:
final colorSchemePrimary = Theme.of(context).colorScheme.primary;
final heroTag = Utils.makeHeroTag(currentDesc.bizId);

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';
import 'controller.dart';
import 'package:webview_flutter/webview_flutter.dart';
@ -24,11 +25,20 @@ class _WebviewPageState extends State<WebviewPage> {
style: Theme.of(context).textTheme.titleMedium,
),
actions: [
TextButton(
const SizedBox(width: 4),
IconButton(
onPressed: () {
_webviewController.controller.reload();
},
child: const Text('刷新'),
icon: Icon(Icons.refresh_outlined,
color: Theme.of(context).colorScheme.primary),
),
IconButton(
onPressed: () {
launchUrl(Uri.parse(_webviewController.url));
},
icon: Icon(Icons.open_in_browser_outlined,
color: Theme.of(context).colorScheme.primary),
),
Obx(
() => _webviewController.type.value == 'login'
@ -38,7 +48,7 @@ class _WebviewPageState extends State<WebviewPage> {
)
: const SizedBox(),
),
const SizedBox(width: 10)
const SizedBox(width: 12)
],
),
body: Column(

View File

@ -121,6 +121,7 @@ class SettingBoxKey {
static const String enableWordRe = 'enableWordRe';
static const String enableSearchWord = 'enableSearchWord';
static const String enableRcmdDynamic = 'enableRcmdDynamic';
static const String enableSaveLastData = 'enableSaveLastData';
/// 外观
static const String themeMode = 'themeMode';