fix vote image

hmxc
小赖 4 years ago
parent e3dd5ed9e3
commit 18017af532

@ -15,6 +15,12 @@ class ImgModel {
sort = json['sort'];
}
static String first(List<ImgModel> models) {
if (models == null) return '';
if (models.isEmpty) return '';
return models.first.url ?? '';
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;

@ -9,6 +9,12 @@ class VotingDetailModel {
List<ImgModel> imgUrls;
List<AppVoteCandidateVos> appVoteCandidateVos;
String get firstImage {
if (imgUrls == null) return '';
if (imgUrls.isEmpty) return '';
return imgUrls.first.url ?? '';
}
VotingDetailModel(
{this.id,
this.title,

@ -59,9 +59,11 @@ class _EventVotingPageState extends State<EventVotingPage> {
width: double.infinity,
child: ClipRect(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(
model.imgUrls.isNotEmpty ? model.imgUrls.first.url : '')),
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(
model.imgUrls.isNotEmpty ? model.imgUrls.first.url : ''),
fit: BoxFit.cover,
),
),
),
Padding(

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -122,8 +123,12 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
child: ClipRRect(
borderRadius: BorderRadius.circular(4.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(model.imgUrls.first.url)),
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(
ImgModel.first(model.imgUrls),
),
fit: BoxFit.cover,
),
),
),
30.w.widthBox,
@ -213,15 +218,11 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
children: [
_model.title.text.black.size(32.sp).bold.maxLines(2).make(),
44.w.heightBox,
SizedBox(
width: double.infinity,
height: 228.w,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(_model.imgUrls.first.url),
),
ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(_model.firstImage),
),
),
44.w.heightBox,

@ -169,11 +169,11 @@ class ManagerFunc {
}
static Future<VotingDetailModel> voteDetail(int id) async {
BaseModel baseModel = await NetUtil().get(API.manager.voteDetail,
params: {
'voteId': 1,
},
showMessage: false);
BaseModel baseModel = await NetUtil().get(
API.manager.voteDetail,
params: {'voteId': id},
showMessage: false,
);
return VotingDetailModel.fromJson(baseModel.data);
}

Loading…
Cancel
Save