Skip to content

Commit

Permalink
fix(neon_framework): Do not inherit the current TextStyle in rich obj…
Browse files Browse the repository at this point in the history
…ects

Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Nov 11, 2024
1 parent a8afaae commit e850437
Show file tree
Hide file tree
Showing 6 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
9 changes: 1 addition & 8 deletions packages/neon_framework/lib/src/widgets/rich_text/file.dart
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 @@ -155,18 +155,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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 0 additions & 16 deletions packages/neon_framework/test/rich_text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void main() {
..id = 'username'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -111,7 +110,6 @@ void main() {
..id = 'other'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -138,7 +136,6 @@ void main() {
..name = 'name'
..iconUrl = '',
),
textStyle: null,
),
),
);
Expand All @@ -160,7 +157,6 @@ void main() {
..id = ''
..name = 'name',
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -191,7 +187,6 @@ void main() {
..id = 'group'
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -214,7 +209,6 @@ void main() {
..id = 'other'
..name = 'name',
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -248,7 +242,6 @@ void main() {
..path = ''
..link = '/link',
),
textStyle: null,
),
),
);
Expand All @@ -273,7 +266,6 @@ void main() {
..path = ''
..blurhash = validBlurHash,
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -301,7 +293,6 @@ void main() {
..previewAvailable = 'no'
..path = 'path',
),
textStyle: null,
),
),
);
Expand All @@ -325,7 +316,6 @@ void main() {
..previewAvailable = 'yes'
..path = 'path',
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -363,7 +353,6 @@ void main() {
..width = width.toString()
..height = height.toString(),
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -396,7 +385,6 @@ void main() {
..width = ((maxWidth * widthFactor) * pixelRatio).toString()
..height = ((maxHeight * heightFactor) * pixelRatio).toString(),
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -430,7 +418,6 @@ void main() {
..mimetype = 'image/gif'
..blurhash = validBlurHash,
),
textStyle: null,
),
),
);
Expand Down Expand Up @@ -462,7 +449,6 @@ void main() {
..name = 'name'
..link = '/link',
),
textStyle: null,
),
),
);
Expand All @@ -481,7 +467,6 @@ void main() {
..id = ''
..name = 'name',
),
textStyle: null,
),
),
);
Expand All @@ -507,7 +492,6 @@ void main() {
..name = 'name'
..iconUrl = '',
),
textStyle: null,
),
),
);
Expand Down

0 comments on commit e850437

Please sign in to comment.