From 82dc8df758a5c296e8001e0c03ba210e9e344a62 Mon Sep 17 00:00:00 2001 From: Zied Dahmani Date: Tue, 27 Aug 2024 13:52:04 +0100 Subject: [PATCH 1/2] feat: implement proposal details page redirection --- .../details/proposal_details_page.dart | 12 + .../hypha_proposals_action_card.dart | 11 +- .../list/components/proposals_view.dart | 1 - .../list/interactor/page_command.dart | 6 - .../list/interactor/proposals_bloc.dart | 3 +- .../interactor/proposals_bloc.freezed.dart | 431 ++---------------- .../list/interactor/proposals_event.dart | 3 +- .../list/interactor/proposals_state.dart | 3 +- lib/ui/proposals/list/proposals_page.dart | 17 +- .../list/usecases/get_proposals_use_case.dart | 2 +- 10 files changed, 61 insertions(+), 428 deletions(-) create mode 100644 lib/ui/proposals/details/proposal_details_page.dart delete mode 100644 lib/ui/proposals/list/interactor/page_command.dart diff --git a/lib/ui/proposals/details/proposal_details_page.dart b/lib/ui/proposals/details/proposal_details_page.dart new file mode 100644 index 00000000..936aa325 --- /dev/null +++ b/lib/ui/proposals/details/proposal_details_page.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:hypha_wallet/core/network/models/proposal_model.dart'; + +class ProposalDetailsPage extends StatelessWidget { + final ProposalModel proposal; + const ProposalDetailsPage(this.proposal, {super.key}); + + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} 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 ff00d1c2..b55d4251 100644 --- a/lib/ui/proposals/list/components/hypha_proposals_action_card.dart +++ b/lib/ui/proposals/list/components/hypha_proposals_action_card.dart @@ -1,8 +1,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:get/get.dart' as Get; +import 'package:hypha_wallet/core/extension/proposal_model_extensions.dart'; import 'package:hypha_wallet/core/network/models/proposal_model.dart'; -import 'package:hypha_wallet/core/network/models/proposal_model_extensions.dart'; import 'package:hypha_wallet/core/network/models/vote_model.dart'; import 'package:hypha_wallet/design/avatar_image/hypha_avatar_image.dart'; import 'package:hypha_wallet/design/dividers/hypha_divider.dart'; @@ -10,6 +11,7 @@ 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/blocs/authentication/authentication_bloc.dart'; +import 'package:hypha_wallet/ui/proposals/details/proposal_details_page.dart'; import 'package:percent_indicator/linear_percent_indicator.dart'; class HyphaProposalsActionCard extends StatelessWidget { @@ -25,7 +27,12 @@ class HyphaProposalsActionCard extends StatelessWidget { HyphaCard( child: InkWell( borderRadius: BorderRadius.circular(16), - onTap: () {}, + onTap: () { + Get.Get.to( + ProposalDetailsPage(proposalModel), + transition: Get.Transition.rightToLeft, + ); + }, child: Padding( padding: const EdgeInsets.all(22), child: Column( diff --git a/lib/ui/proposals/list/components/proposals_view.dart b/lib/ui/proposals/list/components/proposals_view.dart index 40b50064..45066212 100644 --- a/lib/ui/proposals/list/components/proposals_view.dart +++ b/lib/ui/proposals/list/components/proposals_view.dart @@ -1,7 +1,6 @@ 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/proposal_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'; diff --git a/lib/ui/proposals/list/interactor/page_command.dart b/lib/ui/proposals/list/interactor/page_command.dart deleted file mode 100644 index 9238108c..00000000 --- a/lib/ui/proposals/list/interactor/page_command.dart +++ /dev/null @@ -1,6 +0,0 @@ -part of 'proposals_bloc.dart'; - -@freezed -class PageCommand with _$PageCommand { - const factory PageCommand.navigateToProposalDetails(ProposalModel proposal) = _NavigateToProposalDetails; -} \ No newline at end of file diff --git a/lib/ui/proposals/list/interactor/proposals_bloc.dart b/lib/ui/proposals/list/interactor/proposals_bloc.dart index 2353158e..ca83be5b 100644 --- a/lib/ui/proposals/list/interactor/proposals_bloc.dart +++ b/lib/ui/proposals/list/interactor/proposals_bloc.dart @@ -7,7 +7,6 @@ import 'package:hypha_wallet/ui/architecture/interactor/page_states.dart'; import 'package:hypha_wallet/ui/architecture/result/result.dart'; import 'package:hypha_wallet/ui/proposals/list/usecases/get_proposals_use_case.dart'; -part 'page_command.dart'; part 'proposals_bloc.freezed.dart'; part 'proposals_event.dart'; part 'proposals_state.dart'; @@ -34,4 +33,4 @@ class ProposalsBloc extends Bloc { emit(state.copyWith(pageState: PageState.failure)); } } -} \ No newline at end of file +} diff --git a/lib/ui/proposals/list/interactor/proposals_bloc.freezed.dart b/lib/ui/proposals/list/interactor/proposals_bloc.freezed.dart index 4bf4b2dc..9ac0b8cf 100644 --- a/lib/ui/proposals/list/interactor/proposals_bloc.freezed.dart +++ b/lib/ui/proposals/list/interactor/proposals_bloc.freezed.dart @@ -14,273 +14,47 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -/// @nodoc -mixin _$PageCommand { - ProposalModel get proposal => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult when({ - required TResult Function(ProposalModel proposal) navigateToProposalDetails, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ProposalModel proposal)? navigateToProposalDetails, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ProposalModel proposal)? navigateToProposalDetails, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_NavigateToProposalDetails value) - navigateToProposalDetails, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_NavigateToProposalDetails value)? - navigateToProposalDetails, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_NavigateToProposalDetails value)? - navigateToProposalDetails, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - - /// Create a copy of PageCommand - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PageCommandCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PageCommandCopyWith<$Res> { - factory $PageCommandCopyWith( - PageCommand value, $Res Function(PageCommand) then) = - _$PageCommandCopyWithImpl<$Res, PageCommand>; - @useResult - $Res call({ProposalModel proposal}); -} - -/// @nodoc -class _$PageCommandCopyWithImpl<$Res, $Val extends PageCommand> - implements $PageCommandCopyWith<$Res> { - _$PageCommandCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PageCommand - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? proposal = null, - }) { - return _then(_value.copyWith( - proposal: null == proposal - ? _value.proposal - : proposal // ignore: cast_nullable_to_non_nullable - as ProposalModel, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$NavigateToProposalDetailsImplCopyWith<$Res> - implements $PageCommandCopyWith<$Res> { - factory _$$NavigateToProposalDetailsImplCopyWith( - _$NavigateToProposalDetailsImpl value, - $Res Function(_$NavigateToProposalDetailsImpl) then) = - __$$NavigateToProposalDetailsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ProposalModel proposal}); -} - -/// @nodoc -class __$$NavigateToProposalDetailsImplCopyWithImpl<$Res> - extends _$PageCommandCopyWithImpl<$Res, _$NavigateToProposalDetailsImpl> - implements _$$NavigateToProposalDetailsImplCopyWith<$Res> { - __$$NavigateToProposalDetailsImplCopyWithImpl( - _$NavigateToProposalDetailsImpl _value, - $Res Function(_$NavigateToProposalDetailsImpl) _then) - : super(_value, _then); - - /// Create a copy of PageCommand - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? proposal = null, - }) { - return _then(_$NavigateToProposalDetailsImpl( - null == proposal - ? _value.proposal - : proposal // ignore: cast_nullable_to_non_nullable - as ProposalModel, - )); - } -} - -/// @nodoc - -class _$NavigateToProposalDetailsImpl implements _NavigateToProposalDetails { - const _$NavigateToProposalDetailsImpl(this.proposal); - - @override - final ProposalModel proposal; - - @override - String toString() { - return 'PageCommand.navigateToProposalDetails(proposal: $proposal)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NavigateToProposalDetailsImpl && - (identical(other.proposal, proposal) || - other.proposal == proposal)); - } - - @override - int get hashCode => Object.hash(runtimeType, proposal); - - /// Create a copy of PageCommand - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NavigateToProposalDetailsImplCopyWith<_$NavigateToProposalDetailsImpl> - get copyWith => __$$NavigateToProposalDetailsImplCopyWithImpl< - _$NavigateToProposalDetailsImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ProposalModel proposal) navigateToProposalDetails, - }) { - return navigateToProposalDetails(proposal); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ProposalModel proposal)? navigateToProposalDetails, - }) { - return navigateToProposalDetails?.call(proposal); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ProposalModel proposal)? navigateToProposalDetails, - required TResult orElse(), - }) { - if (navigateToProposalDetails != null) { - return navigateToProposalDetails(proposal); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_NavigateToProposalDetails value) - navigateToProposalDetails, - }) { - return navigateToProposalDetails(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_NavigateToProposalDetails value)? - navigateToProposalDetails, - }) { - return navigateToProposalDetails?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_NavigateToProposalDetails value)? - navigateToProposalDetails, - required TResult orElse(), - }) { - if (navigateToProposalDetails != null) { - return navigateToProposalDetails(this); - } - return orElse(); - } -} - -abstract class _NavigateToProposalDetails implements PageCommand { - const factory _NavigateToProposalDetails(final ProposalModel proposal) = - _$NavigateToProposalDetailsImpl; - - @override - ProposalModel get proposal; - - /// Create a copy of PageCommand - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NavigateToProposalDetailsImplCopyWith<_$NavigateToProposalDetailsImpl> - get copyWith => throw _privateConstructorUsedError; -} - /// @nodoc mixin _$ProposalsEvent { + bool get refresh => throw _privateConstructorUsedError; @optionalTypeArgs TResult when({ required TResult Function(bool refresh) initial, - required TResult Function() clearPageCommand, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ TResult? Function(bool refresh)? initial, - TResult? Function()? clearPageCommand, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ TResult Function(bool refresh)? initial, - TResult Function()? clearPageCommand, required TResult orElse(), }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult map({ required TResult Function(_Initial value) initial, - required TResult Function(_ClearPageCommand value) clearPageCommand, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ TResult? Function(_Initial value)? initial, - TResult? Function(_ClearPageCommand value)? clearPageCommand, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap({ TResult Function(_Initial value)? initial, - TResult Function(_ClearPageCommand value)? clearPageCommand, required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Create a copy of ProposalsEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProposalsEventCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc @@ -288,6 +62,8 @@ abstract class $ProposalsEventCopyWith<$Res> { factory $ProposalsEventCopyWith( ProposalsEvent value, $Res Function(ProposalsEvent) then) = _$ProposalsEventCopyWithImpl<$Res, ProposalsEvent>; + @useResult + $Res call({bool refresh}); } /// @nodoc @@ -302,13 +78,27 @@ class _$ProposalsEventCopyWithImpl<$Res, $Val extends ProposalsEvent> /// Create a copy of ProposalsEvent /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? refresh = null, + }) { + return _then(_value.copyWith( + refresh: null == refresh + ? _value.refresh + : refresh // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } } /// @nodoc -abstract class _$$InitialImplCopyWith<$Res> { +abstract class _$$InitialImplCopyWith<$Res> + implements $ProposalsEventCopyWith<$Res> { factory _$$InitialImplCopyWith( _$InitialImpl value, $Res Function(_$InitialImpl) then) = __$$InitialImplCopyWithImpl<$Res>; + @override @useResult $Res call({bool refresh}); } @@ -374,7 +164,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult when({ required TResult Function(bool refresh) initial, - required TResult Function() clearPageCommand, }) { return initial(refresh); } @@ -383,7 +172,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult? whenOrNull({ TResult? Function(bool refresh)? initial, - TResult? Function()? clearPageCommand, }) { return initial?.call(refresh); } @@ -392,7 +180,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult maybeWhen({ TResult Function(bool refresh)? initial, - TResult Function()? clearPageCommand, required TResult orElse(), }) { if (initial != null) { @@ -405,7 +192,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult map({ required TResult Function(_Initial value) initial, - required TResult Function(_ClearPageCommand value) clearPageCommand, }) { return initial(this); } @@ -414,7 +200,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult? mapOrNull({ TResult? Function(_Initial value)? initial, - TResult? Function(_ClearPageCommand value)? clearPageCommand, }) { return initial?.call(this); } @@ -423,7 +208,6 @@ class _$InitialImpl implements _Initial { @optionalTypeArgs TResult maybeMap({ TResult Function(_Initial value)? initial, - TResult Function(_ClearPageCommand value)? clearPageCommand, required TResult orElse(), }) { if (initial != null) { @@ -436,125 +220,21 @@ class _$InitialImpl implements _Initial { abstract class _Initial implements ProposalsEvent { const factory _Initial({final bool refresh}) = _$InitialImpl; + @override bool get refresh; /// Create a copy of ProposalsEvent /// with the given fields replaced by the non-null parameter values. + @override @JsonKey(includeFromJson: false, includeToJson: false) _$$InitialImplCopyWith<_$InitialImpl> get copyWith => throw _privateConstructorUsedError; } -/// @nodoc -abstract class _$$ClearPageCommandImplCopyWith<$Res> { - factory _$$ClearPageCommandImplCopyWith(_$ClearPageCommandImpl value, - $Res Function(_$ClearPageCommandImpl) then) = - __$$ClearPageCommandImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$ClearPageCommandImplCopyWithImpl<$Res> - extends _$ProposalsEventCopyWithImpl<$Res, _$ClearPageCommandImpl> - implements _$$ClearPageCommandImplCopyWith<$Res> { - __$$ClearPageCommandImplCopyWithImpl(_$ClearPageCommandImpl _value, - $Res Function(_$ClearPageCommandImpl) _then) - : super(_value, _then); - - /// Create a copy of ProposalsEvent - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc - -class _$ClearPageCommandImpl implements _ClearPageCommand { - const _$ClearPageCommandImpl(); - - @override - String toString() { - return 'ProposalsEvent.clearPageCommand()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$ClearPageCommandImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(bool refresh) initial, - required TResult Function() clearPageCommand, - }) { - return clearPageCommand(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(bool refresh)? initial, - TResult? Function()? clearPageCommand, - }) { - return clearPageCommand?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(bool refresh)? initial, - TResult Function()? clearPageCommand, - required TResult orElse(), - }) { - if (clearPageCommand != null) { - return clearPageCommand(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_ClearPageCommand value) clearPageCommand, - }) { - return clearPageCommand(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_ClearPageCommand value)? clearPageCommand, - }) { - return clearPageCommand?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_ClearPageCommand value)? clearPageCommand, - required TResult orElse(), - }) { - if (clearPageCommand != null) { - return clearPageCommand(this); - } - return orElse(); - } -} - -abstract class _ClearPageCommand implements ProposalsEvent { - const factory _ClearPageCommand() = _$ClearPageCommandImpl; -} - /// @nodoc mixin _$ProposalsState { PageState get pageState => throw _privateConstructorUsedError; List get proposals => throw _privateConstructorUsedError; - PageCommand? get command => throw _privateConstructorUsedError; /// Create a copy of ProposalsState /// with the given fields replaced by the non-null parameter values. @@ -569,12 +249,7 @@ abstract class $ProposalsStateCopyWith<$Res> { ProposalsState value, $Res Function(ProposalsState) then) = _$ProposalsStateCopyWithImpl<$Res, ProposalsState>; @useResult - $Res call( - {PageState pageState, - List proposals, - PageCommand? command}); - - $PageCommandCopyWith<$Res>? get command; + $Res call({PageState pageState, List proposals}); } /// @nodoc @@ -594,7 +269,6 @@ class _$ProposalsStateCopyWithImpl<$Res, $Val extends ProposalsState> $Res call({ Object? pageState = null, Object? proposals = null, - Object? command = freezed, }) { return _then(_value.copyWith( pageState: null == pageState @@ -605,26 +279,8 @@ class _$ProposalsStateCopyWithImpl<$Res, $Val extends ProposalsState> ? _value.proposals : proposals // ignore: cast_nullable_to_non_nullable as List, - command: freezed == command - ? _value.command - : command // ignore: cast_nullable_to_non_nullable - as PageCommand?, ) as $Val); } - - /// Create a copy of ProposalsState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $PageCommandCopyWith<$Res>? get command { - if (_value.command == null) { - return null; - } - - return $PageCommandCopyWith<$Res>(_value.command!, (value) { - return _then(_value.copyWith(command: value) as $Val); - }); - } } /// @nodoc @@ -635,13 +291,7 @@ abstract class _$$ProposalsStateImplCopyWith<$Res> __$$ProposalsStateImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {PageState pageState, - List proposals, - PageCommand? command}); - - @override - $PageCommandCopyWith<$Res>? get command; + $Res call({PageState pageState, List proposals}); } /// @nodoc @@ -659,7 +309,6 @@ class __$$ProposalsStateImplCopyWithImpl<$Res> $Res call({ Object? pageState = null, Object? proposals = null, - Object? command = freezed, }) { return _then(_$ProposalsStateImpl( pageState: null == pageState @@ -670,10 +319,6 @@ class __$$ProposalsStateImplCopyWithImpl<$Res> ? _value._proposals : proposals // ignore: cast_nullable_to_non_nullable as List, - command: freezed == command - ? _value.command - : command // ignore: cast_nullable_to_non_nullable - as PageCommand?, )); } } @@ -683,8 +328,7 @@ class __$$ProposalsStateImplCopyWithImpl<$Res> class _$ProposalsStateImpl implements _ProposalsState { const _$ProposalsStateImpl( {this.pageState = PageState.initial, - final List proposals = const [], - this.command}) + final List proposals = const []}) : _proposals = proposals; @override @@ -699,12 +343,9 @@ class _$ProposalsStateImpl implements _ProposalsState { return EqualUnmodifiableListView(_proposals); } - @override - final PageCommand? command; - @override String toString() { - return 'ProposalsState(pageState: $pageState, proposals: $proposals, command: $command)'; + return 'ProposalsState(pageState: $pageState, proposals: $proposals)'; } @override @@ -715,13 +356,12 @@ class _$ProposalsStateImpl implements _ProposalsState { (identical(other.pageState, pageState) || other.pageState == pageState) && const DeepCollectionEquality() - .equals(other._proposals, _proposals) && - (identical(other.command, command) || other.command == command)); + .equals(other._proposals, _proposals)); } @override - int get hashCode => Object.hash(runtimeType, pageState, - const DeepCollectionEquality().hash(_proposals), command); + int get hashCode => Object.hash( + runtimeType, pageState, const DeepCollectionEquality().hash(_proposals)); /// Create a copy of ProposalsState /// with the given fields replaced by the non-null parameter values. @@ -736,15 +376,12 @@ class _$ProposalsStateImpl implements _ProposalsState { abstract class _ProposalsState implements ProposalsState { const factory _ProposalsState( {final PageState pageState, - final List proposals, - final PageCommand? command}) = _$ProposalsStateImpl; + final List proposals}) = _$ProposalsStateImpl; @override PageState get pageState; @override List get proposals; - @override - PageCommand? get command; /// Create a copy of ProposalsState /// with the given fields replaced by the non-null parameter values. diff --git a/lib/ui/proposals/list/interactor/proposals_event.dart b/lib/ui/proposals/list/interactor/proposals_event.dart index ae742b50..b5ce4886 100644 --- a/lib/ui/proposals/list/interactor/proposals_event.dart +++ b/lib/ui/proposals/list/interactor/proposals_event.dart @@ -3,5 +3,4 @@ part of 'proposals_bloc.dart'; @freezed class ProposalsEvent with _$ProposalsEvent { const factory ProposalsEvent.initial({@Default(false) bool refresh}) = _Initial; - const factory ProposalsEvent.clearPageCommand() = _ClearPageCommand; -} \ No newline at end of file +} diff --git a/lib/ui/proposals/list/interactor/proposals_state.dart b/lib/ui/proposals/list/interactor/proposals_state.dart index 29923b49..ffa79c03 100644 --- a/lib/ui/proposals/list/interactor/proposals_state.dart +++ b/lib/ui/proposals/list/interactor/proposals_state.dart @@ -5,6 +5,5 @@ class ProposalsState with _$ProposalsState { const factory ProposalsState({ @Default(PageState.initial) PageState pageState, @Default([]) List proposals, - PageCommand? command, }) = _ProposalsState; -} \ No newline at end of file +} diff --git a/lib/ui/proposals/list/proposals_page.dart b/lib/ui/proposals/list/proposals_page.dart index 0ef71d02..6a994427 100644 --- a/lib/ui/proposals/list/proposals_page.dart +++ b/lib/ui/proposals/list/proposals_page.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get_it/get_it.dart'; -import 'package:hypha_wallet/core/network/models/proposal_model.dart'; import 'package:hypha_wallet/ui/proposals/list/components/proposals_view.dart'; import 'package:hypha_wallet/ui/proposals/list/interactor/proposals_bloc.dart'; @@ -12,19 +11,7 @@ class ProposalsPage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => GetIt.I.get()..add(const ProposalsEvent.initial()), - child: BlocListener( - listenWhen: (previous, current) => previous.command != current.command, - listener: (context, state) { - state.command?.when( - navigateToProposalDetails: (ProposalModel proposal) { - // TODO: redirection - }, - ); - - context.read().add(const ProposalsEvent.clearPageCommand()); - }, - child: const ProposalsView(), - ), + child: const ProposalsView(), ); } -} \ No newline at end of file +} diff --git a/lib/ui/proposals/list/usecases/get_proposals_use_case.dart b/lib/ui/proposals/list/usecases/get_proposals_use_case.dart index b14176e2..27d4a3ce 100644 --- a/lib/ui/proposals/list/usecases/get_proposals_use_case.dart +++ b/lib/ui/proposals/list/usecases/get_proposals_use_case.dart @@ -11,4 +11,4 @@ class GetProposalsUseCase { GetProposalsUseCase(this._authRepository, this._proposalRepository); Future, HyphaError>> run() async => _proposalRepository.getProposals(_authRepository.authDataOrCrash.userProfileData); -} \ No newline at end of file +} From b35814050bd1cf1e1e38c38243a9417666b10e02 Mon Sep 17 00:00:00 2001 From: Zied Dahmani Date: Thu, 29 Aug 2024 16:21:16 +0100 Subject: [PATCH 2/2] refactor: redirect via details button --- .../hypha_proposals_action_card.dart | 104 +++++++++--------- 1 file changed, 50 insertions(+), 54 deletions(-) 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 b55d4251..8bab1c12 100644 --- a/lib/ui/proposals/list/components/hypha_proposals_action_card.dart +++ b/lib/ui/proposals/list/components/hypha_proposals_action_card.dart @@ -25,59 +25,50 @@ class HyphaProposalsActionCard extends StatelessWidget { children: [ _buildVoteStatusOverlay(context), HyphaCard( - child: InkWell( - borderRadius: BorderRadius.circular(16), - onTap: () { - Get.Get.to( - ProposalDetailsPage(proposalModel), - transition: Get.Transition.rightToLeft, - ); - }, - child: Padding( - padding: const EdgeInsets.all(22), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildHeader( - context, - proposalModel.daoName, - 'https://etudestech.com/wp-content/uploads/2023/05/midjourney-scaled.jpeg', - ), - const SizedBox(height: 18), - const HyphaDivider(), - const SizedBox(height: 18), - _buildProposalRoleAssignment( - context, - proposalModel.commitment ?? 0, - proposalModel.title ?? 'No title set for this proposal.', - ), - const SizedBox(height: 20), - _buildProposalPercentageIndicator( - context, - 'Unity', - proposalModel.unityToPercent(), - ), - const SizedBox(height: 20), - _buildProposalPercentageIndicator( - context, - 'Quorum', - proposalModel.quorumToPercent(), - ), - const SizedBox(height: 20), - _buildProposalExpirationInfo( - context, - proposalModel.formatExpiration(), - ), - const SizedBox(height: 16), - const HyphaDivider(), - const SizedBox(height: 16), - _buildProposalCardFooter( - context, - proposalModel.creator, - 'https://etudestech.com/wp-content/uploads/2023/05/midjourney-scaled.jpeg', - ), - ], - ), + child: Padding( + padding: const EdgeInsets.all(22), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildHeader( + context, + proposalModel.daoName, + 'https://etudestech.com/wp-content/uploads/2023/05/midjourney-scaled.jpeg', + ), + const SizedBox(height: 18), + const HyphaDivider(), + const SizedBox(height: 18), + _buildProposalRoleAssignment( + context, + proposalModel.commitment ?? 0, + proposalModel.title ?? 'No title set for this proposal.', + ), + const SizedBox(height: 20), + _buildProposalPercentageIndicator( + context, + 'Unity', + proposalModel.unityToPercent(), + ), + const SizedBox(height: 20), + _buildProposalPercentageIndicator( + context, + 'Quorum', + proposalModel.quorumToPercent(), + ), + const SizedBox(height: 20), + _buildProposalExpirationInfo( + context, + proposalModel.formatExpiration(), + ), + const SizedBox(height: 16), + const HyphaDivider(), + const SizedBox(height: 16), + _buildProposalCardFooter( + context, + proposalModel.creator, + 'https://etudestech.com/wp-content/uploads/2023/05/midjourney-scaled.jpeg', + ), + ], ), ), ), @@ -260,7 +251,12 @@ class HyphaProposalsActionCard extends StatelessWidget { ), const Spacer(), GestureDetector( - onTap: () {}, + onTap: () { + Get.Get.to( + ProposalDetailsPage(proposalModel), + transition: Get.Transition.rightToLeft, + ); + }, child: Container( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), decoration: BoxDecoration(