Skip to content

Commit af571af

Browse files
committed
fix(community_management): handle null reaction and localize reaction types
- Add null check for engagement.reaction and display "N/A" if null - Implement extension method to provide localized names for reaction types - Update UI to use localized reaction type names
1 parent 60af73e commit af571af

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

lib/community_management/view/engagements_page.dart

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,22 @@ class _EngagementsDataSource extends DataTableSource {
198198
return DataRow2(
199199
cells: [
200200
DataCell(
201-
Chip(
202-
label: Text(engagement.reaction.reactionType.name),
203-
backgroundColor: _getReactionColor(
204-
context,
205-
engagement.reaction.reactionType,
206-
),
207-
side: BorderSide.none,
208-
visualDensity: VisualDensity.compact,
209-
),
201+
engagement.reaction != null
202+
? Chip(
203+
label: Text(
204+
engagement.reaction!.reactionType.l10n(context),
205+
),
206+
backgroundColor: _getReactionColor(
207+
context,
208+
engagement.reaction!.reactionType,
209+
),
210+
side: BorderSide.none,
211+
visualDensity: VisualDensity.compact,
212+
)
213+
: Text(
214+
l10n.notAvailable,
215+
style: Theme.of(context).textTheme.bodySmall,
216+
),
210217
),
211218
DataCell(
212219
Text(DateFormat('dd-MM-yyyy').format(engagement.createdAt.toLocal())),
@@ -243,3 +250,23 @@ class _EngagementsDataSource extends DataTableSource {
243250
}
244251
}
245252
}
253+
254+
extension on ReactionType {
255+
String l10n(BuildContext context) {
256+
final l10n = AppLocalizationsX(context).l10n;
257+
switch (this) {
258+
case ReactionType.like:
259+
return l10n.reactionTypeLike;
260+
case ReactionType.insightful:
261+
return l10n.reactionTypeInsightful;
262+
case ReactionType.amusing:
263+
return l10n.reactionTypeAmusing;
264+
case ReactionType.sad:
265+
return l10n.reactionTypeSad;
266+
case ReactionType.angry:
267+
return l10n.reactionTypeAngry;
268+
case ReactionType.skeptical:
269+
return l10n.reactionTypeSkeptical;
270+
}
271+
}
272+
}

0 commit comments

Comments
 (0)