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,18 +780,15 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
Widget replyList(LoadingState<List<ReplyInfo>?> loadingState) {
return switch (loadingState) {
Loading() => SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
Loading() => SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
itemCount: 8,
),
Success() => loadingState.response?.isNotEmpty == true
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
? SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length) {
_dynamicDetailController.onLoadMore();
return Container(
@@ -841,8 +838,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
);
}
},
childCount: loadingState.response!.length + 1,
),
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) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -177,11 +175,9 @@ class _DynamicsTabPageState
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
loadingState.response!.length - 1) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
controller.onLoadMore();
}
final item = loadingState.response![index];
@@ -197,8 +193,7 @@ class _DynamicsTabPageState
}
return const SizedBox.shrink();
},
childCount: loadingState.response!.length,
),
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(
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,
),
1,
),
for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i + 2)
],
],
),
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,9 +120,8 @@ class _FavFolderSortPageState extends State<FavFolderSortPage> {
footer: SizedBox(
height: MediaQuery.of(context).padding.bottom + 80,
),
children: List.generate(
sortList.length,
(index) {
itemCount: sortList.length,
itemBuilder: (context, index) {
final item = sortList[index];
final key = item.id.toString();
return SizedBox(
@@ -139,7 +138,6 @@ class _FavFolderSortPageState extends State<FavFolderSortPage> {
),
);
},
),
);
}
}

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(
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,
),
),
)
.toList(),
);
},
);
}
}

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) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -137,11 +135,9 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
loadingState.response!.length - 1) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
_memberDynamicController.onLoadMore();
}
return DynamicPanel(
@@ -150,8 +146,7 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
onSetTop: _memberDynamicController.onSetTop,
);
},
childCount: loadingState.response!.length,
),
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) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
return const DynamicCardSkeleton();
},
childCount: 10,
),
itemCount: 10,
),
),
const SliverFillRemaining()
@@ -120,9 +118,8 @@ class _SearchDynamicState extends State<SearchDynamic>
const SliverFillRemaining(),
SliverConstrainedCrossAxis(
maxExtent: Grid.smallCardWidth * 2,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
sliver: SliverList.builder(
itemBuilder: (context, index) {
if (index == loadingState.response!.length - 1) {
EasyThrottle.throttle('member_dynamics',
const Duration(milliseconds: 1000), () {
@@ -133,8 +130,7 @@ class _SearchDynamicState extends State<SearchDynamic>
item: loadingState.response![index],
);
},
childCount: loadingState.response!.length,
),
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) {
SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
itemCount: 8,
)
],
),

View File

@@ -196,18 +196,15 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
Widget _buildBody(LoadingState loadingState) {
return switch (loadingState) {
Loading() => SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
Loading() => SliverList.builder(
itemBuilder: (BuildContext context, index) {
return const VideoReplySkeleton();
},
childCount: 5,
),
itemCount: 5,
),
Success() => loadingState.response?.isNotEmpty == true
? SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
? SliverList.builder(
itemBuilder: (context, index) {
double bottom = MediaQuery.of(context).padding.bottom;
if (index == loadingState.response.length) {
_videoReplyController.onLoadMore();
@@ -259,8 +256,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
);
}
},
childCount: loadingState.response.length + 1,
),
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) {
SliverList.builder(
itemBuilder: (context, index) {
return const VideoReplySkeleton();
},
childCount: 8,
),
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(