diff --git a/assets/images/logo_nh1.png b/assets/images/logo_nh1.png deleted file mode 100644 index 3921a07..0000000 Binary files a/assets/images/logo_nh1.png and /dev/null differ diff --git a/assets/images/logo_nh_b1.png b/assets/images/logo_nh_b1.png deleted file mode 100644 index a65a3f1..0000000 Binary files a/assets/images/logo_nh_b1.png and /dev/null differ diff --git a/lib/pages/videos/config_page.dart b/lib/pages/videos/config_page.dart new file mode 100644 index 0000000..7141409 --- /dev/null +++ b/lib/pages/videos/config_page.dart @@ -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, + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/videos/videos_layout.dart b/lib/pages/videos/videos_layout.dart index 7da5f8c..e0bbf61 100644 --- a/lib/pages/videos/videos_layout.dart +++ b/lib/pages/videos/videos_layout.dart @@ -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 createState() => _VideosLayoutState(); } class _VideosLayoutState extends State { - int _selectedMenuIndex = 0; final GlobalKey _scaffoldKey = GlobalKey(); final List _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 { child: Column( children: [ _buildHeader(isMobile), - Expanded(child: _buildContent()), + Expanded(child: widget.child), ], ), ), @@ -68,7 +69,11 @@ class _VideosLayoutState extends State { 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 { 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 { title: item.title, isSelected: isSelected, onTap: () { - setState(() => _selectedMenuIndex = item.index); + context.go(item.route); }, ), ); @@ -720,7 +727,9 @@ class _VideosLayoutState extends State { 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 { 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 { ); } - 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 { 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 { 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, }); } diff --git a/lib/router/router.dart b/lib/router/router.dart index e0ef8bc..2920871 100644 --- a/lib/router/router.dart +++ b/lib/router/router.dart @@ -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 '/'; } return null; }, errorBuilder: (context, state) => const PageNotFoundPage(), routes: [ - 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(), + ), + ), + ], + ), ], );