feat: read专栏内容渲染

This commit is contained in:
guozhigq
2024-09-26 23:45:58 +08:00
parent 1ed098fd81
commit 71566ba064
13 changed files with 856 additions and 60 deletions

View File

@ -1,6 +1,9 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:pilipala/plugin/pl_gallery/hero_dialog_route.dart';
import 'package:pilipala/plugin/pl_gallery/interactiveviewer_gallery.dart';
import 'network_img_layer.dart';
// ignore: must_be_immutable
@ -44,20 +47,52 @@ class HtmlRender extends StatelessWidget {
if (isMall) {
return const SizedBox();
}
// bool inTable =
// extensionContext.element!.previousElementSibling == null ||
// extensionContext.element!.nextElementSibling == null;
// imgUrl = Utils().imageUrl(imgUrl!);
// return Image.network(
// imgUrl,
// width: isEmote ? 22 : null,
// height: isEmote ? 22 : null,
// );
return NetworkImgLayer(
width: isEmote ? 22 : Get.size.width - 24,
height: isEmote ? 22 : 200,
src: imgUrl,
return InkWell(
onTap: () {
Navigator.of(context).push(
HeroDialogRoute<void>(
builder: (BuildContext context) =>
InteractiveviewerGallery(
sources: imgList ?? [imgUrl],
initIndex: imgList?.indexOf(imgUrl) ?? 0,
itemBuilder: (
BuildContext context,
int index,
bool isFocus,
bool enablePageView,
) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (enablePageView) {
Navigator.of(context).pop();
}
},
child: Center(
child: Hero(
tag: imgUrl,
child: CachedNetworkImage(
fadeInDuration:
const Duration(milliseconds: 0),
imageUrl: imgUrl,
fit: BoxFit.contain,
),
),
),
);
},
onPageChanged: (int pageIndex) {},
),
),
);
},
child: CachedNetworkImage(imageUrl: imgUrl),
);
// return NetworkImgLayer(
// width: isEmote ? 22 : Get.size.width - 24,
// height: isEmote ? 22 : 200,
// src: imgUrl,
// );
} catch (err) {
return const SizedBox();
}
@ -66,7 +101,7 @@ class HtmlRender extends StatelessWidget {
],
style: {
'html': Style(
fontSize: FontSize.medium,
fontSize: FontSize.large,
lineHeight: LineHeight.percent(140),
),
'body': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
@ -78,7 +113,7 @@ class HtmlRender extends StatelessWidget {
margin: Margins.only(bottom: 10),
),
'span': Style(
fontSize: FontSize.medium,
fontSize: FontSize.large,
height: Height(1.65),
),
'div': Style(height: Height.auto()),