feat: clean fav

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-27 13:26:31 +08:00
parent caee40a5d9
commit 1d8e469a46
35 changed files with 148 additions and 107 deletions

View File

@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void showConfirmDialog({
required BuildContext context,
required String title,
String? content,
required VoidCallback onConfirm,
}) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(title),
content: content == null ? null : Text(content),
actions: [
TextButton(
onPressed: Get.back,
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: onConfirm,
child: Text('确认'),
),
],
);
},
);
}

View File

@@ -182,6 +182,8 @@ class Api {
static const String deleteFolder = '/x/v3/fav/folder/del';
static const String cleanFav = '/x/v3/fav/resource/clean';
/// 收藏夹 详情
/// media_id 当前收藏夹id 搜索全部时为默认收藏夹id
/// pn int 当前页

View File

@@ -62,6 +62,27 @@ class UserHttp {
}
}
static Future cleanFav({
required dynamic mediaId,
}) async {
var res = await Request().post(
Api.cleanFav,
data: {
'media_id': mediaId,
'platform': 'web',
'csrf': await Request.getCsrf(),
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future deleteFolder({
required List<dynamic> mediaIds,
}) async {

View File

@@ -275,6 +275,9 @@ class MyApp extends StatelessWidget {
progressIndicatorTheme: ProgressIndicatorThemeData(
refreshBackgroundColor: colorScheme.onSecondary,
),
dialogTheme: DialogTheme(
titleTextStyle: TextStyle(fontSize: 18),
),
);
}
}

View File

@@ -53,7 +53,8 @@ class _AboutPageState extends State<AboutPage> {
TextStyle subTitleStyle =
TextStyle(fontSize: 13, color: Theme.of(context).colorScheme.outline);
return Scaffold(
appBar: widget.showAppBar == false ? null : AppBar(title: Text('关于')),
appBar:
widget.showAppBar == false ? null : AppBar(title: const Text('关于')),
body: ListView(
children: [
GestureDetector(

View File

@@ -156,7 +156,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('评论详情'),
title: const Text('评论详情'),
titleSpacing: automaticallyImplyLeading ? null : 12,
automaticallyImplyLeading: automaticallyImplyLeading,
),

View File

@@ -309,10 +309,7 @@ class AuthorPanel extends StatelessWidget {
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'举报动态',
style: TextStyle(fontSize: 18),
),
title: const Text('举报动态'),
titlePadding: const EdgeInsets.only(left: 22, top: 16, right: 22),
contentPadding: const EdgeInsets.only(top: 5),
actionsPadding:

View File

@@ -26,7 +26,7 @@ class _FavPageState extends State<FavPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('我的收藏'),
title: const Text('我的收藏'),
actions: [
IconButton(
onPressed: () {

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/user.dart';
import 'package:PiliPlus/models/user/fav_folder.dart';
@@ -159,13 +160,32 @@ class _FavDetailPageState extends State<FavDetailPage> {
},
child: Text('编辑信息'),
),
PopupMenuItem(
onTap: () {
UserHttp.cleanFav(mediaId: mediaId)
.then((data) {
if (data['status']) {
SmartDialog.showToast('清除成功');
_favDetailController.onReload();
} else {
SmartDialog.showToast(data['msg']);
}
});
},
child: Text('清除失效内容'),
),
if (!Utils.isDefault(
_favDetailController.item.value.attr ??
0))
PopupMenuItem(
onTap: () {
showConfirmDialog(
context: context,
title: '确定删除该收藏夹?',
onConfirm: () {
UserHttp.deleteFolder(
mediaIds: [mediaId]).then((data) {
mediaIds: [mediaId])
.then((data) {
if (data['status']) {
SmartDialog.showToast('删除成功');
Get.back(result: true);
@@ -175,7 +195,16 @@ class _FavDetailPageState extends State<FavDetailPage> {
}
});
},
child: Text('删除'),
);
},
child: Text(
'删除',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.error,
),
),
),
],
)

View File

@@ -36,7 +36,7 @@ class _HistoryPageState extends State<HistoryPage> {
appBar: AppBarWidget(
visible: _historyController.enableMultiSelect.value,
child1: AppBar(
title: Text('观看记录'),
title: const Text('观看记录'),
actions: [
IconButton(
tooltip: '搜索',

View File

@@ -145,7 +145,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('评论详情'),
title: const Text('评论详情'),
titleSpacing: automaticallyImplyLeading ? null : 12,
automaticallyImplyLeading: automaticallyImplyLeading,
),

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/model_hot_video_item.dart';
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
@@ -79,23 +80,12 @@ class LaterController extends MultiSelectController {
}
// 一键清空
Future toViewClear(BuildContext context) async {
await showDialog(
void toViewClear(BuildContext context) {
showConfirmDialog(
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 {
title: '清空确认',
content: '确定要清空你的稍后再看列表吗?',
onConfirm: () async {
var res = await UserHttp.toViewClear();
if (res['status']) {
loadingState.value = LoadingState.success([]);
@@ -103,11 +93,6 @@ class LaterController extends MultiSelectController {
Get.back();
SmartDialog.showToast(res['msg']);
},
child: const Text('确认'),
)
],
);
},
);
}

View File

@@ -313,7 +313,6 @@ class LoginPageController extends GetxController
title: const Text(
"本次登录需要验证您的手机号",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18),
),
content: Column(
mainAxisSize: MainAxisSize.min,

View File

@@ -276,10 +276,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(
'修改$title',
style: TextStyle(fontSize: 18),
),
title: Text('修改$title'),
content: TextField(
controller: _textController,
minLines: type == ProfileType.uname ? 1 : 4,

View File

@@ -53,7 +53,7 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Ta的投稿'),
title: const Text('Ta的投稿'),
actions: [
Obx(
() => TextButton.icon(

View File

@@ -46,7 +46,7 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
super.build(context);
return widget.mid == null
? Scaffold(
appBar: AppBar(title: Text('Ta的动态')),
appBar: AppBar(title: const Text('Ta的动态')),
body: _buildBody,
)
: _buildBody;

View File

@@ -47,7 +47,7 @@ class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Ta的专栏')),
appBar: AppBar(title: const Text('Ta的专栏')),
body: Padding(
padding: const EdgeInsets.only(
left: StyleString.safeSpace,

View File

@@ -95,7 +95,7 @@ class _LogsPageState extends State<LogsPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('日志'),
title: const Text('日志'),
actions: [
PopupMenuButton<String>(
onSelected: (String type) {

View File

@@ -191,7 +191,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('倍速设置'),
title: const Text('倍速设置'),
actions: [
TextButton(
onPressed: () async {

View File

@@ -23,7 +23,9 @@ class _PlaySettingState extends State<PlaySetting> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: widget.showAppBar == false ? null : AppBar(title: Text('播放器设置')),
appBar: widget.showAppBar == false
? null
: AppBar(title: const Text('播放器设置')),
body: ListView(
children: [
...playSettings.map((item) => item.widget),

View File

@@ -9,7 +9,7 @@ class PrivacySetting extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: showAppBar == false ? null : AppBar(title: Text('隐私设置')),
appBar: showAppBar == false ? null : AppBar(title: const Text('隐私设置')),
body: ListView(
children: [
...privacySettings.map((item) => item.widget),

View File

@@ -9,7 +9,7 @@ class RecommendSetting extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: showAppBar == false ? null : AppBar(title: Text('推荐流设置')),
appBar: showAppBar == false ? null : AppBar(title: const Text('推荐流设置')),
body: ListView(
children: [
...recommendSettings.map((item) => item.widget),

View File

@@ -9,7 +9,7 @@ class VideoSetting extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: showAppBar == false ? null : AppBar(title: Text('音视频设置')),
appBar: showAppBar == false ? null : AppBar(title: const Text('音视频设置')),
body: ListView(
children: [
...videoSettings.map((item) => item.widget),

View File

@@ -1268,10 +1268,7 @@ List<SettingsModel> get recommendSettings => [
builder: (context) {
String duration = '';
return AlertDialog(
title: Text(
'自定义时长',
style: TextStyle(fontSize: 18),
),
title: const Text('自定义时长'),
content: TextField(
autofocus: true,
onChanged: (value) => duration = value,
@@ -1415,7 +1412,7 @@ List<SettingsModel> get extraSettings => [
context: Get.context!,
builder: (context) {
return AlertDialog(
title: Text('检查周期', style: TextStyle(fontSize: 18)),
title: const Text('检查周期'),
content: TextFormField(
autofocus: true,
initialValue: dynamicPeriod.toString(),
@@ -1543,7 +1540,7 @@ List<SettingsModel> get extraSettings => [
context: Get.context!,
builder: (context) {
return AlertDialog(
title: Text('评论折叠行数', style: TextStyle(fontSize: 18)),
title: const Text('评论折叠行数'),
content: TextFormField(
autofocus: true,
initialValue: replyLengthLimit,
@@ -1601,7 +1598,7 @@ List<SettingsModel> get extraSettings => [
context: Get.context!,
builder: (context) {
return AlertDialog(
title: Text('弹幕行高', style: TextStyle(fontSize: 18)),
title: const Text('弹幕行高'),
content: TextFormField(
autofocus: true,
initialValue: danmakuLineHeight,
@@ -1824,10 +1821,7 @@ List<SettingsModel> get extraSettings => [
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text(
'自定义参数',
style: TextStyle(fontSize: 18),
),
title: const Text('自定义参数'),
content: TextField(
autofocus: true,
onChanged: (value) => param = value,
@@ -2178,10 +2172,7 @@ SettingsModel getBanwordModel({
context: Get.context!,
builder: (context) {
return AlertDialog(
title: Text(
title,
style: TextStyle(fontSize: 18),
),
title: Text(title),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,

View File

@@ -30,10 +30,7 @@ class _MultiSelectDialogState<T> extends State<MultiSelectDialog<T>> {
Widget build(BuildContext context) {
return AlertDialog(
clipBehavior: Clip.hardEdge,
title: Text(
widget.title,
style: TextStyle(fontSize: 18),
),
title: Text(widget.title),
contentPadding: const EdgeInsets.only(top: 12),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return SingleChildScrollView(

View File

@@ -107,10 +107,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
Widget build(BuildContext context) {
return AlertDialog(
clipBehavior: Clip.hardEdge,
title: Text(
widget.title,
style: TextStyle(fontSize: 18),
),
title: Text(widget.title),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return SingleChildScrollView(

View File

@@ -37,10 +37,7 @@ class _SlideDialogState<T extends num> extends State<SlideDialog<T>> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(
widget.title,
style: TextStyle(fontSize: 18),
),
title: Text(widget.title),
contentPadding:
const EdgeInsets.only(top: 20, left: 8, right: 8, bottom: 8),
content: SizedBox(

View File

@@ -49,10 +49,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
'确定禁用 SSL 证书验证?',
style: TextStyle(fontSize: 18),
),
title: const Text('确定禁用 SSL 证书验证?'),
content: const Text('禁用容易受到中间人攻击'),
actions: [
TextButton(

View File

@@ -21,7 +21,7 @@ class _SubPageState extends State<SubPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('我的订阅')),
appBar: AppBar(title: const Text('我的订阅')),
body: CustomScrollView(
slivers: [
Obx(() => _buildBody(_subController.loadingState.value)),

View File

@@ -1662,10 +1662,7 @@ class VideoDetailController extends GetxController
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text(
'确定无误再提交',
style: TextStyle(fontSize: 18),
),
title: const Text('确定无误再提交'),
actions: [
TextButton(
onPressed: Get.back,

View File

@@ -56,7 +56,7 @@ class _FavPanelState extends State<FavPanel> {
onPressed: Get.back,
icon: const Icon(Icons.close_outlined),
),
title: Text('添加到收藏夹'),
title: const Text('添加到收藏夹'),
actions: [
TextButton.icon(
onPressed: () {

View File

@@ -94,7 +94,7 @@ class _GroupPanelState extends State<GroupPanel> {
tooltip: '关闭',
onPressed: Get.back,
icon: const Icon(Icons.close_outlined)),
title: Text('设置关注分组'),
title: const Text('设置关注分组'),
),
Expanded(
child: Material(

View File

@@ -1826,7 +1826,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
appBar: AppBar(
automaticallyImplyLeading: false,
titleSpacing: 16,
title: Text('分段信息'),
title: const Text('分段信息'),
actions: [
Text(
'分段进度条',

View File

@@ -659,10 +659,7 @@ class _HeaderControlState extends State<HeaderControl> {
builder: (context) {
String duration = '';
return AlertDialog(
title: Text(
'自定义时长',
style: TextStyle(fontSize: 18),
),
title: const Text('自定义时长'),
content: TextField(
autofocus: true,
onChanged: (value) => duration = value,

View File

@@ -49,7 +49,7 @@ class PiliScheme {
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('评论详情'),
title: const Text('评论详情'),
actions: [
IconButton(
tooltip: '前往原视频',
@@ -133,7 +133,7 @@ class PiliScheme {
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('评论详情'),
title: const Text('评论详情'),
actions: [
IconButton(
tooltip: '前往',
@@ -173,7 +173,7 @@ class PiliScheme {
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('评论详情'),
title: const Text('评论详情'),
actions: [
IconButton(
tooltip: '前往',