Skip to content

Commit

Permalink
Merge pull request #2701 from nextcloud/fix/neon_rich_text/rich-objec…
Browse files Browse the repository at this point in the history
…ts-stop-inherit-textstyle

fix(neon_rich_text): Do not inherit the current TextStyle in rich objects
  • Loading branch information
provokateurin authored Dec 10, 2024
2 parents 090047d + ebbe458 commit 75dc994
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ class NeonRichObjectFallback extends StatelessWidget {
/// Creates a new Neon rich object fallback
const NeonRichObjectFallback({
required this.parameter,
required this.textStyle,
super.key,
});

/// The parameter to display.
final core.RichObjectParameter parameter;

/// The TextStyle to applied to all text elements in this rich object.
final TextStyle? textStyle;

@override
Widget build(BuildContext context) {
final iconUrl = parameter.iconUrl;
Expand All @@ -45,10 +41,7 @@ class NeonRichObjectFallback extends StatelessWidget {
padding: EdgeInsets.zero,
labelPadding: labelPadding,
avatar: avatar,
label: Text(
parameter.name,
style: textStyle,
),
label: Text(parameter.name),
onPressed: () async {
final link = parameter.link;
if (link != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ class NeonRichObjectFile extends StatelessWidget {
/// Creates a new Neon rich object file.
const NeonRichObjectFile({
required this.parameter,
required this.textStyle,
super.key,
});

/// The parameter to display.
final core.RichObjectParameter parameter;

/// The TextStyle to applied to all text elements in this rich object.
final TextStyle? textStyle;

@override
Widget build(BuildContext context) {
final child = LayoutBuilder(
Expand Down Expand Up @@ -101,10 +97,7 @@ class NeonRichObjectFile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
image,
Text(
parameter.name,
style: textStyle,
),
Text(parameter.name),
],
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ class NeonRichObjectMention extends StatelessWidget {
/// Create a new Neon rich object mention.
const NeonRichObjectMention({
required this.parameter,
required this.textStyle,
super.key,
});

/// The parameter to display.
final core.RichObjectParameter parameter;

/// The TextStyle to applied to all text elements in this rich object.
final TextStyle? textStyle;

@override
Widget build(BuildContext context) {
final Widget child;
Expand Down Expand Up @@ -89,7 +85,6 @@ class NeonRichObjectMention extends StatelessWidget {
horizontal: VisualDensity.minimumDensity,
vertical: VisualDensity.minimumDensity,
),
labelStyle: textStyle,
label: Text(
parameter.name,
style: TextStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ InlineSpan buildRichObjectParameter({
core.RichObjectParameter_Type.userGroup =>
NeonRichObjectMention(
parameter: parameter,
textStyle: textStyle,
),
core.RichObjectParameter_Type.file => NeonRichObjectFile(
parameter: parameter,
textStyle: textStyle,
),
core.RichObjectParameter_Type.deckCard => NeonRichObjectDeckCard(
parameter: parameter,
),
_ => NeonRichObjectFallback(
parameter: parameter,
textStyle: textStyle,
),
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void main() {
..name = 'name'
..link = '/link',
),
textStyle: null,
),
),
);
Expand All @@ -62,7 +61,6 @@ void main() {
..id = ''
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -88,7 +86,6 @@ void main() {
..name = 'name'
..iconUrl = '',
),
textStyle: null,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ void main() {
..path = ''
..link = '/link',
),
textStyle: null,
),
),
);
Expand All @@ -77,7 +76,6 @@ void main() {
..path = ''
..blurhash = validBlurHash,
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -105,7 +103,6 @@ void main() {
..previewAvailable = 'no'
..path = 'path',
),
textStyle: null,
),
),
);
Expand All @@ -129,7 +126,6 @@ void main() {
..previewAvailable = 'yes'
..path = 'path',
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -167,7 +163,6 @@ void main() {
..width = width.toString()
..height = height.toString(),
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -200,7 +195,6 @@ void main() {
..width = ((maxWidth * widthFactor) * pixelRatio).toString()
..height = ((maxHeight * heightFactor) * pixelRatio).toString(),
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -234,7 +228,6 @@ void main() {
..mimetype = 'image/gif'
..blurhash = validBlurHash,
),
textStyle: null,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void main() {
..id = 'username'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -63,7 +62,6 @@ void main() {
..id = 'other'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -90,7 +88,6 @@ void main() {
..name = 'name'
..iconUrl = '',
),
textStyle: null,
),
),
);
Expand All @@ -112,7 +109,6 @@ void main() {
..id = ''
..name = 'name',
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -143,7 +139,6 @@ void main() {
..id = 'group'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -166,7 +161,6 @@ void main() {
..id = 'other'
..name = 'name',
),
textStyle: null,
),
),
);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75dc994

Please sign in to comment.