Skip to content

Commit b038d03

Browse files
Merge pull request #487 from Adamant-im/develop
Release 3.6.1
2 parents c187d78 + d927ac3 commit b038d03

File tree

44 files changed

+512
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+512
-310
lines changed

Adamant.xcodeproj/project.pbxproj

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
265AA1622B74E6B900CF98B0 /* ChatPreservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 265AA1612B74E6B900CF98B0 /* ChatPreservation.swift */; };
1111
269E13522B594B2D008D1CA7 /* AccountFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269E13512B594B2D008D1CA7 /* AccountFooterView.swift */; };
12+
26A975FF2B7E843E0095C367 /* SelectTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A975FE2B7E843E0095C367 /* SelectTextView.swift */; };
13+
26A976012B7E852E0095C367 /* ChatSelectTextViewFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */; };
1214
3A20D93B2AE7F316005475A6 /* AdamantTransactionDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A20D93A2AE7F316005475A6 /* AdamantTransactionDetails.swift */; };
1315
3A2F55F92AC6F308000A3F26 /* CoinTransaction+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2F55F72AC6F308000A3F26 /* CoinTransaction+CoreDataClass.swift */; };
1416
3A2F55FA2AC6F308000A3F26 /* CoinTransaction+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2F55F82AC6F308000A3F26 /* CoinTransaction+CoreDataProperties.swift */; };
@@ -130,7 +132,6 @@
130132
6416B1A321AD7EA1006089AC /* LskTransactionDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6416B1A221AD7EA1006089AC /* LskTransactionDetailsViewController.swift */; };
131133
6416B1A721B024B6006089AC /* LskWalletService+Send.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6416B1A621B024B6006089AC /* LskWalletService+Send.swift */; };
132134
644793C32166314A00FC4CF5 /* OnboardPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 644793C22166314A00FC4CF5 /* OnboardPage.swift */; };
133-
644793C52166315900FC4CF5 /* OnboardPage.xib in Resources */ = {isa = PBXBuildFile; fileRef = 644793C42166315900FC4CF5 /* OnboardPage.xib */; };
134135
6448C291235CA6E100F3F15B /* ERC20WalletService+RichMessageProviderWithStatusCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA64235CA0930033B936 /* ERC20WalletService+RichMessageProviderWithStatusCheck.swift */; };
135136
6449BA68235CA0930033B936 /* ERC20WalletService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA5E235CA0930033B936 /* ERC20WalletService.swift */; };
136137
6449BA69235CA0930033B936 /* ERC20TransferViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA5F235CA0930033B936 /* ERC20TransferViewController.swift */; };
@@ -655,6 +656,8 @@
655656
/* Begin PBXFileReference section */
656657
265AA1612B74E6B900CF98B0 /* ChatPreservation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatPreservation.swift; sourceTree = "<group>"; };
657658
269E13512B594B2D008D1CA7 /* AccountFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountFooterView.swift; sourceTree = "<group>"; };
659+
26A975FE2B7E843E0095C367 /* SelectTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTextView.swift; sourceTree = "<group>"; };
660+
26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatSelectTextViewFactory.swift; sourceTree = "<group>"; };
658661
33975C0D891698AA7E74EBCC /* Pods_Adamant.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Adamant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
659662
36AB8CE9537B3B873972548B /* Pods_AdmCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdmCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
660663
3A20D93A2AE7F316005475A6 /* AdamantTransactionDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdamantTransactionDetails.swift; sourceTree = "<group>"; };
@@ -771,7 +774,6 @@
771774
6416B1A221AD7EA1006089AC /* LskTransactionDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LskTransactionDetailsViewController.swift; sourceTree = "<group>"; };
772775
6416B1A621B024B6006089AC /* LskWalletService+Send.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LskWalletService+Send.swift"; sourceTree = "<group>"; };
773776
644793C22166314A00FC4CF5 /* OnboardPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardPage.swift; sourceTree = "<group>"; };
774-
644793C42166315900FC4CF5 /* OnboardPage.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OnboardPage.xib; sourceTree = "<group>"; };
775777
6449BA5E235CA0930033B936 /* ERC20WalletService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20WalletService.swift; sourceTree = "<group>"; };
776778
6449BA5F235CA0930033B936 /* ERC20TransferViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20TransferViewController.swift; sourceTree = "<group>"; };
777779
6449BA60235CA0930033B936 /* ERC20Wallet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20Wallet.swift; sourceTree = "<group>"; };
@@ -1705,6 +1707,8 @@
17051707
93996A9829682690008D080B /* Subviews */,
17061708
938F7D592955C8CB001915CA /* Managers */,
17071709
938F7D632955C94F001915CA /* ChatViewController.swift */,
1710+
26A975FE2B7E843E0095C367 /* SelectTextView.swift */,
1711+
26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */,
17081712
);
17091713
path = View;
17101714
sourceTree = "<group>";
@@ -2165,7 +2169,6 @@
21652169
645FEB32213E72C100D6BA2D /* OnboardViewController.swift */,
21662170
645FEB33213E72C100D6BA2D /* OnboardViewController.xib */,
21672171
644793C22166314A00FC4CF5 /* OnboardPage.swift */,
2168-
644793C42166315900FC4CF5 /* OnboardPage.xib */,
21692172
E96BBE3021F70F5E009AA738 /* ReadonlyTextView.swift */,
21702173
);
21712174
path = Onboard;
@@ -2803,7 +2806,6 @@
28032806
4198D57F28C8B834009337F2 /* short-success.mp3 in Resources */,
28042807
4198D57D28C8B7FA009337F2 /* relax-message-tone.mp3 in Resources */,
28052808
E983AE2D20E6720D00497E1A /* AccountFooter.xib in Resources */,
2806-
644793C52166315900FC4CF5 /* OnboardPage.xib in Resources */,
28072809
E95F85C8200A9B070070534A /* ChatTableViewCell.xib in Resources */,
28082810
E913C8F91FFFA51D001A83F7 /* Assets.xcassets in Resources */,
28092811
93496BB42A6CAED100DD062F /* Roboto_400_italic.ttf in Resources */,
@@ -3010,6 +3012,7 @@
30103012
648CE3A6229AD1CD0070A2CC /* DashWalletService+Send.swift in Sources */,
30113013
E987024920C2B1F700E393F4 /* AdamantChatsProvider+fakeMessages.swift in Sources */,
30123014
6403F5E222723F7500D58779 /* DashWallet.swift in Sources */,
3015+
26A975FF2B7E843E0095C367 /* SelectTextView.swift in Sources */,
30133016
93294B822AAD0BB400911109 /* BtcWalletFactory.swift in Sources */,
30143017
648DD7A42237DB9E00B811FD /* DogeWalletService+Send.swift in Sources */,
30153018
93294B7D2AAD067000911109 /* AppContainer.swift in Sources */,
@@ -3117,6 +3120,7 @@
31173120
9399F5ED29A85A48006C3E30 /* ChatCacheService.swift in Sources */,
31183121
3A9015A92A615893002A2464 /* ChatMessagesListViewModel.swift in Sources */,
31193122
936658952B0AC15300BDB2D3 /* Node+UI.swift in Sources */,
3123+
26A976012B7E852E0095C367 /* ChatSelectTextViewFactory.swift in Sources */,
31203124
41A1995429D56E340031AD75 /* ChatMessageReplyCell.swift in Sources */,
31213125
93294B872AAD0E0A00911109 /* AdmWallet.swift in Sources */,
31223126
6449BA6B235CA0930033B936 /* ERC20TransactionDetailsViewController.swift in Sources */,
@@ -3754,7 +3758,7 @@
37543758
"$(inherited)",
37553759
"@executable_path/Frameworks",
37563760
);
3757-
MARKETING_VERSION = 3.6.0;
3761+
MARKETING_VERSION = 3.6.1;
37583762
PRODUCT_BUNDLE_IDENTIFIER = "im.adamant.adamant-messenger-dev";
37593763
PRODUCT_NAME = "$(TARGET_NAME)";
37603764
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -3785,7 +3789,7 @@
37853789
"$(inherited)",
37863790
"@executable_path/Frameworks",
37873791
);
3788-
MARKETING_VERSION = 3.6.0;
3792+
MARKETING_VERSION = 3.6.1;
37893793
PRODUCT_BUNDLE_IDENTIFIER = "im.adamant.adamant-messenger";
37903794
PRODUCT_NAME = "$(TARGET_NAME)";
37913795
PROVISIONING_PROFILE_SPECIFIER = "";

