Skip to content

Commit d25d16c

Browse files
authored
fix(cat-voices): Proposal builder UI fixes (#2320)
* chore: rename files * fix: make sure guidance for subsection is not shown under parent section * fix: guidance title * fix: jump scroll to top when guidance changes
1 parent 6ea3709 commit d25d16c

File tree

7 files changed

+45
-21
lines changed

7 files changed

+45
-21
lines changed
Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,54 @@
1+
import 'dart:async';
2+
13
import 'package:catalyst_voices/pages/proposal_builder/proposal_builder_guidance.dart';
24
import 'package:catalyst_voices/widgets/widgets.dart';
5+
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
36
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
47
import 'package:flutter/material.dart';
8+
import 'package:flutter_bloc/flutter_bloc.dart';
59

6-
class ProposalBuilderSetupPanel extends StatelessWidget {
10+
class ProposalBuilderSetupPanel extends StatefulWidget {
711
const ProposalBuilderSetupPanel({super.key});
812

13+
@override
14+
State<ProposalBuilderSetupPanel> createState() =>
15+
_ProposalBuilderSetupPanelState();
16+
}
17+
18+
class _ProposalBuilderSetupPanelState extends State<ProposalBuilderSetupPanel> {
19+
final ScrollController _scrollController = ScrollController();
20+
StreamSubscription<dynamic>? _guidanceSub;
21+
922
@override
1023
Widget build(BuildContext context) {
1124
return SpaceSidePanel(
1225
isLeft: false,
26+
scrollController: _scrollController,
1327
onCollapseTap: () {},
1428
tabs: [
1529
SpaceSidePanelTab(
1630
name: context.l10n.guidance,
1731
body: const ProposalBuilderGuidanceSelector(),
1832
),
19-
// TODO(damian-molinski): uncomment and implement when builder
20-
// collaboration is ready.
21-
/*SpaceSidePanelTab(
22-
name: 'Comments',
23-
body: CommentCard(
24-
comment: Comment(
25-
text: 'Lacks clarity on key objectives and measurable outcomes.',
26-
date: DateTime.now(),
27-
userName: 'Community Member',
28-
),
29-
),
30-
),*/
31-
//No actions for now
32-
// SpaceSidePanelTab(
33-
// name: 'Actions',
34-
// body: const Offstage(),
35-
// ),
3633
],
3734
);
3835
}
36+
37+
@override
38+
void dispose() {
39+
_scrollController.dispose();
40+
unawaited(_guidanceSub?.cancel());
41+
super.dispose();
42+
}
43+
44+
@override
45+
void initState() {
46+
super.initState();
47+
final bloc = context.read<ProposalBuilderBloc>();
48+
49+
_guidanceSub = bloc.stream
50+
.map((state) => state.guidance)
51+
.distinct()
52+
.listen((_) => _scrollController.jumpTo(0));
53+
}
3954
}

β€Žcatalyst_voices/apps/voices/lib/pages/proposals/widgets/proposals_pagination.dartβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:catalyst_voices/pages/proposals/widgets/proposals_pagination_empty_state.dart';
22
import 'package:catalyst_voices/pages/proposals/widgets/proposals_pagination_tile.dart';
33
import 'package:catalyst_voices/widgets/pagination/builders/paged_wrap_child_builder.dart';
4-
import 'package:catalyst_voices/widgets/pagination/layouts/paginated_grid_view.dart.dart';
4+
import 'package:catalyst_voices/widgets/pagination/layouts/paginated_grid_view.dart';
55
import 'package:catalyst_voices/widgets/pagination/paging_controller.dart';
66
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
77
import 'package:flutter/material.dart';

β€Žcatalyst_voices/apps/voices/lib/widgets/containers/sidebar/space_side_panel.dartβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class SpaceSidePanel extends StatefulWidget {
1313
final bool isLeft;
1414
final VoidCallback? onCollapseTap;
1515
final TabController? tabController;
16+
final ScrollController? scrollController;
1617
final List<SpaceSidePanelTab> tabs;
1718
final EdgeInsetsGeometry margin;
1819

@@ -21,6 +22,7 @@ class SpaceSidePanel extends StatefulWidget {
2122
required this.isLeft,
2223
this.onCollapseTap,
2324
this.tabController,
25+
this.scrollController,
2426
required this.tabs,
2527
this.margin = const EdgeInsets.only(
2628
top: 12,
@@ -153,6 +155,7 @@ class _SpaceSidePanelState extends State<SpaceSidePanel>
153155
const SizedBox(height: 12),
154156
Flexible(
155157
child: SingleChildScrollView(
158+
controller: widget.scrollController,
156159
padding: const EdgeInsets.only(bottom: 12),
157160
child: TabBarStackView(
158161
controller: widget.tabController,

β€Žcatalyst_voices/apps/voices/lib/widgets/document_builder/value/document_builder_value_widget.dartβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export 'radio_button_selection_widget.dart';
88
export 'simple_text_entry_widget.dart';
99
export 'single_dropdown_selection_widget.dart';
1010
export 'single_grouped_tag_selector_widget.dart';
11-
export 'single_line_https_url_widget.dart.dart';
11+
export 'single_line_https_url_widget.dart';
1212
export 'yes_no_choice_widget.dart';

β€Žcatalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/proposal_builder/proposal_builder_bloc.dartβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,17 @@ final class ProposalBuilderBloc
244244
DocumentSection section,
245245
DocumentProperty property,
246246
) sync* {
247+
if (property.schema.isSubsection && section.id != property.nodeId) {
248+
// Since the property is a standalone subsection we cannot
249+
// lookup guidance items for it in a context of given section.
250+
return;
251+
}
252+
247253
final guidance = property.schema.guidance;
248254
if (guidance != null) {
249255
yield ProposalGuidanceItem(
250256
segmentTitle: segment.schema.title,
251-
sectionTitle: section.schema.title,
257+
sectionTitle: property.schema.title,
252258
description: guidance,
253259
);
254260
}

0 commit comments

Comments
Β (0)