Skip to content

Commit 9ce8d89

Browse files
LynxLynxxneil-iohkdamian-molinski
authored
chore(cat-voices): cherry-pick of Voices RC4 (#3607)
* chore: cherry-pick merge conflicts * fix(cat-voices): bugs found in RC3 for F15 (#3597) * Fixed copy in briefs * fix: not setting loading to false (#3594) * select category checkbox text (#3595) Co-authored-by: Ryszard Schossler <[email protected]> * fix: formating (#3588) Co-authored-by: Ryszard Schossler <[email protected]> Co-authored-by: Ryszard Schossler <[email protected]> * fix: keychain deleted dialog (#3598) --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Damian Moliński <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Damian Moliński <[email protected]>
1 parent 9bb741c commit 9ce8d89

File tree

10 files changed

+121
-67
lines changed

10 files changed

+121
-67
lines changed

catalyst_voices/apps/voices/lib/pages/account/widgets/account_keychain_tile.dart

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import 'dart:async';
22

33
import 'package:catalyst_voices/common/ext/build_context_ext.dart';
4+
import 'package:catalyst_voices/pages/account/delete_keychain_dialog.dart';
5+
import 'package:catalyst_voices/routes/routes.dart';
46
import 'package:catalyst_voices/widgets/widgets.dart';
57
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
68
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
9+
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
710
import 'package:flutter/material.dart';
811

12+
// TODO(damian-molinski): Remove this once KeychainDeletedDialog is migrated to CatalystMessenger.
13+
bool showKeychainDeletedDialog = false;
14+
915
class AccountKeychainTile extends StatefulWidget {
1016
final VoidCallback onRemoveTap;
1117

@@ -32,7 +38,7 @@ class _AccountKeychainTileState extends State<AccountKeychainTile> {
3238
style: ButtonStyle(
3339
textStyle: WidgetStatePropertyAll(context.textTheme.labelSmall),
3440
),
35-
onTap: widget.onRemoveTap,
41+
onTap: _removeKeychain,
3642
child: Text(context.l10n.removeKeychain),
3743
),
3844
child: VoicesTextField(
@@ -69,4 +75,34 @@ class _AccountKeychainTileState extends State<AccountKeychainTile> {
6975
.distinct()
7076
.listen((event) => _controller.text = event);
7177
}
78+
79+
Future<void> _removeKeychain() async {
80+
final confirmed = await DeleteKeychainDialog.show(context);
81+
if (!confirmed) {
82+
return;
83+
}
84+
85+
if (mounted) {
86+
await context.read<AccountCubit>().deleteActiveKeychain();
87+
showKeychainDeletedDialog = true;
88+
}
89+
90+
if (mounted) {
91+
// TODO(damian-molinski): refactor it. Should be inside AccountCubit and emit signals to page.
92+
final phaseType = context.read<CampaignPhaseAwareCubit>().state.activeCampaignPhaseType;
93+
94+
switch (phaseType) {
95+
case CampaignPhaseType.communityReview:
96+
case CampaignPhaseType.communityVoting:
97+
const VotingRoute($extra: true).go(context);
98+
case null:
99+
case CampaignPhaseType.proposalSubmission:
100+
case CampaignPhaseType.votingRegistration:
101+
case CampaignPhaseType.reviewRegistration:
102+
case CampaignPhaseType.votingResults:
103+
case CampaignPhaseType.projectOnboarding:
104+
const DiscoveryRoute($extra: true).go(context);
105+
}
106+
}
107+
}
72108
}

catalyst_voices/apps/voices/lib/pages/discovery/discovery_page.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22

33
import 'package:catalyst_voices/common/error_handler.dart';
44
import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart';
5+
import 'package:catalyst_voices/pages/account/widgets/account_keychain_tile.dart';
56
import 'package:catalyst_voices/pages/campaign_phase_aware/proposal_submission_phase_aware.dart';
67
import 'package:catalyst_voices/pages/discovery/sections/campaign_hero.dart';
78
import 'package:catalyst_voices/pages/discovery/sections/how_it_works.dart';
@@ -17,7 +18,10 @@ import 'package:sentry_flutter/sentry_flutter.dart';
1718
class DiscoveryPage extends StatefulWidget {
1819
final bool keychainDeleted;
1920

20-
const DiscoveryPage({super.key, this.keychainDeleted = false});
21+
const DiscoveryPage({
22+
super.key,
23+
this.keychainDeleted = false,
24+
});
2125

2226
@override
2327
State<DiscoveryPage> createState() => _DiscoveryPageState();
@@ -71,7 +75,8 @@ class _DiscoveryPageState extends State<DiscoveryPage>
7175
void didUpdateWidget(DiscoveryPage oldWidget) {
7276
super.didUpdateWidget(oldWidget);
7377

74-
if (widget.keychainDeleted && widget.keychainDeleted != oldWidget.keychainDeleted) {
78+
if (showKeychainDeletedDialog) {
79+
showKeychainDeletedDialog = false;
7580
WidgetsBinding.instance.addPostFrameCallback((_) async {
7681
await _showKeychainDeletedDialog(context);
7782
});
@@ -84,7 +89,8 @@ class _DiscoveryPageState extends State<DiscoveryPage>
8489

8590
unawaited(_loadData());
8691

87-
if (widget.keychainDeleted) {
92+
if (showKeychainDeletedDialog) {
93+
showKeychainDeletedDialog = false;
8894
WidgetsBinding.instance.addPostFrameCallback((_) async {
8995
await _showKeychainDeletedDialog(context);
9096
});

catalyst_voices/apps/voices/lib/pages/discovery/sections/stay_involved.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class _ReviewerCard extends StatelessWidget {
168168
),
169169
BlocSelector<DiscoveryCubit, DiscoveryState, DateRange?>(
170170
selector: (state) {
171-
return state.campaign.votingStartsAt;
171+
return state.campaign.reviewStartsAt;
172172
},
173173
builder: (context, date) {
174174
return _DatetimeRangeTimeline(

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:async';
33
import 'package:catalyst_voices/common/error_handler.dart';
44
import 'package:catalyst_voices/common/signal_handler.dart';
55
import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart';
6+
import 'package:catalyst_voices/pages/account/widgets/account_keychain_tile.dart';
67
import 'package:catalyst_voices/pages/campaign_phase_aware/campaign_phase_aware.dart';
78
import 'package:catalyst_voices/pages/voting/widgets/content/pre_voting_content.dart';
89
import 'package:catalyst_voices/pages/voting/widgets/content/voting_background.dart';
@@ -92,6 +93,13 @@ class _VotingPageState extends State<VotingPage>
9293
if (widget.tab != oldWidget.tab) {
9394
_tabController.animateToTab(tab);
9495
}
96+
97+
if (showKeychainDeletedDialog) {
98+
showKeychainDeletedDialog = false;
99+
WidgetsBinding.instance.addPostFrameCallback((_) async {
100+
await _showKeychainDeletedDialog(context);
101+
});
102+
}
95103
}
96104

97105
@override
@@ -160,7 +168,8 @@ class _VotingPageState extends State<VotingPage>
160168

161169
// TODO(damian-molinski): same behavior already exists in DiscoveryPage because
162170
// of way confirmation dialog is shown. Refactor it.
163-
if (widget.keychainDeleted) {
171+
if (showKeychainDeletedDialog) {
172+
showKeychainDeletedDialog = false;
164173
WidgetsBinding.instance.addPostFrameCallback((_) async {
165174
await _showKeychainDeletedDialog(context);
166175
});

catalyst_voices/apps/voices/lib/widgets/modals/proposals/create_new_proposal_action_buttons.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:async';
22

3-
import 'package:catalyst_voices/common/ext/active_fund_number_selector_ext.dart';
43
import 'package:catalyst_voices/common/ext/build_context_ext.dart';
54
import 'package:catalyst_voices/routes/routing/proposal_builder_route.dart';
65
import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart';
@@ -28,24 +27,29 @@ class CreateNewProposalActionButtons extends StatelessWidget {
2827
color: context.colors.outlineBorderVariant,
2928
),
3029
),
30+
color: context.colors.elevationsOnSurfaceNeutralLv1White,
3131
),
32-
padding: const EdgeInsets.fromLTRB(24, 16, 24, 24),
32+
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 16),
3333
child: switch (step) {
3434
CreateProposalWithPreselectedCategoryStep() => const Row(
3535
mainAxisAlignment: MainAxisAlignment.spaceBetween,
36+
spacing: 8,
3637
children: [
37-
_AgreementCheckboxes(),
38+
Flexible(
39+
child: _AgreementCheckboxes(),
40+
),
3841
_StartProposalButton(),
3942
],
4043
),
4144
CreateProposalWithoutPreselectedCategoryStep(:final stage)
4245
when stage == CreateProposalStage.selectCategory =>
4346
const Row(
47+
spacing: 8,
4448
children: [
45-
_AgreementCheckboxes(),
46-
Spacer(),
49+
Flexible(
50+
child: _AgreementCheckboxes(),
51+
),
4752
_BackButton(),
48-
SizedBox(width: 8),
4953
_StartProposalButton(),
5054
],
5155
),
@@ -88,7 +92,7 @@ class _AgreementCheckboxes extends StatelessWidget {
8892
context.read<NewProposalCubit>().updateAgreeToNoFurtherCategoryChange(value: value);
8993
},
9094
label: Text(
91-
context.l10n.agreementCantChangeCategory(context.activeCampaignFundNumber),
95+
context.l10n.agreementCantChangeCategory,
9296
),
9397
),
9498
],

catalyst_voices/apps/voices/lib/widgets/modals/proposals/create_new_proposal_category_selection.dart

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -94,40 +94,37 @@ class _CreateNewProposalCategorySelectionState extends State<CreateNewProposalCa
9494
@override
9595
Widget build(BuildContext context) {
9696
return Expanded(
97-
child: Padding(
98-
padding: const EdgeInsets.only(bottom: 68),
99-
child: Row(
100-
crossAxisAlignment: CrossAxisAlignment.start,
101-
children: [
102-
Expanded(
103-
child: ListView.separated(
104-
itemBuilder: (context, index) => _CategoryCard(
105-
name: widget.categories[index].formattedName,
106-
description: widget.categories[index].shortDescription,
107-
ref: widget.categories[index].id,
108-
isSelected: widget.categories[index].id == widget.selectedCategory,
109-
onCategorySelected: widget.onCategorySelected,
110-
),
111-
separatorBuilder: (context, index) => const SizedBox(height: 16),
112-
itemCount: widget.categories.length,
97+
child: Row(
98+
crossAxisAlignment: CrossAxisAlignment.start,
99+
children: [
100+
Expanded(
101+
child: ListView.separated(
102+
itemBuilder: (context, index) => _CategoryCard(
103+
name: widget.categories[index].formattedName,
104+
description: widget.categories[index].shortDescription,
105+
ref: widget.categories[index].id,
106+
isSelected: widget.categories[index].id == widget.selectedCategory,
107+
onCategorySelected: widget.onCategorySelected,
113108
),
109+
separatorBuilder: (context, index) => const SizedBox(height: 16),
110+
itemCount: widget.categories.length,
114111
),
115-
const SizedBox(width: 16),
116-
Expanded(
117-
flex: 2,
118-
child: _selectedCategory != null
119-
? VoicesScrollbar(
112+
),
113+
const SizedBox(width: 16),
114+
Expanded(
115+
flex: 2,
116+
child: _selectedCategory != null
117+
? VoicesScrollbar(
118+
controller: _scrollController,
119+
alwaysVisible: true,
120+
child: SingleChildScrollView(
120121
controller: _scrollController,
121-
alwaysVisible: true,
122-
child: SingleChildScrollView(
123-
controller: _scrollController,
124-
child: CategoryCompactDetailView(category: _selectedCategory!),
125-
),
126-
)
127-
: const _NoneCategorySelected(),
128-
),
129-
],
130-
),
122+
child: CategoryCompactDetailView(category: _selectedCategory!),
123+
),
124+
)
125+
: const _NoneCategorySelected(),
126+
),
127+
],
131128
),
132129
);
133130
}

catalyst_voices/apps/voices/lib/widgets/modals/proposals/create_new_proposal_dialog.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,15 @@ class _ContentView extends StatelessWidget {
9292

9393
@override
9494
Widget build(BuildContext context) {
95-
return Stack(
95+
return Column(
9696
children: [
97-
Padding(
98-
padding: const EdgeInsets.fromLTRB(24, 0, 24, 24),
99-
child: child,
100-
),
101-
Align(
102-
alignment: Alignment.bottomCenter,
103-
child: CreateNewProposalActionButtons(step: step),
97+
Expanded(
98+
child: Padding(
99+
padding: const EdgeInsets.fromLTRB(24, 0, 24, 6),
100+
child: child,
101+
),
104102
),
103+
CreateNewProposalActionButtons(step: step),
105104
],
106105
);
107106
}
@@ -159,6 +158,7 @@ class _ProposalCategory extends StatelessWidget {
159158
Widget build(BuildContext context) {
160159
return Column(
161160
crossAxisAlignment: CrossAxisAlignment.start,
161+
mainAxisSize: MainAxisSize.min,
162162
spacing: 28,
163163
children: [
164164
_SectionTitle(

catalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/category/category_detail_cubit.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class CategoryDetailCubit extends Cubit<CategoryDetailState> {
4444
}
4545

4646
Future<void> getCategoryDetail(SignedDocumentRef categoryId) async {
47-
if (categoryId.id == state.category?.id.id) return;
47+
if (categoryId.id == state.category?.id.id) {
48+
return emit(state.copyWith(isLoading: false));
49+
}
4850

4951
if (!state.isLoading) {
5052
emit(state.copyWith(isLoading: true));

catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,9 @@
113113
"@agree": {
114114
"description": "Button text for confirming agreement"
115115
},
116-
"agreementCantChangeCategory": "I understand that I can’t change my category selection in Fund{fundNumber}.",
116+
"agreementCantChangeCategory": "I understand that after I choose a category, the proposal’s category is locked and switching categories requires creating a new proposal.",
117117
"@agreementCantChangeCategory": {
118-
"description": "Text for the agreement checkbox that explains that user can't change category selection in Fund",
119-
"placeholders": {
120-
"fundNumber": {
121-
"description": "Number of fund",
122-
"type": "int"
123-
}
124-
}
118+
"description": "Text for the agreement checkbox that explains that user can't change category selection"
125119
},
126120
"agreementFitToCategoryCriteria": "I understand the category brief and will make sure my proposal fits the criteria.",
127121
"@agreementFitToCategoryCriteria": {

0 commit comments

Comments
 (0)