feat: modo dia/noche y campana de notificaciones

- ThemeProvider con persistencia en SharedPreferences
- Toggle animado en sidebar (sol/luna con switch visual)
- Temas light y dark completos en MaterialApp
- Campana en navbar con badge rojo y panel inferior de notificaciones

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-27 08:36:53 -05:00
co-authored by Claude Sonnet 4.6
parent 76c05a5820
commit 842a67cdea
4 changed files with 323 additions and 44 deletions
+41 -21
View File
@@ -15,6 +15,7 @@ import 'package:prosapp_web_app/providers/score_provider.dart';
import 'package:prosapp_web_app/providers/services_provider.dart';
import 'package:prosapp_web_app/providers/settings_provider.dart';
import 'package:prosapp_web_app/providers/sidemenu_provider.dart';
import 'package:prosapp_web_app/providers/theme_provider.dart';
import 'package:prosapp_web_app/router/router.dart';
import 'package:prosapp_web_app/services/local_storage.dart';
import 'package:prosapp_web_app/services/navigation_service.dart';
@@ -26,15 +27,10 @@ import 'package:provider/provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
await LocalStorage.configurePrefs();
await initializeDateFormatting('es_ES', null);
Flurorouter.configureRoutes();
runApp(const AppState());
}
@@ -48,6 +44,7 @@ class AppState extends StatelessWidget {
ChangeNotifierProvider(lazy: false, create: (_) => AuthProvider()),
ChangeNotifierProvider(lazy: false, create: (_) => SideMenuProvider()),
ChangeNotifierProvider(lazy: false, create: (_) => ProfessionalProvider()),
ChangeNotifierProvider(lazy: false, create: (_) => ThemeProvider()),
ChangeNotifierProvider(create: (_) => SettingsProvider()),
ChangeNotifierProvider(create: (_) => ProfileFormProvider()),
ChangeNotifierProvider(create: (_) => ProfessionalFormProvider()),
@@ -70,6 +67,8 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'ProsApp',
@@ -77,25 +76,46 @@ class MyApp extends StatelessWidget {
onGenerateRoute: Flurorouter.router.generator,
navigatorKey: NavigationService.navigatorKey,
scaffoldMessengerKey: NotificationsService.messengerKey,
themeMode: themeProvider.mode,
theme: _buildLight(),
darkTheme: _buildDark(),
builder: (_, child) {
final authProvider = Provider.of<AuthProvider>(context);
if (authProvider.authStatus == AuthStatus.checking) {
return const SplashLayout();
}
if (authProvider.authStatus == AuthStatus.authenticated) {
return DashboardLayout(child: child!);
} else {
return AuthLayout(child: child!);
}
if (authProvider.authStatus == AuthStatus.checking) return const SplashLayout();
if (authProvider.authStatus == AuthStatus.authenticated) return DashboardLayout(child: child!);
return AuthLayout(child: child!);
},
theme: ThemeData.light().copyWith(
scrollbarTheme: const ScrollbarThemeData().copyWith(
thumbColor: WidgetStateProperty.all(
Colors.grey.withOpacity(0.5),
),
),
);
}
ThemeData _buildLight() {
return ThemeData.light().copyWith(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF42A4EF)),
scaffoldBackgroundColor: const Color(0xFFF4F6FA),
cardColor: Colors.white,
scrollbarTheme: const ScrollbarThemeData().copyWith(
thumbColor: WidgetStateProperty.all(Colors.grey.withOpacity(0.5)),
),
);
}
ThemeData _buildDark() {
return ThemeData.dark().copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF42A4EF),
brightness: Brightness.dark,
),
scaffoldBackgroundColor: const Color(0xFF0F172A),
cardColor: const Color(0xFF1E293B),
dialogBackgroundColor: const Color(0xFF1E293B),
appBarTheme: const AppBarTheme(backgroundColor: Color(0xFF1E293B)),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: const Color(0xFF1E293B),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
),
scrollbarTheme: const ScrollbarThemeData().copyWith(
thumbColor: WidgetStateProperty.all(Colors.white24),
),
);
}