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 {
final List<OnlinePodcast> _subscribedList = [];
bool _update = false;
List<OnlinePodcast> get subscribedList => _subscribedList;
bool get update => _update;
OnlinePodcast _selectedPodcast;
OnlinePodcast get selectedPodcast => _selectedPodcast;
2021-01-31 15:26:54 +01:00
Genre _genre;
Genre get genre => _genre;
2020-10-28 13:10:43 +01:00
set selectedPodcast(OnlinePodcast podcast) {
_selectedPodcast = podcast;
notifyListeners();
}
2021-01-31 15:26:54 +01:00
set setGenre(Genre genre) {
_genre = genre;
notifyListeners();
}
2020-10-28 13:10:43 +01:00
bool isSubscribed(OnlinePodcast podcast) => _subscribedList.contains(podcast);
void clearSelect() {
_selectedPodcast = null;
notifyListeners();
}
void clearList() {
_subscribedList.clear();
}
2021-01-31 15:26:54 +01:00
void clearGenre(){
_genre = null;
notifyListeners();
}
2020-10-28 13:10:43 +01:00
void addPodcast(OnlinePodcast podcast) {
_subscribedList.add(podcast);
_update = !_update;
notifyListeners();
}
}