mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: article content
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -11,6 +11,7 @@ Widget articleContent({
|
|||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required List<ArticleContentModel> list,
|
required List<ArticleContentModel> list,
|
||||||
Function(List<String>, int)? callback,
|
Function(List<String>, int)? callback,
|
||||||
|
required double maxWidth,
|
||||||
}) {
|
}) {
|
||||||
List<String>? imgList = list
|
List<String>? imgList = list
|
||||||
.where((item) => item.pic != null)
|
.where((item) => item.pic != null)
|
||||||
@@ -57,31 +58,28 @@ Widget articleContent({
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (item.pic != null) {
|
} else if (item.pic != null) {
|
||||||
return LayoutBuilder(
|
return Hero(
|
||||||
builder: (context, constraints) => Hero(
|
tag: item.pic!.pics!.first.url!,
|
||||||
tag: item.pic!.pics!.first.url!,
|
child: GestureDetector(
|
||||||
child: GestureDetector(
|
onTap: () {
|
||||||
onTap: () {
|
if (callback != null) {
|
||||||
if (callback != null) {
|
callback(
|
||||||
callback(
|
imgList,
|
||||||
imgList,
|
imgList.indexOf(item.pic!.pics!.first.url!),
|
||||||
imgList.indexOf(item.pic!.pics!.first.url!),
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
context.imageView(
|
||||||
context.imageView(
|
initialPage: imgList.indexOf(item.pic!.pics!.first.url!),
|
||||||
initialPage: imgList.indexOf(item.pic!.pics!.first.url!),
|
imgList: imgList.map((url) => SourceModel(url: url)).toList(),
|
||||||
imgList:
|
);
|
||||||
imgList.map((url) => SourceModel(url: url)).toList(),
|
}
|
||||||
);
|
},
|
||||||
}
|
child: NetworkImgLayer(
|
||||||
},
|
width: maxWidth,
|
||||||
child: NetworkImgLayer(
|
height: maxWidth *
|
||||||
width: constraints.maxWidth,
|
item.pic!.pics!.first.height! /
|
||||||
height: constraints.maxWidth *
|
item.pic!.pics!.first.width!,
|
||||||
item.pic!.pics!.first.height! /
|
src: item.pic!.pics!.first.url,
|
||||||
item.pic!.pics!.first.width!,
|
|
||||||
src: item.pic!.pics!.first.url,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -564,14 +564,17 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget get _buildContent => SliverPadding(
|
Widget get _buildContent => SliverPadding(
|
||||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _htmlRenderCtr.loaded.value
|
() => _htmlRenderCtr.loaded.value
|
||||||
? _htmlRenderCtr.response['isJsonContent'] == true
|
? _htmlRenderCtr.response['isJsonContent'] == true
|
||||||
? articleContent(
|
? LayoutBuilder(
|
||||||
context: context,
|
builder: (context, constraints) => articleContent(
|
||||||
list: _htmlRenderCtr.response['content'],
|
context: context,
|
||||||
callback: _getImageCallback,
|
list: _htmlRenderCtr.response['content'],
|
||||||
|
callback: _getImageCallback,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: SliverToBoxAdapter(
|
: SliverToBoxAdapter(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
@@ -583,9 +586,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: SliverToBoxAdapter(
|
: SliverToBoxAdapter(child: const SizedBox()),
|
||||||
child: const SizedBox(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user