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

Fontsize Up #75

Open
steveshp opened this issue Dec 11, 2023 · 7 comments
Open

Fontsize Up #75

steveshp opened this issue Dec 11, 2023 · 7 comments
Labels
bug Something isn't working question Further information is requested

Comments

@steveshp
Copy link

Hello, I wanted to reach out to see if I could maybe get some help on an issue regarding changing the style of the text in the messages dash chat2 generates. In our project we are using dash chat2 to help connect senior citizens with other users of the app; to make it more accessible we wanted to be able to increase the font size for all text fields on the chat widget. I'm having trouble figuring out how to implement those properties. Would you maybe be willing to provide a quick example or some pointers on how to do so?

@SebastienBtr SebastienBtr added the question Further information is requested label Feb 1, 2024
@LegendAF
Copy link
Contributor

LegendAF commented Feb 19, 2024

Looks like this specifically is stopping the text size from being controlled via the textTheme.

For the short term (and easy solution) you could mark all of your messages as isMarkdown (since markdown uses the textTheme by default).

Here is an example controlling all of the text:

      data: ThemeData(
        ...,
        textTheme: const TextTheme(
          bodySmall: TextStyle(fontSize: 20),  // YOUR FONT SIZE
          bodyMedium: TextStyle(fontSize: 30), // YOUR FONT SIZE
          bodyLarge: TextStyle(fontSize: 40), // YOUR FONT SIZE
        ),
      ),
userNameBuilder: (user) => DefaultUserName(
  user: user,
  style: const TextStyle(
    fontSize: 20, // YOUR FONT SIZE
    color: Colors.grey,
  ),
),

**** Caveats the mentions will still be small in this case.

It may be worthwhile adding a textScale parameter to do this all with one variable.

@SebastienBtr
Copy link
Owner

Looks like this specifically is stopping the text size from being controlled via the textTheme.

For the short term (and easy solution) you could mark all of your messages as isMarkdown (since markdown uses the textTheme by default).

Here is an example controlling all of the text:

      data: ThemeData(
        ...,
        textTheme: const TextTheme(
          bodySmall: TextStyle(fontSize: 20),  // YOUR FONT SIZE
          bodyMedium: TextStyle(fontSize: 30), // YOUR FONT SIZE
          bodyLarge: TextStyle(fontSize: 40), // YOUR FONT SIZE
        ),
      ),
userNameBuilder: (user) => DefaultUserName(
  user: user,
  style: const TextStyle(
    fontSize: 20, // YOUR FONT SIZE
    color: Colors.grey,
  ),
),

**** Caveats the mentions will still be small in this case.

It may be worthwhile adding a textScale parameter to do this all with one variable.

I guess, instead of overwriting the style it could use the Theme data and only override what we need?

@SebastienBtr SebastienBtr added the bug Something isn't working label Feb 19, 2024
@LegendAF
Copy link
Contributor

The biggest offender here is that ParsedText needs to consume the theme data.

ParsedText( 
  parse: messageOptions.parsePatterns != null
      ? messageOptions.parsePatterns!
      : defaultParsePatterns,
  text: text,
  style: TextStyle(
    color: isOwnMessage
        ? messageOptions.currentUserTextColor(context)
        : messageOptions.textColor,
    fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize,
  ),
);

But yeah. I am a fan of only overriding what is needed.

For what it is worth, I removed the style from ParsedText to test and the issue persists.

@SebastienBtr
Copy link
Owner

SebastienBtr commented Feb 19, 2024

Did you try something like that:

style: Theme.of(context).textTheme.bodySmall.copyWith(
              color: isOwnMessage
                          ? messageOptions.currentUserTextColor(context)
                          : messageOptions.textColor,
            )

Not sure which textTheme style should be picked though

I think this, or what you did, is the way to go

@SebastienBtr
Copy link
Owner

Or we just add a textFontSize in message options, I can see there is a timeFontSize already

@LegendAF
Copy link
Contributor

Did you try something like that:

style: Theme.of(context).textTheme.bodySmall.copyWith(
              color: isOwnMessage
                          ? messageOptions.currentUserTextColor(context)
                          : messageOptions.textColor,
            )

Not sure which textTheme style should be picked though

I think this, or what you did, is the way to go

I did not but I don't see why this wouldn't work. If we want to keep in with allowing theme to control most things this is probably the best route. There is also a fontSize associated with DefaultUserName. I am not sure how to tie those directly into the textTheme without some sort of scaling. It may just be best to allow people to control it directly.

In the app I maintain that implements Dash Chat we use the builders in places where the default sizes would otherwise be used. So it doesn't currently effect my use cases.

@ramluro1
Copy link

I am still having an issue with increase the font size of the chat message. Any guidance would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants