feat: Enhance admin panel navigation and UI by implementing tab management and improving layout structure
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:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../features/auth/data/auth_providers.dart';
|
||||
import '../../features/admin/presentation/admin_screen.dart';
|
||||
import '../../features/recipes/data/recipes_grid_provider.dart';
|
||||
|
||||
const _profileHeaderDestination = _AppDestination(
|
||||
@@ -93,6 +94,7 @@ class AppShell extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final locationUri = Uri.parse(location);
|
||||
final isAdmin = ref.watch(isAdminProvider);
|
||||
final dests = _destinations(isAdmin);
|
||||
final selectedIndex = _selectedIndex(dests);
|
||||
@@ -109,10 +111,43 @@ class AppShell extends ConsumerWidget {
|
||||
final isRecipesRoute = location.startsWith('/recipes') &&
|
||||
!location.startsWith('/recipes/');
|
||||
final isImportRoute = location == '/import';
|
||||
final isAdminRoute = location.startsWith('/admin');
|
||||
final adminTab = AdminViewTabX.fromQuery(
|
||||
locationUri.queryParameters['tab'],
|
||||
);
|
||||
|
||||
void navigateToAdminTab(AdminViewTab tab) {
|
||||
final target = '/admin?tab=${tab.queryValue}';
|
||||
if (target != location && context.mounted) {
|
||||
onNavigateToPath(target);
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildAdminTitle() {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ChoiceChip(
|
||||
label: const Text('Användare'),
|
||||
selected: adminTab == AdminViewTab.users,
|
||||
onSelected: (_) => navigateToAdminTab(AdminViewTab.users),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ChoiceChip(
|
||||
label: const Text('Databas'),
|
||||
selected: adminTab == AdminViewTab.database,
|
||||
onSelected: (_) => navigateToAdminTab(AdminViewTab.database),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget shell = Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(selectedDestination.title),
|
||||
title: isAdminRoute ? buildAdminTitle() : Text(selectedDestination.title),
|
||||
bottom: isImportRoute
|
||||
? const TabBar(
|
||||
tabs: [
|
||||
|
||||
Reference in New Issue
Block a user