mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 00:56:31 +08:00
opt marquee
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,12 +5,18 @@ class MarqueeText extends StatelessWidget {
|
|||||||
final double maxWidth;
|
final double maxWidth;
|
||||||
final String text;
|
final String text;
|
||||||
final TextStyle? style;
|
final TextStyle? style;
|
||||||
|
final int? count;
|
||||||
|
final bool bounce;
|
||||||
|
final double spacing;
|
||||||
|
|
||||||
const MarqueeText(
|
const MarqueeText(
|
||||||
this.text, {
|
this.text, {
|
||||||
|
super.key,
|
||||||
required this.maxWidth,
|
required this.maxWidth,
|
||||||
this.style,
|
this.style,
|
||||||
super.key,
|
this.count,
|
||||||
|
this.bounce = true,
|
||||||
|
this.spacing = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -22,18 +28,21 @@ class MarqueeText extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
)..layout(maxWidth: maxWidth);
|
)..layout();
|
||||||
|
final width = textPainter.width;
|
||||||
final child = Text(
|
final child = Text(
|
||||||
text,
|
text,
|
||||||
style: style,
|
style: style,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
);
|
);
|
||||||
if (textPainter.didExceedMaxLines) {
|
if (width > maxWidth) {
|
||||||
return SingleWidgetMarquee(
|
return SingleWidgetMarquee(
|
||||||
child,
|
child,
|
||||||
duration: const Duration(seconds: 5),
|
duration: Duration(milliseconds: (width / 50 * 1000).round()),
|
||||||
bounce: true,
|
bounce: bounce,
|
||||||
|
count: count,
|
||||||
|
spacing: spacing,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return child;
|
return child;
|
||||||
@@ -46,6 +55,7 @@ class SingleWidgetMarquee extends StatefulWidget {
|
|||||||
final Duration? duration;
|
final Duration? duration;
|
||||||
final bool bounce;
|
final bool bounce;
|
||||||
final double spacing;
|
final double spacing;
|
||||||
|
final int? count;
|
||||||
|
|
||||||
const SingleWidgetMarquee(
|
const SingleWidgetMarquee(
|
||||||
this.child, {
|
this.child, {
|
||||||
@@ -53,6 +63,7 @@ class SingleWidgetMarquee extends StatefulWidget {
|
|||||||
this.duration,
|
this.duration,
|
||||||
this.bounce = false,
|
this.bounce = false,
|
||||||
this.spacing = 0,
|
this.spacing = 0,
|
||||||
|
this.count,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -65,7 +76,7 @@ class _SingleWidgetMarqueeState extends State<SingleWidgetMarquee>
|
|||||||
vsync: this,
|
vsync: this,
|
||||||
duration: widget.duration,
|
duration: widget.duration,
|
||||||
reverseDuration: widget.duration,
|
reverseDuration: widget.duration,
|
||||||
)..repeat(reverse: widget.bounce);
|
)..repeat(reverse: widget.bounce, count: widget.count);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => widget.bounce
|
Widget build(BuildContext context) => widget.bounce
|
||||||
|
|||||||
@@ -1956,36 +1956,44 @@ class HeaderControlState extends TripleState<HeaderControl> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
LayoutBuilder(
|
Padding(
|
||||||
builder: (context, constraints) {
|
padding: isPortrait
|
||||||
return Obx(
|
? EdgeInsets.zero
|
||||||
() {
|
: const EdgeInsets.only(right: 10),
|
||||||
final videoDetail =
|
child: LayoutBuilder(
|
||||||
introController.videoDetail.value;
|
builder: (context, constraints) {
|
||||||
final String title;
|
return Obx(
|
||||||
if (videoDetail.videos == 1) {
|
() {
|
||||||
title = videoDetail.title!;
|
final videoDetail =
|
||||||
} else {
|
introController.videoDetail.value;
|
||||||
title =
|
final String title;
|
||||||
videoDetail.pages
|
if (videoDetail.videos == 1) {
|
||||||
?.firstWhereOrNull(
|
title = videoDetail.title!;
|
||||||
(e) =>
|
} else {
|
||||||
e.cid == videoDetailCtr.cid.value,
|
title =
|
||||||
)
|
videoDetail.pages
|
||||||
?.pagePart ??
|
?.firstWhereOrNull(
|
||||||
videoDetail.title!;
|
(e) =>
|
||||||
}
|
e.cid == videoDetailCtr.cid.value,
|
||||||
return MarqueeText(
|
)
|
||||||
title,
|
?.pagePart ??
|
||||||
maxWidth: constraints.maxWidth,
|
videoDetail.title!;
|
||||||
style: const TextStyle(
|
}
|
||||||
color: Colors.white,
|
return MarqueeText(
|
||||||
fontSize: 16,
|
title,
|
||||||
),
|
maxWidth: constraints.maxWidth,
|
||||||
);
|
count: 3,
|
||||||
},
|
bounce: false,
|
||||||
);
|
spacing: 30,
|
||||||
},
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (introController.isShowOnlineTotal)
|
if (introController.isShowOnlineTotal)
|
||||||
Obx(
|
Obx(
|
||||||
|
|||||||
Reference in New Issue
Block a user