Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[leancode_markup] Default text style is lost with tagFactory #308

Open
RobertOdrowaz opened this issue Jun 13, 2024 · 0 comments
Open

[leancode_markup] Default text style is lost with tagFactory #308

RobertOdrowaz opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
p: leancode_markup Related to the leancode_markup pacakge

Comments

@RobertOdrowaz
Copy link
Member

When adding a custom url tag I had to force it a little to get correct link style and alignment with the rest of the text.

  1. I had to provide modified default style in tagStyles
MarkupTagStyle.delegate(
  tagName: 'a',
  styleCreator: (_) => style.copyWith( // Here I needed a copy the `style` because the `DefaultTextStyle` provided above wasn't used for the link span
    fontWeight: FontWeight.bold,
    color: linkColor ?? colors.primary,
  ),
),

I would expect to just need to provide empty text style with the desired properties as is the case for bold tag

MarkupTagStyle.delegate(
  tagName: 'b',
  styleCreator: (_) => const TextStyle(fontWeight: FontWeight.bold),
),
  1. I had to add some arguments in WidgetSpan to get proper alignment of the link text. I don't know if we can fix this in the package, maybe we just should include this in the readme/example.
'a': (child, parameter) {
  return WidgetSpan(
    baseline: TextBaseline.alphabetic, // here
    alignment: PlaceholderAlignment.baseline, // and here
    child: GestureDetector(
      onTap: () async {
        if (parameter != null) {
          await alxLaunchUrl(url: parameter);
        }
      },
      child: child,
    ),
  );
},
@pdenert pdenert added the p: leancode_markup Related to the leancode_markup pacakge label Jun 13, 2024
@pdenert pdenert self-assigned this Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: leancode_markup Related to the leancode_markup pacakge
Projects
None yet
Development

No branches or pull requests

2 participants