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