mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +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) {
|
||||
return Stack(
|
||||
children: [
|
||||
child,
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Obx(() {
|
||||
return ClipRect(
|
||||
clipper: _BorderClipper(
|
||||
_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: Obx(
|
||||
() => _BorderIndicator(
|
||||
radius: const Radius.circular(20),
|
||||
isLeft: _liveRoomController.pageIndex.value == 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -957,27 +945,87 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
});
|
||||
}
|
||||
|
||||
class _BorderClipper extends CustomClipper<Rect> {
|
||||
_BorderClipper(this.isLeft);
|
||||
class _BorderIndicator extends LeafRenderObjectWidget {
|
||||
const _BorderIndicator({
|
||||
required this.radius,
|
||||
required this.isLeft,
|
||||
});
|
||||
|
||||
final Radius radius;
|
||||
final bool isLeft;
|
||||
|
||||
@override
|
||||
Rect getClip(Size size) {
|
||||
return Rect.fromLTRB(
|
||||
isLeft ? 0 : size.width / 2,
|
||||
0,
|
||||
isLeft ? size.width / 2 : size.width,
|
||||
size.height,
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
return RenderBorderIndicator(
|
||||
radius: radius,
|
||||
isLeft: isLeft,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(_BorderClipper oldClipper) {
|
||||
return isLeft != oldClipper.isLeft;
|
||||
void updateRenderObject(
|
||||
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 {
|
||||
final LiveRoomController liveRoomController;
|
||||
final PlPlayerController plPlayerController;
|
||||
|
||||
Reference in New Issue
Block a user