|
1 | 1 | import 'package:encointer_wallet/l10n/l10.dart';
|
2 | 2 | import 'package:encointer_wallet/modules/modules.dart';
|
| 3 | +import 'package:encointer_wallet/page-encointer/democracy/widgets/update_proposal_button.dart'; |
3 | 4 | import 'package:encointer_wallet/service/service.dart';
|
4 | 5 | import 'package:flutter/material.dart';
|
5 | 6 | import 'package:intl/intl.dart';
|
@@ -80,17 +81,13 @@ class _ProposalTileState extends State<ProposalTile> {
|
80 | 81 | ListTile(
|
81 | 82 | contentPadding: const EdgeInsets.symmetric(),
|
82 | 83 | leading: Text(widget.proposalId.toString(), style: titleSmall),
|
83 |
| - subtitle: SizedBox( |
84 |
| - // ensure constant height even for missing texts without turnout. |
85 |
| - height: 60, |
86 |
| - child: Column( |
87 |
| - crossAxisAlignment: CrossAxisAlignment.start, |
88 |
| - children: [ |
89 |
| - Text('${l10n.proposalTurnout}: $turnout / $electorateSize'), |
90 |
| - if (turnout != 0) Text(l10n.proposalApprovalThreshold((threshold * 100).toStringAsFixed(2))), |
91 |
| - if (turnout != 0) passingOrFailingText(context, proposal, tally, widget.params), |
92 |
| - ], |
93 |
| - ), |
| 84 | + subtitle: Column( |
| 85 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 86 | + children: [ |
| 87 | + Text('${l10n.proposalTurnout}: $turnout / $electorateSize'), |
| 88 | + if (turnout != 0) Text(l10n.proposalApprovalThreshold((threshold * 100).toStringAsFixed(2))), |
| 89 | + if (turnout != 0) passingOrFailingText(context, proposal, tally, widget.params), |
| 90 | + ], |
94 | 91 | ),
|
95 | 92 | trailing: voteButtonOrProposalStatus(context),
|
96 | 93 | ),
|
@@ -175,18 +172,55 @@ class _ProposalTileState extends State<ProposalTile> {
|
175 | 172 | case Approved:
|
176 | 173 | return Text(l10n.proposalApproved, style: const TextStyle(color: Colors.green));
|
177 | 174 | case Ongoing:
|
| 175 | + final proposalLifetime = Duration(milliseconds: widget.params.proposalLifetime.toInt()); |
| 176 | + if (proposal.isOlderThan(proposalLifetime)) { |
| 177 | + // Proposal lifetime has passed; proposal has expired. |
| 178 | + return SizedBox( |
| 179 | + height: 50, |
| 180 | + width: 60, |
| 181 | + child: UpdateProposalButton( |
| 182 | + proposalId: widget.proposalId, |
| 183 | + onPressed: _updateState, |
| 184 | + ), |
| 185 | + ); |
| 186 | + } else { |
| 187 | + return SizedBox( |
| 188 | + height: 50, |
| 189 | + width: 60, |
| 190 | + child: VoteButton( |
| 191 | + proposal: proposal, |
| 192 | + proposalId: widget.proposalId, |
| 193 | + purposeId: widget.purposeId, |
| 194 | + democracyParams: widget.params, |
| 195 | + onPressed: _updateState, |
| 196 | + ), |
| 197 | + ); |
| 198 | + } |
178 | 199 | case Confirming:
|
179 |
| - return SizedBox( |
180 |
| - height: 50, |
181 |
| - width: 60, |
182 |
| - child: VoteButton( |
183 |
| - proposal: proposal, |
184 |
| - proposalId: widget.proposalId, |
185 |
| - purposeId: widget.purposeId, |
186 |
| - democracyParams: widget.params, |
187 |
| - onPressed: _updateState, |
188 |
| - ), |
189 |
| - ); |
| 200 | + final confirmDuration = Duration(milliseconds: widget.params.confirmationPeriod.toInt()); |
| 201 | + if (proposal.isConfirmingLongerThan(confirmDuration)!) { |
| 202 | + // confirmation time has passed |
| 203 | + return SizedBox( |
| 204 | + height: 50, |
| 205 | + width: 60, |
| 206 | + child: UpdateProposalButton( |
| 207 | + proposalId: widget.proposalId, |
| 208 | + onPressed: _updateState, |
| 209 | + ), |
| 210 | + ); |
| 211 | + } else { |
| 212 | + return SizedBox( |
| 213 | + height: 50, |
| 214 | + width: 60, |
| 215 | + child: VoteButton( |
| 216 | + proposal: proposal, |
| 217 | + proposalId: widget.proposalId, |
| 218 | + purposeId: widget.purposeId, |
| 219 | + democracyParams: widget.params, |
| 220 | + onPressed: _updateState, |
| 221 | + ), |
| 222 | + ); |
| 223 | + } |
190 | 224 | default:
|
191 | 225 | // should never happen.
|
192 | 226 | return const Text('Unknown Proposal State');
|
|
0 commit comments