tsacdop-podcast-app-android/lib/state/search_state.dart

47 lines
1.1 KiB
Dart
Raw Normal View History

2020-10-28 13:10:43 +01:00
import 'package:flutter/material.dart';
2021-01-31 15:26:54 +01:00
import 'package:tsacdop/type/search_api/search_genre.dart';
2020-10-28 13:10:43 +01:00
import '../type/search_api/searchpodcast.dart';
class SearchState extends ChangeNotifier {
2022-04-30 17:16:19 +02:00
final List<OnlinePodcast?> _subscribedList = [];
2020-10-28 13:10:43 +01:00
bool _update = false;
2022-04-30 17:16:19 +02:00
List<OnlinePodcast?> get subscribedList => _subscribedList;
2020-10-28 13:10:43 +01:00
bool get update => _update;
2022-04-30 17:16:19 +02:00
OnlinePodcast? _selectedPodcast;
OnlinePodcast? get selectedPodcast => _selectedPodcast;
Genre? _genre;
Genre? get genre => _genre;
2020-10-28 13:10:43 +01:00
2022-04-30 17:16:19 +02:00
set selectedPodcast(OnlinePodcast? podcast) {
2020-10-28 13:10:43 +01:00
_selectedPodcast = podcast;
notifyListeners();
}
2021-01-31 15:26:54 +01:00
set setGenre(Genre genre) {
_genre = genre;
notifyListeners();
}
2022-04-30 17:16:19 +02:00
bool isSubscribed(OnlinePodcast? podcast) => _subscribedList.contains(podcast);
2020-10-28 13:10:43 +01:00
void clearSelect() {
_selectedPodcast = null;
notifyListeners();
}
void clearList() {
_subscribedList.clear();
}
2021-01-31 15:26:54 +01:00
void clearGenre(){
_genre = null;
notifyListeners();
}
2022-04-30 17:16:19 +02:00
void addPodcast(OnlinePodcast? podcast) {
2020-10-28 13:10:43 +01:00
_subscribedList.add(podcast);
_update = !_update;
notifyListeners();
}
}