mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: later page: multi select
feat: fav detail page: multi select opt: reply item opt: load more Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/http/user.dart';
|
||||
import 'package:PiliPalaX/models/user/fav_detail.dart';
|
||||
import 'package:PiliPalaX/models/user/fav_folder.dart';
|
||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/pages/common/multi_select_controller.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/http/video.dart';
|
||||
|
||||
class FavDetailController extends CommonController {
|
||||
class FavDetailController extends MultiSelectController {
|
||||
Rx<FavFolderItemData> item = FavFolderItemData().obs;
|
||||
int? mediaId;
|
||||
late String heroTag;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
RxBool isOwner = false.obs;
|
||||
RxBool titleCtr = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -27,20 +28,6 @@ class FavDetailController extends CommonController {
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
Future onRefresh() {
|
||||
loadingText.value = '加载中...';
|
||||
return super.onRefresh();
|
||||
}
|
||||
|
||||
@override
|
||||
Future queryData([bool isRefresh = true]) {
|
||||
if (isRefresh.not && loadingText.value == '没有更多了') {
|
||||
return Future.value();
|
||||
}
|
||||
return super.queryData(isRefresh);
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(Success response) {
|
||||
if (currentPage == 1) {
|
||||
@@ -49,28 +36,30 @@ class FavDetailController extends CommonController {
|
||||
GStorage.userInfo.get('userInfoCache')?.mid;
|
||||
}
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
response.response.medias
|
||||
.insertAll(0, (loadingState.value as Success).response);
|
||||
response.response.medias?.insertAll(
|
||||
0,
|
||||
List<FavDetailItemData>.from((loadingState.value as Success).response),
|
||||
);
|
||||
}
|
||||
loadingState.value = LoadingState.success(response.response.medias);
|
||||
if (response.response.medias.length >= response.response.info.mediaCount) {
|
||||
loadingText.value = '没有更多了';
|
||||
isEnd = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
onCancelFav(int id, int type) async {
|
||||
var result = await VideoHttp.favVideo(
|
||||
aid: id,
|
||||
addIds: '',
|
||||
var result = await VideoHttp.delFav(
|
||||
ids: ['$id:$type'],
|
||||
delIds: mediaId.toString(),
|
||||
type: type,
|
||||
);
|
||||
if (result['status']) {
|
||||
List dataList = (loadingState.value as Success).response;
|
||||
dataList = dataList.where((item) => item.id != id).toList();
|
||||
dataList.removeWhere((item) => item.id == id);
|
||||
loadingState.value = LoadingState.success(dataList);
|
||||
SmartDialog.showToast('取消收藏');
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +69,51 @@ class FavDetailController extends CommonController {
|
||||
ps: 20,
|
||||
mediaId: mediaId!,
|
||||
);
|
||||
|
||||
onDelChecked(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text('确认删除所选收藏吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
List list = ((loadingState.value as Success).response as List)
|
||||
.where((e) => e.checked)
|
||||
.toList();
|
||||
dynamic result = await VideoHttp.delFav(
|
||||
ids: list.map((item) => '${item.id}:${item.type}').toList(),
|
||||
delIds: mediaId.toString(),
|
||||
);
|
||||
if (result['status']) {
|
||||
List dataList = (loadingState.value as Success).response;
|
||||
Set remainList = dataList.toSet().difference(list.toSet());
|
||||
loadingState.value =
|
||||
LoadingState.success(remainList.toList());
|
||||
SmartDialog.showToast('取消收藏');
|
||||
checkedCount.value = 0;
|
||||
enableMultiSelect.value = false;
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
},
|
||||
child: const Text('确认'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/http/user.dart';
|
||||
import 'package:PiliPalaX/models/user/fav_folder.dart';
|
||||
import 'package:PiliPalaX/pages/fav_search/view.dart' show SearchType;
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -28,28 +26,18 @@ class FavDetailPage extends StatefulWidget {
|
||||
class _FavDetailPageState extends State<FavDetailPage> {
|
||||
final FavDetailController _favDetailController =
|
||||
Get.put(FavDetailController());
|
||||
late StreamController<bool> titleStreamC; // a
|
||||
late String mediaId;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mediaId = Get.parameters['mediaId']!;
|
||||
titleStreamC = StreamController<bool>();
|
||||
_favDetailController.scrollController.addListener(
|
||||
() {
|
||||
if (_favDetailController.scrollController.offset > 160) {
|
||||
titleStreamC.add(true);
|
||||
_favDetailController.titleCtr.value = true;
|
||||
} else if (_favDetailController.scrollController.offset <= 160) {
|
||||
titleStreamC.add(false);
|
||||
}
|
||||
|
||||
if (_favDetailController.scrollController.position.pixels >=
|
||||
_favDetailController.scrollController.position.maxScrollExtent -
|
||||
200) {
|
||||
EasyThrottle.throttle('favDetail', const Duration(seconds: 1), () {
|
||||
_favDetailController.onLoadMore();
|
||||
});
|
||||
_favDetailController.titleCtr.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -57,200 +45,235 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
titleStreamC.close();
|
||||
_favDetailController.scrollController.removeListener(() {});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: _favDetailController.scrollController,
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
expandedHeight: 220 - MediaQuery.of(context).padding.top,
|
||||
pinned: true,
|
||||
title: StreamBuilder(
|
||||
stream: titleStreamC.stream,
|
||||
initialData: false,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
opacity: snapshot.data ? 1 : 0,
|
||||
curve: Curves.easeOut,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(
|
||||
() => Column(
|
||||
return Obx(
|
||||
() => PopScope(
|
||||
canPop: _favDetailController.enableMultiSelect.value.not,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (_favDetailController.enableMultiSelect.value) {
|
||||
_favDetailController.handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: _favDetailController.scrollController,
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
leading: _favDetailController.enableMultiSelect.value
|
||||
? IconButton(
|
||||
tooltip: '取消',
|
||||
onPressed: _favDetailController.handleSelect,
|
||||
icon: const Icon(Icons.close_outlined),
|
||||
)
|
||||
: null,
|
||||
expandedHeight: 220 - MediaQuery.of(context).padding.top,
|
||||
pinned: true,
|
||||
title: _favDetailController.enableMultiSelect.value
|
||||
? Text(
|
||||
'已选择${_favDetailController.checkedCount.value}项',
|
||||
)
|
||||
: Obx(
|
||||
() => AnimatedOpacity(
|
||||
opacity: _favDetailController.titleCtr.value ? 1 : 0,
|
||||
curve: Curves.easeOut,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_favDetailController.item.value.title ?? '',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Text(
|
||||
'共${_favDetailController.item.value.mediaCount}条视频',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: _favDetailController.enableMultiSelect.value
|
||||
? [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
_favDetailController.handleSelect(true),
|
||||
child: const Text('全选'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
_favDetailController.onDelChecked(context),
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
]
|
||||
: [
|
||||
IconButton(
|
||||
tooltip: '搜索',
|
||||
onPressed: () =>
|
||||
Get.toNamed('/favSearch', arguments: {
|
||||
'type': 0,
|
||||
'mediaId': int.parse(mediaId),
|
||||
'searchType': SearchType.fav,
|
||||
}),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: const Icon(Icons.more_vert),
|
||||
// ),
|
||||
Obx(
|
||||
() => _favDetailController.isOwner.value
|
||||
? PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/createFav',
|
||||
parameters: {'mediaId': mediaId},
|
||||
)?.then((res) {
|
||||
if (res is FavFolderItemData) {
|
||||
_favDetailController.item.value =
|
||||
res;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text('编辑信息'),
|
||||
),
|
||||
if (!Utils.isDefault(
|
||||
_favDetailController.item.value.attr ??
|
||||
0))
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
UserHttp.deleteFolder(
|
||||
mediaIds: [mediaId]).then((data) {
|
||||
if (data['status']) {
|
||||
SmartDialog.showToast('删除成功');
|
||||
Get.back(result: true);
|
||||
} else {
|
||||
SmartDialog.showToast(
|
||||
data['msg']);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text('删除'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: kTextTabBarHeight +
|
||||
MediaQuery.of(context).padding.top +
|
||||
10,
|
||||
left: 14,
|
||||
right: 20),
|
||||
child: SizedBox(
|
||||
height: 110,
|
||||
child: Obx(
|
||||
() => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_favDetailController.item.value.title ?? '',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
Hero(
|
||||
tag: _favDetailController.heroTag,
|
||||
child: NetworkImgLayer(
|
||||
width: 180,
|
||||
height: 110,
|
||||
src: _favDetailController.item.value.cover,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 110,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_favDetailController.item.value.title ??
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.fontSize,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
if (_favDetailController
|
||||
.item.value.intro?.isNotEmpty ==
|
||||
true)
|
||||
Text(
|
||||
_favDetailController.item.value.intro ??
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_favDetailController
|
||||
.item.value.upper?.name ??
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
const Spacer(),
|
||||
if (_favDetailController.item.value.attr !=
|
||||
null)
|
||||
Text(
|
||||
'共${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicText(_favDetailController.item.value.attr ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'共${_favDetailController.item.value.mediaCount}条视频',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '搜索',
|
||||
onPressed: () => Get.toNamed('/favSearch', arguments: {
|
||||
'type': 0,
|
||||
'mediaId': int.parse(mediaId),
|
||||
'searchType': SearchType.fav,
|
||||
}),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: const Icon(Icons.more_vert),
|
||||
// ),
|
||||
Obx(
|
||||
() => _favDetailController.isOwner.value
|
||||
? PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/createFav',
|
||||
parameters: {'mediaId': mediaId},
|
||||
)?.then((res) {
|
||||
if (res is FavFolderItemData) {
|
||||
_favDetailController.item.value = res;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text('编辑信息'),
|
||||
),
|
||||
if (!Utils.isDefault(
|
||||
_favDetailController.item.value.attr ?? 0))
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
UserHttp.deleteFolder(mediaIds: [mediaId])
|
||||
.then((data) {
|
||||
if (data['status']) {
|
||||
SmartDialog.showToast('删除成功');
|
||||
Get.back(result: true);
|
||||
} else {
|
||||
SmartDialog.showToast(data['msg']);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text('删除'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: kTextTabBarHeight +
|
||||
MediaQuery.of(context).padding.top +
|
||||
10,
|
||||
left: 14,
|
||||
right: 20),
|
||||
child: SizedBox(
|
||||
height: 110,
|
||||
child: Obx(
|
||||
() => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Hero(
|
||||
tag: _favDetailController.heroTag,
|
||||
child: NetworkImgLayer(
|
||||
width: 180,
|
||||
height: 110,
|
||||
src: _favDetailController.item.value.cover,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 110,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_favDetailController.item.value.title ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.fontSize,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
if (_favDetailController
|
||||
.item.value.intro?.isNotEmpty ==
|
||||
true)
|
||||
Text(
|
||||
_favDetailController.item.value.intro ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_favDetailController.item.value.upper?.name ??
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
const Spacer(),
|
||||
if (_favDetailController.item.value.attr !=
|
||||
null)
|
||||
Text(
|
||||
'共${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicText(_favDetailController.item.value.attr ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() => _buildBody(_favDetailController.loadingState.value)),
|
||||
],
|
||||
),
|
||||
Obx(() => _buildBody(_favDetailController.loadingState.value)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -287,25 +310,103 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == loadingState.response.length) {
|
||||
_favDetailController.onLoadMore();
|
||||
return Container(
|
||||
height: 60,
|
||||
alignment: Alignment.center,
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_favDetailController.loadingText.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: 13),
|
||||
child: Text(
|
||||
_favDetailController.isEnd.not ? '加载中...' : '没有更多了',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return FavVideoCardH(
|
||||
videoItem: loadingState.response[index],
|
||||
callFn: () => _favDetailController.onCancelFav(
|
||||
loadingState.response[index].id,
|
||||
loadingState.response[index].type,
|
||||
),
|
||||
return Stack(
|
||||
children: [
|
||||
FavVideoCardH(
|
||||
videoItem: loadingState.response[index],
|
||||
callFn: () => _favDetailController.onCancelFav(
|
||||
loadingState.response[index].id,
|
||||
loadingState.response[index].type,
|
||||
),
|
||||
onTap:
|
||||
_favDetailController.enableMultiSelect.value.not
|
||||
? null
|
||||
: () {
|
||||
_favDetailController.onSelect(index);
|
||||
},
|
||||
onLongPress: () {
|
||||
if (_favDetailController
|
||||
.enableMultiSelect.value.not) {
|
||||
_favDetailController.enableMultiSelect.value =
|
||||
true;
|
||||
_favDetailController.onSelect(index);
|
||||
}
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 12,
|
||||
bottom: 0,
|
||||
child: IgnorePointer(
|
||||
child: LayoutBuilder(
|
||||
builder: (_, constraints) => AnimatedOpacity(
|
||||
opacity: loadingState.response[index].checked
|
||||
? 1
|
||||
: 0,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: constraints.maxHeight,
|
||||
width: constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 34,
|
||||
height: 34,
|
||||
child: AnimatedScale(
|
||||
scale:
|
||||
loadingState.response[index].checked
|
||||
? 1
|
||||
: 0,
|
||||
duration:
|
||||
const Duration(milliseconds: 250),
|
||||
curve: Curves.easeInOut,
|
||||
child: IconButton(
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
EdgeInsets.zero),
|
||||
backgroundColor:
|
||||
WidgetStateProperty.resolveWith(
|
||||
(states) {
|
||||
return Theme.of(context)
|
||||
.colorScheme
|
||||
.surface
|
||||
.withOpacity(0.8);
|
||||
},
|
||||
),
|
||||
),
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
Icons.done_all_outlined,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length + 1,
|
||||
|
||||
@@ -17,12 +17,16 @@ class FavVideoCardH extends StatelessWidget {
|
||||
final dynamic videoItem;
|
||||
final Function? callFn;
|
||||
final int? searchType;
|
||||
final GestureTapCallback? onTap;
|
||||
final GestureLongPressCallback? onLongPress;
|
||||
|
||||
const FavVideoCardH({
|
||||
super.key,
|
||||
required this.videoItem,
|
||||
this.callFn,
|
||||
this.searchType,
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -32,6 +36,10 @@ class FavVideoCardH extends StatelessWidget {
|
||||
String heroTag = Utils.makeHeroTag(id);
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
if (onTap != null) {
|
||||
onTap!();
|
||||
return;
|
||||
}
|
||||
int? seasonId;
|
||||
String? epId;
|
||||
if (videoItem.ogv != null &&
|
||||
@@ -65,6 +73,7 @@ class FavVideoCardH extends StatelessWidget {
|
||||
epId != null ? SearchType.media_bangumi : SearchType.video,
|
||||
});
|
||||
},
|
||||
onLongPress: onLongPress,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
@@ -213,14 +222,15 @@ class FavVideoCardH extends StatelessWidget {
|
||||
content: const Text('要取消收藏吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
)),
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await callFn?.call();
|
||||
|
||||
Reference in New Issue
Block a user