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';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class VideosLayout extends StatefulWidget {
|
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
|
@override
|
||||||
State<VideosLayout> createState() => _VideosLayoutState();
|
State<VideosLayout> createState() => _VideosLayoutState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VideosLayoutState extends State<VideosLayout> {
|
class _VideosLayoutState extends State<VideosLayout> {
|
||||||
int _selectedMenuIndex = 0;
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
final List<MenuItem> _menuItems = [
|
final List<MenuItem> _menuItems = [
|
||||||
MenuItem(
|
MenuItem(
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
icon: Icons.dashboard,
|
icon: Icons.dashboard,
|
||||||
index: 0,
|
route: '/dashboard',
|
||||||
subtitle: 'Visualiza métricas y estadísticas globales de tus contenidos',
|
subtitle: 'Visualiza métricas y estadísticas globales de tus contenidos',
|
||||||
),
|
),
|
||||||
MenuItem(
|
MenuItem(
|
||||||
title: 'Gestor de Videos',
|
title: 'Gestor de Videos',
|
||||||
icon: Icons.video_library,
|
icon: Icons.video_library,
|
||||||
index: 1,
|
route: '/videos',
|
||||||
subtitle: 'Administra, edita y organiza tu biblioteca multimedia',
|
subtitle: 'Administra, edita y organiza tu biblioteca multimedia',
|
||||||
),
|
),
|
||||||
MenuItem(
|
MenuItem(
|
||||||
title: 'Configuración',
|
title: 'Configuración',
|
||||||
icon: Icons.settings,
|
icon: Icons.settings,
|
||||||
index: 2,
|
route: '/config',
|
||||||
subtitle: 'Personaliza las preferencias de tu plataforma',
|
subtitle: 'Personaliza las preferencias de tu plataforma',
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@@ -56,7 +57,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildHeader(isMobile),
|
_buildHeader(isMobile),
|
||||||
Expanded(child: _buildContent()),
|
Expanded(child: widget.child),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -68,7 +69,11 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
Widget _buildHeader(bool isMobile) {
|
Widget _buildHeader(bool isMobile) {
|
||||||
final isDark = AppTheme.themeMode == ThemeMode.dark;
|
final isDark = AppTheme.themeMode == ThemeMode.dark;
|
||||||
final isLightBackground = !isDark;
|
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(
|
return Container(
|
||||||
padding: EdgeInsets.all(isMobile ? 16 : 24),
|
padding: EdgeInsets.all(isMobile ? 16 : 24),
|
||||||
@@ -282,7 +287,9 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
children: _menuItems.map((item) {
|
children: _menuItems.map((item) {
|
||||||
final isSelected = _selectedMenuIndex == item.index;
|
final currentLocation =
|
||||||
|
GoRouterState.of(context).matchedLocation;
|
||||||
|
final isSelected = currentLocation == item.route;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
child: _buildPremiumMenuItem(
|
child: _buildPremiumMenuItem(
|
||||||
@@ -290,7 +297,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
title: item.title,
|
title: item.title,
|
||||||
isSelected: isSelected,
|
isSelected: isSelected,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() => _selectedMenuIndex = item.index);
|
context.go(item.route);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -720,7 +727,9 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||||
children: _menuItems.map((item) {
|
children: _menuItems.map((item) {
|
||||||
final isSelected = _selectedMenuIndex == item.index;
|
final currentLocation =
|
||||||
|
GoRouterState.of(context).matchedLocation;
|
||||||
|
final isSelected = currentLocation == item.route;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
child: _buildPremiumMenuItem(
|
child: _buildPremiumMenuItem(
|
||||||
@@ -728,7 +737,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
title: item.title,
|
title: item.title,
|
||||||
isSelected: isSelected,
|
isSelected: isSelected,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() => _selectedMenuIndex = item.index);
|
context.go(item.route);
|
||||||
Navigator.pop(context);
|
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() {
|
Widget _buildLogoutButton() {
|
||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
cursor: SystemMouseCursors.click,
|
cursor: SystemMouseCursors.click,
|
||||||
@@ -939,6 +903,7 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
if (confirm == true) {
|
if (confirm == true) {
|
||||||
// Cerrar sesión
|
// Cerrar sesión
|
||||||
await supabase.auth.signOut();
|
await supabase.auth.signOut();
|
||||||
|
currentUser = null; // Limpiar usuario global
|
||||||
userState.logout();
|
userState.logout();
|
||||||
|
|
||||||
// Navegar al login
|
// Navegar al login
|
||||||
@@ -1019,13 +984,13 @@ class _VideosLayoutState extends State<VideosLayout> {
|
|||||||
class MenuItem {
|
class MenuItem {
|
||||||
final String title;
|
final String title;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final int index;
|
final String route;
|
||||||
final String? subtitle;
|
final String? subtitle;
|
||||||
|
|
||||||
MenuItem({
|
MenuItem({
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.index,
|
required this.route,
|
||||||
this.subtitle,
|
this.subtitle,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import 'package:go_router/go_router.dart';
|
|||||||
|
|
||||||
import 'package:energy_media/helpers/globals.dart';
|
import 'package:energy_media/helpers/globals.dart';
|
||||||
import 'package:energy_media/pages/videos/videos_layout.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/pages/pages.dart';
|
||||||
import 'package:energy_media/services/navigation_service.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 user is logged in and in the login page
|
||||||
if (loggedIn && isLoggingIn) {
|
if (loggedIn && isLoggingIn) {
|
||||||
if (currentUser!.role.roleId == 14 || currentUser!.role.roleId == 13) {
|
return '/';
|
||||||
return '/book_page_main';
|
|
||||||
} else {
|
|
||||||
return '/';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
errorBuilder: (context, state) => const PageNotFoundPage(),
|
errorBuilder: (context, state) => const PageNotFoundPage(),
|
||||||
routes: <RouteBase>[
|
routes: <RouteBase>[
|
||||||
GoRoute(
|
|
||||||
path: '/',
|
|
||||||
name: 'root',
|
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
|
||||||
return const VideosLayout();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/login',
|
path: '/login',
|
||||||
name: 'login',
|
name: 'login',
|
||||||
@@ -45,5 +37,37 @@ final GoRouter router = GoRouter(
|
|||||||
return const LoginPage();
|
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