opt: item

opt: util

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-16 23:48:25 +08:00
parent 12c711424b
commit d886569dc3
85 changed files with 1983 additions and 1964 deletions

View File

@@ -22,6 +22,7 @@ import 'package:PiliPlus/pages/video/detail/post_panel/post_panel.dart';
import 'package:PiliPlus/pages/video/detail/widgets/send_danmaku_panel.dart';
import 'package:PiliPlus/pages/video/detail/widgets/media_list_panel.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
@@ -428,7 +429,7 @@ class VideoDetailController extends GetxController
: null,
);
if (plPlayerController.isFullScreen.value) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
child: plPlayerController.darkVideoPage && MyApp.darkThemeData != null
? Theme(
@@ -1368,7 +1369,7 @@ class VideoDetailController extends GetxController
);
}
if (plPlayerController.isFullScreen.value) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
child: plPlayerController.darkVideoPage && MyApp.darkThemeData != null
? Theme(
@@ -1664,7 +1665,7 @@ class VideoDetailController extends GetxController
Get.find<VideoIntroController>(tag: heroTag).videoDetail.value.title;
} catch (_) {}
if (plPlayerController.isFullScreen.value) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
child: plPlayerController.darkVideoPage && MyApp.darkThemeData != null
? Theme(

View File

@@ -8,6 +8,8 @@ import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
import 'package:PiliPlus/pages/video/detail/introduction/pay_coins_page.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
@@ -471,7 +473,7 @@ class VideoIntroController extends GetxController
),
onTap: () {
Get.back();
Utils.launchURL(videoUrl);
PageUtils.launchURL(videoUrl);
},
),
ListTile(
@@ -570,7 +572,7 @@ class VideoIntroController extends GetxController
}
return;
} else {
Utils.actionRelationMod(
RequestUtils.actionRelationMod(
context: context,
mid: videoDetail.value.owner?.mid,
isFollow: attr != 0,
@@ -598,7 +600,7 @@ class VideoIntroController extends GetxController
if (videoDetailCtr.isPlayAll) {
if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) ==
-1) {
Utils.toViewPage(
PageUtils.toVideoPage(
'bvid=$bvid&cid=$cid',
arguments: {
if (cover != null) 'pic': cover,
@@ -866,7 +868,7 @@ class VideoIntroController extends GetxController
);
} else {
SearchHttp.ab2c(aid: videoItem.aid, bvid: videoItem.bvid).then(
(cid) => Utils.toViewPage(
(cid) => PageUtils.toVideoPage(
'bvid=${videoItem.bvid}&cid=${videoItem.cid}',
arguments: {
'videoItem': videoItem,
@@ -912,10 +914,10 @@ class VideoIntroController extends GetxController
if (type == 'tap') {
actionFavVideo(type: 'default');
} else {
Utils.showFavBottomSheet(context: context, ctr: this);
PageUtils.showFavBottomSheet(context: context, ctr: this);
}
} else if (type != 'longPress') {
Utils.showFavBottomSheet(context: context, ctr: this);
PageUtils.showFavBottomSheet(context: context, ctr: this);
}
}
}

View File

@@ -5,6 +5,8 @@ import 'package:PiliPlus/pages/search/widgets/search_text.dart';
import 'package:PiliPlus/utils/app_scheme.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:expandable/expandable.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
@@ -296,112 +298,125 @@ class _VideoInfoState extends State<VideoInfo> {
children: [
Expanded(
child: videoItem['staff'] == null
? GestureDetector(
onTap: onPushMember,
behavior: HitTestBehavior.opaque,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Obx(
() => Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
type: 'avatar',
src: videoIntroController.userStat
.value['card']?['face'] ??
'',
width: 35,
height: 35,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
if ((videoIntroController.userStat
.value['card']
?['official_verify']
?['type'] ??
-1) !=
-1)
Positioned(
right: -2,
bottom: -2,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context)
.colorScheme
.surface,
? Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: onPushMember,
behavior: HitTestBehavior.opaque,
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Obx(
() => Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
type: 'avatar',
src: videoIntroController
.userStat
.value['card']
?['face'] ??
'',
width: 35,
height: 35,
fadeInDuration: Duration.zero,
fadeOutDuration:
Duration.zero,
),
if ((videoIntroController
.userStat
.value['card']
?[
'official_verify']
?['type'] ??
-1) !=
-1)
Positioned(
right: -2,
bottom: -2,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context)
.colorScheme
.surface,
),
child: Icon(
Icons.offline_bolt,
color: videoIntroController
.userStat
.value['card']
?[
'official_verify']
?['type'] ==
0
? Colors.yellow
: Colors
.lightBlueAccent,
size: 14,
),
),
),
child: Icon(
Icons.offline_bolt,
color: videoIntroController
],
),
),
const SizedBox(width: 10),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Obx(
() => Text(
videoIntroController.userStat
.value['card']
?['name'] ??
"",
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: (videoIntroController
.userStat
.value['card']?['vip']
?[
'status'] ??
-1) >
0 &&
videoIntroController
.userStat
.value['card']
?[
'official_verify']
?['type'] ==
0
? Colors.yellow
: Colors
.lightBlueAccent,
size: 14,
'vip']?['type'] ==
2
? context.vipColor
: null,
),
),
),
],
),
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Obx(
() => Text(
videoIntroController.userStat
.value['card']
?['name'] ??
"",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: (videoIntroController
.userStat
.value['card']?['vip']
?[
'status'] ??
-1) >
0 &&
videoIntroController
.userStat
.value['card']
?[
'vip']?['type'] ==
2
? context.vipColor
: null,
const SizedBox(height: 0),
Obx(
() => Text(
'${Utils.numFormat(videoIntroController.userStat.value['follower'])}粉丝 ${videoIntroController.userStat.value['archive_count'] != null ? '${Utils.numFormat(videoIntroController.userStat.value['archive_count'])}视频' : ''}',
style: TextStyle(
fontSize: 12,
color:
t.colorScheme.outline,
),
),
),
),
const SizedBox(height: 0),
Obx(
() => Text(
'${Utils.numFormat(videoIntroController.userStat.value['follower'])}粉丝 ${videoIntroController.userStat.value['archive_count'] != null ? '${Utils.numFormat(videoIntroController.userStat.value['archive_count'])}视频' : ''}',
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
),
],
),
],
),
],
),
followButton(context, t),
],
),
),
const Spacer(),
followButton(context, t),
],
)
: SelfSizedHorizontalList(
gapSize: 25,
@@ -489,7 +504,7 @@ class _VideoInfoState extends State<VideoInfo> {
customBorder:
const CircleBorder(),
onTap: () {
Utils
RequestUtils
.actionRelationMod(
context: context,
mid: videoItem[
@@ -1140,7 +1155,7 @@ class _VideoInfoState extends State<VideoInfo> {
recognizer: TapGestureRecognizer()
..onTap = () {
try {
Utils.handleWebview(matchStr);
PageUtils.handleWebview(matchStr);
} catch (err) {
SmartDialog.showToast(err.toString());
}

View File

@@ -43,7 +43,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
if (data['status']) {
_titleController.text = data['data']['title'];
_introController.text = data['data']['intro'];
_isPublic = Utils.isPublic(data['data']['attr']);
_isPublic = Utils.isPublicFav(data['data']['attr']);
_cover = data['data']['cover'];
_attr = data['data']['attr'];
} else {
@@ -171,7 +171,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
Widget get _buildBody => SingleChildScrollView(
child: Column(
children: [
if (_attr == null || !Utils.isDefault(_attr!)) ...[
if (_attr == null || !Utils.isDefaultFav(_attr!)) ...[
ListTile(
tileColor: Theme.of(context).colorScheme.onInverseSurface,
onTap: () {
@@ -285,11 +285,11 @@ class _CreateFavPageState extends State<CreateFavPage> {
),
title: TextField(
autofocus: true,
readOnly: _attr != null && Utils.isDefault(_attr!),
readOnly: _attr != null && Utils.isDefaultFav(_attr!),
controller: _titleController,
style: TextStyle(
fontSize: 14,
color: _attr != null && Utils.isDefault(_attr!)
color: _attr != null && Utils.isDefaultFav(_attr!)
? Theme.of(context).colorScheme.outline
: null,
),
@@ -312,7 +312,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
),
),
const SizedBox(height: 16),
if (_attr == null || !Utils.isDefault(_attr!)) ...[
if (_attr == null || !Utils.isDefaultFav(_attr!)) ...[
ListTile(
tileColor: Theme.of(context).colorScheme.onInverseSurface,
title: Row(

View File

@@ -107,7 +107,7 @@ class _FavPanelState extends State<FavPanel> {
1,
index),
dense: true,
leading: Utils.isPublic(widget
leading: Utils.isPublicFav(widget
.ctr.favFolderData.value.list[index].attr)
? const Icon(Icons.folder_outlined)
: const Icon(Icons.lock_outline),
@@ -115,7 +115,7 @@ class _FavPanelState extends State<FavPanel> {
title: Text(widget
.ctr.favFolderData.value.list[index].title!),
subtitle: Text(
'${widget.ctr.favFolderData.value.list[index].mediaCount}个内容 . ${Utils.isPublicText(widget.ctr.favFolderData.value.list[index].attr)}',
'${widget.ctr.favFolderData.value.list[index].mediaCount}个内容 . ${Utils.isPublicFavText(widget.ctr.favFolderData.value.list[index].attr)}',
),
trailing: Transform.scale(
scale: 0.9,

View File

@@ -6,7 +6,7 @@ import 'package:PiliPlus/models/space_archive/item.dart';
import 'package:PiliPlus/pages/common/common_data_controller.dart';
import 'package:PiliPlus/pages/member/content/member_contribute/member_contribute.dart'
show ContributeType;
import 'package:PiliPlus/utils/utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:get/get.dart';
class HorizontalMemberPageController extends CommonDataController {
@@ -28,7 +28,7 @@ class HorizontalMemberPageController extends CommonDataController {
}
Future getUserInfo() async {
wwebid ??= await Utils.getWwebid(mid);
wwebid ??= await RequestUtils.getWwebid(mid);
dynamic res = await MemberHttp.memberInfo(mid: mid, wwebid: wwebid);
if (res['status']) {
userState.value = LoadingState.success(res['data']);

View File

@@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/video/detail/member/controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/grid.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
@@ -338,7 +339,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
SmartDialog.showToast('账号未登录');
return;
}
Utils.actionRelationMod(
RequestUtils.actionRelationMod(
context: context,
mid: widget.mid,
isFollow: memberInfoModel.isFollowed ?? false,

View File

@@ -46,9 +46,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
),
Success() => loadingState.response?.isNotEmpty == true
? SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom,
),
padding: const EdgeInsets.only(bottom: 80),
sliver: SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate((context, index) {

View File

@@ -12,6 +12,7 @@ import 'package:PiliPlus/common/widgets/save_panel.dart';
import 'package:PiliPlus/pages/video/detail/reply/widgets/zan_grpc.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart';
import 'package:flutter/gestures.dart';
@@ -917,14 +918,14 @@ class ReplyItemGrpc extends StatelessWidget {
});
return;
}
Utils.handleWebview(matchStr);
PageUtils.handleWebview(matchStr);
}
} else {
if (appUrlSchema.startsWith('bilibili://search')) {
Get.toNamed('/searchResult',
parameters: {'keyword': title});
} else {
Utils.handleWebview(matchStr);
PageUtils.handleWebview(matchStr);
}
}
},
@@ -960,7 +961,7 @@ class ReplyItemGrpc extends StatelessWidget {
),
recognizer: TapGestureRecognizer()
..onTap = () {
Utils.handleWebview(matchStr);
PageUtils.handleWebview(matchStr);
},
),
);
@@ -1019,7 +1020,7 @@ class ReplyItemGrpc extends StatelessWidget {
return;
}
Utils.handleWebview(patternStr);
PageUtils.handleWebview(patternStr);
},
)
],
@@ -1074,7 +1075,8 @@ class ReplyItemGrpc extends StatelessWidget {
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () => Utils.handleWebview(content.richText.note.clickUrl),
..onTap =
() => PageUtils.handleWebview(content.richText.note.clickUrl),
),
);
}

View File

@@ -6,6 +6,8 @@ import 'package:PiliPlus/pages/common/common_slide_page.dart';
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -287,7 +289,7 @@ class _VideoReplyReplyPanelState
vsync: this,
duration: const Duration(milliseconds: 200),
)..forward();
Utils.onHorizontalPreview(
PageUtils.onHorizontalPreview(
_key,
AnimationController(
vsync: this,
@@ -351,7 +353,7 @@ class _VideoReplyReplyPanelState
.then((res) {
if (res != null) {
_savedReplies[key] = null;
ReplyInfo replyInfo = Utils.replyCast(res);
ReplyInfo replyInfo = RequestUtils.replyCast(res);
List<ReplyInfo> list =
_videoReplyReplyController.loadingState.value is Success
? (_videoReplyReplyController.loadingState.value as Success)

View File

@@ -22,6 +22,7 @@ import 'package:PiliPlus/pages/video/detail/widgets/ai_detail.dart';
import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:auto_orientation/auto_orientation.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -557,7 +558,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
void enterPip() {
if (Get.currentRoute.startsWith('/video') &&
videoDetailController.floating != null) {
Utils.enterPip(
PageUtils.enterPip(
videoDetailController.floating!,
videoDetailController.data.dash!.video!.first.width!,
videoDetailController.data.dash!.video!.first.height!,
@@ -875,7 +876,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
SmartDialog.showToast(
'账号未登录');
} else {
Utils.reportVideo(
PageUtils.reportVideo(
videoDetailController
.oid.value);
}
@@ -1462,7 +1463,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
if (!Accounts.main.isLogin) {
SmartDialog.showToast('账号未登录');
} else {
Utils.reportVideo(
PageUtils.reportVideo(
videoDetailController.oid.value);
}
break;
@@ -2195,7 +2196,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
vsync: this,
duration: const Duration(milliseconds: 200),
)..forward();
Utils.onHorizontalPreview(
PageUtils.onHorizontalPreview(
videoDetailController.childKey,
AnimationController(
vsync: this,
@@ -2309,7 +2310,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
},
);
if (isFullScreen) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
isFullScreen: () => isFullScreen,
child: videoDetailController.plPlayerController.darkVideoPage
@@ -2407,7 +2408,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
void showViewPoints() {
if (isFullScreen) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
isFullScreen: () => isFullScreen,
child: videoDetailController.plPlayerController.darkVideoPage

View File

@@ -1,6 +1,7 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart';
import 'package:PiliPlus/pages/video/detail/controller.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -50,7 +51,7 @@ class _AiDetailState extends CommonCollapseSlidePageState<AiDetail> {
..onTap = () {
// 处理点击事件
try {
Utils.handleWebview(match.group(0)!);
PageUtils.handleWebview(match.group(0)!);
} catch (err) {
SmartDialog.showToast(err.toString());
}

View File

@@ -11,6 +11,7 @@ import 'package:PiliPlus/pages/setting/widgets/switch_item.dart';
import 'package:PiliPlus/pages/video/detail/introduction/widgets/action_item.dart';
import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:canvas_danmaku/canvas_danmaku.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
@@ -99,7 +100,7 @@ class HeaderControlState extends State<HeaderControl> {
}
void showBottomSheet(StatefulWidgetBuilder builder, {double? padding}) {
Utils.showFSSheet(
PageUtils.showVideoBottomSheet(
context,
isFullScreen: () => isFullScreen,
padding: padding,
@@ -191,7 +192,7 @@ class HeaderControlState extends State<HeaderControl> {
dense: true,
onTap: () => {
Get.back(),
Utils.scheduleExit(this.context, isFullScreen)
PageUtils.scheduleExit(this.context, isFullScreen)
},
leading: const Icon(Icons.hourglass_top_outlined, size: 20),
title: const Text('定时关闭', style: titleStyle),
@@ -582,7 +583,7 @@ class HeaderControlState extends State<HeaderControl> {
return;
}
Get.back();
Utils.reportVideo(videoDetailCtr.oid.value);
PageUtils.reportVideo(videoDetailCtr.oid.value);
},
leading: const Icon(Icons.error_outline, size: 20),
title: const Text('举报', style: titleStyle),
@@ -2237,7 +2238,7 @@ class HeaderControlState extends State<HeaderControl> {
const Duration(seconds: 3), () {});
}
if (!context.mounted) return;
Utils.enterPip(
PageUtils.enterPip(
widget.floating!,
widget
.videoDetailCtr.data.dash!.video!.first.width!,

View File

@@ -240,7 +240,7 @@ class _MediaListPanelState
Theme.of(context).colorScheme.outline,
),
),
const SizedBox(height: 2),
const SizedBox(height: 3),
Row(
children: [
StatView(