@@ -3,6 +3,8 @@ import 'package:data_table_2/data_table_2.dart';
33import 'package:flutter/material.dart' ;
44import 'package:flutter_bloc/flutter_bloc.dart' ;
55import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart' ;
6+ import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/app_user_role_l10n.dart' ;
7+ import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/dashboard_user_role_l10n.dart' ;
68import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
79import 'package:flutter_news_app_web_dashboard_full_source_code/user_management/bloc/user_filter/user_filter_bloc.dart' ;
810import 'package:flutter_news_app_web_dashboard_full_source_code/user_management/bloc/user_management_bloc.dart' ;
@@ -41,9 +43,7 @@ class _UsersPageState extends State<UsersPage> {
4143
4244 /// Checks if any filters are currently active in the UserFilterBloc.
4345 bool _areFiltersActive (UserFilterState state) {
44- return state.searchQuery.isNotEmpty ||
45- state.selectedAppRoles.isNotEmpty ||
46- state.selectedDashboardRoles.isNotEmpty;
46+ return state.searchQuery.isNotEmpty || state.selectedAppRoles.isNotEmpty;
4747 }
4848
4949 @override
@@ -129,16 +129,16 @@ class _UsersPageState extends State<UsersPage> {
129129 size: ColumnSize .L ,
130130 ),
131131 DataColumn2 (
132- label: Text (l10n.appRole ),
132+ label: Text (l10n.authentication ),
133133 size: ColumnSize .S ,
134134 ),
135135 DataColumn2 (
136- label: Text (l10n.dashboardRole ),
136+ label: Text (l10n.subscription ),
137137 size: ColumnSize .S ,
138138 ),
139139 DataColumn2 (
140140 label: Text (l10n.createdAt),
141- size: ColumnSize .S ,
141+ size: ColumnSize .M ,
142142 ),
143143 DataColumn2 (
144144 label: Text (l10n.actions),
@@ -213,10 +213,23 @@ class _UsersDataSource extends DataTableSource {
213213 return DataRow2 (
214214 // We don't implement onSelectChanged because user edits are handled
215215 // via the action buttons, not by navigating to a dedicated edit page.
216+ // The email cell is wrapped in an Expanded widget to allow truncation.
216217 cells: [
217- DataCell (Text (user.email)),
218- DataCell (Text (user.appRole.name)),
219- DataCell (Text (user.dashboardRole.name)),
218+ DataCell (
219+ Row (
220+ children: [
221+ Expanded (
222+ child: Text (
223+ user.email,
224+ overflow: TextOverflow .ellipsis,
225+ maxLines: 1 ,
226+ ),
227+ ),
228+ ],
229+ ),
230+ ),
231+ DataCell (Text (user.appRole.authenticationStatusL10n (context))),
232+ DataCell (Text (user.appRole.subscriptionStatusL10n (context))),
220233 DataCell (
221234 Text (
222235 DateFormat ('dd-MM-yyyy' ).format (user.createdAt.toLocal ()),
@@ -241,3 +254,35 @@ class _UsersDataSource extends DataTableSource {
241254 @override
242255 int get selectedRowCount => 0 ;
243256}
257+
258+ /// An extension to get the localized string for the authentication status
259+ /// derived from [AppUserRole] .
260+ extension AuthenticationStatusL10n on AppUserRole {
261+ /// Returns the localized authentication status string.
262+ String authenticationStatusL10n (BuildContext context) {
263+ final l10n = AppLocalizationsX (context).l10n;
264+ switch (this ) {
265+ case AppUserRole .guestUser:
266+ return l10n.authenticationAnonymous;
267+ case AppUserRole .standardUser:
268+ case AppUserRole .premiumUser:
269+ return l10n.authenticationAuthenticated;
270+ }
271+ }
272+ }
273+
274+ /// An extension to get the localized string for the subscription status
275+ /// derived from [AppUserRole] .
276+ extension SubscriptionStatusL10n on AppUserRole {
277+ /// Returns the localized subscription status string.
278+ String subscriptionStatusL10n (BuildContext context) {
279+ final l10n = AppLocalizationsX (context).l10n;
280+ switch (this ) {
281+ case AppUserRole .guestUser:
282+ case AppUserRole .standardUser:
283+ return l10n.subscriptionFree;
284+ case AppUserRole .premiumUser:
285+ return l10n.subscriptionPremium;
286+ }
287+ }
288+ }
0 commit comments