Skip to content

Commit 97776e6

Browse files
committed
refactor(local_ads_management): improve layout and functionality of data table
- Remove status column and archive/edit actions from main row - Add PopupMenuButton for secondary actions (edit and archive) - Copy ID action remains as a primary action - Adjust column sizes and remove fixed width restrictions
1 parent 4b1949b commit 97776e6

File tree

4 files changed

+60
-47
lines changed

4 files changed

+60
-47
lines changed

lib/content_management/view/headlines_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/content_manageme
66
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart';
77
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
88
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
9-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/content_status_l10n.dart';
109
import 'package:go_router/go_router.dart';
1110
import 'package:intl/intl.dart';
1211
import 'package:ui_kit/ui_kit.dart';

lib/content_management/view/sources_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/content_manageme
66
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart';
77
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
88
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
9-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/content_status_l10n.dart';
109
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/source_type_l10n.dart';
1110
import 'package:go_router/go_router.dart';
1211
import 'package:intl/intl.dart';

lib/content_management/view/topics_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/content_manageme
66
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart';
77
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
88
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
9-
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/shared.dart';
109
import 'package:go_router/go_router.dart';
1110
import 'package:intl/intl.dart';
1211
import 'package:ui_kit/ui_kit.dart';

lib/local_ads_management/view/local_ads_management_page.dart

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,11 @@ class _LocalAdsDataTable extends StatelessWidget {
273273
),
274274
DataColumn2(
275275
label: Text(l10n.lastUpdated),
276-
size: ColumnSize.M,
277-
),
278-
DataColumn2(
279-
label: Text(l10n.status),
280276
size: ColumnSize.S,
281277
),
282278
DataColumn2(
283279
label: Text(l10n.actions),
284280
size: ColumnSize.S,
285-
fixedWidth: 180,
286281
),
287282
],
288283
source: _LocalAdsDataSource(
@@ -348,6 +343,7 @@ class _LocalAdsDataSource extends DataTableSource {
348343
final ad = ads[index];
349344
String title;
350345
DateTime updatedAt;
346+
// ignore: unused_local_variable
351347
ContentStatus status;
352348

353349
// Determine title, updatedAt, and status based on ad type
@@ -392,48 +388,10 @@ class _LocalAdsDataSource extends DataTableSource {
392388
DateFormat('dd-MM-yyyy').format(updatedAt.toLocal()),
393389
),
394390
),
395-
DataCell(Text(status.l10n(context))),
396391
DataCell(
397392
Row(
398393
children: [
399-
IconButton(
400-
icon: const Icon(Icons.archive),
401-
tooltip: l10n.archive,
402-
onPressed: () {
403-
context.read<LocalAdsManagementBloc>().add(
404-
ArchiveLocalAdRequested(ad.id, adType.toAdType()),
405-
);
406-
},
407-
),
408-
IconButton(
409-
icon: const Icon(Icons.edit),
410-
tooltip: l10n.editLocalAds,
411-
onPressed: () {
412-
// Navigate to edit page based on ad type
413-
switch (ad.adType) {
414-
case 'native':
415-
context.goNamed(
416-
Routes.editLocalNativeAdName,
417-
pathParameters: {'id': ad.id},
418-
);
419-
case 'banner':
420-
context.goNamed(
421-
Routes.editLocalBannerAdName,
422-
pathParameters: {'id': ad.id},
423-
);
424-
case 'interstitial':
425-
context.goNamed(
426-
Routes.editLocalInterstitialAdName,
427-
pathParameters: {'id': ad.id},
428-
);
429-
case 'video':
430-
context.goNamed(
431-
Routes.editLocalVideoAdName,
432-
pathParameters: {'id': ad.id},
433-
);
434-
}
435-
},
436-
),
394+
// Primary action: Copy ID button
437395
IconButton(
438396
icon: const Icon(Icons.copy),
439397
tooltip: l10n.copyId,
@@ -448,6 +406,64 @@ class _LocalAdsDataSource extends DataTableSource {
448406
);
449407
},
450408
),
409+
// Secondary actions: Edit and Archive via PopupMenuButton
410+
PopupMenuButton<String>(
411+
icon: const Icon(Icons.more_vert),
412+
tooltip: l10n.moreActions,
413+
onSelected: (value) {
414+
if (value == 'edit') {
415+
// Navigate to edit page based on ad type
416+
switch (ad.adType) {
417+
case 'native':
418+
context.goNamed(
419+
Routes.editLocalNativeAdName,
420+
pathParameters: {'id': ad.id},
421+
);
422+
case 'banner':
423+
context.goNamed(
424+
Routes.editLocalBannerAdName,
425+
pathParameters: {'id': ad.id},
426+
);
427+
case 'interstitial':
428+
context.goNamed(
429+
Routes.editLocalInterstitialAdName,
430+
pathParameters: {'id': ad.id},
431+
);
432+
case 'video':
433+
context.goNamed(
434+
Routes.editLocalVideoAdName,
435+
pathParameters: {'id': ad.id},
436+
);
437+
}
438+
} else if (value == 'archive') {
439+
context.read<LocalAdsManagementBloc>().add(
440+
ArchiveLocalAdRequested(ad.id, adType.toAdType()),
441+
);
442+
}
443+
},
444+
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
445+
PopupMenuItem<String>(
446+
value: 'edit',
447+
child: Row(
448+
children: [
449+
const Icon(Icons.edit),
450+
const SizedBox(width: AppSpacing.sm),
451+
Text(l10n.editLocalAds),
452+
],
453+
),
454+
),
455+
PopupMenuItem<String>(
456+
value: 'archive',
457+
child: Row(
458+
children: [
459+
const Icon(Icons.archive),
460+
const SizedBox(width: AppSpacing.sm),
461+
Text(l10n.archive),
462+
],
463+
),
464+
),
465+
],
466+
),
451467
],
452468
),
453469
),

0 commit comments

Comments
 (0)