mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -557,6 +557,7 @@ class RenderParagraph extends RenderBox
|
||||
@override
|
||||
@protected
|
||||
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
|
||||
if (_tapGestureRecognizer != null) {
|
||||
if (_morePainter case final textPainter?) {
|
||||
late final height = _textPainter.height;
|
||||
if (position.dx < textPainter.width &&
|
||||
@@ -566,6 +567,7 @@ class RenderParagraph extends RenderBox
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final GlyphInfo? glyph = _textPainter.getClosestGlyphForOffset(position);
|
||||
// The hit-test can't fall through the horizontal gaps between visually
|
||||
@@ -696,18 +698,18 @@ class RenderParagraph extends RenderBox
|
||||
|
||||
VoidCallback? _onShowMore;
|
||||
set onShowMore(VoidCallback? onShowMore) {
|
||||
if (_onShowMore != onShowMore) {
|
||||
_onShowMore = onShowMore;
|
||||
_tapGestureRecognizer?.onTap = onShowMore;
|
||||
}
|
||||
}
|
||||
|
||||
TapGestureRecognizer? _tapGestureRecognizer;
|
||||
TapGestureRecognizer get _effectiveTapRecognizer =>
|
||||
_tapGestureRecognizer ??= TapGestureRecognizer()..onTap = _onShowMore;
|
||||
|
||||
TextSpan get _moreTextSpan => TextSpan(
|
||||
style: text.style!.copyWith(color: _primary),
|
||||
text: '查看更多',
|
||||
recognizer: _effectiveTapRecognizer,
|
||||
recognizer: _tapGestureRecognizer,
|
||||
);
|
||||
TextPainter? _morePainter;
|
||||
|
||||
@@ -734,6 +736,9 @@ class RenderParagraph extends RenderBox
|
||||
size.height < textSize.height || _textPainter.didExceedMaxLines;
|
||||
|
||||
if (didOverflowHeight) {
|
||||
if (_onShowMore != null) {
|
||||
_tapGestureRecognizer ??= TapGestureRecognizer()..onTap = _onShowMore;
|
||||
}
|
||||
_morePainter ??= TextPainter(
|
||||
text: _moreTextSpan,
|
||||
textDirection: textDirection,
|
||||
|
||||
@@ -115,6 +115,7 @@ class RichText extends MultiChildRenderObjectWidget {
|
||||
this.selectionRegistrar,
|
||||
this.selectionColor,
|
||||
this.onShowMore,
|
||||
required this.primary,
|
||||
}) : assert(maxLines == null || maxLines > 0),
|
||||
assert(selectionRegistrar == null || selectionColor != null),
|
||||
assert(
|
||||
@@ -229,6 +230,8 @@ class RichText extends MultiChildRenderObjectWidget {
|
||||
/// widgets.
|
||||
final Color? selectionColor;
|
||||
|
||||
final Color primary;
|
||||
|
||||
final VoidCallback? onShowMore;
|
||||
|
||||
@override
|
||||
@@ -248,7 +251,7 @@ class RichText extends MultiChildRenderObjectWidget {
|
||||
locale: locale ?? Localizations.maybeLocaleOf(context),
|
||||
registrar: selectionRegistrar,
|
||||
selectionColor: selectionColor,
|
||||
primary: Theme.of(context).colorScheme.primary,
|
||||
primary: primary,
|
||||
onShowMore: onShowMore,
|
||||
);
|
||||
}
|
||||
@@ -270,7 +273,7 @@ class RichText extends MultiChildRenderObjectWidget {
|
||||
..locale = locale ?? Localizations.maybeLocaleOf(context)
|
||||
..registrar = selectionRegistrar
|
||||
..selectionColor = selectionColor
|
||||
..primary = Theme.of(context).colorScheme.primary
|
||||
..primary = primary
|
||||
..onShowMore = onShowMore;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ class Text extends StatelessWidget {
|
||||
this.textHeightBehavior,
|
||||
this.selectionColor,
|
||||
this.onShowMore,
|
||||
required this.primary,
|
||||
}) : textSpan = null,
|
||||
assert(
|
||||
textScaler == null || textScaleFactor == null,
|
||||
@@ -213,6 +214,7 @@ class Text extends StatelessWidget {
|
||||
this.textHeightBehavior,
|
||||
this.selectionColor,
|
||||
this.onShowMore,
|
||||
required this.primary,
|
||||
}) : data = null,
|
||||
assert(
|
||||
textScaler == null || textScaleFactor == null,
|
||||
@@ -351,6 +353,8 @@ class Text extends StatelessWidget {
|
||||
/// (semi-transparent grey).
|
||||
final Color? selectionColor;
|
||||
|
||||
final Color primary;
|
||||
|
||||
final VoidCallback? onShowMore;
|
||||
|
||||
@override
|
||||
@@ -408,6 +412,7 @@ class Text extends StatelessWidget {
|
||||
text: data,
|
||||
children: textSpan != null ? <InlineSpan>[textSpan!] : null,
|
||||
),
|
||||
primary: primary,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@@ -440,6 +445,7 @@ class Text extends StatelessWidget {
|
||||
children: textSpan != null ? <InlineSpan>[textSpan!] : null,
|
||||
),
|
||||
onShowMore: onShowMore,
|
||||
primary: primary,
|
||||
);
|
||||
}
|
||||
if (semanticsLabel != null || semanticsIdentifier != null) {
|
||||
@@ -537,6 +543,7 @@ class _SelectableTextContainer extends StatefulWidget {
|
||||
required this.textWidthBasis,
|
||||
this.textHeightBehavior,
|
||||
required this.selectionColor,
|
||||
required this.primary,
|
||||
});
|
||||
|
||||
final TextSpan text;
|
||||
@@ -551,6 +558,7 @@ class _SelectableTextContainer extends StatefulWidget {
|
||||
final TextWidthBasis textWidthBasis;
|
||||
final ui.TextHeightBehavior? textHeightBehavior;
|
||||
final Color selectionColor;
|
||||
final Color primary;
|
||||
|
||||
@override
|
||||
State<_SelectableTextContainer> createState() =>
|
||||
@@ -593,6 +601,7 @@ class _SelectableTextContainerState extends State<_SelectableTextContainer> {
|
||||
textHeightBehavior: widget.textHeightBehavior,
|
||||
selectionColor: widget.selectionColor,
|
||||
text: widget.text,
|
||||
primary: widget.primary,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -613,6 +622,7 @@ class _RichText extends StatelessWidget {
|
||||
required this.textWidthBasis,
|
||||
this.textHeightBehavior,
|
||||
required this.selectionColor,
|
||||
required this.primary,
|
||||
});
|
||||
|
||||
final GlobalKey? textKey;
|
||||
@@ -628,6 +638,7 @@ class _RichText extends StatelessWidget {
|
||||
final TextWidthBasis textWidthBasis;
|
||||
final ui.TextHeightBehavior? textHeightBehavior;
|
||||
final Color selectionColor;
|
||||
final Color primary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -647,6 +658,7 @@ class _RichText extends StatelessWidget {
|
||||
selectionRegistrar: registrar,
|
||||
selectionColor: selectionColor,
|
||||
text: text,
|
||||
primary: primary,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ Widget content(
|
||||
richNodes,
|
||||
maxLines: isSave ? null : 6,
|
||||
onShowMore: () => PageUtils.pushDynDetail(item, isPush: true),
|
||||
primary: theme.colorScheme.primary,
|
||||
),
|
||||
if (pics?.isNotEmpty == true)
|
||||
CustomGridView(
|
||||
|
||||
@@ -274,6 +274,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
Padding(
|
||||
padding: padding,
|
||||
child: custom_text.Text.rich(
|
||||
primary: theme.colorScheme.primary,
|
||||
style: TextStyle(
|
||||
height: 1.75,
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
|
||||
Reference in New Issue
Block a user