-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement proposal review page #346
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,4 +154,6 @@ void _registerBlocsModule() { | |
dao | ||
), | ||
); | ||
|
||
_registerFactory(() => ProposalCreationBloc()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class ProposalCreationModel { | ||
final String? title; | ||
final String? details; | ||
|
||
ProposalCreationModel({this.title, this.details}); | ||
|
||
ProposalCreationModel copyWith(Map<String, dynamic> updates) { | ||
return ProposalCreationModel( | ||
title: updates.containsKey('title') ? updates['title'] : title, | ||
details: updates.containsKey('details') ? updates['details'] : details, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
lib/ui/proposals/creation/components/proposal_review_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import 'dart:convert'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_quill/flutter_quill.dart'; | ||
import 'package:flutter_quill/quill_delta.dart'; | ||
import 'package:get/get_utils/src/extensions/context_extensions.dart'; | ||
import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; | ||
import 'package:hypha_wallet/design/buttons/hypha_app_button.dart'; | ||
import 'package:hypha_wallet/design/dividers/hypha_divider.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/components/proposal_header.dart'; | ||
import 'package:hypha_wallet/ui/proposals/creation/interactor/proposal_creation_bloc.dart'; | ||
|
||
class ProposalReviewView extends StatelessWidget { | ||
const ProposalReviewView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
padding: const EdgeInsets.symmetric(horizontal: 20), | ||
height: double.infinity, | ||
color: context.isDarkMode ? HyphaColors.darkBlack : HyphaColors.offWhite, | ||
child: SafeArea( | ||
bottom: true, | ||
child: LayoutBuilder( | ||
builder: (context, constraint) { | ||
return SingleChildScrollView( | ||
child: ConstrainedBox( | ||
constraints: BoxConstraints(minHeight: constraint.maxHeight), | ||
child: IntrinsicHeight( | ||
child: BlocBuilder<ProposalCreationBloc, ProposalCreationState>( | ||
builder: (context, state) { | ||
final List<dynamic> jsonData = jsonDecode(state.proposal!.details!); | ||
final Document document = Document.fromDelta(Delta.fromJson(jsonData)); | ||
|
||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const SizedBox(height: 20), | ||
const Row( | ||
children: [ | ||
Expanded( | ||
child: ProposalHeader( | ||
DaoData( | ||
docId: 21345, | ||
detailsDaoName: '', | ||
settingsDaoTitle: 'HyphaDao', | ||
logoIPFSHash: '', | ||
logoType: '', | ||
settingsDaoUrl: '', | ||
), | ||
text: 'Builders', | ||
), | ||
), | ||
SizedBox(width: 10), | ||
Icon(CupertinoIcons.hand_thumbsup, color: HyphaColors.primaryBlu), | ||
], | ||
), | ||
const Padding( | ||
padding: EdgeInsets.only(top: 10, bottom: 20), | ||
child: HyphaDivider(), | ||
), | ||
Text( | ||
'Agreement for', | ||
style: context.hyphaTextTheme.ralMediumSmallNote.copyWith(color: HyphaColors.primaryBlu), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: 10, bottom: 20), | ||
child: Text( | ||
state.proposal!.title!, | ||
style: context.hyphaTextTheme.mediumTitles, | ||
), | ||
), | ||
Text( | ||
'Details', | ||
style: context.hyphaTextTheme.ralMediumSmallNote.copyWith(color: HyphaColors.primaryBlu), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(top: 10, bottom: 20), | ||
child: QuillEditor.basic( | ||
controller: QuillController( | ||
document: document, | ||
selection: const TextSelection.collapsed(offset: 0), | ||
readOnly: true, | ||
), | ||
), | ||
), | ||
const Spacer(), | ||
HyphaAppButton( | ||
title: 'Publish', | ||
onPressed: () async { | ||
}, | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
part of 'proposal_creation_bloc.dart'; | ||
|
||
@freezed | ||
class PageCommand with _$PageCommand { | ||
const factory PageCommand.navigateBackToProposals() = _NavigateBackToProposals; | ||
} |
68 changes: 68 additions & 0 deletions
68
lib/ui/proposals/creation/interactor/proposal_creation_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:hypha_wallet/core/network/models/proposal_creation_model.dart'; | ||
import 'package:hypha_wallet/core/network/models/proposal_details_model.dart'; | ||
import 'package:hypha_wallet/ui/architecture/interactor/page_states.dart'; | ||
|
||
part 'page_command.dart'; | ||
part 'proposal_creation_bloc.freezed.dart'; | ||
part 'proposal_creation_event.dart'; | ||
part 'proposal_creation_state.dart'; | ||
|
||
class ProposalCreationBloc | ||
extends Bloc<ProposalCreationEvent, ProposalCreationState> { | ||
ProposalCreationBloc() : super(ProposalCreationState(proposal: ProposalCreationModel())) { | ||
on<_UpdateCurrentView>(_updateCurrentView); | ||
on<_UpdateProposal>(_updateProposal); | ||
on<_ClearPageCommand>((_, emit) => emit(state.copyWith(command: null))); | ||
} | ||
|
||
// TODO(Saif): pass initialPage as parameter | ||
final PageController _pageController = PageController(initialPage: 0); | ||
PageController get pageController => _pageController; | ||
|
||
Future<void> _updateCurrentView(_UpdateCurrentView event, Emitter<ProposalCreationState> emit) async { | ||
if (event.nextViewIndex == -1) { | ||
emit(state.copyWith(command: const PageCommand.navigateBackToProposals())); | ||
} else { | ||
switch (event.nextViewIndex) { | ||
case 0: | ||
navigate(emit, event.nextViewIndex); | ||
n13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break; | ||
case 1: | ||
navigate(emit, event.nextViewIndex); | ||
break; | ||
case 2: | ||
if(state.proposal?.details != null) { | ||
navigate(emit, event.nextViewIndex); | ||
} | ||
break; | ||
case 3: | ||
navigate(emit, event.nextViewIndex); | ||
break; | ||
case 4: | ||
navigate(emit, event.nextViewIndex); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void navigate(Emitter<ProposalCreationState> emit, int nextIndex) { | ||
emit(state.copyWith(currentViewIndex: nextIndex)); | ||
_pageController.animateToPage( | ||
nextIndex, | ||
duration: const Duration(milliseconds: 200), | ||
curve: Curves.easeInOut, | ||
); | ||
} | ||
|
||
Future<void> _updateProposal(_UpdateProposal event, Emitter<ProposalCreationState> emit) async { | ||
final ProposalCreationModel? proposal = state.proposal?.copyWith(event.updates); | ||
if (proposal != null) { | ||
emit(state.copyWith(proposal: proposal)); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why is Marketing Circle hard-coded here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is supposed to be the circle it could either be an empty string (no circle) - which should then be the default, or some other text if there is a circle selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what the Marketing Circle is, so we let it default, created a ticket, and will get back to it later (I remember Luigi said we would remove it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok please make the default "" empty string then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's OK to merge something that is clearly wrong. Principle. Just like we don't merge bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string should be fine as default - some proposals will have a circle some won't (default is no circle)