mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
Use textDefaultFont in all variants of the InputToolbarView
This commit is contained in:
@@ -382,6 +382,8 @@ typedef enum : NSUInteger
|
||||
*/
|
||||
@property (nonatomic) NSAttributedString *attributedTextMessage;
|
||||
|
||||
@property (nonatomic, readonly, nonnull) UIFont *textDefaultFont;
|
||||
|
||||
- (void)dismissValidationView:(MXKImageView*)validationView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -358,6 +358,10 @@
|
||||
self.textMessage = [NSString stringWithFormat:@"%@%@", self.textMessage, text];
|
||||
}
|
||||
|
||||
- (UIFont *)textDefaultFont
|
||||
{
|
||||
return [UIFont systemFontOfSize:15.f];
|
||||
}
|
||||
|
||||
#pragma mark - MXKFileSizes
|
||||
|
||||
|
||||
@@ -79,8 +79,9 @@ class PillsFormatter: NSObject {
|
||||
/// - Parameters:
|
||||
/// - markdownString: An attributed string with markdown formatting
|
||||
/// - roomState: The current room state
|
||||
/// - font: The font to use for the pill text
|
||||
/// - Returns: A new attributed string with pills.
|
||||
static func insertPills(in markdownString: NSAttributedString, roomState: MXRoomState) -> NSAttributedString {
|
||||
static func insertPills(in markdownString: NSAttributedString, roomState: MXRoomState, font: UIFont) -> NSAttributedString {
|
||||
// Create a regexp that detects markdown links.
|
||||
let pattern = "\\[([^\\]]+)\\]\\(([^\\)\"\\s]+)(?:\\s+\"(.*)\")?\\)"
|
||||
guard let regExp = try? NSRegularExpression(pattern: pattern) else { return markdownString }
|
||||
@@ -108,7 +109,7 @@ class PillsFormatter: NSObject {
|
||||
let roomMember = roomMember(withUserId: userId,
|
||||
roomState: roomState,
|
||||
andLatestRoomState: nil) {
|
||||
let attachmentString = mentionPill(withRoomMember: roomMember, isHighlighted: false, font: UIFont.systemFont(ofSize: 14))
|
||||
let attachmentString = mentionPill(withRoomMember: roomMember, isHighlighted: false, font: font)
|
||||
mutable.replaceCharacters(in: match.range, with: attachmentString)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ extension RoomViewController {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: UIFont.systemFont(ofSize: 14)))
|
||||
font: inputToolbarView.textDefaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ extension RoomViewController {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: UIFont.systemFont(ofSize: 14)))
|
||||
font: inputToolbarView.textDefaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
@@ -169,7 +169,9 @@ extension RoomViewController {
|
||||
// Switching from RTE -> plain, replace markdown links with Pills.
|
||||
if !wysiwygInputToolbar.textFormattingEnabled, #available(iOS 15.0, *),
|
||||
let attributedText = wysiwygInputToolbar.attributedTextMessage {
|
||||
wysiwygInputToolbar.attributedTextMessage = PillsFormatter.insertPills(in: attributedText, roomState: self.roomDataSource.roomState)
|
||||
wysiwygInputToolbar.attributedTextMessage = PillsFormatter.insertPills(in: attributedText,
|
||||
roomState: self.roomDataSource.roomState,
|
||||
font: self.inputToolbarView.textDefaultFont)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +283,7 @@ extension RoomViewController {
|
||||
|
||||
return PillsFormatter.mentionPill(withRoomMember: member,
|
||||
isHighlighted: false,
|
||||
font: UIFont.systemFont(ofSize: 14))
|
||||
font: inputToolbarView.textDefaultFont)
|
||||
}
|
||||
|
||||
@objc func showWaitingOtherParticipantHeader() {
|
||||
|
||||
@@ -99,6 +99,10 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
|
||||
self.wysiwygViewModel.textView.attributedText = newValue
|
||||
}
|
||||
}
|
||||
|
||||
override var textDefaultFont: UIFont {
|
||||
return self.wysiwygViewModel.textView.font ?? UIFont.preferredFont(forTextStyle: .body)
|
||||
}
|
||||
|
||||
var isMaximised: Bool {
|
||||
wysiwygViewModel.maximised
|
||||
|
||||
Reference in New Issue
Block a user