Skip to content

Commit b113c3b

Browse files
authored
Merge branch 'main' into feat/2044-catalystId-documents
2 parents 6a5f07f + 3ee1022 commit b113c3b

File tree

67 files changed

+1512
-745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1512
-745
lines changed

catalyst_voices/apps/voices/lib/dependency/dependencies.dart

+7
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ final class Dependencies extends DependencyProvider {
169169
get<CatalystDatabase>(),
170170
);
171171
})
172+
..registerLazySingleton<DocumentFavoriteSource>(() {
173+
return DatabaseDocumentFavoriteSource(
174+
get<CatalystDatabase>(),
175+
);
176+
})
172177
..registerLazySingleton<CatGatewayDocumentDataSource>(() {
173178
return CatGatewayDocumentDataSource(
174179
get<ApiServices>(),
@@ -182,6 +187,7 @@ final class Dependencies extends DependencyProvider {
182187
get<DatabaseDraftsDataSource>(),
183188
get<SignedDocumentDataSource>(),
184189
get<CatGatewayDocumentDataSource>(),
190+
get<DocumentFavoriteSource>(),
185191
);
186192
})
187193
..registerLazySingleton<DocumentMapper>(() => const DocumentMapperImpl())
@@ -244,6 +250,7 @@ final class Dependencies extends DependencyProvider {
244250
registerLazySingleton<ProposalService>(() {
245251
return ProposalService(
246252
get<ProposalRepository>(),
253+
get<DocumentRepository>(),
247254
get<UserService>(),
248255
get<KeyDerivationService>(),
249256
get<CampaignRepository>(),

catalyst_voices/apps/voices/lib/pages/funded_projects/funded_projects_page.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final _proposals = [
3131
category: 'Cardano Use Cases / MVP',
3232
title: 'Proposal Title that rocks the world',
3333
fundedDate: DateTime.now().minusDays(2),
34-
fundsRequested: Coin.fromAda(100000),
34+
fundsRequested: const Coin.fromWholeAda(100000),
3535
commentsCount: 0,
3636
description: _proposalDescription,
3737
),
@@ -41,7 +41,7 @@ final _proposals = [
4141
category: 'Cardano Use Cases / MVP',
4242
title: 'Proposal Title that rocks the world',
4343
fundedDate: DateTime.now().minusDays(2),
44-
fundsRequested: Coin.fromAda(100000),
44+
fundsRequested: const Coin.fromWholeAda(100000),
4545
commentsCount: 0,
4646
description: _proposalDescription,
4747
),
@@ -51,7 +51,7 @@ final _proposals = [
5151
category: 'Cardano Use Cases / MVP',
5252
title: 'Proposal Title that rocks the world',
5353
fundedDate: DateTime.now().minusDays(2),
54-
fundsRequested: Coin.fromAda(100000),
54+
fundsRequested: const Coin.fromWholeAda(100000),
5555
commentsCount: 0,
5656
description: _proposalDescription,
5757
),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
part of 'proposal_builder_segments.dart';
2+
3+
class _CategoryDetails extends StatelessWidget {
4+
final DocumentProperty property;
5+
6+
const _CategoryDetails({required this.property});
7+
8+
@override
9+
Widget build(BuildContext context) {
10+
return BlocSelector<ProposalBuilderBloc, ProposalBuilderState,
11+
CampaignCategoryDetailsViewModel?>(
12+
selector: (state) => state.category,
13+
builder: (context, category) {
14+
if (category == null) {
15+
return const Offstage();
16+
}
17+
18+
return Column(
19+
mainAxisSize: MainAxisSize.min,
20+
crossAxisAlignment: CrossAxisAlignment.start,
21+
children: [
22+
Text(
23+
category.name,
24+
style: Theme.of(context).textTheme.titleSmall,
25+
),
26+
const SizedBox(height: 8),
27+
Text(
28+
category.subname,
29+
style: Theme.of(context).textTheme.headlineMedium,
30+
),
31+
const SizedBox(height: 20),
32+
_Stats(category: category),
33+
const SizedBox(height: 20),
34+
Text(
35+
context.l10n.shortSummary,
36+
style: Theme.of(context).textTheme.titleSmall,
37+
),
38+
const SizedBox(height: 8),
39+
Text(
40+
category.description,
41+
style: Theme.of(context).textTheme.bodyLarge,
42+
),
43+
],
44+
);
45+
},
46+
);
47+
}
48+
}
49+
50+
class _Stats extends StatelessWidget {
51+
final CampaignCategoryDetailsViewModel category;
52+
53+
const _Stats({required this.category});
54+
55+
@override
56+
Widget build(BuildContext context) {
57+
return Row(
58+
children: [
59+
Expanded(
60+
child: _StatsItem(
61+
label: context.l10n.fundsAvailable,
62+
value: category.availableFunds,
63+
),
64+
),
65+
Expanded(
66+
child: _StatsItem(
67+
label: context.l10n.minBudgetRequest,
68+
value: category.range.min,
69+
),
70+
),
71+
Expanded(
72+
child: _StatsItem(
73+
label: context.l10n.maxBudgetRequest,
74+
value: category.range.max,
75+
),
76+
),
77+
],
78+
);
79+
}
80+
}
81+
82+
class _StatsItem extends StatelessWidget {
83+
final String label;
84+
final Coin value;
85+
86+
const _StatsItem({
87+
required this.label,
88+
required this.value,
89+
});
90+
91+
@override
92+
Widget build(BuildContext context) {
93+
return Column(
94+
crossAxisAlignment: CrossAxisAlignment.start,
95+
mainAxisSize: MainAxisSize.min,
96+
children: [
97+
Text(
98+
CryptocurrencyFormatter.formatAmount(value),
99+
style: Theme.of(context).textTheme.titleLarge,
100+
),
101+
Text(
102+
label,
103+
style: Theme.of(context).textTheme.bodySmall,
104+
),
105+
],
106+
);
107+
}
108+
}

catalyst_voices/apps/voices/lib/pages/proposal_builder/proposal_builder_segments.dart

+24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
import 'package:catalyst_cardano_serialization/catalyst_cardano_serialization.dart';
12
import 'package:catalyst_voices/widgets/widgets.dart';
23
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
4+
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
35
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
6+
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
47
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
58
import 'package:flutter/material.dart';
69
import 'package:flutter_bloc/flutter_bloc.dart';
710
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
811

12+
part 'proposal_builder_document_widgets.dart';
13+
14+
final DocumentPropertyBuilderOverrides _widgetOverrides = {
15+
ProposalDocument.categoryDetailsNodeId: (context, property) =>
16+
_CategoryDetails(property: property),
17+
};
18+
919
class ProposalBuilderSegmentsSelector extends StatelessWidget {
1020
final ItemScrollController itemScrollController;
1121

@@ -70,6 +80,18 @@ class _Section extends StatelessWidget {
7080
required this.isSelected,
7181
});
7282

83+
bool get _isEditable {
84+
for (final overriddenNodeId in _widgetOverrides.keys) {
85+
final sectionHasOverrides = overriddenNodeId.isChildOf(property.nodeId);
86+
if (sectionHasOverrides) {
87+
// disable editing for overridden widgets
88+
return false;
89+
}
90+
}
91+
92+
return true;
93+
}
94+
7395
@override
7496
Widget build(BuildContext context) {
7597
return BlocSelector<ProposalBuilderBloc, ProposalBuilderState, bool>(
@@ -79,13 +101,15 @@ class _Section extends StatelessWidget {
79101
key: key,
80102
section: property,
81103
isSelected: isSelected,
104+
isEditable: _isEditable,
82105
autovalidateMode: showValidationErrors
83106
? AutovalidateMode.always
84107
: AutovalidateMode.disabled,
85108
onChanged: (value) {
86109
final event = SectionChangedEvent(changes: value);
87110
context.read<ProposalBuilderBloc>().add(event);
88111
},
112+
overrides: _widgetOverrides,
89113
);
90114
},
91115
);

catalyst_voices/apps/voices/lib/pages/proposals/proposals_pagination.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class _ProposalsPaginationState extends State<ProposalsPagination> {
9292
},
9393
onFavoriteChanged: (isFavorite) async {
9494
await context.read<ProposalsCubit>().onChangeFavoriteProposal(
95-
item.ref.id,
95+
item.ref,
9696
isFavorite: isFavorite,
9797
);
9898
},

catalyst_voices/apps/voices/lib/pages/voting/voting_page.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final _proposals = [
2727
category: 'Cardano Use Cases / MVP',
2828
title: 'Proposal Title that rocks the world',
2929
lastUpdateDate: DateTime.now().minusDays(2),
30-
fundsRequested: Coin.fromAda(100000),
30+
fundsRequested: const Coin.fromWholeAda(100000),
3131
commentsCount: 0,
3232
description: _proposalDescription,
3333
publishStage: ProposalPublish.publishedDraft,
@@ -41,7 +41,7 @@ final _proposals = [
4141
category: 'Cardano Use Cases / MVP',
4242
title: 'Proposal Title that rocks the world',
4343
lastUpdateDate: DateTime.now().minusDays(2),
44-
fundsRequested: Coin.fromAda(100000),
44+
fundsRequested: const Coin.fromWholeAda(100000),
4545
commentsCount: 0,
4646
description: _proposalDescription,
4747
publishStage: ProposalPublish.submittedProposal,
@@ -55,7 +55,7 @@ final _proposals = [
5555
category: 'Cardano Use Cases / MVP',
5656
title: 'Proposal Title that rocks the world',
5757
lastUpdateDate: DateTime.now().minusDays(2),
58-
fundsRequested: Coin.fromAda(100000),
58+
fundsRequested: const Coin.fromWholeAda(100000),
5959
commentsCount: 0,
6060
description: _proposalDescription,
6161
publishStage: ProposalPublish.publishedDraft,

catalyst_voices/apps/voices/lib/pages/workspace/page/workspace_page.dart

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'dart:async';
22

33
import 'package:catalyst_voices/common/error_handler.dart';
4+
import 'package:catalyst_voices/common/signal_handler.dart';
45
import 'package:catalyst_voices/pages/workspace/header/workspace_header.dart';
56
import 'package:catalyst_voices/pages/workspace/page/workspace_error.dart';
67
import 'package:catalyst_voices/pages/workspace/page/workspace_loading.dart';
78
import 'package:catalyst_voices/pages/workspace/page/workspace_user_proposals.dart';
89
import 'package:catalyst_voices/routes/routing/proposal_builder_route.dart';
910
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
10-
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:flutter_bloc/flutter_bloc.dart';
1313

@@ -19,9 +19,9 @@ class WorkspacePage extends StatefulWidget {
1919
}
2020

2121
class _WorkspacePageState extends State<WorkspacePage>
22-
with ErrorHandlerStateMixin<WorkspaceBloc, WorkspacePage> {
23-
StreamSubscription<dynamic>? _importedProposalSub;
24-
22+
with
23+
SignalHandlerStateMixin<WorkspaceBloc, WorkspaceSignal, WorkspacePage>,
24+
ErrorHandlerStateMixin<WorkspaceBloc, WorkspacePage> {
2525
@override
2626
Widget build(BuildContext context) {
2727
return const Scaffold(
@@ -44,10 +44,13 @@ class _WorkspacePageState extends State<WorkspacePage>
4444
}
4545

4646
@override
47-
void dispose() {
48-
unawaited(_importedProposalSub?.cancel());
49-
_importedProposalSub = null;
50-
super.dispose();
47+
void handleSignal(WorkspaceSignal signal) {
48+
switch (signal) {
49+
case ImportedProposalWorkspaceSignal():
50+
unawaited(
51+
ProposalBuilderRoute.fromRef(ref: signal.proposalRef).push(context),
52+
);
53+
}
5154
}
5255

5356
@override
@@ -56,16 +59,5 @@ class _WorkspacePageState extends State<WorkspacePage>
5659
final bloc = context.read<WorkspaceBloc>();
5760
// ignore: cascade_invocations
5861
bloc.add(const WatchUserProposalsEvent());
59-
60-
_importedProposalSub =
61-
bloc.stream.map((e) => e.importedProposalRef).listen(_onImportProposal);
62-
}
63-
64-
void _onImportProposal(DocumentRef? ref) {
65-
if (ref != null) {
66-
unawaited(
67-
ProposalBuilderRoute.fromRef(ref: ref).push(context),
68-
);
69-
}
7062
}
7163
}

0 commit comments

Comments
 (0)