mod: 动态长图
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
// 内容
|
// 内容
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pilipala/common/widgets/badge.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
import 'package:pilipala/pages/preview/index.dart';
|
import 'package:pilipala/pages/preview/index.dart';
|
||||||
@ -49,6 +50,12 @@ class _ContentState extends State<Content> {
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, BoxConstraints box) {
|
builder: (context, BoxConstraints box) {
|
||||||
double maxWidth = box.maxWidth.truncateToDouble();
|
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 GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
@ -59,18 +66,29 @@ class _ContentState extends State<Content> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(top: 4),
|
padding: const EdgeInsets.only(top: 4),
|
||||||
child: NetworkImgLayer(
|
constraints: BoxConstraints(maxHeight: maxHeight),
|
||||||
src: pictureItem.url,
|
width: box.maxWidth / 2,
|
||||||
width: maxWidth / 2,
|
height: height,
|
||||||
height: maxWidth *
|
child: Stack(
|
||||||
0.5 *
|
children: [
|
||||||
(pictureItem.height != null && pictureItem.width != null
|
Positioned.fill(
|
||||||
? pictureItem.height! / pictureItem.width!
|
child: NetworkImgLayer(
|
||||||
: 1),
|
src: pictureItem.url,
|
||||||
),
|
width: maxWidth / 2,
|
||||||
),
|
height: height,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
height > maxHeight
|
||||||
|
? const PBadge(
|
||||||
|
text: '长图',
|
||||||
|
right: 8,
|
||||||
|
bottom: 8,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
],
|
||||||
|
)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -850,13 +850,12 @@ InlineSpan buildContent(
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints box) {
|
builder: (BuildContext context, BoxConstraints box) {
|
||||||
double maxHeight = box.maxWidth * 0.6; // 设置最大高度
|
double maxHeight = box.maxWidth * 0.6; // 设置最大高度
|
||||||
double width = (box.maxWidth / 2).truncateToDouble();
|
// double width = (box.maxWidth / 2).truncateToDouble();
|
||||||
double height = ((box.maxWidth /
|
double height = ((box.maxWidth /
|
||||||
2 *
|
2 *
|
||||||
pictureItem['img_height'] /
|
pictureItem['img_height'] /
|
||||||
pictureItem['img_width']))
|
pictureItem['img_width']))
|
||||||
.truncateToDouble();
|
.truncateToDouble();
|
||||||
print('width: $width, height: $height');
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
|
|||||||
Reference in New Issue
Block a user