opt scroll physics

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-20 13:31:28 +08:00
parent 452b54d124
commit 480bdffdaa
59 changed files with 210 additions and 195 deletions

View File

@@ -173,9 +173,8 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
LoadingState<List<SpaceArchiveItem>?> loadingState,
) {
return switch (loadingState) {
Loading() => SliverFixedExtentList.builder(
itemCount: 10,
itemBuilder: (_, _) => const VideoCardHSkeleton(),
Loading() => const SliverFixedExtentList(
delegate: videoHDelegate,
itemExtent: 112,
),
Success(:final response) =>

View File

@@ -187,11 +187,7 @@ class _NoteListPageState extends State<NoteListPage>
color: theme.colorScheme.outline.withValues(alpha: 0.1),
);
return switch (loadingState) {
Loading() => SliverPrototypeExtentList.builder(
prototypeItem: const VideoReplySkeleton(),
itemBuilder: (_, _) => const VideoReplySkeleton(),
itemCount: 8,
),
Loading() => replySkeleton,
Success(:final response) =>
response != null && response.isNotEmpty
? SliverList.separated(

View File

@@ -3,11 +3,14 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
import 'package:PiliPlus/grpc/reply.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/video/video_type.dart';
import 'package:PiliPlus/pages/common/common_controller.dart'
show CommonReloadMixin;
import 'package:PiliPlus/pages/common/reply_controller.dart';
import 'package:PiliPlus/pages/video/controller.dart';
import 'package:get/get.dart';
class VideoReplyController extends ReplyController<MainListReply> {
class VideoReplyController extends ReplyController<MainListReply>
with CommonReloadMixin {
VideoReplyController({
required this.aid,
required this.videoType,

View File

@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/skeleton/video_reply.dart';
import 'package:PiliPlus/common/style.dart';
import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/common/widgets/sliver/sliver_floating_header.dart';
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
show ReplyInfo;
@@ -86,7 +87,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
controller: widget.isNested
? null
: _videoReplyController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
physics: ReloadScrollPhysics(controller: _videoReplyController),
key: const PageStorageKey(_VideoReplyPanelState),
slivers: [
SliverFloatingHeaderWidget(
@@ -173,10 +174,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
LoadingState<List<ReplyInfo>?> loadingState,
) {
return switch (loadingState) {
Loading() => SliverList.builder(
itemBuilder: (context, index) => const VideoReplySkeleton(),
itemCount: 5,
),
Loading() => replySkeleton,
Success(:final response) =>
response != null && response.isNotEmpty
? SliverList.builder(

View File

@@ -2,6 +2,8 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
show ReplyInfo, DetailListReply, Mode;
import 'package:PiliPlus/grpc/reply.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/common/common_controller.dart'
show CommonReloadMixin;
import 'package:PiliPlus/pages/common/publish/publish_route.dart';
import 'package:PiliPlus/pages/common/reply_controller.dart';
import 'package:PiliPlus/pages/video/reply_new/view.dart';
@@ -14,7 +16,7 @@ import 'package:get/get.dart';
import 'package:super_sliver_list/super_sliver_list.dart';
class VideoReplyReplyController extends ReplyController
with GetSingleTickerProviderStateMixin {
with GetSingleTickerProviderStateMixin, CommonReloadMixin {
VideoReplyReplyController({
required this.hasRoot,
required this.id,

View File

@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/colored_box_transition.dart';
import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
import 'package:PiliPlus/common/widgets/scaffold.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
@@ -189,7 +190,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
child: CustomScrollView(
key: ValueKey(scrollController.hashCode),
controller: scrollController,
physics: const AlwaysScrollableScrollPhysics(),
physics: ReloadScrollPhysics(controller: _controller),
slivers: [
if (!isDialogue) ...[
if ((widget.firstFloor ?? _controller.firstFloor.value)
@@ -284,11 +285,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
) {
final jumpIndex = _controller.index.value;
return switch (loadingState) {
Loading() => SliverPrototypeExtentList.builder(
prototypeItem: const VideoReplySkeleton(),
itemBuilder: (_, _) => const VideoReplySkeleton(),
itemCount: 8,
),
Loading() => replySkeleton,
Success(:final response!) => SuperSliverList.builder(
listController: _controller.listController,
itemBuilder: (context, index) {

View File

@@ -1046,6 +1046,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
return false;
},
onSkipSegment: videoDetailController.onSkipSegment,
onDownload: videoDetailController.isFileSource
? null
: () => videoDetailController.onDownload(context),
child: child,
);
}

View File

@@ -24,6 +24,7 @@ class PlayerFocus extends StatelessWidget {
this.canPlay,
this.onSkipSegment,
this.onRefresh,
this.onDownload,
});
final Widget child;
@@ -33,6 +34,7 @@ class PlayerFocus extends StatelessWidget {
final ValueGetter<bool>? canPlay;
final ValueGetter<bool>? onSkipSegment;
final VoidCallback? onRefresh;
final VoidCallback? onDownload;
static bool _shouldHandle(LogicalKeyboardKey logicalKey) {
return logicalKey == LogicalKeyboardKey.tab ||
@@ -224,6 +226,10 @@ class PlayerFocus extends StatelessWidget {
}
return true;
case LogicalKeyboardKey.keyX:
onDownload?.call();
return true;
case LogicalKeyboardKey.enter:
if (onSkipSegment?.call() ?? false) {
return true;