Merge branch 'main' into feature-minePage

This commit is contained in:
guozhigq
2024-10-16 14:17:24 +08:00
parent 676b2f18eb
commit 174eff7151
62 changed files with 1738 additions and 1371 deletions

View File

@ -9,6 +9,7 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/reply.dart';
import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/main/index.dart';
@ -18,6 +19,7 @@ import 'package:pilipala/plugin/pl_gallery/index.dart';
import 'package:pilipala/plugin/pl_popup/index.dart';
import 'package:pilipala/utils/app_scheme.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/url_utils.dart';
@ -48,6 +50,8 @@ class ReplyItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool isOwner = int.parse(replyItem!.member!.mid!) ==
(GlobalDataCache().userInfo?.mid ?? -1);
return Material(
child: InkWell(
// 点击整个评论区 评论详情/回复
@ -73,6 +77,7 @@ class ReplyItem extends StatelessWidget {
return MorePanel(
item: replyItem,
mainFloor: true,
isOwner: isOwner,
);
},
);
@ -195,25 +200,36 @@ class ReplyItem extends StatelessWidget {
),
],
),
Row(
children: <Widget>[
Text(
Utils.dateFormat(replyItem!.ctime),
style: TextStyle(
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline,
),
),
if (replyItem!.replyControl != null &&
replyItem!.replyControl!.location != '')
Text(
'${replyItem!.replyControl!.location!}',
RichText(
text: TextSpan(
children: [
TextSpan(
text: Utils.dateFormat(replyItem!.ctime),
style: TextStyle(
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline),
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline,
),
),
],
)
if (replyItem!.replyControl != null &&
replyItem!.replyControl!.location != '')
TextSpan(
text: '${replyItem!.replyControl!.location!}',
style: TextStyle(
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline,
),
),
if (replyItem!.invisible!)
TextSpan(
text: ' • 隐藏的评论',
style: TextStyle(
color: colorScheme.outline,
fontSize: textTheme.labelSmall!.fontSize,
),
),
],
),
),
],
),
],
@ -698,14 +714,11 @@ InlineSpan buildContent(
'',
);
} else if (RegExp(r'^cv\d+$').hasMatch(matchStr)) {
Get.toNamed(
'/webview',
parameters: {
'url': 'https://www.bilibili.com/read/$matchStr',
'type': 'url',
'pageTitle': title
},
);
Get.toNamed('/read', parameters: {
'title': title,
'id': Utils.matchNum(matchStr).first.toString(),
'articleType': 'read',
});
} else {
Uri uri = Uri.parse(matchStr.replaceAll('/?', '?'));
SchemeEntity scheme = SchemeEntity(
@ -717,7 +730,7 @@ InlineSpan buildContent(
source: '',
dataString: matchStr,
);
PiliSchame.fullPathPush(scheme);
PiliSchame.httpsScheme(scheme);
}
} else {
if (appUrlSchema.startsWith('bilibili://search')) {
@ -1004,10 +1017,12 @@ InlineSpan buildContent(
class MorePanel extends StatelessWidget {
final dynamic item;
final bool mainFloor;
final bool isOwner;
const MorePanel({
super.key,
required this.item,
this.mainFloor = false,
this.isOwner = false,
});
Future<dynamic> menuActionHandler(String type) async {
@ -1043,9 +1058,43 @@ class MorePanel extends StatelessWidget {
// case 'report':
// SmartDialog.showToast('举报');
// break;
// case 'delete':
// SmartDialog.showToast('删除');
// break;
case 'delete':
// 删除评论提示
await showDialog(
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('删除评论'),
content: const Text('删除评论后,评论下所有回复将被删除,确定删除吗?'),
actions: <Widget>[
TextButton(
onPressed: () => Get.back(),
child: Text('取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline)),
),
TextButton(
onPressed: () async {
Get.back();
var result = await ReplyHttp.replyDel(
type: item.type!,
oid: item.oid!,
rpid: item.rpid!,
);
if (result['status']) {
SmartDialog.showToast('评论删除成功,需手动刷新');
Get.back();
} else {
SmartDialog.showToast(result['msg']);
}
},
child: const Text('确定'),
),
],
);
},
);
break;
default:
}
}
@ -1054,6 +1103,7 @@ class MorePanel extends StatelessWidget {
Widget build(BuildContext context) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
Color errorColor = colorScheme.error;
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
@ -1106,12 +1156,14 @@ class MorePanel extends StatelessWidget {
// leading: Icon(Icons.report_outlined, color: errorColor),
// title: Text('举报', style: TextStyle(color: errorColor)),
// ),
// ListTile(
// onTap: () async => await menuActionHandler('del'),
// minLeadingWidth: 0,
// leading: Icon(Icons.delete_outline, color: errorColor),
// title: Text('删除', style: TextStyle(color: errorColor)),
// ),
if (isOwner)
ListTile(
onTap: () async => await menuActionHandler('delete'),
minLeadingWidth: 0,
leading: Icon(Icons.delete_outline, color: errorColor),
title: Text('删除评论',
style: textTheme.titleSmall!.copyWith(color: errorColor)),
),
],
),
);