Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-02-25 18:02:36 +08:00
parent e707764f84
commit 2bdab71138
14 changed files with 81 additions and 64 deletions

View File

@@ -9,7 +9,7 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/gesture/image_horizontal_drag_gesture_recognizer.dart';
import 'package:PiliPlus/common/widgets/image_viewer/viewer.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/gestures.dart' show DoubleTapGestureRecognizer;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/semantics.dart';

View File

@@ -431,7 +431,7 @@ class _ViewerState extends State<Viewer> with SingleTickerProviderStateMixin {
if (initialPosition == null) {
return true;
}
if (_scale <= 1.0) {
if (_scale <= widget.minScale) {
return true;
}
final containerWidth = widget.containerSize.width;
@@ -442,9 +442,9 @@ class _ViewerState extends State<Viewer> with SingleTickerProviderStateMixin {
final dx = (1 - _scale) * containerWidth / 2;
final dxOffset = (imageWidth - containerWidth) / 2;
if (initialPosition.dx < lastPosition.global.dx) {
return _position.dx.equals(dx + dxOffset);
return _position.dx.equals(dx + dxOffset, 1e-6);
} else {
return _position.dx.equals(dx - dxOffset);
return _position.dx.equals(dx - dxOffset, 1e-6);
}
}

View File

@@ -3,22 +3,12 @@ import 'package:PiliPlus/common/widgets/gesture/horizontal_drag_gesture_recogniz
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:flutter/material.dart' hide TabBarView;
Widget videoTabBarView({
required List<Widget> children,
TabController? controller,
}) => TabBarView<CustomHorizontalDragGestureRecognizer>(
controller: controller,
physics: const CustomTabBarViewScrollPhysics(parent: ClampingScrollPhysics()),
horizontalDragGestureRecognizer: CustomHorizontalDragGestureRecognizer.new,
children: children,
);
Widget tabBarView({
required List<Widget> children,
TabController? controller,
}) => TabBarView<CustomHorizontalDragGestureRecognizer>(
physics: const CustomTabBarViewScrollPhysics(),
controller: controller,
physics: clampingScrollPhysics,
horizontalDragGestureRecognizer: CustomHorizontalDragGestureRecognizer.new,
children: children,
);
@@ -32,6 +22,10 @@ SpringDescription _customSpringDescription() {
);
}
const clampingScrollPhysics = CustomTabBarViewScrollPhysics(
parent: ClampingScrollPhysics(),
);
class CustomTabBarViewScrollPhysics extends ScrollPhysics {
const CustomTabBarViewScrollPhysics({super.parent});

View File

@@ -257,9 +257,7 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
width: maxWidth,
margin: const EdgeInsets.only(bottom: 10),
child: PageView.builder(
physics: const CustomTabBarViewScrollPhysics(
parent: ClampingScrollPhysics(),
),
physics: clampingScrollPhysics,
onPageChanged: (value) =>
controller.topIndex.value = value,
itemCount: length,

View File

@@ -127,7 +127,7 @@ class _DynamicsPageState extends CommonPageState<DynamicsPage>
Widget? leading;
List<Widget>? actions;
Widget child = videoTabBarView(
Widget child = tabBarView(
controller: _dynamicsController.tabController,
children: DynamicsTabType.values
.map((e) => DynamicsTabPage(dynamicsType: e))

View File

@@ -7,6 +7,7 @@ import 'package:PiliPlus/common/widgets/flutter/page/tabs.dart';
import 'package:PiliPlus/common/widgets/image/image_save.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/keep_alive_wrapper.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/common/widgets/stat/stat.dart';
import 'package:PiliPlus/http/fav.dart';
import 'package:PiliPlus/http/loading_state.dart';
@@ -235,6 +236,7 @@ class _EpisodePanelState extends State<EpisodePanel>
if (_isMulti) {
return TabBarView<TabBarDragGestureRecognizer>(
controller: _tabController,
physics: clampingScrollPhysics,
horizontalDragGestureRecognizer: () =>
TabBarDragGestureRecognizer(isDxAllowed: isDxAllowed),
children: List.generate(

View File

@@ -136,7 +136,7 @@ class _HistoryPageState extends State<HistoryPage>
child: TabBarView<CustomHorizontalDragGestureRecognizer>(
physics: enableMultiSelect
? const NeverScrollableScrollPhysics()
: const CustomTabBarViewScrollPhysics(),
: clampingScrollPhysics,
controller: _historyController.tabController,
horizontalDragGestureRecognizer:
CustomHorizontalDragGestureRecognizer.new,

View File

@@ -132,7 +132,7 @@ class _LaterPageState extends State<LaterPage>
child: TabBarView<CustomHorizontalDragGestureRecognizer>(
physics: enableMultiSelect
? const NeverScrollableScrollPhysics()
: const CustomTabBarViewScrollPhysics(),
: clampingScrollPhysics,
controller: _tabController,
horizontalDragGestureRecognizer:
CustomHorizontalDragGestureRecognizer.new,

View File

@@ -727,9 +727,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
? PageView<CustomHorizontalDragGestureRecognizer>(
key: pageKey,
controller: _liveRoomController.pageController,
physics: const CustomTabBarViewScrollPhysics(
parent: ClampingScrollPhysics(),
),
physics: clampingScrollPhysics,
onPageChanged: (value) =>
_liveRoomController.pageIndex.value = value,
horizontalDragGestureRecognizer:

View File

@@ -96,7 +96,7 @@ class _IntroDetailState extends State<PgcIntroPanel>
Widget buildList(ThemeData theme) {
return TabBarView<TabBarDragGestureRecognizer>(
controller: _tabController,
physics: const CustomTabBarViewScrollPhysics(),
physics: clampingScrollPhysics,
horizontalDragGestureRecognizer: () =>
TabBarDragGestureRecognizer(isDxAllowed: isDxAllowed),
children: [

View File

@@ -335,9 +335,7 @@ class _PayCoinsPageState extends State<PayCoinsPage>
height: 100,
child: PageView(
key: const PageStorageKey(_PayCoinsPageState),
physics: const CustomTabBarViewScrollPhysics(
parent: ClampingScrollPhysics(),
),
physics: clampingScrollPhysics,
controller: _controller,
onPageChanged: (index) {
_scale();

View File

@@ -863,7 +863,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
children: [
buildTabBar(onTap: videoDetailController.animToTop),
Expanded(
child: videoTabBarView(
child: tabBarView(
controller: videoDetailController.tabCtr,
children: [
videoIntro(
@@ -932,7 +932,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
children: [
buildTabBar(),
Expanded(
child: videoTabBarView(
child: tabBarView(
controller: videoDetailController.tabCtr,
children: [
videoIntro(
@@ -1000,7 +1000,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
children: [
buildTabBar(showIntro: false),
Expanded(
child: videoTabBarView(
child: tabBarView(
controller: videoDetailController.tabCtr,
children: [
if (videoDetailController.showReply)
@@ -1080,7 +1080,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
: showIntro,
),
Expanded(
child: videoTabBarView(
child: tabBarView(
controller: videoDetailController.tabCtr,
children: [
if (videoDetailController.isFileSource)

View File

@@ -419,9 +419,9 @@ class PlPlayerController with BlockConfigMixin {
: Colors.black.withValues(alpha: subtitleBgOpacity),
);
late final Rx<SubtitleViewConfiguration> subtitleConfig = _getSubConfig.obs;
late final Rx<SubtitleViewConfiguration> subtitleConfig = getSubConfig.obs;
SubtitleViewConfiguration get _getSubConfig {
SubtitleViewConfiguration get getSubConfig {
final subTitleStyle = this.subTitleStyle;
return SubtitleViewConfiguration(
style: subTitleStyle,
@@ -446,7 +446,7 @@ class PlPlayerController with BlockConfigMixin {
}
void updateSubtitleStyle() {
subtitleConfig.value = _getSubConfig;
subtitleConfig.value = getSubConfig;
}
void onUpdatePadding(EdgeInsets padding) {

View File

@@ -152,40 +152,66 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// Timer? _accessibilityDebounce;
// double _lastAnnouncedValue = -1;
StreamSubscription? _listener;
StreamSubscription? _controlsListener;
bool _pauseDueToPauseUponEnteringBackgroundMode = false;
StreamSubscription? _brightnessListener;
int? tmpSubtitlePaddingB;
StreamSubscription? _controlsListener;
void _controlListener(bool val) {
final visible = val && !plPlayerController.controlsLock.value;
if ((widget.headerControl.key as GlobalKey<TimeBatteryMixin>).currentState
case final state?) {
if (state.mounted) {
state.getBatteryLevelIfNeeded();
state.provider
?..startIfNeeded()
..muted = !visible;
if (visible) {
state.startClock();
} else {
state.stopClock();
}
}
}
if (visible) {
animationController.forward();
} else {
animationController.reverse();
}
if (widget.videoDetailController case final controller?) {
if (controller.vttSubtitlesIndex.value != 0) {
if (visible) {
const int minPadding = 70;
if (plPlayerController.subtitlePaddingB < minPadding) {
tmpSubtitlePaddingB = plPlayerController.subtitlePaddingB;
plPlayerController
..subtitlePaddingB = minPadding
..subtitleConfig.value = plPlayerController.getSubConfig;
}
} else {
if (tmpSubtitlePaddingB != null) {
plPlayerController
..subtitlePaddingB = tmpSubtitlePaddingB!
..subtitleConfig.value = plPlayerController.getSubConfig;
tmpSubtitlePaddingB = null;
}
}
}
}
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_controlsListener = plPlayerController.showControls.listen((bool val) {
final visible = val && !plPlayerController.controlsLock.value;
if ((widget.headerControl.key as GlobalKey<TimeBatteryMixin>).currentState
case final state?) {
if (state.mounted) {
state.getBatteryLevelIfNeeded();
state.provider
?..startIfNeeded()
..muted = !visible;
if (visible) {
state.startClock();
} else {
state.stopClock();
}
}
}
if (visible) {
animationController.forward();
} else {
animationController.reverse();
}
});
_controlsListener = plPlayerController.showControls.listen(
_controlListener,
);
transformationController = TransformationController();
animationController = AnimationController(
vsync: this,
@@ -229,7 +255,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
}
_listener = Platform.isIOS || plPlayerController.setSystemBrightness
_brightnessListener =
Platform.isIOS || plPlayerController.setSystemBrightness
? ScreenBrightnessPlatform
.instance
.onSystemScreenBrightnessChanged
@@ -313,7 +340,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_tapGestureRecognizer.dispose();
_longPressRecognizer?.dispose();
_doubleTapGestureRecognizer.dispose();
_listener?.cancel();
_brightnessListener?.cancel();
_controlsListener?.cancel();
animationController.dispose();
if (PlatformUtils.isMobile) {