80 lines
2.1 KiB
Dart
80 lines
2.1 KiB
Dart
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:qhd_prevention/customWidget/ItemWidgetFactory.dart';
|
||
|
import 'package:qhd_prevention/customWidget/single_image_viewer.dart';
|
||
|
import 'package:qhd_prevention/customWidget/toast_util.dart';
|
||
|
import 'package:qhd_prevention/http/ApiService.dart';
|
||
|
import 'package:qhd_prevention/pages/my_appbar.dart';
|
||
|
import 'package:qhd_prevention/tools/tools.dart';
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class DetailImagesPage extends StatefulWidget {
|
||
|
const DetailImagesPage(this.recordItemId, {super.key});
|
||
|
|
||
|
final String recordItemId;
|
||
|
|
||
|
@override
|
||
|
State<DetailImagesPage> createState() => _DetailImagesPageState();
|
||
|
}
|
||
|
|
||
|
|
||
|
class _DetailImagesPageState extends State<DetailImagesPage> {
|
||
|
|
||
|
|
||
|
List<String> detailImageList =[];
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
// TODO: implement initState
|
||
|
super.initState();
|
||
|
_getDetailImageList();
|
||
|
}
|
||
|
|
||
|
Future<void> _getDetailImageList() async {
|
||
|
try {
|
||
|
|
||
|
final result = await ApiService.getDetailImageList(widget.recordItemId);
|
||
|
if (result['result'] == 'success') {
|
||
|
final List<dynamic> newList = result['imgs'] ?? [];
|
||
|
|
||
|
for(int i=0;i<newList.length;i++){
|
||
|
detailImageList.add(newList[i]["FILEPATH"] as String);
|
||
|
}
|
||
|
setState(() {
|
||
|
|
||
|
});
|
||
|
|
||
|
}else{
|
||
|
ToastUtil.showNormal(context, "加载数据失败");
|
||
|
// _showMessage('加载数据失败');
|
||
|
}
|
||
|
} catch (e) {
|
||
|
// 出错时可以 Toast 或者在页面上显示错误状态
|
||
|
print('加载数据失败:$e');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: MyAppbar(title: "图片"),
|
||
|
body: Padding(
|
||
|
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
|
||
|
child: ListItemFactory.createTextImageItem(
|
||
|
text: "图片",
|
||
|
imageUrls: detailImageList,
|
||
|
onImageTapped: (index) {
|
||
|
presentOpaque(
|
||
|
SingleImageViewer(imageUrl:ApiService.baseImgPath + detailImageList[index]),
|
||
|
context,
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|