Skip to content

Commit 7f2db6f

Browse files
committed
Merge branch 'trello.com/c/vawidi4o'
2 parents e8a05ff + 7ce5fe3 commit 7f2db6f

File tree

42 files changed

+679
-423
lines changed

Some content is hidden

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

42 files changed

+679
-423
lines changed

Adamant.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
6F030E1C2D4C0E950077ACA2 /* EthBIP32Service.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F030E1B2D4C0E770077ACA2 /* EthBIP32Service.swift */; };
272272
6F15B2432D8456C000ACE834 /* NewMessagesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F15B2422D8456C000ACE834 /* NewMessagesCell.swift */; };
273273
6FB686162D3AAE8800CAB6DD /* AdamantWalletsKit in Frameworks */ = {isa = PBXBuildFile; productRef = 6FB686152D3AAE8800CAB6DD /* AdamantWalletsKit */; };
274-
6FB686182D3AB9E200CAB6DD /* SmartTokenInfoProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FB686172D3AB9E200CAB6DD /* SmartTokenInfoProtocol.swift */; };
274+
6FB686182D3AB9E200CAB6DD /* EthWalletService+CoinInfoExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FB686172D3AB9E200CAB6DD /* EthWalletService+CoinInfoExtension.swift */; };
275275
6FB6861A2D3ABA1400CAB6DD /* WalletStaticCoreProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FB686192D3ABA1400CAB6DD /* WalletStaticCoreProtocol.swift */; };
276276
6FB6861C2D3ABE0200CAB6DD /* DashWalletService+Transactions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FB6861B2D3ABE0200CAB6DD /* DashWalletService+Transactions.swift */; };
277277
6FCF2D522D54F2B600F64D20 /* AdmDialogService+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FCF2D502D54F2B600F64D20 /* AdmDialogService+Extension.swift */; };
@@ -1009,7 +1009,7 @@
10091009
64FA53D020E24941006783C9 /* TransactionDetailsViewControllerBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionDetailsViewControllerBase.swift; sourceTree = "<group>"; };
10101010
6F030E1B2D4C0E770077ACA2 /* EthBIP32Service.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EthBIP32Service.swift; sourceTree = "<group>"; };
10111011
6F15B2422D8456C000ACE834 /* NewMessagesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewMessagesCell.swift; sourceTree = "<group>"; };
1012-
6FB686172D3AB9E200CAB6DD /* SmartTokenInfoProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartTokenInfoProtocol.swift; sourceTree = "<group>"; };
1012+
6FB686172D3AB9E200CAB6DD /* EthWalletService+CoinInfoExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EthWalletService+CoinInfoExtension.swift"; sourceTree = "<group>"; };
10131013
6FB686192D3ABA1400CAB6DD /* WalletStaticCoreProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletStaticCoreProtocol.swift; sourceTree = "<group>"; };
10141014
6FB6861B2D3ABE0200CAB6DD /* DashWalletService+Transactions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DashWalletService+Transactions.swift"; sourceTree = "<group>"; };
10151015
6FCF2D4F2D54F2B600F64D20 /* AdamantDialogService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdamantDialogService.swift; sourceTree = "<group>"; };
@@ -1736,7 +1736,6 @@
17361736
3AFE7E502B1F6AFE00718739 /* WalletsService */ = {
17371737
isa = PBXGroup;
17381738
children = (
1739-
6FB686172D3AB9E200CAB6DD /* SmartTokenInfoProtocol.swift */,
17401739
6FB686192D3ABA1400CAB6DD /* WalletStaticCoreProtocol.swift */,
17411740
3AFE7E422B19E4D900718739 /* WalletServiceCompose.swift */,
17421741
E940086D2114AA2E00CD2D67 /* WalletCoreProtocol.swift */,
@@ -2909,6 +2908,7 @@
29092908
E993301D212EF39700CD5200 /* EthTransferViewController.swift */,
29102909
64FA53CC20E1300A006783C9 /* EthTransactionsViewController.swift */,
29112910
E96E86B721679C120061F80A /* EthTransactionDetailsViewController.swift */,
2911+
6FB686172D3AB9E200CAB6DD /* EthWalletService+CoinInfoExtension.swift */,
29122912
);
29132913
path = Ethereum;
29142914
sourceTree = "<group>";
@@ -3752,7 +3752,7 @@
37523752
3AA388052B67F4DD00125684 /* BtcBlockchainInfoDTO.swift in Sources */,
37533753
93547BCA29E2262D00B0914B /* WelcomeViewController.swift in Sources */,
37543754
41047B74294C61D10039E956 /* VisibleWalletsService.swift in Sources */,
3755-
6FB686182D3AB9E200CAB6DD /* SmartTokenInfoProtocol.swift in Sources */,
3755+
6FB686182D3AB9E200CAB6DD /* EthWalletService+CoinInfoExtension.swift in Sources */,
37563756
AA8FFFE52D513787001D8576 /* EdgeInsetTextField.swift in Sources */,
37573757
3AE0A42A2BC6A64900BF7125 /* FilesNetworkManager.swift in Sources */,
37583758
648CE3AC229AD2190070A2CC /* DashTransferViewController.swift in Sources */,

Adamant.xcodeproj/xcshareddata/xcschemes/Adamant.Release.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
</TestAction>
5252
<LaunchAction
5353
buildConfiguration = "Release"
54-
selectedDebuggerIdentifier = ""
55-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
54+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
55+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
5656
launchStyle = "0"
5757
useCustomWorkingDirectory = "NO"
5858
ignoresPersistentStateOnLaunch = "NO"

Adamant/App/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import CryptoSwift
1212
import CoreData
1313
import CommonKit
1414
import FilesStorageKit
15+
import AdamantWalletsKit
1516

1617
// MARK: - Constants
1718
extension String.adamant {

Adamant/App/DI/AppAssembly.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import BitcoinKit
1111
import CommonKit
1212
import FilesStorageKit
1313
import FilesPickerKit
14+
import AdamantWalletsKit
1415

1516
struct AppAssembly: MainThreadAssembly {
1617
func assembleOnMainThread(container: Container) {
@@ -447,8 +448,21 @@ struct AppAssembly: MainThreadAssembly {
447448
ChatPreservation()
448449
}.inObjectScope(.container)
449450

451+
// MARK: Wallet storage
452+
// Should be registered before WalletServiceCompose
453+
container.register(AnyTokensStorage.self) { _ in
454+
TokensStorage()
455+
}
456+
.inObjectScope(.container)
457+
.initCompleted { _, storage in
458+
ERC20Token.supportedTokens = ERC20TokenAssembly.getERC20Tokens(tokensStorage: storage)
459+
CoinInfoProvider.storage = storage
460+
}
461+
container.resolve(AnyTokensStorage.self)?
462+
.loadTokens()
463+
450464
// MARK: Wallet Service Compose
451-
container.register(WalletServiceCompose.self) { r in
465+
container.register(WalletServiceCompose.self) { _ in
452466
var wallets: [WalletCoreProtocol] = [
453467
AdmWalletService(),
454468
BtcWalletService(),

Adamant/Modules/Account/AccountHeaderView.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ private extension AccountHeaderView {
103103
badgeLabel.translatesAutoresizingMaskIntoConstraints = false
104104
bgView.addSubview(badgeLabel)
105105

106-
NSLayoutConstraint.activate([
107-
badgeLabel.widthAnchor.constraint(equalToConstant: badgeSize),
108-
badgeLabel.heightAnchor.constraint(equalToConstant: badgeSize),
109-
badgeLabel.trailingAnchor.constraint(equalTo: bgView.trailingAnchor, constant: 0),
110-
badgeLabel.bottomAnchor.constraint(equalTo: bgView.bottomAnchor, constant: 0)
111-
])
106+
badgeLabel.snp.makeConstraints { make in
107+
make.width.height.equalTo(badgeSize)
108+
make.trailing.equalTo(bgView.snp.trailing)
109+
make.bottom.equalTo(bgView.snp.bottom)
110+
}
112111
}
113112

114113
func addPersistentOutline() {

Adamant/Modules/Account/AccountViewController/AccountViewController.swift

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,9 @@ final class AccountViewController: FormViewController {
10031003
}
10041004

10051005
@objc private func handleRefresh(_ refreshControl: UIRefreshControl) {
1006-
let unavailableNodes: [NodeGroup] = NodeGroup.allCases.filter {
1007-
apiServiceCompose.get($0)?.hasEnabledNode == false
1008-
}
1006+
let unavailableNodes: Set<NodeGroup> = Set(NodeGroup.allCases.filter {
1007+
!(apiServiceCompose.get($0)?.hasSupportedNode ?? true)
1008+
})
10091009

10101010
if unavailableNodes.contains(where: {
10111011
$0.name == currentSelectedWalletItem?.currencyNetwork
@@ -1018,7 +1018,7 @@ final class AccountViewController: FormViewController {
10181018
}
10191019

10201020
Task { @MainActor in
1021-
await accountService.reloadWallets()
1021+
accountService.update()
10221022
refreshControl.endRefreshing()
10231023
}
10241024
}
@@ -1044,7 +1044,25 @@ extension AccountViewController: AccountHeaderViewDelegate {
10441044
}
10451045

10461046
let encodedAddress = AdamantUriTools.encode(request: AdamantUri.address(address: address, params: nil))
1047-
dialogService.presentShareAlertFor(title: nil, stringForPasteboard: address, stringForShare: encodedAddress, stringForQR: encodedAddress, types: [.copyToPasteboard, .share, .generateQr(encodedContent: encodedAddress, sharingTip: address, withLogo: true)], excludedActivityTypes: ShareContentType.address.excludedActivityTypes, animated: true, from: from, completion: nil)
1047+
dialogService.presentShareAlertFor(
1048+
title: nil,
1049+
stringForPasteboard: address,
1050+
stringForShare: encodedAddress,
1051+
stringForQR: encodedAddress,
1052+
types: [
1053+
.copyToPasteboard,
1054+
.share,
1055+
.generateQr(
1056+
encodedContent: encodedAddress,
1057+
sharingTip: address,
1058+
withLogo: true
1059+
)
1060+
],
1061+
excludedActivityTypes: ShareContentType.address.excludedActivityTypes,
1062+
animated: true,
1063+
from: from,
1064+
completion: nil
1065+
)
10481066
}
10491067
}
10501068

Adamant/Modules/Account/AccountViewController/AccountWallets/AccountWalletsState.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
// Copyright © 2025 Adamant. All rights reserved.
77
//
88

9-
extension AccountViewController {
10-
struct AccountWalletsState: Equatable {
11-
var wallets: [WalletCollectionViewCell.Model]
12-
13-
static let `default` = Self(wallets: [])
14-
}
9+
struct AccountWalletsState: Equatable {
10+
var wallets: [WalletCollectionViewCell.Model]
11+
12+
static let `default` = Self(wallets: [])
1513
}

Adamant/Modules/Account/AccountViewController/AccountWallets/AccountWalletsViewModel.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@ import Foundation
1010
import CommonKit
1111
import Combine
1212

13-
extension AccountViewController {
14-
@MainActor
15-
final class AccountWalletsViewModel {
16-
@ObservableValue var state: AccountWalletsState = .default
17-
18-
private let walletsStoreService: WalletStoreServiceProviderProtocol
19-
private var walletSubscriptions: Set<AnyCancellable> = []
20-
private var currentWalletPublisherSubscription: Set<AnyCancellable> = []
21-
22-
init(walletsStoreService: WalletStoreServiceProviderProtocol) {
23-
self.walletsStoreService = walletsStoreService
24-
setup()
25-
}
13+
@MainActor
14+
final class AccountWalletsViewModel {
15+
@ObservableValue var state: AccountWalletsState = .default
16+
17+
private let walletsStoreService: WalletStoreServiceProviderProtocol
18+
private var walletSubscriptions: Set<AnyCancellable> = []
19+
private var currentWalletPublisherSubscription: Set<AnyCancellable> = []
20+
21+
init(walletsStoreService: WalletStoreServiceProviderProtocol) {
22+
self.walletsStoreService = walletsStoreService
23+
setup()
2624
}
2725
}
2826

29-
private extension AccountViewController.AccountWalletsViewModel {
27+
private extension AccountWalletsViewModel {
3028
func setup() {
3129
addObservers()
3230
}
@@ -79,7 +77,7 @@ private extension AccountViewController.AccountWalletsViewModel {
7977
}
8078
}
8179

82-
extension AccountViewController.AccountWalletsViewModel {
80+
extension AccountWalletsViewModel {
8381
func updateState() {
8482
walletSubscriptions.removeAll()
8583
state.wallets.removeAll()

Adamant/Modules/Chat/View/ChatViewController.swift

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ final class ChatViewController: MessagesViewController {
171171
defer { viewAppeared = true }
172172
inputBar.isUserInteractionEnabled = true
173173
chatMessagesCollectionView.fixedBottomOffset = nil
174-
175174
updateUnreadMessages()
176175
if !viewAppeared {
177176
viewModel.presentKeyboardOnStartIfNeeded()
@@ -330,6 +329,11 @@ private extension ChatViewController {
330329
.removeDuplicates()
331330
.sink { [weak self] _ in
332331
self?.updateMessages()
332+
}
333+
.store(in: &subscriptions)
334+
335+
viewModel.messagesUpdated
336+
.sink { [weak self] _ in
333337
self?.updateMessagesPosition()
334338
}
335339
.store(in: &subscriptions)
@@ -416,12 +420,14 @@ private extension ChatViewController {
416420
.sink { [weak self] in self?.processFileToolbarView($0) }
417421
.store(in: &subscriptions)
418422

419-
viewModel.$scrollToMessage
423+
viewModel.$scrollToIdAndPosition
420424
.sink { [weak self] in
421-
guard let toId = $0
425+
guard let idAndPosition = $0
422426
else { return }
423427

424-
self?.scrollToPosition(.messageId(toId), animated: false)
428+
self?.scrollToPosition = idAndPosition.position
429+
self?.scrollToPosition(.messageId(idAndPosition.id), animated: false, setExtraOffset: self?.scrollToPosition == .top)
430+
self?.viewModel.messageIdToShow = nil
425431
}
426432
.store(in: &subscriptions)
427433

@@ -763,10 +769,12 @@ private extension ChatViewController {
763769
func updateMessagesPosition() {
764770
guard !messagesLoaded, !viewModel.messages.isEmpty else { return }
765771
messagesLoaded = true
766-
if let position = viewModel.startPosition {
767-
scrollToPosition(position)
768-
} else if let unreadMessage = viewModel.unreadMessagesIds?.first {
769-
scrollToPosition(.messageId(unreadMessage), animated: false)
772+
if viewModel.messageIdToShow == nil {
773+
if let unreadMessage = viewModel.unreadMessagesIds?.first {
774+
scrollToPosition(.messageId(unreadMessage), setExtraOffset: true)
775+
} else if let position = viewModel.startPosition {
776+
scrollToPosition(position)
777+
}
770778
}
771779
}
772780

@@ -922,7 +930,7 @@ private extension ChatViewController {
922930
}
923931

924932
@MainActor
925-
func scrollToPosition(_ position: ChatStartPosition, animated: Bool = false) {
933+
func scrollToPosition(_ position: ChatStartPosition, animated: Bool = false, setExtraOffset: Bool = false) {
926934
chatMessagesCollectionView.fixedBottomOffset = nil
927935

928936
switch position {
@@ -946,6 +954,10 @@ private extension ChatViewController {
946954
animated: animated
947955
)
948956

957+
if setExtraOffset {
958+
setExtraOffsetForNewMessages()
959+
}
960+
949961
viewModel.needToAnimateCellIndex = needToAnimateCell
950962
? index
951963
: nil
@@ -962,6 +974,17 @@ private extension ChatViewController {
962974
chatMessagesCollectionView.fixedBottomOffset = chatMessagesCollectionView.bottomOffset
963975
}
964976

977+
func setExtraOffsetForNewMessages() {
978+
//extra scroll to 120 to see newMessage line and 2 strings from previus message
979+
let newOffsetY = max(
980+
messagesCollectionView.contentOffset.y - 120,
981+
0
982+
)
983+
let newOffset = CGPoint(x: messagesCollectionView.contentOffset.x, y: newOffsetY)
984+
985+
messagesCollectionView.setContentOffset(newOffset, animated: false)
986+
}
987+
965988
func scrollDownOnNewMessageIfNeeded(previousBottomMessageId: String?) {
966989
let messages = viewModel.messages
967990

Adamant/Modules/Chat/View/Subviews/NewMessagesCell.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import MessageKit
1212
final class NewMessagesCell: MessageReusableView {
1313
private let separatorLine: UIView = {
1414
let view = UIView()
15-
view.backgroundColor = .adamant.active
15+
view.backgroundColor = .adamant.newMessageLineColor
1616
return view
1717
}()
1818

@@ -36,12 +36,12 @@ final class NewMessagesCell: MessageReusableView {
3636

3737
let pixelSize = 1 / UIScreen.main.scale
3838
NSLayoutConstraint.activate([
39-
separatorLine.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 10),
40-
separatorLine.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -10),
39+
separatorLine.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 20),
40+
separatorLine.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20),
4141
separatorLine.topAnchor.constraint(equalTo: topAnchor),
4242
separatorLine.heightAnchor.constraint(equalToConstant: pixelSize),
4343

44-
label.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -10),
44+
label.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20),
4545
label.topAnchor.constraint(equalTo: separatorLine.bottomAnchor, constant: 1)
4646
])
4747
}

0 commit comments

Comments
 (0)