Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-20 22:44:09 +08:00
parent db65e7df76
commit 7617bb692a
21 changed files with 279 additions and 280 deletions

View File

@@ -1,31 +0,0 @@
import 'package:flutter/rendering.dart' show RenderProxyBox, BoxHitTestResult;
import 'package:flutter/widgets.dart';
class ExtraHitTestWidget extends SingleChildRenderObjectWidget {
const ExtraHitTestWidget({
super.key,
required this.width,
required Widget super.child,
});
final double width;
@override
RenderObject createRenderObject(BuildContext context) {
return RenderExtraHitTestWidget(width: width);
}
}
class RenderExtraHitTestWidget extends RenderProxyBox {
RenderExtraHitTestWidget({
required this._width,
});
final double _width;
@override
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
return super.hitTestChildren(result, position: position) ||
position.dx <= _width;
}
}

View File

@@ -9,8 +9,7 @@ import 'dart:io' show Platform;
import 'package:PiliPlus/common/widgets/scroll_behavior.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'
show RefreshScrollPhysics;
import 'package:extended_nested_scroll_view/src/refresh.dart';
import 'package:flutter/foundation.dart' show clampDouble;
import 'package:flutter/material.dart' hide RefreshIndicator;
@@ -618,10 +617,26 @@ class RefreshScrollBehavior extends CustomScrollBehavior {
required this.scrollPhysics,
});
final RefreshScrollPhysics scrollPhysics;
final RefreshScrollPhysicsMixin scrollPhysics;
@override
ScrollPhysics getScrollPhysics(BuildContext context) {
return scrollPhysics;
}
}
class RefreshScrollPhysics extends ClampingScrollPhysics
with RefreshScrollPhysicsMixin {
const RefreshScrollPhysics({
super.parent,
required this.onDrag,
});
@override
final OnDrag onDrag;
@override
RefreshScrollPhysics applyTo(ScrollPhysics? ancestor) {
return RefreshScrollPhysics(parent: buildParent(ancestor), onDrag: onDrag);
}
}

View File

@@ -48,23 +48,6 @@ class TranslucentColumn extends Flex {
spacing: spacing,
);
}
@override
void updateRenderObject(
BuildContext context,
RenderTranslucentColumn renderObject,
) {
renderObject
..direction = direction
..mainAxisAlignment = mainAxisAlignment
..mainAxisSize = mainAxisSize
..crossAxisAlignment = crossAxisAlignment
..textDirection = getEffectiveTextDirection(context)
..verticalDirection = verticalDirection
..textBaseline = textBaseline
..clipBehavior = clipBehavior
..spacing = spacing;
}
}
class RenderTranslucentColumn extends RenderFlex {

View File

@@ -0,0 +1,99 @@
/*
* This file is part of PiliPlus
*
* PiliPlus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PiliPlus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PiliPlus. If not, see <https://www.gnu.org/licenses/>.
*/
import 'package:flutter/rendering.dart'
show BoxHitTestResult, RenderFlex, FlexParentData;
import 'package:flutter/widgets.dart';
class TranslucentRow extends Flex {
const TranslucentRow({
super.key,
super.mainAxisAlignment,
super.mainAxisSize,
super.crossAxisAlignment,
super.textDirection,
super.verticalDirection,
super.textBaseline,
super.spacing,
super.children,
required this.extraWidth,
}) : super(direction: Axis.horizontal);
final double extraWidth;
@override
RenderTranslucentRow createRenderObject(BuildContext context) {
return RenderTranslucentRow(
direction: direction,
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: getEffectiveTextDirection(context),
verticalDirection: verticalDirection,
textBaseline: textBaseline,
clipBehavior: clipBehavior,
spacing: spacing,
extraWidth: extraWidth,
);
}
}
class RenderTranslucentRow extends RenderFlex {
RenderTranslucentRow({
super.children,
super.direction,
super.mainAxisSize,
super.mainAxisAlignment,
super.crossAxisAlignment,
super.textDirection,
super.verticalDirection,
super.textBaseline,
super.clipBehavior,
super.spacing,
required this.extraWidth,
});
final double extraWidth;
@override
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
if (position.dx >= 0.0 &&
position.dx <= extraWidth &&
position.dy >= 0.0 &&
position.dy < size.height) {
return true;
}
RenderBox? child = lastChild;
while (child != null) {
final childParentData = child.parentData! as FlexParentData;
final bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult result, Offset transformed) {
assert(transformed == position - childParentData.offset);
final hit = child!.hitTest(result, position: transformed);
return hit || child.size.contains(transformed);
},
);
if (isHit) {
return true;
}
child = childParentData.previousSibling;
}
return false;
}
}