opt: pages

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-24 16:36:26 +08:00
parent 4d7d9abc60
commit c28729af5b
27 changed files with 266 additions and 310 deletions

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
class StyleString {
static const double cardSpace = 8;
static const double safeSpace = 12;
static BorderRadius mdRadius = BorderRadius.circular(10);
static const BorderRadius mdRadius = BorderRadius.all(Radius.circular(10));
static const Radius imgRadius = Radius.circular(10);
static const double aspectRatio = 16 / 10;
}

View File

@@ -99,7 +99,7 @@ class ShimmerState extends State<Shimmer> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return widget.child ?? const SizedBox();
return widget.child ?? const SizedBox.shrink();
}
}
@@ -165,7 +165,7 @@ class _ShimmerLoadingState extends State<ShimmerLoading> {
final shimmer = Shimmer.of(context)!;
if (!shimmer.isSized) {
return const SizedBox();
return const SizedBox.shrink();
}
final shimmerSize = shimmer.size;
final gradient = shimmer.gradient;

View File

@@ -37,11 +37,12 @@ class HttpError extends StatelessWidget {
),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5),
child: SelectableText(
errMsg ?? '没有数据',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleSmall,
scrollPhysics: const NeverScrollableScrollPhysics(),
),
),
if (onReload != null)

View File

@@ -97,7 +97,7 @@ class NetworkImgLayer extends StatelessWidget {
),
),
child: type == 'bg'
? const SizedBox()
? const SizedBox.shrink()
: Center(
child: Image.asset(
type == 'avatar'

View File

@@ -38,7 +38,7 @@ class _SelfSizedHorizontalListState extends State<SelfSizedHorizontalList> {
if (height == null) {
WidgetsBinding.instance.addPostFrameCallback((v) => setState(() {}));
}
if (widget.itemCount == 0) return const SizedBox();
if (widget.itemCount == 0) return const SizedBox.shrink();
if (isInit) {
return Container(
key: infoKey,

View File

@@ -780,69 +780,65 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
Widget replyList(LoadingState<List<ReplyInfo>?> loadingState) {
return switch (loadingState) {
Loading() => SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
Loading() => SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
itemCount: 8,
),
Success() => loadingState.response?.isNotEmpty == true
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response!.length) {
_dynamicDetailController.onLoadMore();
return Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
height: 125,
child: Text(
_dynamicDetailController.isEnd.not
? '加载中...'
: loadingState.response!.isEmpty
? '没有评论'
: '没有更多了',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
? SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length) {
_dynamicDetailController.onLoadMore();
return Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
height: 125,
child: Text(
_dynamicDetailController.isEnd.not
? '加载中...'
: loadingState.response!.isEmpty
? '还没有评论'
: '没有更多了',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response![index],
replyLevel: '1',
replyReply: (replyItem, id) =>
replyReply(context, replyItem, id),
onReply: () {
_dynamicDetailController.onReply(
context,
replyItem: loadingState.response![index],
index: index,
);
},
onDelete: (subIndex) =>
_dynamicDetailController.onRemove(index, subIndex),
upMid: _dynamicDetailController.upMid,
callback: _getImageCallback,
onCheckReply: (item) =>
_dynamicDetailController.onCheckReply(context, item),
onToggleTop: (isUpTop, rpid) =>
_dynamicDetailController.onToggleTop(
index,
_dynamicDetailController.oid,
_dynamicDetailController.type,
isUpTop,
rpid,
),
);
}
},
childCount: loadingState.response!.length + 1,
),
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response![index],
replyLevel: '1',
replyReply: (replyItem, id) =>
replyReply(context, replyItem, id),
onReply: () {
_dynamicDetailController.onReply(
context,
replyItem: loadingState.response![index],
index: index,
);
},
onDelete: (subIndex) =>
_dynamicDetailController.onRemove(index, subIndex),
upMid: _dynamicDetailController.upMid,
callback: _getImageCallback,
onCheckReply: (item) =>
_dynamicDetailController.onCheckReply(context, item),
onToggleTop: (isUpTop, rpid) =>
_dynamicDetailController.onToggleTop(
index,
_dynamicDetailController.oid,
_dynamicDetailController.type,
isUpTop,
rpid,
),
);
}
},
itemCount: loadingState.response!.length + 1,
)
: HttpError(
onReload: _dynamicDetailController.onReload,

View File

@@ -103,13 +103,11 @@ class _DynamicsTabPageState
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -177,28 +175,25 @@ class _DynamicsTabPageState
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
loadingState.response!.length - 1) {
controller.onLoadMore();
}
final item = loadingState.response![index];
if ((dynamicsController.tabController.index ==
4 &&
dynamicsController.mid.value != -1) ||
!dynamicsController.tempBannedList.contains(
item.modules?.moduleAuthor?.mid)) {
return DynamicPanel(
item: item,
onRemove: controller.onRemove,
);
}
return const SizedBox.shrink();
},
childCount: loadingState.response!.length,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
controller.onLoadMore();
}
final item = loadingState.response![index];
if ((dynamicsController.tabController.index ==
4 &&
dynamicsController.mid.value != -1) ||
!dynamicsController.tempBannedList.contains(
item.modules?.moduleAuthor?.mid)) {
return DynamicPanel(
item: item,
onRemove: controller.onRemove,
);
}
return const SizedBox.shrink();
},
itemCount: loadingState.response!.length,
),
),
const SliverFillRemaining(),

