From 5260a7b4ff4e694f12f8a1b044336cf71b0d2d70 Mon Sep 17 00:00:00 2001 From: Saif Nbet Date: Tue, 24 Sep 2024 18:05:49 +0100 Subject: [PATCH 1/4] feat: Implement proposal history section ui --- .../hypha_proposal_history_card.dart | 51 ++++++++++++ .../list/components/proposals_view.dart | 78 +++++++++++++++---- 2 files changed, 113 insertions(+), 16 deletions(-) create mode 100644 lib/ui/proposals/list/components/hypha_proposal_history_card.dart diff --git a/lib/ui/proposals/list/components/hypha_proposal_history_card.dart b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart new file mode 100644 index 00000000..b61368f1 --- /dev/null +++ b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; +import 'package:hypha_wallet/design/dao_image.dart'; +import 'package:hypha_wallet/design/hypha_card.dart'; +import 'package:hypha_wallet/design/hypha_colors.dart'; +import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; + +class HyphaProposalHistoryCard extends StatelessWidget { + final DaoData? dao; + final String? title; + final String? subTitle; + + const HyphaProposalHistoryCard( + {this.dao, this.title, this.subTitle, super.key}); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () {}, + child: HyphaCard( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20), + child: Row( + children: [ + if (dao != null) DaoImage(dao), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title ?? dao!.settingsDaoTitle, + style: context.hyphaTextTheme.smallTitles, + ), + if (subTitle != null) + Text( + subTitle!, + style: context.hyphaTextTheme.ralMediumBody + .copyWith(color: HyphaColors.midGrey), + ), + ], + ), + const Spacer(), + const Icon(Icons.arrow_forward_ios) + ], + ), + )), + ); + } +} diff --git a/lib/ui/proposals/list/components/proposals_view.dart b/lib/ui/proposals/list/components/proposals_view.dart index 215fbc2b..3ad8da85 100644 --- a/lib/ui/proposals/list/components/proposals_view.dart +++ b/lib/ui/proposals/list/components/proposals_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart' as GetX; +import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; import 'package:hypha_wallet/design/avatar_image/hypha_avatar_image.dart'; import 'package:hypha_wallet/design/background/hypha_page_background.dart'; import 'package:hypha_wallet/design/hypha_colors.dart'; @@ -8,8 +9,8 @@ import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.d import 'package:hypha_wallet/ui/blocs/authentication/authentication_bloc.dart'; import 'package:hypha_wallet/ui/profile/profile_page.dart'; import 'package:hypha_wallet/ui/proposals/filter/filter_proposals_page.dart'; -import 'package:hypha_wallet/ui/proposals/filter/interactor/filter_proposals_bloc.dart'; import 'package:hypha_wallet/ui/proposals/filter/interactor/filter_status.dart'; +import 'package:hypha_wallet/ui/proposals/list/components/hypha_proposal_history_card.dart'; import 'package:hypha_wallet/ui/proposals/list/components/hypha_proposals_action_card.dart'; import 'package:hypha_wallet/ui/proposals/list/interactor/proposals_bloc.dart'; import 'package:hypha_wallet/ui/shared/hypha_body_widget.dart'; @@ -21,6 +22,7 @@ class ProposalsView extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { + print(state.proposals[0].dao); return HyphaPageBackground( backgroundTexture: 'assets/images/graphics/wallet_background.png', withOpacity: false, @@ -101,16 +103,62 @@ class ProposalsView extends StatelessWidget { height: 20, ), Expanded( - child: ListView.separated( - padding: const EdgeInsets.only(bottom: 22), - itemBuilder: (BuildContext context, - int index) => - HyphaProposalsActionCard(state.proposals[index]), - separatorBuilder: - (BuildContext context, int index) { - return const SizedBox(height: 16); - }, - itemCount: state.proposals.length)), + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ListView.separated( + physics: + const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: + const EdgeInsets.only(bottom: 22), + itemBuilder: + (BuildContext context, int index) => + HyphaProposalsActionCard( + state.proposals[index]), + separatorBuilder: + (BuildContext context, int index) { + return const SizedBox(height: 16); + }, + itemCount: state.proposals.length), + const SizedBox( + height: 30, + ), + Text( + 'See Proposals History', + style: context.hyphaTextTheme.ralMediumBody + .copyWith(color: HyphaColors.midGrey), + ), + ...List.generate( + 2, + (index) { + return Container( + margin: const EdgeInsets.symmetric( + vertical: 10), + child: const HyphaProposalHistoryCard( + dao: DaoData( + docId: 67176, + detailsDaoName: 't4rcvben2fe4', + settingsDaoTitle: + 'Think-it Collective', + logoIPFSHash: + 'QmVB8q28U1bjfi51reQMaU7XwP4FThWj39DrU5G8MriMS9', + logoType: 'png', + settingsDaoUrl: + 'think-it-collective'), + subTitle: '1,234 Past Proposals', + )); + }, + ), + const SizedBox( + height: 90, + ) + ], + ), + ), + ), ], ), ), @@ -118,13 +166,11 @@ class ProposalsView extends StatelessWidget { )), floatingActionButton: IconButton( onPressed: () { - GetX.Get.to( - () => const FilterProposalsPage(), - transition: GetX.Transition.leftToRight - ); + GetX.Get.to(() => const FilterProposalsPage(), + transition: GetX.Transition.leftToRight); }, icon: const CircleAvatar( - radius: 30, + radius: 25, backgroundImage: AssetImage( 'assets/images/graphics/wallet_background.png'), child: Icon(Icons.filter_alt_outlined, From ec202ebdf204cf57e5004532ed78298f37d8559d Mon Sep 17 00:00:00 2001 From: Saif Nbet Date: Tue, 24 Sep 2024 18:10:15 +0100 Subject: [PATCH 2/4] chore: remove unnecessary fields and conditions --- .../hypha_proposal_history_card.dart | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/ui/proposals/list/components/hypha_proposal_history_card.dart b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart index b61368f1..57d55616 100644 --- a/lib/ui/proposals/list/components/hypha_proposal_history_card.dart +++ b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart @@ -6,12 +6,11 @@ import 'package:hypha_wallet/design/hypha_colors.dart'; import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; class HyphaProposalHistoryCard extends StatelessWidget { - final DaoData? dao; - final String? title; - final String? subTitle; + final DaoData dao; + final String subTitle; const HyphaProposalHistoryCard( - {this.dao, this.title, this.subTitle, super.key}); + {required this.dao, required this.subTitle, super.key}); @override Widget build(BuildContext context) { @@ -22,7 +21,7 @@ class HyphaProposalHistoryCard extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20), child: Row( children: [ - if (dao != null) DaoImage(dao), + DaoImage(dao), const SizedBox( width: 10, ), @@ -30,15 +29,14 @@ class HyphaProposalHistoryCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - title ?? dao!.settingsDaoTitle, + dao.settingsDaoTitle, style: context.hyphaTextTheme.smallTitles, ), - if (subTitle != null) - Text( - subTitle!, - style: context.hyphaTextTheme.ralMediumBody - .copyWith(color: HyphaColors.midGrey), - ), + Text( + subTitle, + style: context.hyphaTextTheme.ralMediumBody + .copyWith(color: HyphaColors.midGrey), + ), ], ), const Spacer(), From 3cbc6596c2d3d98d8813dd7b7132c31654a3fe52 Mon Sep 17 00:00:00 2001 From: Saif Nbet Date: Tue, 24 Sep 2024 18:26:12 +0100 Subject: [PATCH 3/4] chore: remove unnecessary line --- lib/ui/proposals/list/components/proposals_view.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ui/proposals/list/components/proposals_view.dart b/lib/ui/proposals/list/components/proposals_view.dart index 3ad8da85..20ce7628 100644 --- a/lib/ui/proposals/list/components/proposals_view.dart +++ b/lib/ui/proposals/list/components/proposals_view.dart @@ -22,7 +22,6 @@ class ProposalsView extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - print(state.proposals[0].dao); return HyphaPageBackground( backgroundTexture: 'assets/images/graphics/wallet_background.png', withOpacity: false, From 1649f612b64b32f335464f9dec28e7d2f446546c Mon Sep 17 00:00:00 2001 From: Saif Nbet Date: Mon, 30 Sep 2024 09:56:37 +0100 Subject: [PATCH 4/4] Resolve merge conflicts --- .../proposals/components/proposals_list.dart | 8 ++- .../hypha_proposal_history_card.dart | 7 ++- .../list/components/proposals_view.dart | 50 ++++--------------- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/lib/ui/proposals/components/proposals_list.dart b/lib/ui/proposals/components/proposals_list.dart index d85ed627..115c8649 100644 --- a/lib/ui/proposals/components/proposals_list.dart +++ b/lib/ui/proposals/components/proposals_list.dart @@ -4,14 +4,18 @@ import 'package:hypha_wallet/ui/proposals/list/components/hypha_proposals_action class ProposalsList extends StatelessWidget { final List proposals; + final bool isScrollable; - const ProposalsList(this.proposals, {super.key}); + const ProposalsList(this.proposals, {this.isScrollable = true, super.key}); @override Widget build(BuildContext context) { return ListView.separated( + physics: isScrollable?const BouncingScrollPhysics():const NeverScrollableScrollPhysics(), + shrinkWrap: true, padding: const EdgeInsets.only(bottom: 22), - itemBuilder: (BuildContext context, int index) => HyphaProposalsActionCard(proposals[index]), + itemBuilder: (BuildContext context, int index) => + HyphaProposalsActionCard(proposals[index]), separatorBuilder: (BuildContext context, int index) { return const SizedBox(height: 16); }, diff --git a/lib/ui/proposals/list/components/hypha_proposal_history_card.dart b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart index 57d55616..c17cbf21 100644 --- a/lib/ui/proposals/list/components/hypha_proposal_history_card.dart +++ b/lib/ui/proposals/list/components/hypha_proposal_history_card.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:get/get.dart' as GetX; import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; import 'package:hypha_wallet/design/dao_image.dart'; import 'package:hypha_wallet/design/hypha_card.dart'; import 'package:hypha_wallet/design/hypha_colors.dart'; import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; +import 'package:hypha_wallet/ui/proposals/history/proposals_history_page.dart'; class HyphaProposalHistoryCard extends StatelessWidget { final DaoData dao; @@ -15,7 +17,10 @@ class HyphaProposalHistoryCard extends StatelessWidget { @override Widget build(BuildContext context) { return GestureDetector( - onTap: () {}, + onTap: () { + GetX.Get.to(() => ProposalsHistoryPage(dao), + transition: GetX.Transition.leftToRight); + }, child: HyphaCard( child: Padding( padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20), diff --git a/lib/ui/proposals/list/components/proposals_view.dart b/lib/ui/proposals/list/components/proposals_view.dart index f1d7eebe..64ce85d9 100644 --- a/lib/ui/proposals/list/components/proposals_view.dart +++ b/lib/ui/proposals/list/components/proposals_view.dart @@ -19,6 +19,8 @@ import 'package:hypha_wallet/ui/proposals/list/components/hypha_proposals_action import 'package:hypha_wallet/ui/proposals/list/interactor/proposals_bloc.dart'; import 'package:hypha_wallet/ui/shared/hypha_body_widget.dart'; +import '../../filter/interactor/filter_proposals_bloc.dart'; + class ProposalsView extends StatelessWidget { const ProposalsView({super.key}); @@ -89,7 +91,10 @@ class ProposalsView extends StatelessWidget { ), child: HyphaBodyWidget( pageState: state.pageState, - success: (context) => Padding( + success: (context) { + final List? daoIds = GetIt.I.get().daoIds; + final List proposals = daoIds != null ? state.proposals.filterByDao(daoIds) : state.proposals; + return Padding( padding: const EdgeInsets.symmetric(horizontal: 22), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -98,7 +103,7 @@ class ProposalsView extends StatelessWidget { height: 22, ), Text( - '${state.proposals.length} ${context.read().filterStatus.string} Proposal${state.proposals.length == 1 ? '' : 's'}', + '${proposals.length} ${context.read().filterStatus.string} Proposal${proposals.length == 1 ? '' : 's'}', style: context.hyphaTextTheme.ralMediumBody .copyWith(color: HyphaColors.midGrey), ), @@ -111,21 +116,7 @@ class ProposalsView extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ListView.separated( - physics: - const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: - const EdgeInsets.only(bottom: 22), - itemBuilder: - (BuildContext context, int index) => - HyphaProposalsActionCard( - state.proposals[index]), - separatorBuilder: - (BuildContext context, int index) { - return const SizedBox(height: 16); - }, - itemCount: state.proposals.length), + ProposalsList(proposals,isScrollable: false,), const SizedBox( height: 30, ), @@ -164,30 +155,7 @@ class ProposalsView extends StatelessWidget { ), ], ), - ), - success: (context) { - final List? daoIds = GetIt.I.get().daoIds; - final List proposals = daoIds != null ? state.proposals.filterByDao(daoIds) : state.proposals; - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 22), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 22, - ), - Text( - '${proposals.length} ${context.read().filterStatus.string} Proposal${proposals.length == 1 ? '' : 's'}', - style: context.hyphaTextTheme.ralMediumBody - .copyWith(color: HyphaColors.midGrey), - ), - const SizedBox( - height: 20, - ), - Expanded(child: ProposalsList(proposals)), - ], - ), - ); + ); }, ), )),