-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cat-voices): Proposal setup section (#1177)
* chore: Adding needed translation * feat: Adding models for guidance and comment * feat: Adding widgets for guidance and comment * feat: Guidance cubit for filtering guidance in the view * test: Adding tests to VoicesDropdown Widget * feat: reacting to changing state of proposal navigation * feat: add new dictionary entry for ryszard-schossler and update guidance extension comments for clarity * fix: empty list of guidance * refactor: applying sugestion from code review * chore: update .gitignore to exclude devtools_options.yaml and remove obsolete files from voices and uikit_example directories * refactor: naming cleanup * Delete catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart * Delete catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart * Delete catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart --------- Co-authored-by: Dominik Toton <[email protected]> Co-authored-by: Damian Molinski <[email protected]> Co-authored-by: Damian Moliński <[email protected]>
- Loading branch information
1 parent
31ad353
commit d7db9f8
Showing
20 changed files
with
709 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,7 @@ trailings | |
TXNZD | ||
txos | ||
Typer | ||
ryszard-schossler | ||
unawaited | ||
unchunk | ||
Unlogged | ||
|
21 changes: 21 additions & 0 deletions
21
catalyst_voices/apps/voices/lib/common/ext/guidance_ext.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:catalyst_voices_localization/generated/catalyst_voices_localizations.dart'; | ||
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart'; | ||
|
||
extension GuidanceExt on GuidanceType { | ||
String localizedType(VoicesLocalizations localizations) => switch (this) { | ||
GuidanceType.mandatory => localizations.mandatoryGuidanceType, | ||
GuidanceType.education => localizations.educationGuidanceType, | ||
GuidanceType.tips => localizations.tipsGuidanceType, | ||
}; | ||
|
||
// TODO(ryszard-schossler): when designers will | ||
// provide us with icon, change here accordingly | ||
SvgGenImage get icon { | ||
return switch (this) { | ||
GuidanceType.education => VoicesAssets.icons.newspaper, | ||
GuidanceType.mandatory => VoicesAssets.icons.newspaper, | ||
GuidanceType.tips => VoicesAssets.icons.newspaper, | ||
}; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
catalyst_voices/apps/voices/lib/pages/workspace/workspace_guidance_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import 'package:catalyst_voices/common/ext/guidance_ext.dart'; | ||
import 'package:catalyst_voices/widgets/cards/guidance_card.dart'; | ||
import 'package:catalyst_voices/widgets/dropdown/voices_dropdown.dart'; | ||
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; | ||
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class GuidanceView extends StatefulWidget { | ||
final List<Guidance> guidances; | ||
const GuidanceView(this.guidances); | ||
|
||
@override | ||
State<GuidanceView> createState() => _GuidanceViewState(); | ||
} | ||
|
||
class _GuidanceViewState extends State<GuidanceView> { | ||
final List<Guidance> filteredGuidances = []; | ||
|
||
GuidanceType? selectedType; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
filteredGuidances | ||
..clear() | ||
..addAll(widget.guidances); | ||
} | ||
|
||
@override | ||
void didUpdateWidget(GuidanceView oldWidget) { | ||
super.didUpdateWidget(oldWidget); | ||
if (oldWidget.guidances != widget.guidances) { | ||
filteredGuidances | ||
..clear() | ||
..addAll(widget.guidances); | ||
_filterGuidances(selectedType); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.end, | ||
children: [ | ||
VoicesDropdown<GuidanceType?>( | ||
items: GuidanceType.values | ||
.map( | ||
(e) => VoicesDropdownMenuEntry<GuidanceType>( | ||
label: e.localizedType(context.l10n), | ||
value: e, | ||
context: context, | ||
), | ||
) | ||
.toList(), | ||
onChanged: (value) { | ||
setState(() { | ||
_filterGuidances(value); | ||
}); | ||
}, | ||
value: selectedType, | ||
), | ||
if (filteredGuidances.isEmpty) | ||
Center( | ||
child: Text(context.l10n.noGuidanceOfThisType), | ||
), | ||
Column( | ||
children: filteredGuidances | ||
.sortedByWeight() | ||
.toList() | ||
.map((e) => GuidanceCard(guidance: e)) | ||
.toList(), | ||
), | ||
], | ||
); | ||
} | ||
|
||
void _filterGuidances(GuidanceType? type) { | ||
selectedType = type; | ||
filteredGuidances | ||
..clear() | ||
..addAll( | ||
type == null | ||
? widget.guidances | ||
: widget.guidances.where((e) => e.type == type).toList(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
catalyst_voices/apps/voices/lib/widgets/cards/comment_card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:catalyst_voices/widgets/avatars/voices_avatar.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CommentCard extends StatelessWidget { | ||
final Comment comment; | ||
|
||
const CommentCard({ | ||
super.key, | ||
required this.comment, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return DecoratedBox( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(16), | ||
border: Border.all( | ||
color: Theme.of(context).colorScheme.outline.withOpacity(.38), | ||
width: 1, | ||
), | ||
), | ||
child: Padding( | ||
padding: const EdgeInsets.all(16), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
VoicesAssets.icons.chatAlt.buildIcon(), | ||
const SizedBox(height: 10), | ||
Text(comment.text), | ||
const SizedBox(height: 10), | ||
Row( | ||
children: [ | ||
VoicesAvatar(icon: VoicesAssets.icons.user.buildIcon()), | ||
const SizedBox(width: 8), | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text(comment.userName), | ||
Text(comment.date.toString()), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.