mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-20 13:38:05 +02:00
feat: Introduce core IPTV features, authentication screen, web player, and application theming.
This commit is contained in:
1 parent
c90ea530ea
commit
e699d3ec31
8 files changed
+931
-1379
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Manages the list of favorite channel IDs
|
||||
class FavoritesNotifier extends StateNotifier<List<String>> {
|
||||
FavoritesNotifier() : super([]) {
|
||||
_loadFavorites();
|
||||
}
|
||||
|
||||
static const String _key = 'xtremflow_favorites';
|
||||
|
||||
Future<void> _loadFavorites() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final favorites = prefs.getStringList(_key) ?? [];
|
||||
state = favorites;
|
||||
}
|
||||
|
||||
Future<void> toggleFavorite(String streamId) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (state.contains(streamId)) {
|
||||
state = state.where((id) => id != streamId).toList();
|
||||
} else {
|
||||
state = [...state, streamId];
|
||||
}
|
||||
await prefs.setStringList(_key, state);
|
||||
}
|
||||
|
||||
bool isFavorite(String streamId) {
|
||||
return state.contains(streamId);
|
||||
}
|
||||
}
|
||||
|
||||
final favoritesProvider = StateNotifierProvider<FavoritesNotifier, List<String>>((ref) {
|
||||
return FavoritesNotifier();
|
||||
});
|
||||
Reference in new issue
Block a user