Skip to content

Commit 1e4f48a

Browse files
authored
feat(cat-voices): proposal builder view/edit adjustments (#2142)
* feat: update document property section buttons * feat: update title widget * feat: add property read widget * feat: document property viewer widget * feat: distinguish between answered and not answered * feat: handle overriden widgets in document builder viewer * fix: submit proposal for review * feat: cleanup colors, update save button * chore: cleanup * chore: cleanup * feat: update rich text widget * style: spelling
1 parent 0d63fad commit 1e4f48a

33 files changed

+957
-479
lines changed

catalyst_voices/apps/voices/integration_test/pageobject/profile_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ProfilePage {
99
late PatrolTester $;
1010
final displayNameTile = const Key('AccountDisplayNameTile');
1111
final accountEmailTile = const Key('AccountEmailTile');
12-
final editBtn = const Key('EditableTileEditSaveButton');
12+
final editBtn = const Key('EditableTileEditCancelButton');
1313
final accountRolesTile = const Key('AddRoleTile');
1414
final addRole = const Key('EditRolesButton');
1515
final removeKeychain = const Key('RemoveKeychainButton');

catalyst_voices/apps/voices/lib/pages/proposal_builder/appbar/proposal_builder_status_action.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,19 @@ class _PopupMenuButtonState extends State<_PopupMenuButton> {
269269

270270
final nextIteration = latestVersion.number;
271271

272-
// if it's local draft and the first version then
273-
// it should be shown as local which corresponds to null
274-
final currentIteration =
275-
_isLocal(state.metadata.publish, nextIteration) ? null : nextIteration;
272+
final int? currentIteration;
273+
if (_isLocal(state.metadata.publish, nextIteration)) {
274+
// if it's local draft and the first version then
275+
// it should be shown as local which corresponds to null
276+
currentIteration = null;
277+
} else if (state.metadata.publish == ProposalPublish.localDraft) {
278+
// current iteration is a local draft
279+
// so next iteration must increment the version
280+
currentIteration = nextIteration - 1;
281+
} else {
282+
// only changing status of the iteration, no need to increment the version
283+
currentIteration = nextIteration;
284+
}
276285

277286
final shouldSubmit = await SubmitProposalForReviewDialog.show(
278287
context: context,

catalyst_voices/apps/voices/lib/widgets/buttons/voices_buttons.dart

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,41 +270,70 @@ class VoicesBackButton extends StatelessWidget {
270270
}
271271
}
272272

273-
class VoicesEditSaveButton extends StatelessWidget {
273+
class VoicesEditCancelButton extends StatelessWidget {
274+
final VoicesEditCancelButtonStyle style;
274275
final VoidCallback? onTap;
275276
final bool isEditing;
276277
final bool hasError;
277278

278-
const VoicesEditSaveButton({
279+
const VoicesEditCancelButton({
279280
super.key,
281+
this.style = VoicesEditCancelButtonStyle.text,
280282
this.onTap,
281283
required this.isEditing,
282284
this.hasError = false,
283285
});
284286

285287
@override
286288
Widget build(BuildContext context) {
289+
final theme = Theme.of(context);
287290
final text =
288291
isEditing ? context.l10n.cancelButtonText : context.l10n.editButtonText;
292+
final textStyle = theme.textTheme.labelSmall!;
289293

290294
if (hasError) {
291295
return VoicesFilledButton(
292-
backgroundColor: Theme.of(context).colorScheme.error,
296+
backgroundColor: theme.colorScheme.error,
293297
onTap: onTap,
294-
child: Text(text),
298+
child: Text(
299+
text,
300+
style: textStyle.copyWith(color: theme.colorScheme.onError),
301+
),
295302
);
296-
} else {
303+
}
304+
305+
if (isEditing) {
297306
return VoicesTextButton(
298307
onTap: onTap,
299308
child: Text(
300309
text,
301-
style: Theme.of(context).textTheme.labelSmall,
310+
style: textStyle.copyWith(color: theme.colorScheme.error),
302311
),
303312
);
304313
}
314+
315+
return switch (style) {
316+
VoicesEditCancelButtonStyle.text => VoicesTextButton(
317+
onTap: onTap,
318+
child: Text(text, style: textStyle),
319+
),
320+
VoicesEditCancelButtonStyle.outlinedWithIcon => VoicesOutlinedButton(
321+
onTap: onTap,
322+
leading: VoicesAssets.icons.pencilAlt.buildIcon(),
323+
child: Text(
324+
text,
325+
style: textStyle.copyWith(color: theme.colorScheme.primary),
326+
),
327+
),
328+
};
305329
}
306330
}
307331

332+
enum VoicesEditCancelButtonStyle {
333+
text,
334+
outlinedWithIcon,
335+
}
336+
308337
/// A "Learn More" button that redirects usually to an external content.
309338
class VoicesLearnMoreButton extends StatelessWidget {
310339
final VoidCallback onTap;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
2+
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
3+
import 'package:flutter/material.dart';
4+
5+
class DocumentPropertyBuilderTitle extends StatelessWidget {
6+
final String title;
7+
final bool isRequired;
8+
final Color? color;
9+
10+
const DocumentPropertyBuilderTitle({
11+
super.key,
12+
required this.title,
13+
required this.isRequired,
14+
this.color,
15+
});
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return Text(
20+
title.starred(isEnabled: isRequired),
21+
maxLines: 1,
22+
overflow: TextOverflow.ellipsis,
23+
style: Theme.of(context).textTheme.bodySmall?.copyWith(
24+
color: color ?? Theme.of(context).colors.textOnPrimaryLevel1,
25+
),
26+
);
27+
}
28+
}

catalyst_voices/apps/voices/lib/widgets/document_builder/document_list_property_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:catalyst_voices/widgets/document_builder/common/document_error_text.dart';
12
import 'package:catalyst_voices/widgets/document_builder/value/document_builder_value_widget.dart';
23
import 'package:catalyst_voices/widgets/widgets.dart';
34
import 'package:catalyst_voices_models/catalyst_voices_models.dart'

catalyst_voices/apps/voices/lib/widgets/document_builder/document_object_property_builder.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:catalyst_voices/widgets/document_builder/common/document_error_text.dart';
2+
import 'package:catalyst_voices/widgets/document_builder/common/document_property_builder_title.dart';
13
import 'package:catalyst_voices/widgets/document_builder/value/document_builder_value_widget.dart';
24
import 'package:catalyst_voices/widgets/widgets.dart';
35
import 'package:catalyst_voices_models/catalyst_voices_models.dart'
@@ -85,9 +87,9 @@ class _FormField extends VoicesFormField<DocumentObjectProperty> {
8587
crossAxisAlignment: CrossAxisAlignment.start,
8688
children: [
8789
if (title.isNotEmpty && !schema.isSectionOrSubsection) ...[
88-
Text(
89-
title,
90-
style: Theme.of(context).textTheme.titleSmall,
90+
DocumentPropertyBuilderTitle(
91+
title: title,
92+
isRequired: false,
9193
),
9294
const SizedBox(height: 8),
9395
],

catalyst_voices/apps/voices/lib/widgets/document_builder/value/agreement_confirmation_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:catalyst_voices/widgets/document_builder/value/document_error_text.dart';
1+
import 'package:catalyst_voices/widgets/document_builder/common/document_error_text.dart';
22
import 'package:catalyst_voices/widgets/widgets.dart';
33
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
44
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';

catalyst_voices/apps/voices/lib/widgets/document_builder/value/document_builder_value_widget.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export 'agreement_confirmation_widget.dart';
2-
export 'document_error_text.dart';
32
export 'document_token_value_widget.dart';
43
export 'duration_in_months_widget.dart';
54
export 'language_code_widget.dart';

catalyst_voices/apps/voices/lib/widgets/document_builder/value/duration_in_months_widget.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import 'package:catalyst_voices/widgets/document_builder/common/document_property_builder_title.dart';
12
import 'package:catalyst_voices/widgets/dropdown/voices_dropdown.dart';
23
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
3-
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
44
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
55
import 'package:flutter/material.dart';
66

@@ -23,12 +23,12 @@ class DurationInMonthsWidget extends StatefulWidget {
2323
}
2424

2525
class _DurationInMonthsWidgetState extends State<DurationInMonthsWidget> {
26-
int? get _value => widget.property.value ?? widget.schema.defaultValue;
27-
String get _title => widget.schema.title;
2826
bool get _isRequired => widget.schema.isRequired;
29-
String? get _placeholder => widget.schema.placeholder;
30-
int get _min => widget.schema.numRange?.min ?? 0;
3127
int get _max => widget.schema.numRange?.max ?? 0;
28+
int get _min => widget.schema.numRange?.min ?? 0;
29+
String? get _placeholder => widget.schema.placeholder;
30+
String get _title => widget.schema.title;
31+
int? get _value => widget.property.value ?? widget.schema.defaultValue;
3232

3333
@override
3434
Widget build(BuildContext context) {
@@ -37,9 +37,9 @@ class _DurationInMonthsWidgetState extends State<DurationInMonthsWidget> {
3737
mainAxisSize: MainAxisSize.min,
3838
children: [
3939
if (_title.isNotEmpty) ...[
40-
Text(
41-
_title.starred(isEnabled: _isRequired),
42-
style: Theme.of(context).textTheme.titleSmall,
40+
DocumentPropertyBuilderTitle(
41+
title: _title,
42+
isRequired: _isRequired,
4343
),
4444
const SizedBox(height: 8),
4545
SingleSelectDropdown(

0 commit comments

Comments
 (0)