diff --git a/Adamant/Modules/Chat/View/ChatViewController.swift b/Adamant/Modules/Chat/View/ChatViewController.swift index 3467db538..def74b149 100644 --- a/Adamant/Modules/Chat/View/ChatViewController.swift +++ b/Adamant/Modules/Chat/View/ChatViewController.swift @@ -659,7 +659,9 @@ private extension ChatViewController { animations: { self.messageInputBar.topStackView.addArrangedSubview(self.replyView) }) - messageInputBar.inputTextView.becomeFirstResponder() + if viewAppeared { + messageInputBar.inputTextView.becomeFirstResponder() + } } replyView.update(with: message) diff --git a/Adamant/Modules/Chat/View/Managers/FixedTextMessageSizeCalculator.swift b/Adamant/Modules/Chat/View/Managers/FixedTextMessageSizeCalculator.swift index 33c4e5038..251f45749 100644 --- a/Adamant/Modules/Chat/View/Managers/FixedTextMessageSizeCalculator.swift +++ b/Adamant/Modules/Chat/View/Managers/FixedTextMessageSizeCalculator.swift @@ -127,6 +127,8 @@ let textContainer = NSTextContainer( size: CGSize(width: maxWidth, height: .greatestFiniteMagnitude) ) + textContainer.lineFragmentPadding = .zero + let layoutManager = NSLayoutManager() layoutManager.addTextContainer(textContainer) @@ -134,7 +136,6 @@ let textStorage = NSTextStorage(attributedString: attributedText) textStorage.addLayoutManager(layoutManager) - let range = NSRange(location: 0, length: attributedText.length) let rect = layoutManager.usedRect(for: textContainer) return rect.integral.size @@ -170,5 +171,5 @@ private let messageLabelFont = UIFont.preferredFont(forTextStyle: .body) /// Additional width to fix incorrect size calculating - private let additionalWidth: CGFloat = 5 +private let additionalWidth: CGFloat = 5 private let additionalHeight: CGFloat = 5 diff --git a/Adamant/Modules/Chat/View/Subviews/ChatBaseMessage/ChatMessageCell.swift b/Adamant/Modules/Chat/View/Subviews/ChatBaseMessage/ChatMessageCell.swift index 802d7670a..6e6d89c8a 100644 --- a/Adamant/Modules/Chat/View/Subviews/ChatBaseMessage/ChatMessageCell.swift +++ b/Adamant/Modules/Chat/View/Subviews/ChatBaseMessage/ChatMessageCell.swift @@ -172,10 +172,7 @@ final class ChatMessageCell: TextMessageCell, ChatModelView { func updateOwnReaction() { ownReactionLabel.text = getReaction(for: model.address) - ownReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func updateOpponentReaction() { @@ -206,10 +203,7 @@ final class ChatMessageCell: TextMessageCell, ChatModelView { } opponentReactionLabel.attributedText = fullString - opponentReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func getSenderPublicKeyInReaction(for senderAddress: String) -> String? { diff --git a/Adamant/Modules/Chat/View/Subviews/ChatReply/ChatMessageReplyCell.swift b/Adamant/Modules/Chat/View/Subviews/ChatReply/ChatMessageReplyCell.swift index 38f5dd4b9..f5ebe540d 100644 --- a/Adamant/Modules/Chat/View/Subviews/ChatReply/ChatMessageReplyCell.swift +++ b/Adamant/Modules/Chat/View/Subviews/ChatReply/ChatMessageReplyCell.swift @@ -250,10 +250,7 @@ final class ChatMessageReplyCell: MessageContentCell, ChatModelView { func updateOwnReaction() { ownReactionLabel.text = getReaction(for: model.address) - ownReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func updateOpponentReaction() { @@ -284,10 +281,7 @@ final class ChatMessageReplyCell: MessageContentCell, ChatModelView { } opponentReactionLabel.attributedText = fullString - opponentReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func getSenderPublicKeyInReaction(for senderAddress: String) -> String? { diff --git a/Adamant/Modules/Chat/View/Subviews/ChatTransaction/Container/ChatTransactionContainerView.swift b/Adamant/Modules/Chat/View/Subviews/ChatTransaction/Container/ChatTransactionContainerView.swift index 466917d9e..4ffd6ab26 100644 --- a/Adamant/Modules/Chat/View/Subviews/ChatTransaction/Container/ChatTransactionContainerView.swift +++ b/Adamant/Modules/Chat/View/Subviews/ChatTransaction/Container/ChatTransactionContainerView.swift @@ -205,10 +205,7 @@ private extension ChatTransactionContainerView { func updateOwnReaction() { ownReactionLabel.text = getReaction(for: model.address) - ownReactionLabel.backgroundColor = model.content.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func updateOpponentReaction() { @@ -239,10 +236,7 @@ private extension ChatTransactionContainerView { } opponentReactionLabel.attributedText = fullString - opponentReactionLabel.backgroundColor = model.content.backgroundColor.uiColor.mixin( - infusion: .lightGray, - alpha: 0.15 - ) + opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground } func getSenderPublicKeyInReaction(for senderAddress: String) -> String? { diff --git a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift index d72a6ae5d..4f81b7fdb 100644 --- a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift +++ b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift @@ -191,7 +191,7 @@ final class ChatViewModel: NSObject { } func presentKeyboardOnStartIfNeeded() { - guard !inputText.isEmpty && replyMessage == nil else { return } + guard !inputText.isEmpty || replyMessage != nil else { return } presentKeyboard.send() } diff --git a/Adamant/Modules/PartnerQR/PartnerQRView.swift b/Adamant/Modules/PartnerQR/PartnerQRView.swift index 860596f72..2d8117d0d 100644 --- a/Adamant/Modules/PartnerQR/PartnerQRView.swift +++ b/Adamant/Modules/PartnerQR/PartnerQRView.swift @@ -12,33 +12,37 @@ struct PartnerQRView: View { @ObservedObject var viewModel: PartnerQRViewModel var body: some View { - Form { - infoSection() - toggleSection() - buttonSection() - } - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .principal) { - toolbar() + GeometryReader { geometry in + Form { + infoSection() + toggleSection() + buttonSection() + } + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .principal) { + toolbar(maxWidth: geometry.size.width) + } } } } } private extension PartnerQRView { - func toolbar() -> some View { - Button(action: { - viewModel.renameContact() - }) { + func toolbar(maxWidth: CGFloat) -> some View { + Button(action: viewModel.renameContact) { HStack { if let uiImage = viewModel.partnerImage { Image(uiImage: uiImage) .resizable() .frame(squareSize: viewModel.partnerImageSize) } - Text(viewModel.partnerName).font(.headline) + Text(viewModel.partnerName) + .font(.headline) + .minimumScaleFactor(0.7) + .lineLimit(1) } + .frame(maxWidth: maxWidth - toolbarSpace, alignment: .center) } } @@ -101,3 +105,5 @@ private extension PartnerQRView { } } } + +private let toolbarSpace: CGFloat = 150 diff --git a/CommonKit/Sources/CommonKit/ExtensionsTools/ExtensionsApi.swift b/CommonKit/Sources/CommonKit/ExtensionsTools/ExtensionsApi.swift index 3e9d0893f..5d8080212 100644 --- a/CommonKit/Sources/CommonKit/ExtensionsTools/ExtensionsApi.swift +++ b/CommonKit/Sources/CommonKit/ExtensionsTools/ExtensionsApi.swift @@ -16,7 +16,7 @@ public final class ExtensionsApi { public private(set) lazy var nodes: [Node] = { let nodes = keychainStore.get(nodesStoreKey) ?? AdamantResources.nodes - return nodes.getAllowedNodes(sortedBySpeedDescending: true, needWS: false).reversed() + return nodes.filter { $0.isEnabled }.shuffled() }() private var currentNode: Node? diff --git a/CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift b/CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift index 5e4077409..640ae44d5 100644 --- a/CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift +++ b/CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift @@ -119,8 +119,8 @@ extension UIColor { /// Picked reaction background color public static var pickedReactionBackground: UIColor { - let colorWhiteTheme = UIColor(red: 0.88, green: 0.88, blue: 0.88, alpha: 1.0) - let colorDarkTheme = UIColor(red: 0.278, green: 0.278, blue: 0.278, alpha: 1.0) + let colorWhiteTheme = UIColor(red: 0.92, green: 0.925, blue: 0.93, alpha: 0.85) + let colorDarkTheme = UIColor(red: 0.329, green: 0.329, blue: 0.329, alpha: 1.0) return returnColorByTheme(colorWhiteTheme: colorWhiteTheme, colorDarkTheme: colorDarkTheme) } diff --git a/NotificationServiceExtension/NotificationService.swift b/NotificationServiceExtension/NotificationService.swift index 1749e4bd2..1b3178b1c 100644 --- a/NotificationServiceExtension/NotificationService.swift +++ b/NotificationServiceExtension/NotificationService.swift @@ -121,10 +121,12 @@ class NotificationService: UNNotificationServiceExtension { // MARK: Messages case .chatMessage: guard let chat = transaction.asset.chat, - let message = core.decodeMessage(rawMessage: chat.message, - rawNonce: chat.ownMessage, - senderPublicKey: partnerPublicKey, - privateKey: keypair.privateKey) else { + let message = core.decodeMessage( + rawMessage: chat.message, + rawNonce: chat.ownMessage, + senderPublicKey: partnerPublicKey, + privateKey: keypair.privateKey + ) else { break }