Skip to content

Commit ae5554a

Browse files
committed
feat: creates a new extension on the ContentStatus enum. This extension provides a .l10n() method that will be used to display user-friendly, localized names for each status in the UI. This will resolve the compilation errors we encountered earlier in the data tables.
1 parent 834b2ac commit ae5554a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:flutter/widgets.dart';
2+
import 'package:ht_dashboard/l10n/l10n.dart';
3+
import 'package:ht_shared/ht_shared.dart';
4+
5+
/// Provides a localized string representation for [ContentStatus].
6+
extension ContentStatusL10n on ContentStatus {
7+
/// Returns the localized string for the status.
8+
String l10n(BuildContext context) {
9+
final l10n = context.l10n;
10+
switch (this) {
11+
case ContentStatus.active:
12+
// TODO(l10n): Add translation for contentStatusActive
13+
return 'Active';
14+
case ContentStatus.archived:
15+
// TODO(l10n): Add translation for contentStatusArchived
16+
return 'Archived';
17+
case ContentStatus.draft:
18+
// TODO(l10n): Add translation for contentStatusDraft
19+
return 'Draft';
20+
}
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'content_status_l10n.dart';

lib/shared/shared.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
library;
66

77
export 'constants/constants.dart';
8+
export 'extensions/extensions.dart';
89
export 'theme/theme.dart';
910
export 'utils/utils.dart';
1011
export 'widgets/widgets.dart';

0 commit comments

Comments
 (0)