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

@@ -1,8 +1,14 @@
import 'package:PiliPlus/utils/global_data.dart';
import 'package:flutter/material.dart';
class DynamicCardSkeleton extends StatelessWidget {
const DynamicCardSkeleton({super.key});
const _ = _DynamicCardSkeleton();
const dynSkeleton_ = SliverList(delegate: dynDelegate);
const dynDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _DynamicCardSkeleton extends StatelessWidget {
const _DynamicCardSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,8 +1,13 @@
import 'package:PiliPlus/common/style.dart';
import 'package:flutter/material.dart';
class FavPgcItemSkeleton extends StatelessWidget {
const FavPgcItemSkeleton({super.key});
const _ = _FavPgcItemSkeleton();
const favPgcDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _FavPgcItemSkeleton extends StatelessWidget {
const _FavPgcItemSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,6 +1,11 @@
import 'package:PiliPlus/common/style.dart';
import 'package:flutter/material.dart';
const _ = MediaPgcSkeleton();
const pgcDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class MediaPgcSkeleton extends StatefulWidget {
const MediaPgcSkeleton({super.key});

View File

@@ -1,7 +1,14 @@
import 'package:flutter/material.dart';
class MsgFeedSysMsgSkeleton extends StatelessWidget {
const MsgFeedSysMsgSkeleton({super.key});
const _ = _MsgFeedSysMsgSkeleton();
const sysMsgSkeleton = SliverList(
delegate: SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
),
);
class _MsgFeedSysMsgSkeleton extends StatelessWidget {
const _MsgFeedSysMsgSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,7 +1,13 @@
import 'package:flutter/material.dart';
class MsgFeedTopSkeleton extends StatelessWidget {
const MsgFeedTopSkeleton({super.key});
const _ = _MsgFeedTopSkeleton();
const sysFeedSkeleton = SliverList(delegate: sysFeedDelegate);
const sysFeedDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _MsgFeedTopSkeleton extends StatelessWidget {
const _MsgFeedTopSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,8 +1,13 @@
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
class SpaceOpusSkeleton extends StatelessWidget {
const SpaceOpusSkeleton({super.key});
const _ = _SpaceOpusSkeleton();
const opusDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _SpaceOpusSkeleton extends StatelessWidget {
const _SpaceOpusSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,8 +1,13 @@
import 'package:PiliPlus/common/style.dart';
import 'package:flutter/material.dart';
class VideoCardHSkeleton extends StatelessWidget {
const VideoCardHSkeleton({super.key});
const _ = _VideoCardHSkeleton();
const videoHDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _VideoCardHSkeleton extends StatelessWidget {
const _VideoCardHSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,8 +1,13 @@
import 'package:PiliPlus/common/style.dart';
import 'package:flutter/material.dart';
class VideoCardVSkeleton extends StatelessWidget {
const VideoCardVSkeleton({super.key});
const _ = _VideoCardVSkeleton();
const videoVDelegate = SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
);
class _VideoCardVSkeleton extends StatelessWidget {
const _VideoCardVSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,7 +1,12 @@
import 'package:flutter/material.dart';
class VideoReplySkeleton extends StatelessWidget {
const VideoReplySkeleton({super.key});
const _ = _VideoReplySkeleton();
const replySkeleton = SliverList(
delegate: SliverChildListDelegate.fixed([_, _, _, _, _]),
);
class _VideoReplySkeleton extends StatelessWidget {
const _VideoReplySkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -1,7 +1,14 @@
import 'package:flutter/material.dart';
class WhisperItemSkeleton extends StatelessWidget {
const WhisperItemSkeleton({super.key});
const _ = _WhisperItemSkeleton();
const whisperSkeleton = SliverList(
delegate: SliverChildListDelegate.fixed(
[_, _, _, _, _, _, _, _, _, _],
),
);
class _WhisperItemSkeleton extends StatelessWidget {
const _WhisperItemSkeleton();
@override
Widget build(BuildContext context) {

View File

@@ -551,7 +551,7 @@ class RefreshIndicatorState extends State<RefreshIndicator>
return ScrollConfiguration(
behavior: RefreshScrollBehavior(
scrollPhysics: RefreshScrollPhysics(
parent: const RangeMaintainingScrollPhysics(),
// parent: const RangeMaintainingScrollPhysics(),
onDrag: _onDrag,
),
),

View File

@@ -3,6 +3,10 @@ import 'dart:io' show Platform;
import 'package:flutter/gestures.dart' show PointerDeviceKind;
import 'package:flutter/material.dart';
const _clampingPhysics = ClampingScrollPhysics();
const _bouncingPhysics = BouncingScrollPhysics();
const _bouncingDesktopPhysics = BouncingScrollPhysics(decelerationRate: .fast);
class CustomScrollBehavior extends MaterialScrollBehavior {
const CustomScrollBehavior();
@@ -29,6 +33,17 @@ class CustomScrollBehavior extends MaterialScrollBehavior {
return child;
}
@override
ScrollPhysics getScrollPhysics(BuildContext context) {
if (Platform.isIOS) {
return _bouncingPhysics;
}
if (Platform.isMacOS) {
return _bouncingDesktopPhysics;
}
return _clampingPhysics;
}
@override
Set<PointerDeviceKind> get dragDevices => desktopDragDevices;
}