mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-25 10:38:40 +00:00
@@ -28,10 +28,10 @@ class SliverFloatingHeaderWidget extends SingleChildRenderObjectWidget {
|
|||||||
const SliverFloatingHeaderWidget({
|
const SliverFloatingHeaderWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required Widget super.child,
|
required Widget super.child,
|
||||||
this.backgroundColor,
|
required this.backgroundColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Color? backgroundColor;
|
final Color backgroundColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RenderObject createRenderObject(BuildContext context) =>
|
RenderObject createRenderObject(BuildContext context) =>
|
||||||
@@ -48,11 +48,11 @@ class SliverFloatingHeaderWidget extends SingleChildRenderObjectWidget {
|
|||||||
|
|
||||||
class RenderSliverFloatingHeader extends RenderSliverSingleBoxAdapter {
|
class RenderSliverFloatingHeader extends RenderSliverSingleBoxAdapter {
|
||||||
RenderSliverFloatingHeader({
|
RenderSliverFloatingHeader({
|
||||||
required Color? backgroundColor,
|
required Color backgroundColor,
|
||||||
}) : _backgroundColor = backgroundColor;
|
}) : _backgroundColor = backgroundColor;
|
||||||
|
|
||||||
Color? _backgroundColor;
|
Color _backgroundColor;
|
||||||
set backgroundColor(Color? value) {
|
set backgroundColor(Color value) {
|
||||||
if (_backgroundColor == value) return;
|
if (_backgroundColor == value) return;
|
||||||
_backgroundColor = value;
|
_backgroundColor = value;
|
||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
@@ -135,19 +135,23 @@ class RenderSliverFloatingHeader extends RenderSliverSingleBoxAdapter {
|
|||||||
void paint(PaintingContext context, Offset offset) {
|
void paint(PaintingContext context, Offset offset) {
|
||||||
if (child != null && geometry!.visible) {
|
if (child != null && geometry!.visible) {
|
||||||
offset += Offset(0.0, childMainAxisPosition(child!));
|
offset += Offset(0.0, childMainAxisPosition(child!));
|
||||||
if (_backgroundColor != null) {
|
final size = child!.size;
|
||||||
final size = child!.size;
|
context.canvas.drawRect(
|
||||||
context.canvas.drawRect(
|
Rect.fromLTWH(
|
||||||
Rect.fromLTWH(
|
offset.dx,
|
||||||
offset.dx,
|
offset.dy - 2,
|
||||||
offset.dy - 2,
|
size.width,
|
||||||
size.width,
|
size.height + 2,
|
||||||
size.height + 2,
|
),
|
||||||
),
|
Paint()..color = _backgroundColor,
|
||||||
Paint()..color = _backgroundColor!,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
context.paintChild(child!, offset);
|
context.paintChild(child!, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hitTestSelf({
|
||||||
|
required double mainAxisPosition,
|
||||||
|
required double crossAxisPosition,
|
||||||
|
}) => true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user