Skip to content

Commit

Permalink
Fine Tune
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed Mar 30, 2023
1 parent 8664876 commit 1c15685
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Kimis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@
CODE_SIGN_ENTITLEMENTS = Kimis/Kimis.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 81;
CURRENT_PROJECT_VERSION = 90;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -1879,7 +1879,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8;
MARKETING_VERSION = 1.9;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.kimis.inhouse;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -1900,7 +1900,7 @@
CODE_SIGN_ENTITLEMENTS = Kimis/Kimis.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 81;
CURRENT_PROJECT_VERSION = 90;
DEVELOPMENT_TEAM = 6CMYQQFFT8;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -1918,7 +1918,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.8;
MARKETING_VERSION = 1.9;
PRODUCT_BUNDLE_IDENTIFIER = as.wiki.qaq.kimis;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
8 changes: 6 additions & 2 deletions Kimis/Backend/TextParser/Render/TextParser+Body.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ import Foundation
import UIKit

extension TextParser {
func compileNoteBody(withNote note: Note?) -> NSMutableAttributedString {
func compileNoteBody(withNote note: Note?, removeDuplicatedNewLines: Bool = false) -> NSMutableAttributedString {
guard let note else { return .init(string: "") }
guard let user = source?.users.retain(note.userId) else { return .init(string: "") }

var texts = [String]()
if let cw = note.contentWarning {
texts.append("\(cw)")
}
texts.append(note.text)
var content = note.text
while removeDuplicatedNewLines, content.contains("\n\n") {
content = content.replacingOccurrences(of: "\n\n", with: "\n")
}
texts.append(content)

let text = texts.joined(separator: "\n")
let ans = NSMutableAttributedString(string: text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ extension NotificationCell.MainCell.Snapshot {

let padding = IH.preferredPadding(usingWidth: width)
let tintSize = CGSize(width: 24, height: 24)
let avatarR = 42 + IH.preferredAvatarSizeOffset(usingWidth: width)
let avatarR = 40 + IH.preferredAvatarSizeOffset(usingWidth: width)
let avatarSize = CGSize(width: avatarR, height: avatarR) // two line of text ~= 41 point so
let horizontalSpacing: CGFloat = 8
let verticalSpacing: CGFloat = 8
Expand Down Expand Up @@ -256,17 +256,28 @@ extension NotificationCell.MainCell.Snapshot {
width: avatarSize.width,
height: avatarSize.height
)
titleText = textParser.compileUserHeader(with: user, lineBreak: true)
let titleWidth = contentWidth - avatarViewRect.width - horizontalSpacing
let titleHeight = titleText
.measureHeight(usingWidth: titleWidth, lineLimit: NotificationCell.MainCell.titleLineLimit)

titleText = textParser.compileUserHeader(with: user, lineBreak: true)
var titleHeight: CGFloat = 0
titleHeight = titleText.measureHeight(
usingWidth: titleWidth,
lineLimit: NotificationCell.MainCell.titleLineLimit
)

if titleHeight > avatarViewRect.height {
titleViewRect = CGRect(
x: avatarViewRect.maxX + horizontalSpacing,
y: avatarViewRect.minY,
width: titleWidth,
height: titleHeight
)
avatarViewRect = CGRect(
x: avatarViewRect.minX,
y: avatarViewRect.minY + (titleViewRect.height - avatarViewRect.height) / 2,
width: avatarViewRect.size.width,
height: avatarViewRect.size.height
)
} else {
titleViewRect = CGRect(
x: avatarViewRect.maxX + horizontalSpacing,
Expand All @@ -279,7 +290,7 @@ extension NotificationCell.MainCell.Snapshot {

var noteBody: [NSMutableAttributedString] = []
if let note = source.notes.retain(notification.noteId) {
let body = textParser.compileNoteBody(withNote: note)
let body = textParser.compileNoteBody(withNote: note, removeDuplicatedNewLines: true)
noteBody.append(body)

let attachmentCount = note.attachments.count
Expand All @@ -288,7 +299,7 @@ extension NotificationCell.MainCell.Snapshot {
let renoteId = note.renoteId,
let renote = source.notes.retain(renoteId)
{
let body = textParser.compileNoteBody(withNote: renote)
let body = textParser.compileNoteBody(withNote: renote, removeDuplicatedNewLines: true)
noteBody.append(body)
}
}
Expand Down

0 comments on commit 1c15685

Please sign in to comment.