Fix boton cerrar sesion, añadido rutas en router
This commit is contained in:
@@ -10,33 +10,34 @@ import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class VideosLayout extends StatefulWidget {
|
||||
const VideosLayout({Key? key}) : super(key: key);
|
||||
final Widget child;
|
||||
|
||||
const VideosLayout({Key? key, required this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<VideosLayout> createState() => _VideosLayoutState();
|
||||
}
|
||||
|
||||
class _VideosLayoutState extends State<VideosLayout> {
|
||||
int _selectedMenuIndex = 0;
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
final List<MenuItem> _menuItems = [
|
||||
MenuItem(
|
||||
title: 'Dashboard',
|
||||
icon: Icons.dashboard,
|
||||
index: 0,
|
||||
route: '/dashboard',
|
||||
subtitle: 'Visualiza métricas y estadísticas globales de tus contenidos',
|
||||
),
|
||||
MenuItem(
|
||||
title: 'Gestor de Videos',
|
||||
icon: Icons.video_library,
|
||||
index: 1,
|
||||
route: '/videos',
|
||||
subtitle: 'Administra, edita y organiza tu biblioteca multimedia',
|
||||
),
|
||||
MenuItem(
|
||||
title: 'Configuración',
|
||||
icon: Icons.settings,
|
||||
index: 2,
|
||||
route: '/config',
|
||||
subtitle: 'Personaliza las preferencias de tu plataforma',
|
||||
),
|
||||
];
|
||||
@@ -56,7 +57,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeader(isMobile),
|
||||
Expanded(child: _buildContent()),
|
||||
Expanded(child: widget.child),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -68,7 +69,11 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
Widget _buildHeader(bool isMobile) {
|
||||
final isDark = AppTheme.themeMode == ThemeMode.dark;
|
||||
final isLightBackground = !isDark;
|
||||
final currentMenuItem = _menuItems[_selectedMenuIndex];
|
||||
final currentLocation = GoRouterState.of(context).matchedLocation;
|
||||
final currentMenuItem = _menuItems.firstWhere(
|
||||
(item) => item.route == currentLocation,
|
||||
orElse: () => _menuItems[0],
|
||||
);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.all(isMobile ? 16 : 24),
|
||||
@@ -282,7 +287,9 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
children: _menuItems.map((item) {
|
||||
final isSelected = _selectedMenuIndex == item.index;
|
||||
final currentLocation =
|
||||
GoRouterState.of(context).matchedLocation;
|
||||
final isSelected = currentLocation == item.route;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _buildPremiumMenuItem(
|
||||
@@ -290,7 +297,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
title: item.title,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
setState(() => _selectedMenuIndex = item.index);
|
||||
context.go(item.route);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -720,7 +727,9 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||
children: _menuItems.map((item) {
|
||||
final isSelected = _selectedMenuIndex == item.index;
|
||||
final currentLocation =
|
||||
GoRouterState.of(context).matchedLocation;
|
||||
final isSelected = currentLocation == item.route;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildPremiumMenuItem(
|
||||
@@ -728,7 +737,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
title: item.title,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
setState(() => _selectedMenuIndex = item.index);
|
||||
context.go(item.route);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
@@ -763,51 +772,6 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent() {
|
||||
switch (_selectedMenuIndex) {
|
||||
case 0:
|
||||
return const PremiumDashboardPage();
|
||||
case 1:
|
||||
return const GestorVideosPage();
|
||||
case 2:
|
||||
return _buildWorkInProgress();
|
||||
default:
|
||||
return const PremiumDashboardPage();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildWorkInProgress() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.construction,
|
||||
size: 64,
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
),
|
||||
const Gap(16),
|
||||
Text(
|
||||
'Trabajo en Progreso',
|
||||
style: AppTheme.of(context).title2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
Text(
|
||||
'Esta sección estará disponible próximamente',
|
||||
style: AppTheme.of(context).bodyText1.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLogoutButton() {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
@@ -939,6 +903,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
if (confirm == true) {
|
||||
// Cerrar sesión
|
||||
await supabase.auth.signOut();
|
||||
currentUser = null; // Limpiar usuario global
|
||||
userState.logout();
|
||||
|
||||
// Navegar al login
|
||||
@@ -1019,13 +984,13 @@ class _VideosLayoutState extends State<VideosLayout> {
|
||||
class MenuItem {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final int index;
|
||||
final String route;
|
||||
final String? subtitle;
|
||||
|
||||
MenuItem({
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.index,
|
||||
required this.route,
|
||||
this.subtitle,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user