feat: 收藏搜索结果删除
This commit is contained in:
@ -15,9 +15,14 @@ import '../../../common/widgets/badge.dart';
|
|||||||
class FavVideoCardH extends StatelessWidget {
|
class FavVideoCardH extends StatelessWidget {
|
||||||
final dynamic videoItem;
|
final dynamic videoItem;
|
||||||
final Function? callFn;
|
final Function? callFn;
|
||||||
|
final int? searchType;
|
||||||
|
|
||||||
const FavVideoCardH({Key? key, required this.videoItem, this.callFn})
|
const FavVideoCardH({
|
||||||
: super(key: key);
|
Key? key,
|
||||||
|
required this.videoItem,
|
||||||
|
this.callFn,
|
||||||
|
this.searchType,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -107,7 +112,11 @@ class FavVideoCardH extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
VideoContent(videoItem: videoItem, callFn: callFn)
|
VideoContent(
|
||||||
|
videoItem: videoItem,
|
||||||
|
callFn: callFn,
|
||||||
|
searchType: searchType,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -123,7 +132,13 @@ class FavVideoCardH extends StatelessWidget {
|
|||||||
class VideoContent extends StatelessWidget {
|
class VideoContent extends StatelessWidget {
|
||||||
final dynamic videoItem;
|
final dynamic videoItem;
|
||||||
final Function? callFn;
|
final Function? callFn;
|
||||||
const VideoContent({super.key, required this.videoItem, this.callFn});
|
final int? searchType;
|
||||||
|
const VideoContent({
|
||||||
|
super.key,
|
||||||
|
required this.videoItem,
|
||||||
|
this.callFn,
|
||||||
|
this.searchType,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -189,48 +204,51 @@ class VideoContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Positioned(
|
searchType != 1
|
||||||
right: 0,
|
? Positioned(
|
||||||
bottom: -4,
|
right: 0,
|
||||||
child: IconButton(
|
bottom: -4,
|
||||||
style: ButtonStyle(
|
child: IconButton(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
style: ButtonStyle(
|
||||||
),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
onPressed: () {
|
),
|
||||||
showDialog(
|
onPressed: () {
|
||||||
context: Get.context!,
|
showDialog(
|
||||||
builder: (context) {
|
context: Get.context!,
|
||||||
return AlertDialog(
|
builder: (context) {
|
||||||
title: const Text('提示'),
|
return AlertDialog(
|
||||||
content: const Text('要取消收藏吗?'),
|
title: const Text('提示'),
|
||||||
actions: [
|
content: const Text('要取消收藏吗?'),
|
||||||
TextButton(
|
actions: [
|
||||||
onPressed: () => Get.back(),
|
TextButton(
|
||||||
child: Text(
|
onPressed: () => Get.back(),
|
||||||
'取消',
|
child: Text(
|
||||||
style: TextStyle(
|
'取消',
|
||||||
color:
|
style: TextStyle(
|
||||||
Theme.of(context).colorScheme.outline),
|
color: Theme.of(context)
|
||||||
)),
|
.colorScheme
|
||||||
TextButton(
|
.outline),
|
||||||
onPressed: () async {
|
)),
|
||||||
await callFn!();
|
TextButton(
|
||||||
Get.back();
|
onPressed: () async {
|
||||||
},
|
await callFn!();
|
||||||
child: const Text('确定取消'),
|
Get.back();
|
||||||
)
|
},
|
||||||
],
|
child: const Text('确定取消'),
|
||||||
);
|
)
|
||||||
},
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: Icon(
|
);
|
||||||
Icons.clear_outlined,
|
},
|
||||||
color: Theme.of(context).colorScheme.outline,
|
icon: Icon(
|
||||||
size: 18,
|
Icons.clear_outlined,
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
size: 18,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/models/user/fav_detail.dart';
|
import 'package:pilipala/models/user/fav_detail.dart';
|
||||||
|
|
||||||
|
import '../../http/video.dart';
|
||||||
|
|
||||||
class FavSearchController extends GetxController {
|
class FavSearchController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
Rx<TextEditingController> controller = TextEditingController().obs;
|
Rx<TextEditingController> controller = TextEditingController().obs;
|
||||||
@ -72,4 +75,21 @@ class FavSearchController extends GetxController {
|
|||||||
if (!hasMore) return;
|
if (!hasMore) return;
|
||||||
searchFav(type: 'onLoad');
|
searchFav(type: 'onLoad');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCancelFav(int id) async {
|
||||||
|
var result = await VideoHttp.favVideo(
|
||||||
|
aid: id, addIds: '', delIds: mediaId.toString());
|
||||||
|
if (result['status']) {
|
||||||
|
if (result['data']['prompt']) {
|
||||||
|
List dataList = favList;
|
||||||
|
for (var i in dataList) {
|
||||||
|
if (i.id == id) {
|
||||||
|
dataList.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('取消收藏');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ import 'package:pilipala/pages/fav_detail/widget/fav_video_card.dart';
|
|||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class FavSearchPage extends StatefulWidget {
|
class FavSearchPage extends StatefulWidget {
|
||||||
final int? sourceType;
|
const FavSearchPage({super.key});
|
||||||
final int? mediaId;
|
|
||||||
const FavSearchPage({super.key, this.sourceType, this.mediaId});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FavSearchPage> createState() => _FavSearchPageState();
|
State<FavSearchPage> createState() => _FavSearchPageState();
|
||||||
@ -19,11 +17,12 @@ class FavSearchPage extends StatefulWidget {
|
|||||||
class _FavSearchPageState extends State<FavSearchPage> {
|
class _FavSearchPageState extends State<FavSearchPage> {
|
||||||
final FavSearchController _favSearchCtr = Get.put(FavSearchController());
|
final FavSearchController _favSearchCtr = Get.put(FavSearchController());
|
||||||
late ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
|
late int searchType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
searchType = int.parse(Get.parameters['searchType']!);
|
||||||
scrollController = _favSearchCtr.scrollController;
|
scrollController = _favSearchCtr.scrollController;
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
@ -100,7 +99,11 @@ class _FavSearchPageState extends State<FavSearchPage> {
|
|||||||
} else {
|
} else {
|
||||||
return FavVideoCardH(
|
return FavVideoCardH(
|
||||||
videoItem: _favSearchCtr.favList[index],
|
videoItem: _favSearchCtr.favList[index],
|
||||||
callFn: () => null,
|
searchType: searchType,
|
||||||
|
callFn: () => searchType != 1
|
||||||
|
? _favSearchCtr
|
||||||
|
.onCancelFav(_favSearchCtr.favList[index].id!)
|
||||||
|
: {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user