Skip to content

Commit 3040128

Browse files
Merge pull request #494 from Adamant-im/develop
Release 3.6.2
2 parents b038d03 + 0863b38 commit 3040128

File tree

10 files changed

+42
-49
lines changed

10 files changed

+42
-49
lines changed

Adamant/Modules/Chat/View/ChatViewController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,9 @@ private extension ChatViewController {
659659
animations: {
660660
self.messageInputBar.topStackView.addArrangedSubview(self.replyView)
661661
})
662-
messageInputBar.inputTextView.becomeFirstResponder()
662+
if viewAppeared {
663+
messageInputBar.inputTextView.becomeFirstResponder()
664+
}
663665
}
664666

665667
replyView.update(with: message)

Adamant/Modules/Chat/View/Managers/FixedTextMessageSizeCalculator.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@
127127
let textContainer = NSTextContainer(
128128
size: CGSize(width: maxWidth, height: .greatestFiniteMagnitude)
129129
)
130+
textContainer.lineFragmentPadding = .zero
131+
130132
let layoutManager = NSLayoutManager()
131133

132134
layoutManager.addTextContainer(textContainer)
133135

134136
let textStorage = NSTextStorage(attributedString: attributedText)
135137
textStorage.addLayoutManager(layoutManager)
136138

137-
let range = NSRange(location: 0, length: attributedText.length)
138139
let rect = layoutManager.usedRect(for: textContainer)
139140

140141
return rect.integral.size
@@ -170,5 +171,5 @@
170171
private let messageLabelFont = UIFont.preferredFont(forTextStyle: .body)
171172

172173
/// Additional width to fix incorrect size calculating
173-
private let additionalWidth: CGFloat = 5
174+
private let additionalWidth: CGFloat = 5
174175
private let additionalHeight: CGFloat = 5

