Fix boton cerrar sesion, añadido rutas en router
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 277 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 214 KiB |
94
lib/pages/videos/config_page.dart
Normal file
94
lib/pages/videos/config_page.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:energy_media/theme/theme.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
class ConfigPage extends StatelessWidget {
|
||||
const ConfigPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppTheme.of(context).primaryColor.withOpacity(0.2),
|
||||
AppTheme.of(context).secondaryColor.withOpacity(0.2),
|
||||
],
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.construction_rounded,
|
||||
size: 80,
|
||||
color: AppTheme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
const Gap(32),
|
||||
Text(
|
||||
'Configuración',
|
||||
style: AppTheme.of(context).title2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 32,
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Text(
|
||||
'Esta sección estará disponible próximamente. Aquí podrás personalizar las preferencias de tu plataforma.',
|
||||
style: AppTheme.of(context).bodyText1.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).secondaryText,
|
||||
fontSize: 16,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const Gap(32),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppTheme.of(context).primaryColor.withOpacity(0.1),
|
||||
AppTheme.of(context).secondaryColor.withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppTheme.of(context).primaryColor.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.emoji_objects_rounded,
|
||||
color: AppTheme.of(context).secondaryColor,
|
||||
size: 20,
|
||||
),
|
||||
const Gap(8),
|
||||
Text(
|
||||
'Próximamente: Temas, notificaciones, preferencias y más',
|
||||
style: AppTheme.of(context).bodyText2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).secondaryText,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:energy_media/helpers/globals.dart';
|
||||
import 'package:energy_media/pages/videos/videos_layout.dart';
|
||||
import 'package:energy_media/pages/videos/premium_dashboard_page.dart';
|
||||
import 'package:energy_media/pages/videos/gestor_videos_page.dart';
|
||||
import 'package:energy_media/pages/videos/config_page.dart';
|
||||
import 'package:energy_media/pages/pages.dart';
|
||||
import 'package:energy_media/services/navigation_service.dart';
|
||||
|
||||
@@ -20,24 +23,13 @@ final GoRouter router = GoRouter(
|
||||
|
||||
//if user is logged in and in the login page
|
||||
if (loggedIn && isLoggingIn) {
|
||||
if (currentUser!.role.roleId == 14 || currentUser!.role.roleId == 13) {
|
||||
return '/book_page_main';
|
||||
} else {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
errorBuilder: (context, state) => const PageNotFoundPage(),
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: '/',
|
||||
name: 'root',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
return const VideosLayout();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
@@ -45,5 +37,37 @@ final GoRouter router = GoRouter(
|
||||
return const LoginPage();
|
||||
},
|
||||
),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
return VideosLayout(child: child);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
redirect: (context, state) => '/dashboard',
|
||||
),
|
||||
GoRoute(
|
||||
path: '/dashboard',
|
||||
name: 'dashboard',
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
child: const PremiumDashboardPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/videos',
|
||||
name: 'videos',
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
child: const GestorVideosPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/config',
|
||||
name: 'config',
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
child: const ConfigPage(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user