opt: fav: validate ownership

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-29 16:53:46 +08:00
parent a6cb49fd02
commit 90176a4787
2 changed files with 61 additions and 59 deletions

View File

@@ -339,20 +339,22 @@ class _FavDetailPageState extends State<FavDetailPage> {
loadingState.response[index].id, loadingState.response[index].id,
loadingState.response[index].type, loadingState.response[index].type,
), ),
onTap: onTap: _favDetailController.enableMultiSelect.value
_favDetailController.enableMultiSelect.value.not ? () {
? null _favDetailController.onSelect(index);
: () { }
_favDetailController.onSelect(index); : null,
}, onLongPress: _favDetailController.isOwner.value
onLongPress: () { ? () {
if (_favDetailController if (_favDetailController
.enableMultiSelect.value.not) { .enableMultiSelect.value.not) {
_favDetailController.enableMultiSelect.value = _favDetailController
true; .enableMultiSelect.value = true;
_favDetailController.onSelect(index); _favDetailController.onSelect(index);
} }
}, }
: null,
isOwner: _favDetailController.isOwner.value,
), ),
), ),
Positioned( Positioned(

View File

@@ -20,6 +20,7 @@ class FavVideoCardH extends StatelessWidget {
final int? searchType; final int? searchType;
final GestureTapCallback? onTap; final GestureTapCallback? onTap;
final GestureLongPressCallback? onLongPress; final GestureLongPressCallback? onLongPress;
final bool isOwner;
const FavVideoCardH({ const FavVideoCardH({
super.key, super.key,
@@ -28,6 +29,7 @@ class FavVideoCardH extends StatelessWidget {
this.searchType, this.searchType,
this.onTap, this.onTap,
this.onLongPress, this.onLongPress,
this.isOwner = false,
}); });
@override @override
@@ -211,53 +213,51 @@ class FavVideoCardH extends StatelessWidget {
), ),
], ],
), ),
searchType != 1 if (searchType != 1 && isOwner)
? Positioned( Positioned(
right: 0, right: 0,
bottom: -4, bottom: -4,
child: IconButton( child: IconButton(
tooltip: '取消收藏', tooltip: '取消收藏',
style: ButtonStyle( style: ButtonStyle(
padding: WidgetStateProperty.all(EdgeInsets.zero), padding: WidgetStateProperty.all(EdgeInsets.zero),
), ),
onPressed: () { onPressed: () {
showDialog( showDialog(
context: Get.context!, context: Get.context!,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('提示'), title: const Text('提示'),
content: const Text('要取消收藏吗?'), content: const Text('要取消收藏吗?'),
actions: [ actions: [
TextButton( TextButton(
onPressed: Get.back, onPressed: Get.back,
child: Text( child: Text(
'取消', '取消',
style: TextStyle( style: TextStyle(
color: Theme.of(context) color:
.colorScheme Theme.of(context).colorScheme.outline),
.outline), ),
), ),
), TextButton(
TextButton( onPressed: () async {
onPressed: () async { await callFn?.call();
await callFn?.call(); Get.back();
Get.back(); },
}, child: const Text('确定取消'),
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(), ),
),
], ],
), ),
), ),