Actualizacion del programa
This commit is contained in:
@@ -143,6 +143,11 @@ class RouteSimulatorService extends ChangeNotifier {
|
||||
final n = AppNotification(event:event, title:title, body:body, routeId:routeId);
|
||||
_lastNotification = n;
|
||||
_history.insert(0, n);
|
||||
// Persistir en DB para historial
|
||||
DbHelper.insertNotifHistory(
|
||||
routeId: routeId, eventType: event.name,
|
||||
title: title, body: body,
|
||||
).catchError((_) {});
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
24
lib/services/theme_service.dart
Normal file
24
lib/services/theme_service.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class ThemeService extends ChangeNotifier {
|
||||
ThemeMode _themeMode = ThemeMode.light;
|
||||
ThemeMode get themeMode => _themeMode;
|
||||
bool get isDark => _themeMode == ThemeMode.dark;
|
||||
|
||||
ThemeService() { _load(); }
|
||||
|
||||
Future<void> _load() async {
|
||||
final p = await SharedPreferences.getInstance();
|
||||
final isDark = p.getBool('dark_mode') ?? false;
|
||||
_themeMode = isDark ? ThemeMode.dark : ThemeMode.light;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggle() async {
|
||||
_themeMode = _themeMode == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark;
|
||||
final p = await SharedPreferences.getInstance();
|
||||
await p.setBool('dark_mode', _themeMode == ThemeMode.dark);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user