mod: remove disliked rcmd

Closes #80

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-01 11:35:01 +08:00
parent 1dd7b9ed0a
commit dda0fc15c7
11 changed files with 124 additions and 96 deletions

View File

@@ -1,7 +1,6 @@
import 'package:PiliPalaX/common/widgets/image_save.dart';
import 'package:PiliPalaX/http/search.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../models/home/rcmd/result.dart';
@@ -19,10 +18,12 @@ import 'video_popup_menu.dart';
// 视频卡片 - 垂直布局
class VideoCardV extends StatelessWidget {
final dynamic videoItem;
final VoidCallback? onRemove;
const VideoCardV({
super.key,
required this.videoItem,
this.onRemove,
});
bool isStringNumeric(String str) {
@@ -208,6 +209,7 @@ class VideoCardV extends StatelessWidget {
size: 29,
iconSize: 17,
videoItem: videoItem,
onRemove: onRemove,
),
),
]);

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -23,7 +24,9 @@ class VideoCustomActions {
dynamic videoItem;
BuildContext context;
late List<VideoCustomAction> actions;
VideoCustomActions(this.videoItem, this.context) {
VoidCallback? onRemove;
VideoCustomActions(this.videoItem, this.context, [this.onRemove]) {
actions = [
if ((videoItem.bvid as String?)?.isNotEmpty == true)
VideoCustomAction(
@@ -82,12 +85,10 @@ class VideoCustomActions {
return;
}
Widget actionButton(DislikeReason? r, FeedbackReason? f) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 0.0),
),
onPressed: () async {
return SearchText(
text: r?.name ?? f?.name ?? '未知',
onTap: (_) async {
Get.back();
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.feedDislike(
reasonId: r?.id,
@@ -97,10 +98,12 @@ class VideoCustomActions {
);
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? (r?.toast ?? f?.toast) : res['msg']);
Get.back();
res['status'] ? (r?.toast ?? f?.toast) : res['msg'],
);
if (res['status']) {
onRemove?.call();
}
},
child: Text(r?.name ?? f?.name ?? '未知'),
);
}
@@ -108,53 +111,57 @@ class VideoCustomActions {
context: context,
builder: (context) {
return AlertDialog(
title: const Text('请选择'),
content: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (tp.dislikeReasons != null)
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text('我不想看'),
),
if (tp.dislikeReasons != null)
if (tp.dislikeReasons != null) ...[
Text('我不想看'),
const SizedBox(height: 5),
Wrap(
spacing: 5.0,
runSpacing: 2.0,
spacing: 8.0,
runSpacing: 8.0,
children: tp.dislikeReasons!.map((item) {
return actionButton(item, null);
}).toList(),
),
if (tp.feedbacks != null)
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text('反馈'),
),
if (tp.feedbacks != null)
],
if (tp.feedbacks != null) ...[
const SizedBox(height: 5),
Text('反馈'),
const SizedBox(height: 5),
Wrap(
spacing: 5.0,
runSpacing: 2.0,
spacing: 8.0,
runSpacing: 8.0,
children: tp.feedbacks!.map((item) {
return actionButton(null, item);
}).toList(),
),
//分割线
],
const Divider(),
ElevatedButton(
onPressed: () async {
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.feedDislikeCancel(
// reasonId: r?.id,
// feedbackId: f?.id,
id: v.param!,
goto: v.goto!,
);
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? "成功" : res['msg']);
Get.back();
},
child: const Text("撤销"),
Center(
child: FilledButton.tonal(
onPressed: () async {
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.feedDislikeCancel(
// reasonId: r?.id,
// feedbackId: f?.id,
id: v.param!,
goto: v.goto!,
);
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? "成功" : res['msg']);
Get.back();
},
style: FilledButton.styleFrom(
visualDensity: VisualDensity(
horizontal: -2,
vertical: -2,
),
),
child: const Text("撤销"),
),
),
],
),
@@ -167,7 +174,6 @@ class VideoCustomActions {
context: context,
builder: (context) {
return AlertDialog(
title: const Text('点踩该视频?'),
content: SingleChildScrollView(
child: Column(
children: [
@@ -178,20 +184,28 @@ class VideoCustomActions {
spacing: 5.0,
runSpacing: 2.0,
children: [
ElevatedButton(
FilledButton.tonal(
onPressed: () async {
Get.back();
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.dislikeVideo(
bvid: videoItem.bvid as String, type: true);
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? "点踩成功" : res['msg']);
Get.back();
res['status'] ? "点踩成功" : res['msg'],
);
},
style: FilledButton.styleFrom(
visualDensity: VisualDensity(
horizontal: -2,
vertical: -2,
),
),
child: const Text("点踩"),
),
ElevatedButton(
FilledButton.tonal(
onPressed: () async {
Get.back();
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.dislikeVideo(
bvid: videoItem.bvid as String,
@@ -199,8 +213,13 @@ class VideoCustomActions {
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? "取消踩" : res['msg']);
Get.back();
},
style: FilledButton.styleFrom(
visualDensity: VisualDensity(
horizontal: -2,
vertical: -2,
),
),
child: const Text("撤销"),
),
],
@@ -272,12 +291,14 @@ class VideoPopupMenu extends StatelessWidget {
final double? iconSize;
final double menuItemHeight = 45;
final dynamic videoItem;
final VoidCallback? onRemove;
const VideoPopupMenu({
super.key,
required this.size,
required this.iconSize,
required this.videoItem,
this.onRemove,
});
@override
@@ -296,7 +317,7 @@ class VideoPopupMenu extends StatelessWidget {
position: PopupMenuPosition.under,
onSelected: (String type) {},
itemBuilder: (BuildContext context) =>
VideoCustomActions(videoItem, context).actions.map((e) {
VideoCustomActions(videoItem, context, onRemove).actions.map((e) {
return PopupMenuItem<String>(
value: e.value,
height: menuItemHeight,

View File

@@ -121,10 +121,10 @@ class IntroDetail extends StatelessWidget {
.map(
(item) => SearchText(
fontSize: 13,
searchText: item['tag_name'],
onSelect: (_) => Get.toNamed('/searchResult',
text: item['tag_name'],
onTap: (_) => Get.toNamed('/searchResult',
parameters: {'keyword': item['tag_name']}),
onLongSelect: (_) =>
onLongPress: (_) =>
Utils.copyText(item['tag_name']),
),
)

View File

@@ -128,6 +128,10 @@ class _RcmdPageState extends State<RcmdPage>
? widget.tabType == TabType.rcmd
? VideoCardV(
videoItem: loadingState.response[index],
onRemove: () {
_controller.loadingState.value = LoadingState.success(
(loadingState.response as List)..removeAt(index));
},
)
: LiveCardV(
liveItem: loadingState.response[index],

View File

@@ -217,9 +217,9 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
children: _searchController.historyList
.map(
(item) => SearchText(
searchText: item,
onSelect: _searchController.onClickKeyword,
onLongSelect: _searchController.onLongSelect,
text: item,
onTap: _searchController.onClickKeyword,
onLongPress: _searchController.onLongSelect,
),
)
.toList(),

View File

@@ -1,18 +1,19 @@
import 'package:flutter/material.dart';
class SearchText extends StatelessWidget {
final String? searchText;
final Function? onSelect;
final Function? onLongSelect;
final String text;
final ValueChanged<String>? onTap;
final ValueChanged<String>? onLongPress;
final double? fontSize;
final Color? bgColor;
final Color? textColor;
final TextAlign? textAlign;
const SearchText({
super.key,
this.searchText,
this.onSelect,
this.onLongSelect,
required this.text,
this.onTap,
this.onLongPress,
this.fontSize,
this.bgColor,
this.textColor,
@@ -28,17 +29,17 @@ class SearchText extends StatelessWidget {
padding: EdgeInsets.zero,
child: InkWell(
onTap: () {
onSelect?.call(searchText);
onTap?.call(text);
},
onLongPress: () {
onLongSelect?.call(searchText);
onLongPress?.call(text);
},
borderRadius: BorderRadius.circular(6),
child: Padding(
padding:
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
child: Text(
searchText!,
text,
textAlign: textAlign,
style: TextStyle(
fontSize: fontSize,

View File

@@ -283,8 +283,8 @@ class ArticlePanelController extends GetxController {
children: orderFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (_) async {
text: item['label'],
onTap: (_) async {
Get.back();
currentOrderFilterval.value = item['value'];
SmartDialog.dismiss();
@@ -297,7 +297,7 @@ class ArticlePanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentOrderFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,
@@ -317,8 +317,8 @@ class ArticlePanelController extends GetxController {
children: zoneFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (_) async {
text: item['label'],
onTap: (_) async {
Get.back();
currentZoneFilterval.value = item['value'];
SmartDialog.dismiss();
@@ -331,7 +331,7 @@ class ArticlePanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentZoneFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,

View File

@@ -206,8 +206,8 @@ class UserPanelController extends GetxController {
children: orderFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (_) async {
text: item['label'],
onTap: (_) async {
Get.back();
currentOrderFilterval.value = item['value'];
SmartDialog.dismiss();
@@ -221,7 +221,7 @@ class UserPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentOrderFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,
@@ -241,8 +241,8 @@ class UserPanelController extends GetxController {
children: userTypeFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (_) async {
text: item['label'],
onTap: (_) async {
Get.back();
currentUserTypeFilterval.value = item['value'];
SmartDialog.dismiss();
@@ -255,7 +255,7 @@ class UserPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentUserTypeFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,

View File

@@ -255,10 +255,10 @@ class VideoPanelController extends GetxController {
builder: (context, setState) {
Widget dateWidget([bool isFirst = true]) {
return SearchText(
searchText:
text:
DateFormat('yyyy-MM-dd').format(isFirst ? pubBegin : pubEnd),
textAlign: TextAlign.center,
onSelect: (text) {
onTap: (text) {
showDatePicker(
context: context,
initialDate: isFirst ? pubBegin : pubEnd,
@@ -303,7 +303,7 @@ class VideoPanelController extends GetxController {
}
});
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: currentPubTimeFilterval == -1 &&
(isFirst ? customPubBegin : customPubEnd)
? Theme.of(context).colorScheme.secondaryContainer
@@ -337,8 +337,8 @@ class VideoPanelController extends GetxController {
children: pubTimeFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (text) async {
text: item['label'],
onTap: (text) async {
Get.back();
currentPubTimeFilterval = item['value'];
SmartDialog.dismiss();
@@ -379,7 +379,7 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentPubTimeFilterval
? Theme.of(context)
.colorScheme
@@ -416,8 +416,8 @@ class VideoPanelController extends GetxController {
children: timeFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (text) async {
text: item['label'],
onTap: (text) async {
Get.back();
currentTimeFilterval = item['value'];
SmartDialog.dismiss();
@@ -430,7 +430,7 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentTimeFilterval
? Theme.of(context)
.colorScheme
@@ -454,8 +454,8 @@ class VideoPanelController extends GetxController {
children: zoneFiltersList
.map(
(item) => SearchText(
searchText: item['label'],
onSelect: (text) async {
text: item['label'],
onTap: (text) async {
Get.back();
currentZoneFilterval = item['value'];
SmartDialog.dismiss();
@@ -468,7 +468,7 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongSelect: (_) {},
onLongPress: (_) {},
bgColor: item['value'] == currentZoneFilterval
? Theme.of(context)
.colorScheme

View File

@@ -620,12 +620,12 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
.map(
(item) => SearchText(
fontSize: 13,
searchText: item['tag_name'],
onSelect: (_) => Get.toNamed('/searchResult',
text: item['tag_name'],
onTap: (_) => Get.toNamed('/searchResult',
parameters: {
'keyword': item['tag_name']
}),
onLongSelect: (_) =>
onLongPress: (_) =>
Utils.copyText(item['tag_name']),
),
)

View File

@@ -86,10 +86,10 @@ class IntroDetail extends StatelessWidget {
.map(
(item) => SearchText(
fontSize: 13,
searchText: item['tag_name'],
onSelect: (_) => Get.toNamed('/searchResult',
text: item['tag_name'],
onTap: (_) => Get.toNamed('/searchResult',
parameters: {'keyword': item['tag_name']}),
onLongSelect: (_) =>
onLongPress: (_) =>
Utils.copyText(item['tag_name']),
),
)