mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-22 11:41:09 +08:00
@@ -1,16 +1,24 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/models_new/article/article_view/ops.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/vote.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/image_utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ArticleOpus extends StatelessWidget {
|
||||
const ArticleOpus({super.key, required List<ArticleOps>? ops}) : _ops = ops;
|
||||
const ArticleOpus({
|
||||
super.key,
|
||||
required List<ArticleOps>? ops,
|
||||
required this.maxWidth,
|
||||
}) : _ops = ops;
|
||||
|
||||
final List<ArticleOps>? _ops;
|
||||
final double maxWidth;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -29,6 +37,13 @@ class ArticleOpus extends StatelessWidget {
|
||||
case Insert(:final card):
|
||||
if (card != null) {
|
||||
if (card.url?.isNotEmpty == true) {
|
||||
double? width = card.width == null
|
||||
? null
|
||||
: math.min(maxWidth, card.width!);
|
||||
final height = width == null || card.height == null
|
||||
? null
|
||||
: width * card.height! / card.width!;
|
||||
width ??= maxWidth;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
switch (item.attributes?.clazz) {
|
||||
@@ -55,6 +70,9 @@ class ArticleOpus extends StatelessWidget {
|
||||
child: ClipRRect(
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: CachedNetworkImage(
|
||||
width: width,
|
||||
height: height,
|
||||
memCacheWidth: width.cacheSize(context),
|
||||
imageUrl: ImageUtils.thumbnailUrl(card.url, 60),
|
||||
placeholder: (_, _) => const SizedBox.shrink(),
|
||||
),
|
||||
|
||||
@@ -41,13 +41,14 @@ Widget htmlRender({
|
||||
if (clazz?.contains('cut-off') == true || height != null) {
|
||||
return CachedNetworkImage(
|
||||
width: maxWidth,
|
||||
memCacheWidth: maxWidth.cacheSize(context),
|
||||
height: height != null ? double.parse(height) : null,
|
||||
imageUrl: ImageUtils.thumbnailUrl(imgUrl),
|
||||
fit: BoxFit.contain,
|
||||
placeholder: (_, _) => const SizedBox.shrink(),
|
||||
);
|
||||
}
|
||||
final size = isEmote ? 22.0 : null;
|
||||
final width = isEmote ? 22.0 : maxWidth;
|
||||
return GestureDetector(
|
||||
onTap: () => PageUtils.imageView(
|
||||
imgList: [SourceModel(url: imgUrl)],
|
||||
@@ -56,9 +57,9 @@ Widget htmlRender({
|
||||
child: Hero(
|
||||
tag: imgUrl,
|
||||
child: CachedNetworkImage(
|
||||
width: size,
|
||||
height: size,
|
||||
memCacheWidth: size?.cacheSize(context),
|
||||
width: width,
|
||||
height: isEmote ? 22.0 : null,
|
||||
memCacheWidth: width.cacheSize(context),
|
||||
imageUrl: ImageUtils.thumbnailUrl(imgUrl, 60),
|
||||
fadeInDuration: const Duration(milliseconds: 120),
|
||||
fadeOutDuration: const Duration(milliseconds: 120),
|
||||
|
||||
@@ -215,12 +215,13 @@ class OpusContent extends StatelessWidget {
|
||||
case 2 when (element.pic != null):
|
||||
if (element.pic!.pics!.length == 1) {
|
||||
final pic = element.pic!.pics!.first;
|
||||
final width = pic.width == null
|
||||
double? width = pic.width == null
|
||||
? null
|
||||
: math.min(maxWidth, pic.width!);
|
||||
final height = width == null || pic.height == null
|
||||
? null
|
||||
: width * pic.height! / pic.width!;
|
||||
width ??= maxWidth;
|
||||
return GestureDetector(
|
||||
onTap: () => PageUtils.imageView(
|
||||
imgList: [SourceModel(url: pic.url!)],
|
||||
@@ -232,7 +233,7 @@ class OpusContent extends StatelessWidget {
|
||||
child: CachedNetworkImage(
|
||||
width: width,
|
||||
height: height,
|
||||
memCacheWidth: width?.cacheSize(context),
|
||||
memCacheWidth: width.cacheSize(context),
|
||||
imageUrl: ImageUtils.thumbnailUrl(pic.url!, 60),
|
||||
fadeInDuration: const Duration(milliseconds: 120),
|
||||
fadeOutDuration: const Duration(milliseconds: 120),
|
||||
@@ -259,10 +260,10 @@ class OpusContent extends StatelessWidget {
|
||||
case 3 when (element.line != null):
|
||||
final height = element.line!.pic!.height?.toDouble();
|
||||
return CachedNetworkImage(
|
||||
width: maxWidth,
|
||||
fit: BoxFit.contain,
|
||||
fit: .contain,
|
||||
height: height,
|
||||
memCacheHeight: height?.cacheSize(context),
|
||||
width: maxWidth,
|
||||
memCacheWidth: maxWidth.cacheSize(context),
|
||||
imageUrl: ImageUtils.thumbnailUrl(element.line!.pic!.url!),
|
||||
placeholder: (_, _) => const SizedBox.shrink(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user