opt: html page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-24 13:48:57 +08:00
parent 8c7001c801
commit 4d7d9abc60
3 changed files with 617 additions and 629 deletions

View File

@@ -6,19 +6,20 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'network_img_layer.dart'; import 'network_img_layer.dart';
import 'package:html/dom.dart' as dom;
Widget htmlRender({ Widget htmlRender({
required BuildContext context, required BuildContext context,
String? htmlContent, required dom.Element element,
int? imgCount, int? imgCount,
List<String>? imgList, List<String>? imgList,
required double constrainedWidth, required double maxWidth,
Function(List<String>, int)? callback, Function(List<String>, int)? callback,
}) { }) {
debugPrint('htmlRender'); debugPrint('htmlRender');
return SelectionArea( return SelectionArea(
child: Html( child: Html.fromElement(
data: htmlContent, documentElement: element,
onLinkTap: (String? url, Map<String, String> buildContext, attributes) {}, onLinkTap: (String? url, Map<String, String> buildContext, attributes) {},
extensions: [ extensions: [
TagExtension( TagExtension(
@@ -43,7 +44,7 @@ Widget htmlRender({
?.group(1); ?.group(1);
if (clazz?.contains('cut-off') == true || height != null) { if (clazz?.contains('cut-off') == true || height != null) {
return CachedNetworkImage( return CachedNetworkImage(
width: constrainedWidth, width: maxWidth,
height: height != null ? double.parse(height) : null, height: height != null ? double.parse(height) : null,
imageUrl: Utils.thumbnailImgUrl(imgUrl), imageUrl: Utils.thumbnailImgUrl(imgUrl),
fit: BoxFit.contain, fit: BoxFit.contain,
@@ -62,7 +63,7 @@ Widget htmlRender({
} }
}, },
child: NetworkImgLayer( child: NetworkImgLayer(
width: isEmote ? 22 : constrainedWidth, width: isEmote ? 22 : maxWidth,
height: isEmote ? 22 : 200, height: isEmote ? 22 : 200,
src: imgUrl, src: imgUrl,
ignoreHeight: !isEmote, ignoreHeight: !isEmote,
@@ -70,7 +71,7 @@ Widget htmlRender({
), ),
); );
} catch (err) { } catch (err) {
return const SizedBox(); return const SizedBox.shrink();
} }
}, },
), ),

View File

@@ -500,10 +500,4 @@ https://api.bilibili.com/x/v2/reply/reply?oid=$oid&pn=1&ps=20&root=${rpid ?? rep
SmartDialog.showToast(res['msg']); SmartDialog.showToast(res['msg']);
} }
} }
@override
Future onReload() {
scrollController.jumpToTop();
return super.onReload();
}
} }

File diff suppressed because it is too large Load Diff