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