Adamant/Helpers/String+localized.swift

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ extension String.adamant {
106106
static var unknownError: String {
107107
String.localized("Error.UnknownError", comment: "Shared unknown error")
108108
}
109+
static func admNodeErrorMessage(_ coin: String) -> String {
110+
String.localizedStringWithFormat(.localized("ApiService.InternalError.NoAdmNodesAvailable", comment: "No active ADM nodes to fetch the partner's %@ address"), coin)
111+
}
109112

110113
static var notEnoughMoney: String {
111114
String.localized("WalletServices.SharedErrors.notEnoughMoney", comment: "Wallet Services: Shared error, user do not have enought money.")

Adamant/Modules/Chat/ChatLocalization.swift

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ extension String.adamant {
5454
static var report: String {
5555
String.localized("Chats.Report", comment: "Report")
5656
}
57+
static var selectText: String {
58+
String.localized("Chats.SelectText", comment: "Select Text")
59+
}
5760
static var reply: String {
5861
String.localized("Chats.Reply", comment: "Reply")
5962
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// ChatSelectTextViewFactory.swift
3+
// Adamant
4+
//
5+
// Created by Yana Silosieva on 13.02.2024.
6+
// Copyright © 2024 Adamant. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import Swinject
11+
import UIKit
12+
import SwiftUI
13+
14+
struct ChatSelectTextViewFactory {
15+
@MainActor
16+
func makeViewController(text: String) -> UIViewController {
17+
let view = SelectTextView(text: text)
18+
19+
return UIHostingController(
20+
rootView: view
21+
)
22+
}
23+
}

Adamant/Modules/Chat/View/ChatViewController.swift

+20-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ final class ChatViewController: MessagesViewController {
108108
configureGestures()
109109
setupObservers()
110110
viewModel.loadFirstMessagesIfNeeded()
111-
viewModel.presentKeyboardOnStartIfNeeded()
112111
}
113112

114113
override func viewWillLayoutSubviews() {
@@ -124,12 +123,21 @@ final class ChatViewController: MessagesViewController {
124123
)
125124
}
126125

126+
override func viewWillAppear(_ animated: Bool) {
127+
super.viewWillAppear(animated)
128+
viewModel.updatePartnerName()
129+
}
130+
127131
override func viewDidAppear(_ animated: Bool) {
128132
super.viewDidAppear(animated)
129133
defer { viewAppeared = true }
130134
inputBar.isUserInteractionEnabled = true
131135
chatMessagesCollectionView.fixedBottomOffset = nil
132136

137+
if !viewAppeared {
138+
viewModel.presentKeyboardOnStartIfNeeded()
139+
}
140+
133141
guard isMacOS, !viewAppeared else { return }
134142
focusInputBarWithoutAnimation()
135143
}
@@ -371,6 +379,12 @@ private extension ChatViewController {
371379
viewModel.didTapPartnerQR
372380
.sink { [weak self] in self?.didTapPartenerQR(partner: $0) }
373381
.store(in: &subscriptions)
382+
383+
viewModel.didTapSelectText
384+
.sink { [weak self] text in
385+
self?.didTapSelectText(text: text)
386+
}
387+
.store(in: &subscriptions)
374388
}
375389
}
376390

@@ -684,6 +698,11 @@ private extension ChatViewController {
684698
navigationController?.pushViewController(vc, animated: true)
685699
}
686700

701+
func didTapSelectText(text: String) {
702+
let vc = screensFactory.makeChatSelectTextView(text: text)
703+
present(vc, animated: true)
704+
}
705+
687706
func didTapRichMessageTransaction(_ transaction: RichMessageTransaction) {
688707
guard
689708
let type = transaction.richType,

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

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum ChatAction {
1616
case scrollTo(message: ChatMessageReplyCell.Model)
1717
case swipeState(state: SwipeableView.State)
1818
case copy(text: String)
19+
case copyInPart(text:String)
1920
case report(id: String)
2021
case remove(id: String)
2122
case react(id: String, emoji: String)

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

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ private extension ChatDataSourceManager {
169169
viewModel.reactAction(id, emoji: emoji)
170170
case let .presentMenu(arg):
171171
viewModel.presentMenu(arg: arg)
172+
case .copyInPart(text: let text):
173+
viewModel.copyTextInPartAction(text)
172174
}
173175
}
174176
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class ChatMenuManager: NSObject {
4444
self.delegate = delegate
4545
}
4646

47-
func setup(for contentView: UIView ) {
47+
func setup(for contentView: UIView) {
4848
guard !isiOSAppOnMac else {
4949
let interaction = UIContextMenuInteraction(delegate: self)
5050
contentView.addInteraction(interaction)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// SelectTextView.swift
3+
// Adamant
4+
//
5+
// Created by Yana Silosieva on 13.02.2024.
6+
// Copyright © 2024 Adamant. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import SwiftUI
11+
12+
struct SelectTextView: View {
13+
let text: String
14+
@Environment(\.dismiss) private var dismiss
15+
16+
var body: some View {
17+
if #available(iOS 16.0, *) {
18+
NavigationStack {
19+
contentView
20+
}
21+
} else {
22+
NavigationView {
23+
contentView
24+
}
25+
}
26+
}
27+
28+
var contentView: some View {
29+
VStack {
30+
TextView(text: text)
31+
.accentColor(.blue)
32+
.padding()
33+
34+
Spacer()
35+
}
36+
.navigationBarTitle(String.adamant.chat.selectText, displayMode: .inline)
37+
.navigationBarItems(
38+
trailing:
39+
Button(
40+
action: { dismiss() }
41+
) {
42+
Image(systemName: "xmark")
43+
}
44+
)
45+
.navigationViewStyle(.stack)
46+
}
47+
}
48+
49+
private struct TextView: UIViewRepresentable {
50+
let text: String
51+
52+
func makeUIView(context: Context) -> UITextView {
53+
let textView = UITextView()
54+
textView.isEditable = false
55+
textView.text = text
56+
textView.font = .systemFont(ofSize: 17)
57+
textView.selectAll(nil)
58+
return textView
59+
}
60+
61+
func updateUIView(_ textView: UITextView, context: Context) {
62+
textView.text = text
63+
}
64+
}

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,18 @@ extension ChatMessageCell {
457457
actionHandler(.copy(text: model.text.string))
458458
}
459459

460+
let copyInPart = AMenuItem.action(
461+
title: .adamant.chat.selectText,
462+
systemImageName: "selection.pin.in.out"
463+
) { [actionHandler, model] in
464+
actionHandler(.copyInPart(text: model.text.string))
465+
}
466+
460467
guard !model.isFake else {
461468
return AMenuSection([copy])
462469
}
463470

464-
return AMenuSection([reply, copy, report, remove])
471+
return AMenuSection([reply, copyInPart, copy, report, remove])
465472
}
466473

467474
@objc func tapReactionAction() {

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,14 @@ extension ChatMessageReplyCell {
555555
actionHandler(.copy(text: model.message.string))
556556
}
557557

558-
return AMenuSection([reply, copy, report, remove])
558+
let copyInPart = AMenuItem.action(
559+
title: .adamant.chat.selectText,
560+
systemImageName: "selection.pin.in.out"
561+
) { [actionHandler, model] in
562+
actionHandler(.copyInPart(text: model.message.string))
563+
}
564+
565+
return AMenuSection([reply, copyInPart, copy, report, remove])
559566
}
560567

561568
@objc func tapReactionAction() {

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
4848
let stack = UIStackView()
4949
stack.alignment = .center
5050
stack.axis = .horizontal
51-
stack.spacing = 12
51+
stack.spacing = horizontalStackSpacing
5252
return stack
5353
}()
5454

@@ -57,7 +57,7 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
5757
stack.alignment = .center
5858
stack.axis = .vertical
5959
stack.spacing = 12
60-
60+
6161
stack.addArrangedSubview(statusButton)
6262
stack.addArrangedSubview(ownReactionLabel)
6363
stack.addArrangedSubview(opponentReactionLabel)
@@ -118,9 +118,12 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
118118
private lazy var chatMenuManager = ChatMenuManager(delegate: self)
119119

120120
private let ownReactionSize = CGSize(width: 40, height: 27)
121-
private let opponentReactionSize = CGSize(width: 55, height: 27)
121+
private let opponentReactionSize = CGSize(width: opponentReactionWidth, height: 27)
122122
private let opponentReactionImageSize = CGSize(width: 12, height: 12)
123123

124+
static let opponentReactionWidth: CGFloat = 55
125+
static let horizontalStackSpacing: CGFloat = 12
126+
124127
var isSelected: Bool = false {
125128
didSet {
126129
contentView.isSelected = isSelected
@@ -154,7 +157,7 @@ private extension ChatTransactionContainerView {
154157
addSubview(horizontalStack)
155158
horizontalStack.snp.makeConstraints {
156159
$0.top.bottom.equalToSuperview()
157-
$0.leading.trailing.equalToSuperview().inset(12)
160+
$0.horizontalEdges.equalToSuperview()
158161
}
159162

160163
swipeView.swipeStateAction = { [actionHandler] state in

Adamant/Modules/Chat/View/Subviews/ChatTransaction/Content/ChatTransactionContentView.swift

+13-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,17 @@ final class ChatTransactionContentView: UIView {
129129

130130
extension ChatTransactionContentView.Model {
131131
func height(for width: CGFloat) -> CGFloat {
132-
let maxSize = CGSize(width: width, height: .infinity)
132+
let opponentReactionWidth = ChatTransactionContainerView.opponentReactionWidth
133+
let containerHorizontalOffset = ChatTransactionContainerView.horizontalStackSpacing * 2
134+
let contentHorizontalOffset = horizontalInsets * 2
135+
136+
let maxSize = CGSize(
137+
width: width
138+
- opponentReactionWidth
139+
- containerHorizontalOffset
140+
- contentHorizontalOffset,
141+
height: .infinity
142+
)
133143
let titleString = NSAttributedString(string: title, attributes: [.font: titleFont])
134144
let dateString = NSAttributedString(string: date, attributes: [.font: dateFont])
135145

@@ -181,7 +191,7 @@ private extension ChatTransactionContentView {
181191
addSubview(verticalStack)
182192
verticalStack.snp.makeConstraints {
183193
$0.top.bottom.equalToSuperview().inset(verticalInsets)
184-
$0.leading.trailing.equalToSuperview().inset(12)
194+
$0.leading.trailing.equalToSuperview().inset(horizontalInsets)
185195
}
186196
}
187197

@@ -237,4 +247,5 @@ private let commentFont = UIFont.systemFont(ofSize: 14)
237247
private let iconSize: CGFloat = 55
238248
private let verticalStackSpacing: CGFloat = 6
239249
private let verticalInsets: CGFloat = 8
250+
private let horizontalInsets: CGFloat = 12
240251
private let replyViewHeight: CGFloat = 25

0 commit comments

Comments
 (0)