Adamant/Modules/Chat/View/Subviews/ChatBaseMessage/ChatMessageCell.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ final class ChatMessageCell: TextMessageCell, ChatModelView {
172172

173173
func updateOwnReaction() {
174174
ownReactionLabel.text = getReaction(for: model.address)
175-
ownReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin(
176-
infusion: .lightGray,
177-
alpha: 0.15
178-
)
175+
ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground
179176
}
180177

181178
func updateOpponentReaction() {
@@ -206,10 +203,7 @@ final class ChatMessageCell: TextMessageCell, ChatModelView {
206203
}
207204

208205
opponentReactionLabel.attributedText = fullString
209-
opponentReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin(
210-
infusion: .lightGray,
211-
alpha: 0.15
212-
)
206+
opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground
213207
}
214208

215209
func getSenderPublicKeyInReaction(for senderAddress: String) -> String? {

Adamant/Modules/Chat/View/Subviews/ChatReply/ChatMessageReplyCell.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@ final class ChatMessageReplyCell: MessageContentCell, ChatModelView {
250250

251251
func updateOwnReaction() {
252252
ownReactionLabel.text = getReaction(for: model.address)
253-
ownReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin(
254-
infusion: .lightGray,
255-
alpha: 0.15
256-
)
253+
ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground
257254
}
258255

259256
func updateOpponentReaction() {
@@ -284,10 +281,7 @@ final class ChatMessageReplyCell: MessageContentCell, ChatModelView {
284281
}
285282

286283
opponentReactionLabel.attributedText = fullString
287-
opponentReactionLabel.backgroundColor = model.backgroundColor.uiColor.mixin(
288-
infusion: .lightGray,
289-
alpha: 0.15
290-
)
284+
opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground
291285
}
292286

293287
func getSenderPublicKeyInReaction(for senderAddress: String) -> String? {

Adamant/Modules/Chat/View/Subviews/ChatTransaction/Container/ChatTransactionContainerView.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ private extension ChatTransactionContainerView {
205205

206206
func updateOwnReaction() {
207207
ownReactionLabel.text = getReaction(for: model.address)
208-
ownReactionLabel.backgroundColor = model.content.backgroundColor.uiColor.mixin(
209-
infusion: .lightGray,
210-
alpha: 0.15
211-
)
208+
ownReactionLabel.backgroundColor = .adamant.pickedReactionBackground
212209
}
213210

214211
func updateOpponentReaction() {
@@ -239,10 +236,7 @@ private extension ChatTransactionContainerView {
239236
}
240237

241238
opponentReactionLabel.attributedText = fullString
242-
opponentReactionLabel.backgroundColor = model.content.backgroundColor.uiColor.mixin(
243-
infusion: .lightGray,
244-
alpha: 0.15
245-
)
239+
opponentReactionLabel.backgroundColor = .adamant.pickedReactionBackground
246240
}
247241

248242
func getSenderPublicKeyInReaction(for senderAddress: String) -> String? {

Adamant/Modules/Chat/ViewModel/ChatViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ final class ChatViewModel: NSObject {
191191
}
192192

193193
func presentKeyboardOnStartIfNeeded() {
194-
guard !inputText.isEmpty && replyMessage == nil else { return }
194+
guard !inputText.isEmpty || replyMessage != nil else { return }
195195
presentKeyboard.send()
196196
}
197197

Adamant/Modules/PartnerQR/PartnerQRView.swift

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,37 @@ struct PartnerQRView: View {
1212
@ObservedObject var viewModel: PartnerQRViewModel
1313

1414
var body: some View {
15-
Form {
16-
infoSection()
17-
toggleSection()
18-
buttonSection()
19-
}
20-
.navigationBarTitleDisplayMode(.inline)
21-
.toolbar {
22-
ToolbarItem(placement: .principal) {
23-
toolbar()
15+
GeometryReader { geometry in
16+
Form {
17+
infoSection()
18+
toggleSection()
19+
buttonSection()
20+
}
21+
.navigationBarTitleDisplayMode(.inline)
22+
.toolbar {
23+
ToolbarItem(placement: .principal) {
24+
toolbar(maxWidth: geometry.size.width)
25+
}
2426
}
2527
}
2628
}
2729
}
2830

2931
private extension PartnerQRView {
30-
func toolbar() -> some View {
31-
Button(action: {
32-
viewModel.renameContact()
33-
}) {
32+
func toolbar(maxWidth: CGFloat) -> some View {
33+
Button(action: viewModel.renameContact) {
3434
HStack {
3535
if let uiImage = viewModel.partnerImage {
3636
Image(uiImage: uiImage)
3737
.resizable()
3838
.frame(squareSize: viewModel.partnerImageSize)
3939
}
40-
Text(viewModel.partnerName).font(.headline)
40+
Text(viewModel.partnerName)
41+
.font(.headline)
42+
.minimumScaleFactor(0.7)
43+
.lineLimit(1)
4144
}
45+
.frame(maxWidth: maxWidth - toolbarSpace, alignment: .center)
4246
}
4347
}
4448

@@ -101,3 +105,5 @@ private extension PartnerQRView {
101105
}
102106
}
103107
}
108+
109+
private let toolbarSpace: CGFloat = 150

CommonKit/Sources/CommonKit/ExtensionsTools/ExtensionsApi.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public final class ExtensionsApi {
1616

1717
public private(set) lazy var nodes: [Node] = {
1818
let nodes = keychainStore.get(nodesStoreKey) ?? AdamantResources.nodes
19-
return nodes.getAllowedNodes(sortedBySpeedDescending: true, needWS: false).reversed()
19+
return nodes.filter { $0.isEnabled }.shuffled()
2020
}()
2121

2222
private var currentNode: Node?

CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ extension UIColor {
119119

120120
/// Picked reaction background color
121121
public static var pickedReactionBackground: UIColor {
122-
let colorWhiteTheme = UIColor(red: 0.88, green: 0.88, blue: 0.88, alpha: 1.0)
123-
let colorDarkTheme = UIColor(red: 0.278, green: 0.278, blue: 0.278, alpha: 1.0)
122+
let colorWhiteTheme = UIColor(red: 0.92, green: 0.925, blue: 0.93, alpha: 0.85)
123+
let colorDarkTheme = UIColor(red: 0.329, green: 0.329, blue: 0.329, alpha: 1.0)
124124
return returnColorByTheme(colorWhiteTheme: colorWhiteTheme, colorDarkTheme: colorDarkTheme)
125125
}
126126

NotificationServiceExtension/NotificationService.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ class NotificationService: UNNotificationServiceExtension {
121121
// MARK: Messages
122122
case .chatMessage:
123123
guard let chat = transaction.asset.chat,
124-
let message = core.decodeMessage(rawMessage: chat.message,
125-
rawNonce: chat.ownMessage,
126-
senderPublicKey: partnerPublicKey,
127-
privateKey: keypair.privateKey) else {
124+
let message = core.decodeMessage(
125+
rawMessage: chat.message,
126+
rawNonce: chat.ownMessage,
127+
senderPublicKey: partnerPublicKey,
128+
privateKey: keypair.privateKey
129+
) else {
128130
break
129131
}
130132

0 commit comments

Comments
 (0)