@@ -2,10 +2,13 @@ import 'package:catalyst_cardano_serialization/catalyst_cardano_serialization.da
2
2
import 'package:catalyst_voices/widgets/widgets.dart' ;
3
3
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart' ;
4
4
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart' ;
5
+ import 'package:catalyst_voices_models/catalyst_voices_models.dart' ;
5
6
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart' ;
6
7
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart' ;
7
8
import 'package:flutter/material.dart' ;
8
9
10
+ final _favoriteProposals = ValueNotifier <List <FundedProposal >>([]);
11
+
9
12
final _proposalDescription = """
10
13
Zanzibar is becoming one of the hotspots for DID's through
11
14
World Mobile and PRISM, but its potential is only barely exploited.
@@ -14,9 +17,16 @@ and PRISM, but its potential is only barely exploited.
14
17
"""
15
18
.replaceAll ('\n ' , ' ' );
16
19
20
+ final _proposalImages = {
21
+ for (final (index, proposal) in _proposals.indexed)
22
+ proposal.ref: index.isEven
23
+ ? VoicesAssets .images.proposalBackground1
24
+ : VoicesAssets .images.proposalBackground2,
25
+ };
26
+
17
27
final _proposals = [
18
28
FundedProposal (
19
- id : 'f14/0' ,
29
+ ref : SignedDocumentRef . generateFirstRef () ,
20
30
campaignName: 'F14' ,
21
31
category: 'Cardano Use Cases / MVP' ,
22
32
title: 'Proposal Title that rocks the world' ,
@@ -26,7 +36,7 @@ final _proposals = [
26
36
description: _proposalDescription,
27
37
),
28
38
FundedProposal (
29
- id : 'f14/1' ,
39
+ ref : SignedDocumentRef . generateFirstRef () ,
30
40
campaignName: 'F14' ,
31
41
category: 'Cardano Use Cases / MVP' ,
32
42
title: 'Proposal Title that rocks the world' ,
@@ -36,7 +46,7 @@ final _proposals = [
36
46
description: _proposalDescription,
37
47
),
38
48
FundedProposal (
39
- id : 'f14/2' ,
49
+ ref : SignedDocumentRef . generateFirstRef () ,
40
50
campaignName: 'F14' ,
41
51
category: 'Cardano Use Cases / MVP' ,
42
52
title: 'Proposal Title that rocks the world' ,
@@ -47,14 +57,15 @@ final _proposals = [
47
57
),
48
58
];
49
59
50
- final _proposalImages = {
51
- for (final (index, proposal) in _proposals.indexed)
52
- proposal.id: index.isEven
53
- ? VoicesAssets .images.proposalBackground1
54
- : VoicesAssets .images.proposalBackground2,
55
- };
56
-
57
- final _favoriteProposals = ValueNotifier <List <FundedProposal >>([]);
60
+ void _onFavoriteChanged (FundedProposal proposal, bool isFavorite) {
61
+ final proposals = Set .of (_favoriteProposals.value);
62
+ if (isFavorite) {
63
+ proposals.add (proposal);
64
+ } else {
65
+ proposals.remove (proposal);
66
+ }
67
+ _favoriteProposals.value = proposals.toList ();
68
+ }
58
69
59
70
class FundedProjectsPage extends StatelessWidget {
60
71
const FundedProjectsPage ({super .key});
@@ -76,49 +87,6 @@ class FundedProjectsPage extends StatelessWidget {
76
87
}
77
88
}
78
89
79
- class _Tabs extends StatelessWidget {
80
- const _Tabs ();
81
-
82
- @override
83
- Widget build (BuildContext context) {
84
- return DefaultTabController (
85
- length: 2 ,
86
- child: Column (
87
- mainAxisSize: MainAxisSize .min,
88
- crossAxisAlignment: CrossAxisAlignment .start,
89
- children: [
90
- TabBar (
91
- isScrollable: true ,
92
- tabAlignment: TabAlignment .start,
93
- tabs: [
94
- Tab (
95
- text: context.l10n.noOfFundedProposals (_proposals.length),
96
- ),
97
- Tab (
98
- child: Row (
99
- children: [
100
- VoicesAssets .icons.plusCircleOutlined.buildIcon (),
101
- const SizedBox (width: 8 ),
102
- Text (context.l10n.followed),
103
- ],
104
- ),
105
- ),
106
- ],
107
- ),
108
- const SizedBox (height: 24 ),
109
- const TabBarStackView (
110
- children: [
111
- _AllProposals (),
112
- _FavoriteProposals (),
113
- ],
114
- ),
115
- const SizedBox (height: 12 ),
116
- ],
117
- ),
118
- );
119
- }
120
- }
121
-
122
90
class _AllProposals extends StatelessWidget {
123
91
const _AllProposals ();
124
92
@@ -133,7 +101,7 @@ class _AllProposals extends StatelessWidget {
133
101
children: [
134
102
for (final proposal in _proposals)
135
103
FundedProposalCard (
136
- image: _proposalImages[proposal.id ]! ,
104
+ image: _proposalImages[proposal.ref ]! ,
137
105
proposal: proposal,
138
106
isFavorite: favoriteProposals.contains (proposal),
139
107
onFavoriteChanged: (isFavorite) =>
@@ -160,7 +128,7 @@ class _FavoriteProposals extends StatelessWidget {
160
128
children: [
161
129
for (final proposal in favoriteProposals)
162
130
FundedProposalCard (
163
- image: _proposalImages[proposal.id ]! ,
131
+ image: _proposalImages[proposal.ref ]! ,
164
132
proposal: proposal,
165
133
isFavorite: true ,
166
134
onFavoriteChanged: (isFavorite) =>
@@ -173,12 +141,45 @@ class _FavoriteProposals extends StatelessWidget {
173
141
}
174
142
}
175
143
176
- void _onFavoriteChanged (FundedProposal proposal, bool isFavorite) {
177
- final proposals = Set .of (_favoriteProposals.value);
178
- if (isFavorite) {
179
- proposals.add (proposal);
180
- } else {
181
- proposals.remove (proposal);
144
+ class _Tabs extends StatelessWidget {
145
+ const _Tabs ();
146
+
147
+ @override
148
+ Widget build (BuildContext context) {
149
+ return DefaultTabController (
150
+ length: 2 ,
151
+ child: Column (
152
+ mainAxisSize: MainAxisSize .min,
153
+ crossAxisAlignment: CrossAxisAlignment .start,
154
+ children: [
155
+ TabBar (
156
+ isScrollable: true ,
157
+ tabAlignment: TabAlignment .start,
158
+ tabs: [
159
+ Tab (
160
+ text: context.l10n.noOfFundedProposals (_proposals.length),
161
+ ),
162
+ Tab (
163
+ child: Row (
164
+ children: [
165
+ VoicesAssets .icons.plusCircleOutlined.buildIcon (),
166
+ const SizedBox (width: 8 ),
167
+ Text (context.l10n.followed),
168
+ ],
169
+ ),
170
+ ),
171
+ ],
172
+ ),
173
+ const SizedBox (height: 24 ),
174
+ const TabBarStackView (
175
+ children: [
176
+ _AllProposals (),
177
+ _FavoriteProposals (),
178
+ ],
179
+ ),
180
+ const SizedBox (height: 12 ),
181
+ ],
182
+ ),
183
+ );
182
184
}
183
- _favoriteProposals.value = proposals.toList ();
184
185
}
0 commit comments