修复 活动投票百分比显示不正确的问题

修复 活动投票 总数为0时显示溢出的问题
hmxc
张萌 4 years ago
parent 7ee0ed656d
commit ba6e3e51ff

@ -16,6 +16,7 @@ import 'package:akuCommunity/widget/bee_divider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/buttons/bee_single_check.dart';
import 'package:akuCommunity/widget/buttons/bottom_button.dart';
import 'package:velocity_x/velocity_x.dart';
class VotingDetailPage extends StatefulWidget {
final int id;
@ -33,8 +34,8 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
// List<int> _select = [];
int _selectId;
bool _hasVoted = false;
bool get isVoted {
if ((_model.status == 4) || _hasVoted) {
bool get finishVoted {
if ((_model.status == 4) || _hasVoted || (_model.status == 3)) {
return true;
}
return false;
@ -76,16 +77,24 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
);
}
double _getPercent(num numerator, num denominator) {
if (denominator == 0) {
return 0;
} else {
return (numerator / denominator) * 100;
}
}
Widget _buildVoteCard(AppVoteCandidateVos model) {
double _percent = (model.total.toDouble()) / (_model.totals.toDouble());
double _percent = _getPercent(model.total, _model.totals);
return Container(
padding: EdgeInsets.symmetric(vertical: 40.w),
constraints: BoxConstraints(maxHeight: 230.w),
// constraints: BoxConstraints(maxHeight: 230.w),
child: Row(
children: [
Container(
alignment: Alignment.center,
width: 88.w,
width: 58.w,
height: 150.w,
//
// child: BeeCheckBox(
@ -104,7 +113,7 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
//
//
//
child: _model.status == 3 || _model.status == 1
child: finishVoted
? _unCheck()
: GestureDetector(
onTap: () {
@ -139,21 +148,22 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
// 10.w.heightBox,
model.name.text.black.size(32.sp).make(),
33.w.heightBox,
isVoted && _model.status != 3
finishVoted
? Row(
children: [
SizedBox(
width: 280.w,
width: 290.w,
child: LinearProgressIndicator(
value: _percent,
),
),
8.w.widthBox,
'$_percent%'
'${_percent.toStringAsFixed(2)}%'
.text
.color(ktextSubColor)
.size(24.sp)
.make(),
.make()
.expand(),
],
)
: SizedBox()

@ -238,7 +238,8 @@ class _LifePayPageState extends State<LifePayPage> {
controller: _controller,
extraParams: {'estateId': appProvider.selectedHouse.estateId},
convert: (model) {
_selectPay = List.generate(model.tableList.length,
_selectPay = List.generate(
(_selectPay.length ?? 0) + model.tableList.length,
(index) => SelectPay(payCount: 0, payTotal: 0.0));
return model.tableList
.map((e) => LifePayModel.fromJson(e))

@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class LifePayRecordPage extends StatefulWidget {
LifePayRecordPage({Key key}) : super(key: key);
@ -80,7 +81,7 @@ class _LifePayRecordPageState extends State<LifePayRecordPage> {
.bold
.make(),
Spacer(),
'人才智慧社区 ${model.roomName}'
'${S.of(context).tempPlotName} ${model.roomName}'
.text
.size(24.sp)
.color(Color(0xFF999999))

Loading…
Cancel
Save