Files
minstrel/flutter_client/lib/shared/widgets/main_app_bar_actions.dart
T
bvandeusen d5c8d316c5 fix(flutter): clear analyze --fatal-infos errors from admin parity slice
CI caught six issues against the new admin slice:

- AsyncValue<T> in this Riverpod 3.3.1 codebase exposes `.value`
  (returns T?), not `.valueOrNull`. Switched the three admin readers
  to match the established convention (player_bar, queue_screen,
  now_playing_screen all use `.value`).
- home_screen.dart still has ctx.push calls in _albumsRow / _artistsRow
  (carousel tap handlers) — restored the go_router import that
  Task 2 over-eagerly removed.
- admin_user_edit_sheet.dart had a single-line `if (!await ...) return;`
  that violated curly_braces_in_flow_control_structures. Wrapped in
  braces.
- admin_quarantine_item.dart doc comment had `<top>` placeholders that
  the analyzer flagged as unintended HTML. Rephrased without angle
  brackets.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:02:14 -04:00

64 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../auth/auth_provider.dart';
import '../../theme/theme_extension.dart';
/// Shared AppBar `actions` for top-level screens. Renders Home / Library /
/// Search as primary icons (suppressing the icon for [currentRoute]) plus
/// a kebab overflow with Playlists / Discover / Settings and (for admins)
/// Admin.
class MainAppBarActions extends ConsumerWidget {
const MainAppBarActions({super.key, required this.currentRoute});
final String currentRoute;
@override
Widget build(BuildContext context, WidgetRef ref) {
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
final user = ref.watch(authControllerProvider).value;
final isAdmin = user?.isAdmin ?? false;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (currentRoute != '/home')
IconButton(
key: const Key('app_bar_home'),
icon: Icon(Icons.home, color: fs.parchment),
tooltip: 'Home',
onPressed: () => context.go('/home'),
),
if (currentRoute != '/library')
IconButton(
key: const Key('app_bar_library'),
icon: Icon(Icons.library_music, color: fs.parchment),
tooltip: 'Library',
onPressed: () => context.push('/library'),
),
if (currentRoute != '/search')
IconButton(
key: const Key('app_bar_search'),
icon: Icon(Icons.search, color: fs.parchment),
tooltip: 'Search',
onPressed: () => context.push('/search'),
),
PopupMenuButton<String>(
key: const Key('app_bar_overflow'),
icon: Icon(Icons.more_vert, color: fs.parchment),
tooltip: 'More',
onSelected: (route) => context.push(route),
itemBuilder: (_) => [
const PopupMenuItem(value: '/playlists', child: Text('Playlists')),
const PopupMenuItem(value: '/discover', child: Text('Discover')),
const PopupMenuItem(value: '/settings', child: Text('Settings')),
if (isAdmin)
const PopupMenuItem(value: '/admin', child: Text('Admin')),
],
),
],
);
}
}