Merge pull request #1400 from lightnin/master

Messages: Use large font for message body when message < 2 lines
pull/1052/head^2
Gordon Williams 2022-02-07 10:42:05 +00:00 committed by GitHub
commit 14986d6f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -270,9 +270,18 @@ function showMessage(msgid) {
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
}});
}
var bodyFont = fontMedium;
lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
// If body of message is only two lines long w/ large font, use large font.
var body=msg.body, bodyFont = fontLarge, lines;
if (body) {
var w = g.getWidth()-48;
if (g.setFont(bodyFont).stringWidth(body) > w * 2)
bodyFont = fontMedium;
if (g.setFont(bodyFont).stringWidth(body) > w) {
lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);
body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
}
}
layout = new Layout({ type:"v", c: [
{type:"h", fillx:1, bgCol:colBg, c: [
{ type:"btn", src:getMessageImage(msg), col:getMessageImageCol(msg), pad: 3, cb:()=>{