1
0
mirror of https://github.com/stonega/tsacdop synced 2025-02-24 07:17:52 +01:00

48 lines
1.1 KiB
Dart
Raw Normal View History

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