opt: item

chore: clean up widgets

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-16 21:45:58 +08:00
parent 5ea8a7d313
commit 4972e64cad
104 changed files with 1059 additions and 5871 deletions

View File

@@ -612,14 +612,13 @@ class _VideoInfoState extends State<VideoInfo> {
Stack(
children: [
Row(
children: <Widget>[
children: [
StatView(
context: context,
theme: 'gray',
value: Utils.numFormat(!widget.loadingStatus
? videoDetail.stat?.view ?? '-'
: videoItem['stat']?.view ?? '-'),
size: 'medium',
textColor: t.colorScheme.outline,
),
const SizedBox(width: 10),
@@ -629,7 +628,6 @@ class _VideoInfoState extends State<VideoInfo> {
value: Utils.numFormat(!widget.loadingStatus
? videoDetail.stat?.danmaku ?? '-'
: videoItem['stat']?.danmu ?? '-'),
size: 'medium',
textColor: t.colorScheme.outline,
),
const SizedBox(width: 10),

View File

@@ -1,211 +0,0 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:PiliPlus/common/widgets/stat/stat.dart';
import 'package:PiliPlus/utils/utils.dart';
@Deprecated('deprecated')
class IntroDetail extends StatelessWidget {
const IntroDetail({
super.key,
this.videoDetail,
this.videoTags,
});
final dynamic videoDetail;
final dynamic videoTags;
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Column(
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius:
const BorderRadius.all(Radius.circular(3))),
),
),
),
),
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectableText(
videoDetail!.title,
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 6),
Row(
children: [
StatView(
context: context,
theme: 'gray',
value: Utils.numFormat(videoDetail!.stat!.view),
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
context: context,
theme: 'gray',
value: Utils.numFormat(videoDetail!.stat!.danmu),
size: 'medium',
),
const SizedBox(width: 10),
Text(
Utils.dateFormat(videoDetail!.pubdate,
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
),
],
),
if (videoTags is List && videoTags.isNotEmpty) ...[
const SizedBox(height: 10),
Wrap(
spacing: 8,
runSpacing: 8,
children: (videoTags as List)
.map(
(item) => SearchText(
fontSize: 13,
text: item['tag_name'],
onTap: (_) => Get.toNamed('/searchResult',
parameters: {'keyword': item['tag_name']}),
onLongPress: (_) =>
Utils.copyText(item['tag_name']),
),
)
.toList(),
)
],
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: SelectableRegion(
focusNode: FocusNode(),
selectionControls: MaterialTextSelectionControls(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
videoDetail!.bvid!,
style: TextStyle(
fontSize: 13,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 10),
Text.rich(
style: const TextStyle(
height: 1.4,
// fontSize: 13,
),
TextSpan(
children: [
buildContent(context, videoDetail!),
],
),
),
],
),
),
),
const SizedBox(height: 100),
],
),
),
)
],
),
),
);
}
InlineSpan buildContent(BuildContext context, content) {
final List descV2 = content.descV2;
// type
// 1 普通文本
// 2 @用户
final List<TextSpan> spanChildren = List.generate(descV2.length, (index) {
final currentDesc = descV2[index];
switch (currentDesc.type) {
case 1:
final List<InlineSpan> spanChildren = <InlineSpan>[];
final RegExp urlRegExp = RegExp(Constants.urlPattern);
final Iterable<Match> matches =
urlRegExp.allMatches(currentDesc.rawText);
int previousEndIndex = 0;
for (final Match match in matches) {
if (match.start > previousEndIndex) {
spanChildren.add(TextSpan(
text: currentDesc.rawText
.substring(previousEndIndex, match.start)));
}
spanChildren.add(
TextSpan(
text: match.group(0),
style: TextStyle(
color: Theme.of(context).colorScheme.primary), // 设置颜色为蓝色
recognizer: TapGestureRecognizer()
..onTap = () {
// 处理点击事件
try {
Utils.handleWebview(match.group(0)!);
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
),
);
previousEndIndex = match.end;
}
if (previousEndIndex < currentDesc.rawText.length) {
spanChildren.add(TextSpan(
text: currentDesc.rawText.substring(previousEndIndex)));
}
final TextSpan result = TextSpan(children: spanChildren);
return result;
case 2:
final Color colorSchemePrimary =
Theme.of(context).colorScheme.primary;
final String heroTag = Utils.makeHeroTag(currentDesc.bizId);
return TextSpan(
text: '@${currentDesc.rawText}',
style: TextStyle(color: colorSchemePrimary),
recognizer: TapGestureRecognizer()
..onTap = () {
Get.toNamed(
'/member?mid=${currentDesc.bizId}',
arguments: {'face': '', 'heroTag': heroTag},
);
},
);
default:
return const TextSpan();
}
});
return TextSpan(children: spanChildren);
}
}

View File

@@ -4,7 +4,7 @@ import 'package:PiliPlus/models/member/info.dart';
import 'package:PiliPlus/models/space_archive/data.dart';
import 'package:PiliPlus/models/space_archive/item.dart';
import 'package:PiliPlus/pages/common/common_data_controller.dart';
import 'package:PiliPlus/pages/member/new/content/member_contribute/member_contribute.dart'
import 'package:PiliPlus/pages/member/content/member_contribute/member_contribute.dart'
show ContributeType;
import 'package:PiliPlus/utils/utils.dart';
import 'package:get/get.dart';

View File

@@ -1,4 +1,3 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
@@ -191,11 +190,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
bottom: MediaQuery.of(context).padding.bottom + 80,
),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response.length - 1 &&