View File

@@ -134,17 +134,17 @@ Widget addWidget(item, context, type, {floor = 1}) {
),
),
)
: const SizedBox()
: const SizedBox();
: const SizedBox.shrink()
: const SizedBox.shrink();
case 'ADDITIONAL_TYPE_GOODS':
// 商品
return const SizedBox();
return const SizedBox.shrink();
case 'ADDITIONAL_TYPE_MATCH':
return const SizedBox();
return const SizedBox.shrink();
case 'ADDITIONAL_TYPE_COMMON':
return const SizedBox();
return const SizedBox.shrink();
case 'ADDITIONAL_TYPE_VOTE':
return const SizedBox();
return const SizedBox.shrink();
default:
return const Text('11');
}

View File

@@ -6,7 +6,7 @@ Widget picWidget(item, context, callback) {
item.modules.moduleDynamic.major.type == 'MAJOR_TYPE_OPUS') {
/// fix 图片跟rich_node_panel重复
// pictures = item.modules.moduleDynamic.major.opus.pics;
return const SizedBox();
return const SizedBox.shrink();
}
return LayoutBuilder(
builder: (context, constraints) => imageView(

View File

@@ -70,36 +70,37 @@ class _UpPanelState extends State<UpPanel> {
),
),
const SliverToBoxAdapter(child: SizedBox(height: 10)),
SliverList(
delegate: SliverChildListDelegate(
[
if (widget.dynamicsController.showLiveItems &&
liveList.isNotEmpty) ...[
for (int i = 0; i < liveList.length; i++) ...[
upItemBuild(liveList[i], i)
],
],
upItemBuild(UpItem(face: '', uname: '全部动态', mid: -1), 0),
upItemBuild(
UpItem(
uname: '',
face: widget.dynamicsController.face,
mid: widget.dynamicsController.ownerMid,
),
1,
),
for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i + 2)
],
],
if (widget.dynamicsController.showLiveItems && liveList.isNotEmpty)
SliverList.builder(
itemCount: liveList.length,
itemBuilder: (context, index) {
return upItemBuild(liveList[index]);
},
),
SliverToBoxAdapter(
child: upItemBuild(UpItem(face: '', uname: '全部动态', mid: -1)),
),
SliverToBoxAdapter(
child: upItemBuild(
UpItem(
uname: '',
face: widget.dynamicsController.face,
mid: widget.dynamicsController.ownerMid,
),
),
),
SliverList.builder(
itemCount: upList.length,
itemBuilder: (context, index) {
return upItemBuild(upList[index]);
},
),
const SliverToBoxAdapter(child: SizedBox(height: 200)),
],
);
}
Widget upItemBuild(data, i) {
Widget upItemBuild(data) {
bool isCurrent = widget.dynamicsController.currentMid == data.mid ||
widget.dynamicsController.currentMid == -1;
return SizedBox(

View File

@@ -112,7 +112,7 @@ class _FavFolderSortPageState extends State<FavFolderSortPage> {
}
Widget get _buildBody {
return ReorderableListView(
return ReorderableListView.builder(
key: _key,
scrollController: _scrollController,
onReorder: onReorder,
@@ -120,26 +120,24 @@ class _FavFolderSortPageState extends State<FavFolderSortPage> {
footer: SizedBox(
height: MediaQuery.of(context).padding.bottom + 80,
),
children: List.generate(
sortList.length,
(index) {
final item = sortList[index];
final key = item.id.toString();
return SizedBox(
key: Key(key),
height: 98,
child: FavItem(
heroTag: key,
favFolderItem: item,
onLongPress: index == 0
? () {
SmartDialog.showToast('默认收藏夹不支持排序');
}
: null,
),
);
},
),
itemCount: sortList.length,
itemBuilder: (context, index) {
final item = sortList[index];
final key = item.id.toString();
return SizedBox(
key: Key(key),
height: 98,
child: FavItem(
heroTag: key,
favFolderItem: item,
onLongPress: index == 0
? () {
SmartDialog.showToast('默认收藏夹不支持排序');
}
: null,
),
);
},
);
}
}

View File

@@ -119,7 +119,7 @@ class _FavSortPageState extends State<FavSortPage> {
}
Widget get _buildBody {
return ReorderableListView(
return ReorderableListView.builder(
key: _key,
scrollController: _scrollController,
onReorder: onReorder,
@@ -127,18 +127,18 @@ class _FavSortPageState extends State<FavSortPage> {
footer: SizedBox(
height: MediaQuery.of(context).padding.bottom + 80,
),
children: sortList
.map(
(item) => SizedBox(
key: Key(item.id.toString()),
height: 98,
child: FavVideoCardH(
isSort: true,
videoItem: item,
),
),
)
.toList(),
itemCount: sortList.length,
itemBuilder: (context, index) {
final item = sortList[index];
return SizedBox(
key: Key(item.id.toString()),
height: 98,
child: FavVideoCardH(
isSort: true,
videoItem: item,
),
);
},
);
}
}

View File

@@ -84,7 +84,7 @@ class _LaterPageState extends State<LaterPage>
label: const Text('播放全部'),
icon: const Icon(Icons.playlist_play),
)
: const SizedBox(),
: const SizedBox.shrink(),
),
body: SafeArea(
top: false,

View File

@@ -370,7 +370,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
future: _futureBuilder,
builder: (context, snapshot) {
if (snapshot.data == null) {
return const SizedBox();
return const SizedBox.shrink();
}
Map data = snapshot.data as Map;
if (data['status']) {
@@ -449,7 +449,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
),
);
} else {
return const SizedBox();
return const SizedBox.shrink();
}
},
),

View File

@@ -75,13 +75,11 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -137,21 +135,18 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
loadingState.response!.length - 1) {
_memberDynamicController.onLoadMore();
}
return DynamicPanel(
item: loadingState.response![index],
onRemove: _memberDynamicController.onRemove,
onSetTop: _memberDynamicController.onSetTop,
);
},
childCount: loadingState.response!.length,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
_memberDynamicController.onLoadMore();
}
return DynamicPanel(
item: loadingState.response![index],
onRemove: _memberDynamicController.onRemove,
onSetTop: _memberDynamicController.onSetTop,
);
},
itemCount: loadingState.response!.length,
),
),
const SliverFillRemaining(),

