mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-04 00:00:14 +08:00
fix dyn showmore
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -150,7 +150,22 @@ class RenderParagraph extends RenderBox
|
|||||||
|
|
||||||
/// The text to display.
|
/// The text to display.
|
||||||
InlineSpan get text => _textPainter.text!;
|
InlineSpan get text => _textPainter.text!;
|
||||||
set text(InlineSpan value) {
|
set text(({InlineSpan text, Color primary}) params) {
|
||||||
|
final value = params.text;
|
||||||
|
_primary = params.primary;
|
||||||
|
if (_morePainter case final textPainter?) {
|
||||||
|
final textSpan = _moreTextSpan(params.text.style);
|
||||||
|
switch (textPainter.text!.compareTo(textSpan)) {
|
||||||
|
case RenderComparison.paint:
|
||||||
|
textPainter.text = textSpan;
|
||||||
|
case RenderComparison.layout:
|
||||||
|
textPainter
|
||||||
|
..text = textSpan
|
||||||
|
..layout();
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (_textPainter.text!.compareTo(value)) {
|
switch (_textPainter.text!.compareTo(value)) {
|
||||||
case RenderComparison.identical:
|
case RenderComparison.identical:
|
||||||
return;
|
return;
|
||||||
@@ -567,7 +582,7 @@ class RenderParagraph extends RenderBox
|
|||||||
if (position.dx < textPainter.width &&
|
if (position.dx < textPainter.width &&
|
||||||
position.dy > height &&
|
position.dy > height &&
|
||||||
position.dy < height + textPainter.height) {
|
position.dy < height + textPainter.height) {
|
||||||
result.add(HitTestEntry(_moreTextSpan));
|
result.add(HitTestEntry(textPainter.text as TextSpan));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -693,13 +708,6 @@ class RenderParagraph extends RenderBox
|
|||||||
|
|
||||||
Color _primary;
|
Color _primary;
|
||||||
|
|
||||||
set primary(Color primary) {
|
|
||||||
if (_primary != primary) {
|
|
||||||
_primary = primary;
|
|
||||||
_morePainter?.text = _moreTextSpan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VoidCallback? _onShowMore;
|
VoidCallback? _onShowMore;
|
||||||
set onShowMore(VoidCallback? onShowMore) {
|
set onShowMore(VoidCallback? onShowMore) {
|
||||||
if (_onShowMore != onShowMore) {
|
if (_onShowMore != onShowMore) {
|
||||||
@@ -710,8 +718,8 @@ class RenderParagraph extends RenderBox
|
|||||||
|
|
||||||
TapGestureRecognizer? _tapGestureRecognizer;
|
TapGestureRecognizer? _tapGestureRecognizer;
|
||||||
|
|
||||||
TextSpan get _moreTextSpan => TextSpan(
|
TextSpan _moreTextSpan([TextStyle? style]) => TextSpan(
|
||||||
style: text.style!.copyWith(color: _primary),
|
style: (style ?? text.style!).copyWith(color: _primary),
|
||||||
text: '查看更多',
|
text: '查看更多',
|
||||||
recognizer: _tapGestureRecognizer,
|
recognizer: _tapGestureRecognizer,
|
||||||
);
|
);
|
||||||
@@ -744,7 +752,7 @@ class RenderParagraph extends RenderBox
|
|||||||
_tapGestureRecognizer ??= TapGestureRecognizer()..onTap = _onShowMore;
|
_tapGestureRecognizer ??= TapGestureRecognizer()..onTap = _onShowMore;
|
||||||
}
|
}
|
||||||
_morePainter ??= TextPainter(
|
_morePainter ??= TextPainter(
|
||||||
text: _moreTextSpan,
|
text: _moreTextSpan(),
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
textScaler: textScaler,
|
textScaler: textScaler,
|
||||||
locale: locale,
|
locale: locale,
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class RichText extends MultiChildRenderObjectWidget {
|
|||||||
void updateRenderObject(BuildContext context, RenderParagraph renderObject) {
|
void updateRenderObject(BuildContext context, RenderParagraph renderObject) {
|
||||||
assert(textDirection != null || debugCheckHasDirectionality(context));
|
assert(textDirection != null || debugCheckHasDirectionality(context));
|
||||||
renderObject
|
renderObject
|
||||||
..text = text
|
..text = (text: text, primary: primary)
|
||||||
..textAlign = textAlign
|
..textAlign = textAlign
|
||||||
..textDirection = textDirection ?? Directionality.of(context)
|
..textDirection = textDirection ?? Directionality.of(context)
|
||||||
..softWrap = softWrap
|
..softWrap = softWrap
|
||||||
@@ -277,7 +277,6 @@ class RichText extends MultiChildRenderObjectWidget {
|
|||||||
..locale = locale ?? Localizations.maybeLocaleOf(context)
|
..locale = locale ?? Localizations.maybeLocaleOf(context)
|
||||||
..registrar = selectionRegistrar
|
..registrar = selectionRegistrar
|
||||||
..selectionColor = selectionColor
|
..selectionColor = selectionColor
|
||||||
..primary = primary
|
|
||||||
..onShowMore = onShowMore;
|
..onShowMore = onShowMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user