opt: article list page

opt: fav/sub detail

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-10 15:44:58 +08:00
parent 91af974bd4
commit 3b6fd8019b
37 changed files with 401 additions and 447 deletions

View File

@@ -18,7 +18,6 @@ class FavDetailController
late int mediaId;
late String heroTag;
RxBool isOwner = false.obs;
RxBool titleCtr = false.obs;
dynamic mid;

View File

@@ -36,18 +36,6 @@ class _FavDetailPageState extends State<FavDetailPage> {
void initState() {
super.initState();
mediaId = Get.parameters['mediaId']!;
_favDetailController.scrollController.addListener(listener);
}
void listener() {
_favDetailController.titleCtr.value =
_favDetailController.scrollController.offset >= 130;
}
@override
void dispose() {
_favDetailController.scrollController.removeListener(listener);
super.dispose();
}
@override
@@ -81,323 +69,280 @@ class _FavDetailPageState extends State<FavDetailPage> {
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: kToolbarHeight + 130,
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.textTheme.titleMedium,
),
Text(
'${_favDetailController.item.value.mediaCount}条视频',
style: theme.textTheme.labelMedium,
)
],
),
),
_buildHeader(theme),
Obx(() => _buildBody(
theme, _favDetailController.loadingState.value)),
],
),
),
),
),
),
);
}
Widget _buildHeader(ThemeData theme) {
return SliverAppBar.medium(
leading: _favDetailController.enableMultiSelect.value
? IconButton(
tooltip: '取消',
onPressed: _favDetailController.handleSelect,
icon: const Icon(Icons.close_outlined),
)
: null,
expandedHeight: kToolbarHeight + 130,
pinned: true,
title: _favDetailController.enableMultiSelect.value
? Text('已选: ${_favDetailController.checkedCount.value}')
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_favDetailController.item.value.title ?? '',
style: theme.textTheme.titleMedium,
),
Text(
'${_favDetailController.item.value.mediaCount}条视频',
style: theme.textTheme.labelMedium,
)
],
),
actions: _favDetailController.enableMultiSelect.value
? [
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () => _favDetailController.handleSelect(true),
child: const Text('全选'),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () {
RequestUtils.onCopyOrMove<FavDetailData, FavDetailItemData>(
context: context,
isCopy: true,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
mid: _favDetailController.mid,
);
},
child: Text(
'复制',
style: TextStyle(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () {
RequestUtils.onCopyOrMove<FavDetailData, FavDetailItemData>(
context: context,
isCopy: false,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
mid: _favDetailController.mid,
);
},
child: Text(
'移动',
style: TextStyle(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () => _favDetailController.onDelChecked(context),
child: Text(
'删除',
style: TextStyle(color: theme.colorScheme.error),
),
),
const SizedBox(width: 6),
]
: [
IconButton(
tooltip: '搜索',
onPressed: () => Get.toNamed(
'/favSearch',
arguments: {
'type': 0,
'mediaId': int.parse(mediaId),
'title': _favDetailController.item.value.title,
'count': _favDetailController.item.value.mediaCount,
'isOwner': _favDetailController.isOwner.value,
},
),
icon: const Icon(Icons.search_outlined),
),
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: const Text('编辑信息'),
),
actions: _favDetailController.enableMultiSelect.value
? [
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () =>
_favDetailController.handleSelect(true),
child: const Text('全选'),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () {
RequestUtils.onCopyOrMove<FavDetailData,
FavDetailItemData>(
PopupMenuItem(
onTap: () {
UserHttp.cleanFav(mediaId: mediaId).then((data) {
if (data['status']) {
SmartDialog.showToast('清除成功');
Future.delayed(
const Duration(milliseconds: 200), () {
_favDetailController.onReload();
});
} else {
SmartDialog.showToast(data['msg']);
}
});
},
child: const Text('清除失效内容'),
),
PopupMenuItem(
onTap: () {
if (_favDetailController.loadingState.value
is Success &&
((_favDetailController.loadingState.value
as Success)
.response as List?)
?.isNotEmpty ==
true) {
if ((_favDetailController
.item.value.mediaCount ??
0) >
1000) {
SmartDialog.showToast('内容太多啦超过1000不支持排序');
return;
}
Get.to(
FavSortPage(
favDetailController:
_favDetailController),
);
}
},
child: const Text('排序'),
),
if (!Utils.isDefaultFav(
_favDetailController.item.value.attr ?? 0))
PopupMenuItem(
onTap: () {
showConfirmDialog(
context: context,
isCopy: true,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
mid: _favDetailController.mid,
title: '确定删除该收藏夹?',
onConfirm: () {
UserHttp.deleteFolder(mediaIds: [mediaId])
.then((data) {
if (data['status']) {
SmartDialog.showToast('删除成功');
Get.back(result: true);
} else {
SmartDialog.showToast(data['msg']);
}
});
},
);
},
child: Text(
'复制',
style: TextStyle(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () {
RequestUtils.onCopyOrMove<FavDetailData,
FavDetailItemData>(
context: context,
isCopy: false,
ctr: _favDetailController,
mediaId: _favDetailController.mediaId,
mid: _favDetailController.mid,
);
},
child: Text(
'移动',
style: TextStyle(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
),
onPressed: () =>
_favDetailController.onDelChecked(context),
child: Text(
'删除',
style:
TextStyle(color: theme.colorScheme.error),
style: TextStyle(
color: theme.colorScheme.error,
),
),
),
const SizedBox(width: 6),
]
: [
IconButton(
tooltip: '搜索',
onPressed: () => Get.toNamed(
'/favSearch',
arguments: {
'type': 0,
'mediaId': int.parse(mediaId),
'title':
_favDetailController.item.value.title,
'count': _favDetailController
.item.value.mediaCount,
'isOwner': _favDetailController.isOwner.value,
},
),
icon: const Icon(Icons.search_outlined),
),
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: const Text('编辑信息'),
),
PopupMenuItem(
onTap: () {
UserHttp.cleanFav(mediaId: mediaId)
.then((data) {
if (data['status']) {
SmartDialog.showToast('清除成功');
Future.delayed(
const Duration(
milliseconds: 200), () {
_favDetailController
.onReload();
});
} else {
SmartDialog.showToast(
data['msg']);
}
});
},
child: const Text('清除失效内容'),
),
PopupMenuItem(
onTap: () {
if (_favDetailController
.loadingState
.value is Success &&
((_favDetailController
.loadingState
.value
as Success)
.response as List?)
?.isNotEmpty ==
true) {
if ((_favDetailController.item
.value.mediaCount ??
0) >
1000) {
SmartDialog.showToast(
'内容太多啦超过1000不支持排序');
return;
}
Get.to(
FavSortPage(
favDetailController:
_favDetailController),
);
}
},
child: const Text('排序'),
),
if (!Utils.isDefaultFav(
_favDetailController
.item.value.attr ??
0))
PopupMenuItem(
onTap: () {
showConfirmDialog(
context: context,
title: '确定删除该收藏夹?',
onConfirm: () {
UserHttp.deleteFolder(
mediaIds: [mediaId])
.then((data) {
if (data['status']) {
SmartDialog.showToast(
'删除成功');
Get.back(result: true);
} else {
SmartDialog.showToast(
data['msg']);
}
});
},
);
},
child: Text(
'删除',
style: TextStyle(
color: theme.colorScheme.error,
),
),
),
],
)
: const SizedBox.shrink(),
),
const SizedBox(width: 6),
],
flexibleSpace: FlexibleSpaceBar(
background: Padding(
padding: EdgeInsets.only(
top: kToolbarHeight +
MediaQuery.of(context).padding.top +
10,
left: 14,
right: 20,
bottom: 10,
),
child: SizedBox(
height: 110,
child: Obx(
() => Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: _favDetailController.heroTag,
child: NetworkImgLayer(
width: 176,
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.textTheme
.titleMedium!.fontSize,
fontWeight: FontWeight.bold),
),
if (_favDetailController
.item.value.intro?.isNotEmpty ==
true)
Text(
_favDetailController
.item.value.intro ??
'',
style: TextStyle(
fontSize: theme.textTheme
.labelSmall!.fontSize,
color:
theme.colorScheme.outline),
),
const SizedBox(height: 4),
Text(
_favDetailController
.item.value.upper?.name ??
'',
style: TextStyle(
fontSize: theme.textTheme
.labelSmall!.fontSize,
color: theme.colorScheme.outline),
),
const Spacer(),
if (_favDetailController
.item.value.attr !=
null)
Text(
'${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicFavText(_favDetailController.item.value.attr ?? 0)}',
style: TextStyle(
fontSize: theme.textTheme
.labelSmall!.fontSize,
color:
theme.colorScheme.outline),
),
],
),
),
),
],
),
],
)
: const SizedBox.shrink(),
),
const SizedBox(width: 6),
],
flexibleSpace: FlexibleSpaceBar(
background: Padding(
padding: EdgeInsets.only(
top: kToolbarHeight + MediaQuery.of(context).padding.top + 10,
left: 14,
right: 20,
bottom: 10,
),
child: SizedBox(
height: 110,
child: Obx(
() => Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: _favDetailController.heroTag,
child: NetworkImgLayer(
width: 176,
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.textTheme.titleMedium!.fontSize,
fontWeight: FontWeight.bold),
),
),
if (_favDetailController
.item.value.intro?.isNotEmpty ==
true)
Text(
_favDetailController.item.value.intro ?? '',
style: TextStyle(
fontSize:
theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline),
),
const SizedBox(height: 4),
Text(
_favDetailController.item.value.upper?.name ?? '',
style: TextStyle(
fontSize: theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline),
),
const Spacer(),
if (_favDetailController.item.value.attr != null)
Text(
'${_favDetailController.item.value.mediaCount}条视频 · ${Utils.isPublicFavText(_favDetailController.item.value.attr ?? 0)}',
style: TextStyle(
fontSize:
theme.textTheme.labelSmall!.fontSize,
color: theme.colorScheme.outline),
),
],
),
),
),
Obx(() => _buildBody(
theme, _favDetailController.loadingState.value)),
],
),
),