Skip to content

Commit

Permalink
Merge pull request #494 from Adamant-im/develop
Browse files Browse the repository at this point in the history
Release 3.6.2
  • Loading branch information
StanislavDevIOS authored Jun 13, 2024
2 parents b038d03 + 0863b38 commit 3040128
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 49 deletions.
4 changes: 3 additions & 1 deletion Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@
let textContainer = NSTextContainer(
size: CGSize(width: maxWidth, height: .greatestFiniteMagnitude)
)
textContainer.lineFragmentPadding = .zero

let layoutManager = NSLayoutManager()

layoutManager.addTextContainer(textContainer)

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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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? {
Expand Down
2 changes: 1 addition & 1 deletion Adamant/Modules/Chat/ViewModel/ChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
34 changes: 20 additions & 14 deletions Adamant/Modules/PartnerQR/PartnerQRView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -101,3 +105,5 @@ private extension PartnerQRView {
}
}
}

private let toolbarSpace: CGFloat = 150
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
10 changes: 6 additions & 4 deletions NotificationServiceExtension/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3040128

Please sign in to comment.