mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 19:47:47 +08:00
search download
This commit is contained in:
@@ -30,7 +30,6 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
super.initState();
|
||||
_querySeriesDetails();
|
||||
}
|
||||
@@ -62,7 +61,12 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
|
||||
),
|
||||
Text("${ep.title}", textAlign: TextAlign.left),
|
||||
const Expanded(child: Text("")),
|
||||
IconButton(onPressed: () {}, icon: const Icon(Icons.search))
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_searchAndDownload(
|
||||
context, seriesId, ep.seasonNumber!, ep.episodeNumber!);
|
||||
},
|
||||
icon: const Icon(Icons.search))
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -148,6 +152,24 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
|
||||
details = SeriesDetails.fromJson(rsp.data);
|
||||
});
|
||||
}
|
||||
|
||||
void _searchAndDownload(BuildContext context, String seriesId, int seasonNum,
|
||||
int episodeNum) async {
|
||||
var resp = await Dio().post(APIs.searchAndDownloadUrl, data: {
|
||||
"id": int.parse(seriesId),
|
||||
"season": seasonNum,
|
||||
"episode": episodeNum,
|
||||
});
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code != 0 && context.mounted) {
|
||||
Utils.showAlertDialog(context, sp.message);
|
||||
return;
|
||||
}
|
||||
var name = (sp.data as Map<String, dynamic>)["name"];
|
||||
if (context.mounted) {
|
||||
Utils.showSnakeBar(context, "$name 开始下载...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SeriesDetails {
|
||||
|
||||
Reference in New Issue
Block a user