opt: code

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-28 16:16:40 +08:00
parent 1f71dc9a67
commit f4866258d2
41 changed files with 943 additions and 1223 deletions

View File

@@ -312,7 +312,8 @@ class _BangumiInfoState extends State<BangumiInfo>
),
Row(
children: [
StatView(
statView(
context: context,
theme: 'gray',
view: !widget.loadingStatus
? widget.bangumiDetail!.stat!['views']
@@ -320,7 +321,8 @@ class _BangumiInfoState extends State<BangumiInfo>
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
statDanMu(
context: context,
theme: 'gray',
danmu: !widget.loadingStatus
? widget

View File

@@ -59,13 +59,15 @@ class IntroDetail extends StatelessWidget {
const SizedBox(height: 4),
Row(
children: [
StatView(
statView(
context: context,
theme: 'gray',
view: bangumiDetail!.stat!['views'],
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
statDanMu(
context: context,
theme: 'gray',
danmu: bangumiDetail!.stat!['danmakus'],
size: 'medium',

View File

@@ -123,20 +123,15 @@ class BangumiCardV extends StatelessWidget {
}),
),
),
BangumiContent(bangumiItem: bangumiItem)
bagumiContent(context)
],
),
),
),
);
}
}
class BangumiContent extends StatelessWidget {
const BangumiContent({super.key, required this.bangumiItem});
final dynamic bangumiItem;
@override
Widget build(BuildContext context) {
Widget bagumiContent(context) {
return Expanded(
child: Padding(
// 多列

View File

@@ -254,9 +254,7 @@ class MorePanel extends StatelessWidget {
TextButton(
onPressed: () {
Get.back();
if (onRemove != null) {
onRemove!(item.idStr);
}
onRemove?.call(item.idStr);
},
child: const Text('确定'),
),

View File

@@ -255,9 +255,7 @@ class MorePanel extends StatelessWidget {
TextButton(
onPressed: () {
Get.back();
if (onRemove != null) {
onRemove!(item.idStr);
}
onRemove?.call(item.idStr);
},
child: const Text('确定'),
),

View File

@@ -1,4 +1,3 @@
import 'package:PiliPalaX/models/user/fav_folder.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:PiliPalaX/common/constants.dart';
@@ -48,7 +47,7 @@ class FavItem extends StatelessWidget {
},
),
),
VideoContent(favFolderItem: favFolderItem)
videoContent(context)
],
),
);
@@ -57,14 +56,8 @@ class FavItem extends StatelessWidget {
),
);
}
}
class VideoContent extends StatelessWidget {
final FavFolderItemData favFolderItem;
const VideoContent({super.key, required this.favFolderItem});
@override
Widget build(BuildContext context) {
Widget videoContent(context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 2, 6, 0),

View File

@@ -116,11 +116,7 @@ class FavVideoCardH extends StatelessWidget {
},
),
),
VideoContent(
videoItem: videoItem,
callFn: callFn,
searchType: searchType,
)
videoContent(context)
],
),
);
@@ -131,21 +127,8 @@ class FavVideoCardH extends StatelessWidget {
),
);
}
}
class VideoContent extends StatelessWidget {
final dynamic videoItem;
final Function? callFn;
final int? searchType;
const VideoContent({
super.key,
required this.videoItem,
this.callFn,
this.searchType,
});
@override
Widget build(BuildContext context) {
Widget videoContent(context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 2, 6, 0),
@@ -195,13 +178,17 @@ class VideoContent extends StatelessWidget {
padding: const EdgeInsets.only(top: 2),
child: Row(
children: [
StatView(
statView(
context: context,
theme: 'gray',
view: videoItem.cntInfo['play'],
),
const SizedBox(width: 8),
StatDanMu(
theme: 'gray', danmu: videoItem.cntInfo['danmaku']),
statDanMu(
context: context,
theme: 'gray',
danmu: videoItem.cntInfo['danmaku'],
),
const Spacer(),
],
),
@@ -236,7 +223,7 @@ class VideoContent extends StatelessWidget {
)),
TextButton(
onPressed: () async {
await callFn!();
await callFn?.call();
Get.back();
},
child: const Text('确定取消'),

View File

@@ -37,7 +37,7 @@ class HistoryItem extends StatelessWidget {
onTap: () async {
if (ctr!.enableMultiple.value) {
feedBack();
onChoose!();
onChoose?.call();
return;
}
if (videoItem.history.business.contains('article')) {
@@ -158,8 +158,8 @@ class HistoryItem extends StatelessWidget {
if (!ctr!.enableMultiple.value) {
feedBack();
ctr!.enableMultiple.value = true;
onChoose!();
onUpdateMultiple!();
onChoose?.call();
onUpdateMultiple?.call();
}
},
child: Column(
@@ -264,7 +264,7 @@ class HistoryItem extends StatelessWidget {
),
onPressed: () {
feedBack();
onChoose!();
onChoose?.call();
},
icon: Icon(Icons.done_all_outlined,
color: Theme.of(context)
@@ -301,7 +301,7 @@ class HistoryItem extends StatelessWidget {
)
],
),
VideoContent(videoItem: videoItem, ctr: ctr)
videoContent(context)
],
),
);
@@ -312,15 +312,8 @@ class HistoryItem extends StatelessWidget {
),
);
}
}
class VideoContent extends StatelessWidget {
final dynamic videoItem;
final dynamic ctr;
const VideoContent({super.key, required this.videoItem, this.ctr});
@override
Widget build(BuildContext context) {
Widget videoContent(context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 2, 6, 0),

View File

@@ -448,12 +448,14 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
sliver: Obx(
() => _htmlRenderCtr.loaded.value
? _htmlRenderCtr.response['isJsonContent'] == true
? ArticleContent(
? articleContent(
context: context,
list: _htmlRenderCtr.response['content'],
)
: SliverToBoxAdapter(
child: LayoutBuilder(
builder: (_, constraints) => HtmlRender(
builder: (_, constraints) => htmlRender(
context: context,
htmlContent: _htmlRenderCtr.response['content'],
constrainedWidth: constraints.maxWidth,
),

View File

@@ -29,11 +29,7 @@ class LiveCardV extends StatelessWidget {
Get.toNamed('/liveRoom?roomid=${liveItem.roomId}',
arguments: {'liveItem': liveItem, 'heroTag': heroTag});
},
onLongPress: () {
if (longPress != null) {
longPress!();
}
},
onLongPress: longPress,
child: Column(
children: [
ClipRRect(
@@ -60,9 +56,7 @@ class LiveCardV extends StatelessWidget {
child: AnimatedOpacity(
opacity: 1,
duration: const Duration(milliseconds: 200),
child: VideoStat(
liveItem: liveItem,
),
child: videoStat(context),
),
),
],
@@ -70,19 +64,14 @@ class LiveCardV extends StatelessWidget {
}),
),
),
LiveContent(liveItem: liveItem)
liveContent(context)
],
),
),
);
}
}
class LiveContent extends StatelessWidget {
final dynamic liveItem;
const LiveContent({super.key, required this.liveItem});
@override
Widget build(BuildContext context) {
Widget liveContent(context) {
return Expanded(
flex: 1,
child: Padding(
@@ -92,7 +81,7 @@ class LiveContent extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
liveItem.title,
'${liveItem.title}',
textAlign: TextAlign.start,
style: const TextStyle(
fontWeight: FontWeight.w400,
@@ -105,7 +94,7 @@ class LiveContent extends StatelessWidget {
children: [
Expanded(
child: Text(
liveItem.uname,
'${liveItem.uname}',
textAlign: TextAlign.start,
style: TextStyle(
fontSize:
@@ -123,18 +112,8 @@ class LiveContent extends StatelessWidget {
),
);
}
}
class VideoStat extends StatelessWidget {
final LiveItemModel? liveItem;
const VideoStat({
super.key,
required this.liveItem,
});
@override
Widget build(BuildContext context) {
Widget videoStat(context) {
return Container(
height: 50,
padding: const EdgeInsets.only(top: 26, left: 10, right: 10),
@@ -153,14 +132,14 @@ class VideoStat extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
liveItem!.areaName!,
'${liveItem.areaName}',
style: const TextStyle(fontSize: 11, color: Colors.white),
semanticsLabel: "${liveItem!.areaName!}直播",
semanticsLabel: "${liveItem.areaName}直播",
),
Text(
liveItem!.watchedShow!['text_small'],
liveItem.watchedShow!['text_small'],
style: const TextStyle(fontSize: 11, color: Colors.white),
semanticsLabel: "${liveItem!.watchedShow!['text_small']}围观",
semanticsLabel: "${liveItem.watchedShow?['text_small']}围观",
),
],
),

View File

@@ -68,7 +68,8 @@ class MemberCoinsItem extends StatelessWidget {
const SizedBox(height: 4),
Row(
children: [
StatView(
statView(
context: context,
view: coinItem.view,
theme: 'gray',
),

View File

@@ -72,7 +72,8 @@ class MemberSeasonsItem extends StatelessWidget {
const SizedBox(height: 4),
Row(
children: [
StatView(
statView(
context: context,
view: seasonItem.view,
theme: 'gray',
),

View File

@@ -27,7 +27,7 @@ class HotKeyword extends StatelessWidget {
borderRadius: BorderRadius.circular(3),
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () => onClick!(i.keyword),
onTap: () => onClick?.call(i.keyword),
child: Padding(
padding: EdgeInsets.only(
left: 2,

View File

@@ -29,10 +29,10 @@ class SearchText extends StatelessWidget {
padding: EdgeInsets.zero,
child: InkWell(
onTap: () {
onSelect!(searchText);
onSelect?.call(searchText);
},
onLongPress: () {
onLongSelect!(searchText);
onLongSelect?.call(searchText);
},
borderRadius: BorderRadius.circular(6),
child: Padding(

View File

@@ -163,7 +163,7 @@ class CustomFilterChip extends StatelessWidget {
// Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
backgroundColor: Colors.transparent,
side: BorderSide.none,
onSelected: (bool selected) => callFn!(selected),
onSelected: (bool selected) => callFn?.call(selected),
),
);
}

View File

@@ -56,10 +56,7 @@ class SubItem extends StatelessWidget {
},
),
),
VideoContent(
subFolderItem: subFolderItem,
cancelSub: cancelSub,
)
videoContent(context)
],
),
);
@@ -68,15 +65,8 @@ class SubItem extends StatelessWidget {
),
);
}
}
class VideoContent extends StatelessWidget {
final SubFolderItemData subFolderItem;
final Function(SubFolderItemData)? cancelSub;
const VideoContent({super.key, required this.subFolderItem, this.cancelSub});
@override
Widget build(BuildContext context) {
Widget videoContent(context) {
// subFolderItem.type == 11播单
// subFolderItem.type == 21合集
// 其它:其它
@@ -130,7 +120,7 @@ class VideoContent extends StatelessWidget {
height: 35,
width: 35,
child: IconButton(
onPressed: () => cancelSub?.call(subFolderItem),
onPressed: () => cancelSub(subFolderItem),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.outline,
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),

View File

@@ -91,10 +91,7 @@ class SubVideoCardH extends StatelessWidget {
},
),
),
VideoContent(
videoItem: videoItem,
searchType: searchType,
)
videoContent(context)
],
),
);
@@ -105,19 +102,8 @@ class SubVideoCardH extends StatelessWidget {
),
);
}
}
class VideoContent extends StatelessWidget {
final dynamic videoItem;
final int? searchType;
const VideoContent({
super.key,
required this.videoItem,
this.searchType,
});
@override
Widget build(BuildContext context) {
Widget videoContent(context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 2, 6, 0),
@@ -127,7 +113,7 @@ class VideoContent extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
videoItem.title,
'${videoItem.title}',
textAlign: TextAlign.start,
style: const TextStyle(
fontWeight: FontWeight.w400,
@@ -147,13 +133,17 @@ class VideoContent extends StatelessWidget {
padding: const EdgeInsets.only(top: 2),
child: Row(
children: [
StatView(
statView(
context: context,
theme: 'gray',
view: videoItem.cntInfo['play'],
view: videoItem.cntInfo?['play'],
),
const SizedBox(width: 8),
StatDanMu(
theme: 'gray', danmu: videoItem.cntInfo['danmaku']),
statDanMu(
context: context,
theme: 'gray',
danmu: videoItem.cntInfo?['danmaku'],
),
const Spacer(),
],
),

View File

@@ -444,7 +444,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
onTap: showIntroDetail,
child: Row(
children: <Widget>[
StatView(
statView(
context: context,
theme: 'gray',
view: !loadingStatus
? widget.videoDetail?.stat?.view ?? '-'
@@ -452,7 +453,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
statDanMu(
context: context,
theme: 'gray',
danmu: !loadingStatus
? widget.videoDetail?.stat?.danmu ?? '-'

View File

@@ -32,13 +32,11 @@ class ActionRowItem extends StatelessWidget {
child: InkWell(
onTap: () => {
feedBack(),
onTap!(),
onTap?.call(),
},
onLongPress: () {
feedBack();
if (onLongPress != null) {
onLongPress!();
}
onLongPress?.call();
},
child: Padding(
padding: const EdgeInsets.fromLTRB(15, 7, 15, 7),

View File

@@ -56,13 +56,15 @@ class IntroDetail extends StatelessWidget {
const SizedBox(height: 6),
Row(
children: [
StatView(
statView(
context: context,
theme: 'gray',
view: videoDetail!.stat!.view,
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
statDanMu(
context: context,
theme: 'gray',
danmu: videoDetail!.stat!.danmu,
size: 'medium',

View File

@@ -61,7 +61,7 @@ class MenuRow extends StatelessWidget {
child: InkWell(
onTap: () => {
feedBack(),
onTap!(),
onTap?.call(),
},
child: Container(
padding: const EdgeInsets.fromLTRB(13, 5.5, 13, 4.5),
@@ -120,7 +120,7 @@ class ActionRowLineItem extends StatelessWidget {
child: InkWell(
onTap: () => {
feedBack(),
onTap!(),
onTap?.call(),
},
child: Container(
padding: const EdgeInsets.fromLTRB(13, 5.5, 13, 4.5),

View File

@@ -60,9 +60,7 @@ class ReplyItem extends StatelessWidget {
return MorePanel(
item: replyItem!,
onDelete: (rpid) {
if (onDelete != null) {
onDelete!(rpid, null);
}
onDelete?.call(rpid, null);
},
);
},
@@ -318,9 +316,7 @@ class ReplyItem extends StatelessWidget {
replyItem: replyItem,
replyReply: replyReply,
onDelete: (rpid) {
if (onDelete != null) {
onDelete!(rpid, replyItem!.rpid);
}
onDelete?.call(rpid, replyItem!.rpid);
},
),
),
@@ -339,10 +335,7 @@ class ReplyItem extends StatelessWidget {
child: TextButton(
onPressed: () {
feedBack();
if (onReply != null) {
onReply!();
return;
}
onReply?.call();
},
child: Row(children: [
Icon(Icons.reply,
@@ -990,8 +983,8 @@ class MorePanel extends StatelessWidget {
'https://www.bilibili.com/h5/comment/report?mid=${item.mid}&oid=${item.oid}&pageType=1&rpid=${item.rpid}&platform=android',
},
);
if (result == true && onDelete != null) {
onDelete!(item.rpid!);
if (result == true) {
onDelete?.call(item.rpid!);
}
break;
case 'copyAll':
@@ -1056,10 +1049,7 @@ class MorePanel extends StatelessWidget {
SmartDialog.dismiss();
if (result['status']) {
SmartDialog.showToast('删除成功');
// Get.back();
if (onDelete != null) {
onDelete!(item.rpid!);
}
onDelete?.call(item.rpid!);
} else {
SmartDialog.showToast('删除失败, ${result["msg"]}');
}

File diff suppressed because it is too large Load Diff

View File

@@ -292,9 +292,7 @@ class _ReplyPageState extends State<ReplyPage>
_enablePublish = false;
_publishStream.add(false);
}
if (widget.onSaveReply != null) {
widget.onSaveReply!(value);
}
widget.onSaveReply?.call(value);
},
focusNode: _focusNode,
decoration: const InputDecoration(
@@ -537,8 +535,6 @@ class _ReplyPageState extends State<ReplyPage>
selection:
TextSelection.collapsed(offset: cursorPosition + emote.text!.length),
);
if (widget.onSaveReply != null) {
widget.onSaveReply!(_replyContentController.text);
}
widget.onSaveReply?.call(_replyContentController.text);
}
}

View File

@@ -1350,20 +1350,28 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
showEpisodes(index, season, episodes, bvid, aid, cid) {
ListSheet(
index: index,
season: season,
episodes: episodes,
bvid: bvid,
aid: aid,
currentCid: cid,
changeFucCall: videoDetailController.videoType == SearchType.media_bangumi
? bangumiIntroController.changeSeasonOrbangu
: videoIntroController.changeSeasonOrbangu,
context: context,
scaffoldState: isFullScreen
? videoDetailController.scaffoldKey.currentState
: videoDetailController.childKey.currentState,
).buildShowBottomSheet();
PersistentBottomSheetController? bottomSheetController;
Widget listSheetContent() => ListSheetContent(
index: index,
season: season,
episodes: episodes,
bvid: bvid,
aid: aid,
currentCid: cid,
changeFucCall:
videoDetailController.videoType == SearchType.media_bangumi
? bangumiIntroController.changeSeasonOrbangu
: videoIntroController.changeSeasonOrbangu,
onClose: bottomSheetController?.close,
);
bottomSheetController = isFullScreen
? videoDetailController.scaffoldKey.currentState?.showBottomSheet(
(context) => listSheetContent(),
)
: videoDetailController.scaffoldKey.currentState?.showBottomSheet(
(context) => listSheetContent(),
);
}
}