feat: Introduce SearchableCategoryField component and integrate it into admin panels for enhanced category selection
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -12,13 +12,6 @@ const _profileHeaderDestination = _AppDestination(
|
||||
label: 'Profil',
|
||||
);
|
||||
|
||||
const _adminHeaderDestination = _AppDestination(
|
||||
path: '/admin',
|
||||
title: 'Admin',
|
||||
icon: Icons.admin_panel_settings_outlined,
|
||||
label: 'Admin',
|
||||
);
|
||||
|
||||
class AppShell extends ConsumerWidget {
|
||||
final String location;
|
||||
final ValueChanged<String> onNavigateToPath;
|
||||
@@ -64,9 +57,7 @@ class AppShell extends ConsumerWidget {
|
||||
),
|
||||
];
|
||||
|
||||
List<_AppDestination> _destinations(bool isAdmin) => isAdmin
|
||||
? [..._baseDestinations, _adminHeaderDestination]
|
||||
: _baseDestinations;
|
||||
List<_AppDestination> _destinations() => _baseDestinations;
|
||||
|
||||
int? _selectedIndex(List<_AppDestination> destinations) {
|
||||
final index = destinations.indexWhere(
|
||||
@@ -77,14 +68,10 @@ class AppShell extends ConsumerWidget {
|
||||
|
||||
_AppDestination _selectedHeaderDestination(
|
||||
List<_AppDestination> destinations,
|
||||
bool isAdmin,
|
||||
) {
|
||||
if (location.startsWith('/profile')) {
|
||||
return _profileHeaderDestination;
|
||||
}
|
||||
if (location.startsWith('/admin') && isAdmin) {
|
||||
return _adminHeaderDestination;
|
||||
}
|
||||
final selectedIndex = _selectedIndex(destinations);
|
||||
if (selectedIndex != null) {
|
||||
return destinations[selectedIndex];
|
||||
@@ -96,9 +83,9 @@ class AppShell extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final locationUri = Uri.parse(location);
|
||||
final isAdmin = ref.watch(isAdminProvider);
|
||||
final dests = _destinations(isAdmin);
|
||||
final dests = _destinations();
|
||||
final selectedIndex = _selectedIndex(dests);
|
||||
final selectedDestination = _selectedHeaderDestination(dests, isAdmin);
|
||||
final selectedDestination = _selectedHeaderDestination(dests);
|
||||
final isWide = MediaQuery.of(context).size.width >= 900;
|
||||
|
||||
void navigateTo(int index) {
|
||||
@@ -210,6 +197,11 @@ class AppShell extends ConsumerWidget {
|
||||
onNavigateToPath('/profile');
|
||||
}
|
||||
break;
|
||||
case 'admin':
|
||||
if (location != '/admin' && context.mounted) {
|
||||
onNavigateToPath('/admin');
|
||||
}
|
||||
break;
|
||||
case 'logout':
|
||||
await ref.read(authStateProvider.notifier).logout();
|
||||
if (context.mounted) {
|
||||
@@ -227,6 +219,15 @@ class AppShell extends ConsumerWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
if (isAdmin)
|
||||
PopupMenuItem<String>(
|
||||
value: 'admin',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.admin_panel_settings_outlined),
|
||||
title: Text('Admin'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
PopupMenuDivider(),
|
||||
PopupMenuItem<String>(
|
||||
value: 'logout',
|
||||
|
||||
Reference in New Issue
Block a user