View File

@@ -36,11 +36,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
Widget _buildBody(LoadingState<List<HotVideoItemModel>?> loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoCardHSkeleton();
@@ -54,11 +50,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
bottom: MediaQuery.of(context).padding.bottom,
),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate((context, index) {
return VideoCardH(
videoItem: loadingState.response![index],

File diff suppressed because it is too large Load Diff

View File

@@ -1,153 +0,0 @@
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:PiliPlus/http/reply.dart';
import 'package:PiliPlus/models/common/reply_type.dart';
import 'package:PiliPlus/models/video/reply/item.dart';
import 'package:PiliPlus/utils/feed_back.dart';
class ZanButton extends StatefulWidget {
const ZanButton({
super.key,
this.replyItem,
this.replyType,
});
final ReplyItemModel? replyItem;
final ReplyType? replyType;
@override
State<ZanButton> createState() => _ZanButtonState();
}
class _ZanButtonState extends State<ZanButton> {
Future onHateReply() async {
feedBack();
// SmartDialog.showLoading(msg: 'piliplus ...');
final ReplyItemModel replyItem = widget.replyItem!;
final int oid = replyItem.oid!;
final int rpid = replyItem.rpid!;
// 1 已点赞 2 不喜欢 0 未操作
final int action = replyItem.action != 2 ? 2 : 0;
final res = await ReplyHttp.hateReply(
type: widget.replyType!.index,
action: action == 2 ? 1 : 0,
oid: oid,
rpid: rpid,
);
// SmartDialog.dismiss();
if (res['status']) {
SmartDialog.showToast(replyItem.action != 2 ? '点踩成功' : '取消踩');
if (action == 2) {
if (replyItem.action == 1) {
replyItem.like = replyItem.like! - 1;
}
replyItem.action = 2;
} else {
// replyItem.like = replyItem.like! - 1;
replyItem.action = 0;
}
setState(() {});
} else {
SmartDialog.showToast(res['msg']);
}
}
// 评论点赞
Future onLikeReply() async {
feedBack();
// SmartDialog.showLoading(msg: 'piliplus ...');
final ReplyItemModel replyItem = widget.replyItem!;
final int oid = replyItem.oid!;
final int rpid = replyItem.rpid!;
// 1 已点赞 2 不喜欢 0 未操作
final int action = replyItem.action != 1 ? 1 : 0;
final res = await ReplyHttp.likeReply(
type: widget.replyType!.index, oid: oid, rpid: rpid, action: action);
// SmartDialog.dismiss();
if (res['status']) {
SmartDialog.showToast(replyItem.action != 1 ? '点赞成功' : '取消赞');
if (action == 1) {
replyItem.like = replyItem.like! + 1;
replyItem.action = 1;
} else {
replyItem.like = replyItem.like! - 1;
replyItem.action = 0;
}
setState(() {});
} else {
SmartDialog.showToast(res['msg']);
}
}
bool isProcessing = false;
void handleState(Future Function() action) async {
if (isProcessing.not) {
isProcessing = true;
await action();
isProcessing = false;
}
}
@override
Widget build(BuildContext context) {
final ThemeData t = Theme.of(context);
final Color color = t.colorScheme.outline;
final Color primary = t.colorScheme.primary;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 32,
child: TextButton(
onPressed: () => handleState(onHateReply),
child: Icon(
widget.replyItem!.action == 2
? FontAwesomeIcons.solidThumbsDown
: FontAwesomeIcons.thumbsDown,
size: 16,
color: widget.replyItem!.action == 2 ? primary : color,
semanticLabel: widget.replyItem!.action == 2 ? '已踩' : '点踩',
),
),
),
SizedBox(
height: 32,
child: TextButton(
onPressed: () => handleState(onLikeReply),
child: Row(
children: [
Icon(
widget.replyItem!.action == 1
? FontAwesomeIcons.solidThumbsUp
: FontAwesomeIcons.thumbsUp,
size: 16,
color: widget.replyItem!.action == 1 ? primary : color,
semanticLabel: widget.replyItem!.action == 1 ? '已赞' : '点赞',
),
const SizedBox(width: 4),
AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
transitionBuilder:
(Widget child, Animation<double> animation) {
return ScaleTransition(scale: animation, child: child);
},
child: Text(
Utils.numFormat(widget.replyItem!.like),
key: ValueKey<int>(widget.replyItem!.like!),
style: TextStyle(
color: widget.replyItem!.action == 1 ? primary : color,
fontSize: t.textTheme.labelSmall!.fontSize,
),
),
),
],
),
),
),
],
);
}
}

View File

@@ -235,10 +235,7 @@ class _MediaListPanelState
Text(
item.upper!.name!,
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize,
fontSize: 12,
color:
Theme.of(context).colorScheme.outline,
),