View File

@@ -59,13 +59,11 @@ class _SearchDynamicState extends State<SearchDynamic>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -120,21 +118,19 @@ class _SearchDynamicState extends State<SearchDynamic>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response!.length - 1) {
EasyThrottle.throttle('member_dynamics',
const Duration(milliseconds: 1000), () {
widget.ctr.searchDynamic(false);
});
}
return DynamicPanel(
item: loadingState.response![index],
);
},
childCount: loadingState.response!.length,
),
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
EasyThrottle.throttle('member_dynamics',
const Duration(milliseconds: 1000), () {
widget.ctr.searchDynamic(false);
});
}
return DynamicPanel(
item: loadingState.response![index],
);
},
itemCount: loadingState.response!.length,
),
),
const SliverFillRemaining(),

View File

@@ -71,7 +71,6 @@ class _NavigationbarSetPageState extends State<NavigationBarSetPage> {
),
body: ReorderableListView(
onReorder: onReorder,
physics: const NeverScrollableScrollPhysics(),
footer: SizedBox(
height: MediaQuery.of(context).padding.bottom + 30,
),

View File

@@ -83,7 +83,6 @@ class _TabbarSetPageState extends State<TabbarSetPage> {
),
body: ReorderableListView(
onReorder: onReorder,
physics: const NeverScrollableScrollPhysics(),
footer: SizedBox(
height: MediaQuery.of(context).padding.bottom + 30,
child: const Align(

View File

@@ -86,7 +86,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
@override
Widget build(BuildContext context) {
if (episodes.isEmpty) {
return const SizedBox();
return const SizedBox.shrink();
}
return Builder(builder: (BuildContext context) {
return Container(

View File

@@ -135,13 +135,11 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
Loading() => CustomScrollView(
physics: const NeverScrollableScrollPhysics(),
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
itemCount: 8,
)
],
),

View File

@@ -196,71 +196,67 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
Widget _buildBody(LoadingState loadingState) {
return switch (loadingState) {
Loading() => SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
return const VideoReplySkeleton();
},
childCount: 5,
),
Loading() => SliverList.builder(
itemBuilder: (BuildContext context, index) {
return const VideoReplySkeleton();
},
itemCount: 5,
),
Success() => loadingState.response?.isNotEmpty == true
? SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
double bottom = MediaQuery.of(context).padding.bottom;
if (index == loadingState.response.length) {
_videoReplyController.onLoadMore();
return Container(
alignment: Alignment.center,
padding: EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Text(
_videoReplyController.isEnd.not
? '加载中...'
: loadingState.response.isEmpty
? '没有评论'
: '没有更多了',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
? SliverList.builder(
itemBuilder: (context, index) {
double bottom = MediaQuery.of(context).padding.bottom;
if (index == loadingState.response.length) {
_videoReplyController.onLoadMore();
return Container(
alignment: Alignment.center,
padding: EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Text(
_videoReplyController.isEnd.not
? '加载中...'
: loadingState.response.isEmpty
? '还没有评论'
: '没有更多了',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response[index],
replyLevel: widget.replyLevel,
replyReply: widget.replyReply,
onReply: () {
_videoReplyController.onReply(
context,
replyItem: loadingState.response[index],
index: index,
);
},
onDelete: (subIndex) =>
_videoReplyController.onRemove(index, subIndex),
upMid: _videoReplyController.upMid,
getTag: () => heroTag,
onViewImage: widget.onViewImage,
onDismissed: widget.onDismissed,
callback: widget.callback,
onCheckReply: (item) =>
_videoReplyController.onCheckReply(context, item),
onToggleTop: (isUpTop, rpid) =>
_videoReplyController.onToggleTop(
index,
_videoReplyController.aid,
ReplyType.video.index,
isUpTop,
rpid,
),
);
}
},
childCount: loadingState.response.length + 1,
),
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response[index],
replyLevel: widget.replyLevel,
replyReply: widget.replyReply,
onReply: () {
_videoReplyController.onReply(
context,
replyItem: loadingState.response[index],
index: index,
);
},
onDelete: (subIndex) =>
_videoReplyController.onRemove(index, subIndex),
upMid: _videoReplyController.upMid,
getTag: () => heroTag,
onViewImage: widget.onViewImage,
onDismissed: widget.onDismissed,
callback: widget.callback,
onCheckReply: (item) =>
_videoReplyController.onCheckReply(context, item),
onToggleTop: (isUpTop, rpid) =>
_videoReplyController.onToggleTop(
index,
_videoReplyController.aid,
ReplyType.video.index,
isUpTop,
rpid,
),
);
}
},
itemCount: loadingState.response.length + 1,
)
: HttpError(
errMsg: '还没有评论',

View File

@@ -391,13 +391,11 @@ class _VideoReplyReplyPanelState
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
itemCount: 8,
)
],
),

View File

@@ -1226,7 +1226,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
Widget get childWhenEnabled => Obx(
() => !videoDetailController.autoPlay.value
? const SizedBox()
? const SizedBox.shrink()
: PLVideoPlayer(
key: Key(heroTag),
plPlayerController: plPlayerController!,

View File

@@ -782,7 +782,7 @@ class HeaderControlState extends State<HeaderControl> {
Icons.done,
color: Theme.of(context).colorScheme.primary,
)
: const SizedBox(),
: const SizedBox.shrink(),
),
]
],
@@ -858,7 +858,7 @@ class HeaderControlState extends State<HeaderControl> {
Icons.done,
color: Theme.of(context).colorScheme.primary,
)
: const SizedBox(),
: const SizedBox.shrink(),
),
]
],
@@ -1832,7 +1832,7 @@ class HeaderControlState extends State<HeaderControl> {
Icons.done,
color: Theme.of(context).colorScheme.primary,
)
: const SizedBox(),
: const SizedBox.shrink(),
)
],
],
@@ -2014,7 +2014,7 @@ class HeaderControlState extends State<HeaderControl> {
}
clock?.cancel();
clock = null;
return SizedBox.shrink();
return const SizedBox.shrink();
},
),
if (videoDetailCtr.enableSponsorBlock == true)

View File

@@ -130,7 +130,9 @@ class _WhisperDetailPageState
reverse: true,
itemCount: loadingState.response!.length,
padding: const EdgeInsets.only(bottom: 12),
physics: const AlwaysScrollableScrollPhysics(),
physics: const AlwaysScrollableScrollPhysics(
parent: ClampingScrollPhysics(),
),
controller: _whisperDetailController.scrollController,
itemBuilder: (context, int index) {
if (index == loadingState.response!.length - 1) {

View File

@@ -458,7 +458,7 @@ class ChatItem extends StatelessWidget {
return isSystem
? messageContent(context)
: isRevoke
? const SizedBox()
? const SizedBox.shrink()
: GestureDetector(
onLongPress: () {
Feedback.forLongPress(context);

View File

@@ -1270,24 +1270,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
),
// Obx(() {
// if (_.buffered.value == Duration.zero) {
// return Positioned.fill(
// child: Container(
// color: Colors.black,
// child: Center(
// child: Image.asset(
// 'assets/images/loading.gif',
// height: 25,
// ),
// ),
// ),
// );
// } else {
// return Container();
// }
// }),
// 头部、底部控制条
Obx(
() => Positioned.fill(