diff --git a/lib/core/extension/proposal_model_extensions.dart b/lib/core/extension/proposal_model_extensions.dart index 81b1cef4..5a8825a4 100644 --- a/lib/core/extension/proposal_model_extensions.dart +++ b/lib/core/extension/proposal_model_extensions.dart @@ -30,5 +30,8 @@ extension ProposalModelTimeFormatting on ProposalModel { double unityToPercent() => unity==null?0:unity!*.01; double commitmentToPercent() => commitment == null ? 0 : commitment! * .01; bool isExpired() => expiration!.toLocal().isBefore(DateTime.now()); + // TODO(saif): Replace hardcoded values (.2 and .8) with dynamic values fetched from the server. + // These thresholds are relative to each DAO and should be retrieved from the DAO settings. + bool isPassing()=>quorumToPercent()>=.2 && unityToPercent()>=.8; } diff --git a/lib/ui/proposals/details/components/proposal_details_view.dart b/lib/ui/proposals/details/components/proposal_details_view.dart index d70aacce..67003b67 100644 --- a/lib/ui/proposals/details/components/proposal_details_view.dart +++ b/lib/ui/proposals/details/components/proposal_details_view.dart @@ -309,7 +309,7 @@ class _ProposalDetailsViewState extends State { child: ProposalPercentageIndicator( index == 0 ? 'Unity' : 'Quorum', index == 0 ? widget.proposalModel.unityToPercent() : widget.proposalModel.quorumToPercent(), - HyphaColors.success + widget.proposalModel.isPassing()?HyphaColors.success:HyphaColors.error ), ), ), diff --git a/lib/ui/proposals/list/components/hypha_proposals_action_card.dart b/lib/ui/proposals/list/components/hypha_proposals_action_card.dart index 205429cf..e1177347 100644 --- a/lib/ui/proposals/list/components/hypha_proposals_action_card.dart +++ b/lib/ui/proposals/list/components/hypha_proposals_action_card.dart @@ -50,14 +50,17 @@ class HyphaProposalsActionCard extends StatelessWidget { child: ProposalPercentageIndicator( 'Unity', proposalModel.unityToPercent(), - HyphaColors.success + proposalModel.isPassing() + ? HyphaColors.success + : HyphaColors.error, ), ), ProposalPercentageIndicator( - 'Quorum', - proposalModel.quorumToPercent(), - HyphaColors.success - ), + 'Quorum', + proposalModel.quorumToPercent(), + proposalModel.isPassing() + ? HyphaColors.success + : HyphaColors.error), const SizedBox(height: 20), ProposalExpirationTimer( proposalModel.formatExpiration(), @@ -116,7 +119,8 @@ class HyphaProposalsActionCard extends StatelessWidget { ); } - Widget _buildProposalRoleAssignment(BuildContext context, int commitment, String title) { + Widget _buildProposalRoleAssignment( + BuildContext context, int commitment, String title) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -146,12 +150,14 @@ class HyphaProposalsActionCard extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 5), child: Text( text, - style: context.hyphaTextTheme.ralMediumSmallNote.copyWith(color: HyphaColors.midGrey), + style: context.hyphaTextTheme.ralMediumSmallNote + .copyWith(color: HyphaColors.midGrey), ), ); } - Widget _buildProposalCardFooter(BuildContext context, String creatorName, String creatorImageUrl) { + Widget _buildProposalCardFooter( + BuildContext context, String creatorName, String creatorImageUrl) { return Row( children: [ Expanded(child: ProposalCreator(creatorName, creatorImageUrl)),