Skip to content

Commit bf354d4

Browse files
authored
Merge pull request #4323 from anyproto/ios-5490-format-misdesing
IOS-5490 Add text labels to chat formatting menu with horizontal layout
2 parents 0c04566 + c496b7b commit bf354d4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Anytype/Sources/PresentationLayer/Modules/Chat/Subviews/InputPanel/Input/ChatKeys+Menu.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Foundation
22
import Services
33

44
struct ChatMenuItemInfo {
5+
let title: String
56
let icon: ImageAsset
67
let markupType: MarkupType
78
}
@@ -19,15 +20,15 @@ extension NSAttributedString.Key {
1920
func chatToggleMenuItemInfo() -> ChatMenuItemInfo? {
2021
switch self {
2122
case .chatBold:
22-
return ChatMenuItemInfo(icon: .TextStyles.bold, markupType: .bold)
23+
return ChatMenuItemInfo(title: Loc.TextStyle.Bold.title, icon: .TextStyles.bold, markupType: .bold)
2324
case .chatItalic:
24-
return ChatMenuItemInfo(icon: .TextStyles.italic, markupType: .italic)
25+
return ChatMenuItemInfo(title: Loc.TextStyle.Italic.title, icon: .TextStyles.italic, markupType: .italic)
2526
case .chatKeyboard:
26-
return ChatMenuItemInfo(icon: .TextStyles.code, markupType: .keyboard)
27+
return ChatMenuItemInfo(title: Loc.TextStyle.Code.title, icon: .TextStyles.code, markupType: .keyboard)
2728
case .chatStrikethrough:
28-
return ChatMenuItemInfo(icon: .TextStyles.strikethrough, markupType: .strikethrough)
29+
return ChatMenuItemInfo(title: Loc.TextStyle.Strikethrough.title, icon: .TextStyles.strikethrough, markupType: .strikethrough)
2930
case .chatUnderscored:
30-
return ChatMenuItemInfo(icon: .TextStyles.underline, markupType: .underscored)
31+
return ChatMenuItemInfo(title: Loc.TextStyle.Underline.title, icon: .TextStyles.underline, markupType: .underscored)
3132
default:
3233
return nil
3334
}

Anytype/Sources/PresentationLayer/Modules/Chat/Subviews/InputPanel/Input/ChatTextViewCoordinator.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ final class ChatTextViewCoordinator: NSObject, UITextViewDelegate, NSTextContent
248248

249249
let chatMenuKeys = NSAttributedString.Key.chatToggleMenuKeys
250250
let toggleMenuItems = chatMenuKeys.compactMap { makeToggleMenuAction(textView, editMenuForTextIn: range, attributed: $0) }
251-
let format = UIMenu(title: Loc.format, children: toggleMenuItems)
251+
var format = UIMenu(title: Loc.format, children: toggleMenuItems)
252+
format.preferredElementSize = .small
252253

253254
let linkToAction = UIAction(title: Loc.link) { [linkTo] _ in
254255
linkTo?(range)
@@ -332,7 +333,7 @@ final class ChatTextViewCoordinator: NSObject, UITextViewDelegate, NSTextContent
332333
guard let info = attributed.chatToggleMenuItemInfo() else { return nil }
333334

334335
let containsNoStyle = textView.attributedText.containsNilAttribute(attributed, in: range)
335-
return UIAction(image: UIImage(asset: info.icon)) { [weak self] _ in
336+
return UIAction(title: info.title, image: UIImage(asset: info.icon)) { [weak self] _ in
336337
_ = self?.addStyle(
337338
textView: textView,
338339
type: info.markupType,

0 commit comments

Comments
 (0)