mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt live border indicator
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -901,30 +901,18 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
if (_liveRoomController.showSuperChat) {
|
if (_liveRoomController.showSuperChat) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
|
child,
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: Obx(() {
|
child: Obx(
|
||||||
return ClipRect(
|
() => _BorderIndicator(
|
||||||
clipper: _BorderClipper(
|
radius: const Radius.circular(20),
|
||||||
_liveRoomController.pageIndex.value == 0,
|
isLeft: _liveRoomController.pageIndex.value == 0,
|
||||||
),
|
|
||||||
child: const DecoratedBox(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.vertical(
|
|
||||||
top: Radius.circular(20),
|
|
||||||
),
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(color: Colors.white38),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: SizedBox(width: double.infinity, height: 20),
|
|
||||||
),
|
),
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
child,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -957,27 +945,87 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BorderClipper extends CustomClipper<Rect> {
|
class _BorderIndicator extends LeafRenderObjectWidget {
|
||||||
_BorderClipper(this.isLeft);
|
const _BorderIndicator({
|
||||||
|
required this.radius,
|
||||||
|
required this.isLeft,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Radius radius;
|
||||||
final bool isLeft;
|
final bool isLeft;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect getClip(Size size) {
|
RenderObject createRenderObject(BuildContext context) {
|
||||||
return Rect.fromLTRB(
|
return RenderBorderIndicator(
|
||||||
isLeft ? 0 : size.width / 2,
|
radius: radius,
|
||||||
0,
|
isLeft: isLeft,
|
||||||
isLeft ? size.width / 2 : size.width,
|
|
||||||
size.height,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldReclip(_BorderClipper oldClipper) {
|
void updateRenderObject(
|
||||||
return isLeft != oldClipper.isLeft;
|
BuildContext context,
|
||||||
|
RenderBorderIndicator renderObject,
|
||||||
|
) {
|
||||||
|
renderObject
|
||||||
|
..radius = radius
|
||||||
|
..isLeft = isLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RenderBorderIndicator extends RenderBox {
|
||||||
|
RenderBorderIndicator({
|
||||||
|
required Radius radius,
|
||||||
|
required bool isLeft,
|
||||||
|
}) : _radius = radius,
|
||||||
|
_isLeft = isLeft;
|
||||||
|
|
||||||
|
Radius _radius;
|
||||||
|
Radius get radius => _radius;
|
||||||
|
set radius(Radius value) {
|
||||||
|
if (_radius == value) return;
|
||||||
|
_radius = value;
|
||||||
|
markNeedsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isLeft;
|
||||||
|
bool get isLeft => _isLeft;
|
||||||
|
set isLeft(bool value) {
|
||||||
|
if (_isLeft == value) return;
|
||||||
|
_isLeft = value;
|
||||||
|
markNeedsPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void performLayout() {
|
||||||
|
size = constraints.constrain(Size(constraints.maxWidth, _radius.x));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(PaintingContext context, Offset offset) {
|
||||||
|
final size = this.size;
|
||||||
|
final canvas = context.canvas;
|
||||||
|
final width = size.width / 2;
|
||||||
|
if (!_isLeft) {
|
||||||
|
canvas.translate(width, 0);
|
||||||
|
}
|
||||||
|
BoxBorder.paintNonUniformBorder(
|
||||||
|
canvas,
|
||||||
|
Rect.fromLTWH(0, 0, width, size.height),
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: _isLeft ? _radius : .zero,
|
||||||
|
topRight: _isLeft ? .zero : _radius,
|
||||||
|
),
|
||||||
|
textDirection: null,
|
||||||
|
top: const BorderSide(),
|
||||||
|
color: Colors.white38,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isRepaintBoundary => true;
|
||||||
|
}
|
||||||
|
|
||||||
class LiveDanmaku extends StatefulWidget {
|
class LiveDanmaku extends StatefulWidget {
|
||||||
final LiveRoomController liveRoomController;
|
final LiveRoomController liveRoomController;
|
||||||
final PlPlayerController plPlayerController;
|
final PlPlayerController plPlayerController;
|
||||||
|
|||||||
Reference in New Issue
Block a user