chore: make scaling / not scaling consistent when rendering messages and chat list item subtitles (#2618)

This commit is contained in:
ggurdin 2025-05-02 11:14:39 -04:00 committed by GitHub
parent cebfa20d58
commit 3c0c84b366
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View file

@ -336,6 +336,7 @@ class HtmlMessage extends StatelessWidget {
? () => onClick?.call(token)
: null,
child: Text.rich(
textScaler: TextScaler.noScaling,
TextSpan(
children: [
LinkifySpan(
@ -407,6 +408,12 @@ class HtmlMessage extends StatelessWidget {
splashColor: Colors.transparent,
onTap: () => UrlLauncher(context, href, node.text).launchUrl(),
child: Text.rich(
// #Pangea
// Text.rich applies the device's textScaleFactor
// overriding this one since non-html messages don't
// abide by the device's textScaleFactor
textScaler: TextScaler.noScaling,
// Pangea#
TextSpan(
children: _renderWithLineBreaks(
node.nodes,
@ -428,6 +435,9 @@ class HtmlMessage extends StatelessWidget {
child: Padding(
padding: EdgeInsets.only(left: fontSize),
child: Text.rich(
// #Pangea
textScaler: TextScaler.noScaling,
// Pangea#
TextSpan(
children: [
if (node.parent?.localName == 'ul')
@ -461,6 +471,9 @@ class HtmlMessage extends StatelessWidget {
),
),
child: Text.rich(
// #Pangea
textScaler: TextScaler.noScaling,
// Pangea#
TextSpan(
children: _renderWithLineBreaks(
node.nodes,
@ -543,6 +556,9 @@ class HtmlMessage extends StatelessWidget {
obscure = !obscure;
}),
child: Text.rich(
// #Pangea
textScaler: TextScaler.noScaling,
// Pangea#
TextSpan(
children: [
WidgetSpan(
@ -591,6 +607,9 @@ class HtmlMessage extends StatelessWidget {
obscure = !obscure;
}),
child: Text.rich(
// #Pangea
textScaler: TextScaler.noScaling,
// Pangea#
TextSpan(
children: _renderWithLineBreaks(
node.nodes,
@ -670,6 +689,9 @@ class HtmlMessage extends StatelessWidget {
},
// Pangea#
child: Text.rich(
// #Pangea
textScaler: TextScaler.noScaling,
// Pangea#
_renderHtml(
// #Pangea
// parser.parse(html).body ?? dom.Element.html(''),

View file

@ -107,6 +107,7 @@ class ChatListItemSubtitle extends StatelessWidget {
maxLines: pangeaMessageEvent.room.notificationCount >= 1 ? 2 : 1,
overflow: TextOverflow.ellipsis,
isMessage: false,
textScaler: MediaQuery.textScalerOf(context),
);
}

View file

@ -74,6 +74,7 @@ class MessageTokenText extends StatelessWidget {
return Text(
_pangeaMessageEvent.messageDisplayText,
style: _style,
textScaler: TextScaler.noScaling,
);
}
@ -108,6 +109,8 @@ class MessageTextWidget extends StatelessWidget {
final bool isMessage;
final ReadingAssistanceMode? readingAssistanceMode;
final TextScaler? textScaler;
const MessageTextWidget({
super.key,
required this.pangeaMessageEvent,
@ -123,6 +126,7 @@ class MessageTextWidget extends StatelessWidget {
this.isTransitionAnimation = false,
this.isMessage = true,
this.readingAssistanceMode,
this.textScaler,
});
@override
@ -152,6 +156,7 @@ class MessageTextWidget extends StatelessWidget {
softWrap: softWrap,
maxLines: maxLines,
overflow: overflow,
textScaler: textScaler,
);
}
@ -168,6 +173,7 @@ class MessageTextWidget extends StatelessWidget {
softWrap: softWrap ?? true,
maxLines: maxLines,
overflow: overflow ?? TextOverflow.clip,
textScaler: textScaler ?? TextScaler.noScaling,
text: TextSpan(
children:
tokenPositions.mapIndexed((int i, TokenPosition tokenPosition) {