mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
feat: add series delete feature
This commit is contained in:
@@ -10,8 +10,10 @@ var seriesDetailsProvider = AsyncNotifierProvider.autoDispose
|
||||
|
||||
class SeriesDetailData
|
||||
extends AutoDisposeFamilyAsyncNotifier<SeriesDetails, String> {
|
||||
String? id;
|
||||
@override
|
||||
FutureOr<SeriesDetails> build(String arg) async {
|
||||
id = arg;
|
||||
final dio = await APIs.getDio();
|
||||
var resp = await dio.get("${APIs.seriesDetailUrl}$arg");
|
||||
var rsp = ServerResponse.fromJson(resp.data);
|
||||
@@ -21,9 +23,18 @@ class SeriesDetailData
|
||||
return SeriesDetails.fromJson(rsp.data);
|
||||
}
|
||||
|
||||
Future<void> delete() async {
|
||||
final dio = await APIs.getDio();
|
||||
var resp = await dio.delete("${APIs.seriesDetailUrl}$id");
|
||||
var rsp = ServerResponse.fromJson(resp.data);
|
||||
if (rsp.code != 0) {
|
||||
throw rsp.message;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> searchAndDownload(
|
||||
String seriesId, int seasonNum, int episodeNum) async {
|
||||
final dio = await APIs.getDio();
|
||||
final dio = await APIs.getDio();
|
||||
var resp = await dio.post(APIs.searchAndDownloadUrl, data: {
|
||||
"id": int.parse(seriesId),
|
||||
"season": seasonNum,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:ui/providers/APIs.dart';
|
||||
import 'package:ui/providers/server_response.dart';
|
||||
|
||||
final welcomePageDataProvider = FutureProvider((ref) async {
|
||||
final welcomePageDataProvider = FutureProvider.autoDispose((ref) async {
|
||||
final dio = await APIs.getDio();
|
||||
var resp = await dio.get(APIs.watchlistUrl);
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ui/providers/APIs.dart';
|
||||
import 'package:ui/providers/series_details.dart';
|
||||
import 'package:ui/utils.dart';
|
||||
import 'package:ui/weclome.dart';
|
||||
|
||||
class TvDetailsPage extends ConsumerStatefulWidget {
|
||||
static const route = "/series/:id";
|
||||
@@ -112,18 +114,37 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"${details!.name}",
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Text(""),
|
||||
Text(details!.overview!)
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${details!.name}",
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Text(""),
|
||||
Text(details!.overview!)
|
||||
],
|
||||
)),
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(seriesDetailsProvider(
|
||||
seriesId)
|
||||
.notifier)
|
||||
.delete();
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user