mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: images showing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// 转发
|
||||
import 'package:PiliPalaX/common/widgets/imageview.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -17,134 +18,24 @@ import 'rich_node_panel.dart';
|
||||
import 'video_panel.dart';
|
||||
|
||||
InlineSpan picsNodes(List<OpusPicsModel> pics) {
|
||||
List<InlineSpan> spanChildren = [];
|
||||
int len = pics.length;
|
||||
List<String> picList = [];
|
||||
|
||||
if (len == 1) {
|
||||
OpusPicsModel pictureItem = pics.first;
|
||||
picList.add(pictureItem.url!);
|
||||
|
||||
/// 图片上方的空白间隔
|
||||
// spanChildren.add(const TextSpan(text: '\n'));
|
||||
spanChildren.add(
|
||||
WidgetSpan(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, BoxConstraints box) {
|
||||
double maxWidth = box.maxWidth.truncateToDouble();
|
||||
double maxHeight = box.maxWidth * 0.6; // 设置最大高度
|
||||
double height = maxWidth *
|
||||
0.5 *
|
||||
(pictureItem.height != null && pictureItem.width != null
|
||||
? pictureItem.height! / pictureItem.width!
|
||||
: 1);
|
||||
return Semantics(
|
||||
label: '图片1,共1张',
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
useSafeArea: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ImagePreview(initialPage: 0, imgList: picList);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
constraints: BoxConstraints(maxHeight: maxHeight),
|
||||
width: box.maxWidth / 2,
|
||||
height: height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: NetworkImgLayer(
|
||||
src: pictureItem.url,
|
||||
width: maxWidth / 2,
|
||||
height: height,
|
||||
),
|
||||
),
|
||||
height > Get.size.height * 0.9
|
||||
? const PBadge(
|
||||
text: '长图',
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
)),
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (len > 1) {
|
||||
List<Widget> list = [];
|
||||
for (var i = 0; i < len; i++) {
|
||||
picList.add(pics[i].url!);
|
||||
list.add(
|
||||
LayoutBuilder(
|
||||
builder: (context, BoxConstraints box) {
|
||||
double maxWidth = box.maxWidth.truncateToDouble();
|
||||
return Semantics(
|
||||
label: '图片${i + 1},共$len张',
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
useSafeArea: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ImagePreview(initialPage: i, imgList: picList);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
src: pics[i].url,
|
||||
width: maxWidth,
|
||||
height: maxWidth,
|
||||
origAspectRatio:
|
||||
pics[i].width!.toInt() / pics[i].height!.toInt(),
|
||||
),
|
||||
));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
spanChildren.add(
|
||||
WidgetSpan(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, BoxConstraints box) {
|
||||
double maxWidth = box.maxWidth.truncateToDouble();
|
||||
double crossCount = len < 3 ? 2 : 3;
|
||||
double height = maxWidth /
|
||||
crossCount *
|
||||
(len % crossCount == 0
|
||||
? len ~/ crossCount
|
||||
: len ~/ crossCount + 1) +
|
||||
6;
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
height: height,
|
||||
child: GridView.count(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisCount: crossCount.toInt(),
|
||||
mainAxisSpacing: 4.0,
|
||||
crossAxisSpacing: 4.0,
|
||||
childAspectRatio: 1,
|
||||
children: list,
|
||||
return WidgetSpan(
|
||||
child: LayoutBuilder(
|
||||
builder: (_, constraints) => image(
|
||||
constraints.maxWidth,
|
||||
pics
|
||||
.map(
|
||||
(item) => ImageModel(
|
||||
width: item.width,
|
||||
height: item.height,
|
||||
url: item.url ?? '',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextSpan(
|
||||
children: spanChildren,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget forWard(item, context, ctr, source, {floor = 1}) {
|
||||
TextStyle authorStyle =
|
||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||
@@ -237,11 +128,12 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
|
||||
return videoSeasonWidget(item, context, 'archive', floor: floor);
|
||||
// 文章
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
return Container(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 10, top: 12, right: 10, bottom: 10),
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||
child: articlePanel(item, context, floor: floor));
|
||||
return articlePanel(item, context, floor: floor);
|
||||
// return Container(
|
||||
// padding:
|
||||
// const EdgeInsets.only(left: 10, top: 12, right: 10, bottom: 10),
|
||||
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||
// child: articlePanel(item, context, floor: floor));
|
||||
// 转发
|
||||
case 'DYNAMIC_TYPE_FORWARD':
|
||||
return InkWell(
|
||||
|
||||
Reference in New Issue
Block a user