Skip to content

Commit

Permalink
feat: Implement dao selection screen
Browse files Browse the repository at this point in the history
  • Loading branch information
nbetsaif committed Oct 9, 2024
1 parent 335e4fd commit dbe9145
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ 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 HyphaFilterCard extends StatelessWidget {
class HyphaOptionCard extends StatelessWidget {
final DaoData? dao;
final String? title;
final String? subTitle;
final dynamic valueNotifier;
final int index;

const HyphaFilterCard(this.valueNotifier, this.index,
const HyphaOptionCard(this.valueNotifier, this.index,
{this.dao, this.title, this.subTitle, super.key});

@override
Expand Down
64 changes: 64 additions & 0 deletions lib/ui/proposals/creation/components/dao_selection_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_it/get_it.dart';
import 'package:hypha_wallet/core/network/models/dao_data_model.dart';
import 'package:hypha_wallet/design/cards/hypha_option_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/list/interactor/proposals_bloc.dart';

class DaoSelectionView extends StatefulWidget {
const DaoSelectionView({super.key});

@override
State<DaoSelectionView> createState() => _DaoSelectionViewState();
}

class _DaoSelectionViewState extends State<DaoSelectionView> {
late List<DaoData> daos;
final ValueNotifier<int> selectedDaoIndexNotifier = ValueNotifier<int>(0);

@override
void initState() {
super.initState();
daos = GetIt.I.get<ProposalsBloc>().daos;
}

@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.sizeOf(context).height,
color: context.isDarkMode ? HyphaColors.darkBlack : HyphaColors.offWhite,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 20),
Text(
'Select a DAO',
style: context.hyphaTextTheme.smallTitles
.copyWith(color: HyphaColors.primaryBlu),
),
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 30),
child: Text(
'On which of your DAO you want to publish a proposal? Please select one from the list.',
style: context.hyphaTextTheme.ralMediumBody
.copyWith(color: HyphaColors.midGrey),
),
),
...List.generate(
daos.length,
(index) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
child: HyphaOptionCard(
dao: daos[index], selectedDaoIndexNotifier, index),
);
},
)
],
),
);
}
}
6 changes: 3 additions & 3 deletions lib/ui/proposals/filter/components/filter_proposals_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:get/get.dart';
import 'package:hypha_wallet/design/buttons/hypha_app_button.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/filter/components/hypha_filter_card.dart';
import 'package:hypha_wallet/design/cards/hypha_option_card.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/shared/hypha_body_widget.dart';
Expand Down Expand Up @@ -43,7 +43,7 @@ class FilterProposalsView extends StatelessWidget {
(index) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
child: HyphaFilterCard(
child: HyphaOptionCard(
dao: state.daoProposalCounts[index].dao,
subTitle: '${state.daoProposalCounts[index].proposalCount} ${filterProposalsBloc.selectedStatusIndexNotifier.value == 0 ? 'Active' : 'Past'} Proposal${state.daoProposalCounts[index].proposalCount == 1 ? '' : 's'}',
filterProposalsBloc.selectedDaoIndexNotifier,
Expand All @@ -63,7 +63,7 @@ class FilterProposalsView extends StatelessWidget {
(index) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
child: HyphaFilterCard(
child: HyphaOptionCard(
title: _statusFilters[index],
filterProposalsBloc.selectedStatusIndexNotifier,
index,
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/proposals/list/components/proposals_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ProposalsView extends StatelessWidget {
context
.read<ProposalsBloc>()
.add(const ProposalsEvent.initial(refresh: true));

},
child: Container(
margin: const EdgeInsets.only(top: 20),
Expand Down Expand Up @@ -172,7 +173,8 @@ class ProposalsView extends StatelessWidget {
},
),
)),
floatingActionButton: IconButton(
floatingActionButton:context
.read<ProposalsBloc>().daos.isEmpty?null: IconButton(
onPressed: () {
GetX.Get.to(() => const ProposalCreationPage(), transition: GetX.Transition.leftToRight);
},
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/proposals/list/interactor/proposals_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProposalsBloc extends Bloc<ProposalsEvent, ProposalsState> {
final GetProposalsUseCase _getProposalsUseCase;
final FetchProfileUseCase _fetchProfileUseCase;
final ErrorHandlerManager _errorHandlerManager;

List<DaoData> daos=[];
ProposalsBloc(this._getProposalsUseCase, this._fetchProfileUseCase,
this._errorHandlerManager)
: super(const ProposalsState()) {
Expand All @@ -48,7 +48,7 @@ class ProposalsBloc extends Bloc<ProposalsEvent, ProposalsState> {
await _fetchProfileUseCase.run();

if (profileResult.isValue && profileResult.asValue!.value.daos.isNotEmpty) {
final List<DaoData> daos = profileResult.asValue!.value.daos;
daos = profileResult.asValue!.value.daos;

// Fetch Proposals using the fetched DAOs
final Result<List<ProposalModel>, HyphaError> proposalsResult =
Expand Down

0 comments on commit dbe9145

Please sign in to comment.