mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: remove fav folder after deleted
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
|
import 'package:PiliPalaX/models/user/fav_folder.dart';
|
||||||
import 'package:PiliPalaX/pages/fav_search/view.dart';
|
import 'package:PiliPalaX/pages/fav_search/view.dart';
|
||||||
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -53,6 +55,32 @@ class _FavPageState extends State<FavPage> {
|
|||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Get.toNamed('/createFav')?.then((data) {
|
||||||
|
if (data != null) {
|
||||||
|
List list = _favController.loadingState.value is Success
|
||||||
|
? (_favController.loadingState.value as Success).response
|
||||||
|
: [];
|
||||||
|
list.insert(
|
||||||
|
list.isNotEmpty ? 1 : 0,
|
||||||
|
FavFolderItemData(
|
||||||
|
id: data['id'],
|
||||||
|
fid: data['fid'],
|
||||||
|
attr: data['attr'],
|
||||||
|
title: data['title'],
|
||||||
|
favState: data['fav_state'],
|
||||||
|
mediaCount: data['media_count'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_favController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
tooltip: '新建收藏夹',
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_favController.loadingState.value is Success) {
|
if (_favController.loadingState.value is Success) {
|
||||||
@@ -96,7 +124,31 @@ class _FavPageState extends State<FavPage> {
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
childCount: loadingState.response.length,
|
childCount: loadingState.response.length,
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
return FavItem(favFolderItem: loadingState.response[index]);
|
String heroTag =
|
||||||
|
Utils.makeHeroTag(loadingState.response[index].fid);
|
||||||
|
return FavItem(
|
||||||
|
heroTag: heroTag,
|
||||||
|
favFolderItem: loadingState.response[index],
|
||||||
|
onTap: () {
|
||||||
|
Get.toNamed(
|
||||||
|
'/favDetail',
|
||||||
|
arguments: loadingState.response[index],
|
||||||
|
parameters: {
|
||||||
|
'heroTag': heroTag,
|
||||||
|
'mediaId': loadingState.response[index].id.toString(),
|
||||||
|
},
|
||||||
|
)?.then((res) {
|
||||||
|
if (res == true) {
|
||||||
|
List list =
|
||||||
|
(_favController.loadingState.value as Success)
|
||||||
|
.response;
|
||||||
|
list.removeAt(index);
|
||||||
|
_favController.loadingState.value =
|
||||||
|
LoadingState.success(list);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
|
||||||
|
|
||||||
class FavItem extends StatelessWidget {
|
class FavItem extends StatelessWidget {
|
||||||
|
final String heroTag;
|
||||||
final dynamic favFolderItem;
|
final dynamic favFolderItem;
|
||||||
const FavItem({super.key, required this.favFolderItem});
|
final GestureTapCallback onTap;
|
||||||
|
const FavItem({
|
||||||
|
super.key,
|
||||||
|
required this.onTap,
|
||||||
|
required this.heroTag,
|
||||||
|
required this.favFolderItem,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String heroTag = Utils.makeHeroTag(favFolderItem.fid);
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => Get.toNamed(
|
onTap: onTap,
|
||||||
'/favDetail',
|
|
||||||
arguments: favFolderItem,
|
|
||||||
parameters: {
|
|
||||||
'heroTag': heroTag,
|
|
||||||
'mediaId': favFolderItem.id.toString(),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(12, 7, 12, 7),
|
padding: const EdgeInsets.fromLTRB(12, 7, 12, 7),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
@@ -80,6 +77,15 @@ class VideoContent extends StatelessWidget {
|
|||||||
letterSpacing: 0.3,
|
letterSpacing: 0.3,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (favFolderItem.intro.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
favFolderItem.intro,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
'${favFolderItem.mediaCount}个内容',
|
'${favFolderItem.mediaCount}个内容',
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
.then((data) {
|
.then((data) {
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
SmartDialog.showToast('删除成功');
|
SmartDialog.showToast('删除成功');
|
||||||
Get.back();
|
Get.back(result: true);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(data['msg']);
|
SmartDialog.showToast(data['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,13 @@ class _MemberFavoriteState extends State<MemberFavorite>
|
|||||||
'mediaId': item1.id.toString(),
|
'mediaId': item1.id.toString(),
|
||||||
'heroTag': widget.heroTag ?? '',
|
'heroTag': widget.heroTag ?? '',
|
||||||
},
|
},
|
||||||
);
|
)?.then((res) {
|
||||||
|
if (res == true) {
|
||||||
|
_controller.first.value.mediaListResponse?.list
|
||||||
|
?.remove(item1);
|
||||||
|
_controller.first.refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (item1.type == 21) {
|
} else if (item1.type == 21) {
|
||||||
PiliScheme.routePush(Uri.parse(item1.link ?? ''));
|
PiliScheme.routePush(Uri.parse(item1.link ?? ''));
|
||||||
} else if (item1.type == 11) {
|
} else if (item1.type == 11) {
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
gapSize: 10,
|
gapSize: 10,
|
||||||
itemCount: videoItem['staff'].length,
|
itemCount: videoItem['staff'].length,
|
||||||
childBuilder: (index) => Container(
|
childBuilder: (index) => Container(
|
||||||
width: 70,
|
width: 80,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => Get.toNamed(
|
onTap: () => Get.toNamed(
|
||||||
|
|||||||
Reference in New Issue
Block a user