Skip to content

Commit 9fb1116

Browse files
authored
Merge pull request #719 from Adamant-im/trello.com/c/F7EV0pKq
[trello.com/c/F7EV0pKq] Rework of the popup
2 parents 5dbb65b + a013a76 commit 9fb1116

File tree

10 files changed

+43
-13
lines changed

10 files changed

+43
-13
lines changed

Adamant.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
6FCF2D532D54F2B600F64D20 /* AdamantDialogService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FCF2D4F2D54F2B600F64D20 /* AdamantDialogService.swift */; };
273273
6FF9F08C2D6CEB340013A3B1 /* CoreDataRealationMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF9F08B2D6CEB150013A3B1 /* CoreDataRealationMapper.swift */; };
274274
85ACCA662D68DC57005658CE /* ChatMessagesSortDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85ACCA652D68DC52005658CE /* ChatMessagesSortDescriptor.swift */; };
275+
851FF2762D7B3E6B00276625 /* ChatViewController+NavigationControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 851FF2752D7B3E5B00276625 /* ChatViewController+NavigationControllerDelegate.swift */; };
275276
85B405022D3012D5000AB744 /* AccountViewController+Form.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85B405012D3012C7000AB744 /* AccountViewController+Form.swift */; };
276277
9300F94629D0149100FEDDB8 /* RichMessageProviderWithStatusCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9300F94529D0149100FEDDB8 /* RichMessageProviderWithStatusCheck.swift */; };
277278
9304F8BE292F88F900173F18 /* ANSPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9304F8BD292F88F900173F18 /* ANSPayload.swift */; };
@@ -1004,6 +1005,7 @@
10041005
6FF9F08B2D6CEB150013A3B1 /* CoreDataRealationMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataRealationMapper.swift; sourceTree = "<group>"; };
10051006
74D5744703A7ECC98E244B14 /* Pods-AdmCore.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdmCore.debug.xcconfig"; path = "Target Support Files/Pods-AdmCore/Pods-AdmCore.debug.xcconfig"; sourceTree = "<group>"; };
10061007
85ACCA652D68DC52005658CE /* ChatMessagesSortDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessagesSortDescriptor.swift; sourceTree = "<group>"; };
1008+
851FF2752D7B3E5B00276625 /* ChatViewController+NavigationControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ChatViewController+NavigationControllerDelegate.swift"; sourceTree = "<group>"; };
10071009
85B405012D3012C7000AB744 /* AccountViewController+Form.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountViewController+Form.swift"; sourceTree = "<group>"; };
10081010
9300F94529D0149100FEDDB8 /* RichMessageProviderWithStatusCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RichMessageProviderWithStatusCheck.swift; sourceTree = "<group>"; };
10091011
9304F8BD292F88F900173F18 /* ANSPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ANSPayload.swift; sourceTree = "<group>"; };
@@ -2217,6 +2219,7 @@
22172219
93996A9829682690008D080B /* Subviews */,
22182220
938F7D592955C8CB001915CA /* Managers */,
22192221
938F7D632955C94F001915CA /* ChatViewController.swift */,
2222+
851FF2752D7B3E5B00276625 /* ChatViewController+NavigationControllerDelegate.swift */,
22202223
26A975FE2B7E843E0095C367 /* SelectTextView.swift */,
22212224
26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */,
22222225
);
@@ -4038,6 +4041,7 @@
40384041
AAB01CB52D3AF27E007D6BF4 /* DogeInternalApiProtocol.swift in Sources */,
40394042
93ED214F2CC3567600AA1FC8 /* TransactionsStatusServiceCompose.swift in Sources */,
40404043
E96E86B821679C120061F80A /* EthTransactionDetailsViewController.swift in Sources */,
4044+
851FF2762D7B3E6B00276625 /* ChatViewController+NavigationControllerDelegate.swift in Sources */,
40414045
3A26D9432C3C2E19003AD832 /* KlyWalletService+StatusCheck.swift in Sources */,
40424046
265AA1622B74E6B900CF98B0 /* ChatPreservation.swift in Sources */,
40434047
4164A9D728F17D4000EEF16D /* ChatTransactionService.swift in Sources */,

Adamant/Modules/Chat/ChatLocalization.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ extension String.adamant {
102102
static var unknownTitle: String {
103103
String.localized("Chat.unknown.title", comment: "Chat unknown")
104104
}
105+
static var noActiveNodesTitle: String {
106+
String.localized("Chat.Alert.Title.NoActiveNodes", comment: "No active nodes title")
107+
}
105108
static var noActiveNodes: String {
106109
String.localized("Chat.Alert.NoActiveNodes", comment: "No active nodes")
107110
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// ChatViewController+NavigationControllerDelegate.swift
3+
// Adamant
4+
//
5+
// Created by Sergei Veretennikov on 07.03.2025.
6+
// Copyright © 2025 Adamant. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
extension ChatViewController: UINavigationControllerDelegate {
12+
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
13+
if viewController === self {
14+
viewModel.checkForADMNodesAvailability()
15+
}
16+
}
17+
}

Adamant/Modules/Chat/View/ChatViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ final class ChatViewController: MessagesViewController {
154154

155155
override func viewWillAppear(_ animated: Bool) {
156156
super.viewWillAppear(animated)
157+
if navigationController?.delegate !== self {
158+
navigationController?.delegate = self
159+
}
160+
157161
viewModel.updatePartnerName()
158162
}
159163

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private extension ChatDialogManager {
192192

193193
func showNoActiveNodesAlert() {
194194
let alert = UIAlertController(
195-
title: "",
195+
title: .adamant.chat.noActiveNodesTitle,
196196
message: .adamant.chat.noActiveNodes,
197197
preferredStyleSafe: .alert,
198198
source: nil
@@ -201,13 +201,14 @@ private extension ChatDialogManager {
201201
alert.addAction(
202202
.init(
203203
title: .adamant.chat.reviewNodesList,
204-
style: .default,
204+
style: .destructive,
205205
handler: { [weak self] _ in
206206
self?.viewModel.didTapAdmNodesList.send(())
207207
}
208208
)
209209
)
210-
alert.addAction(.init(title: .adamant.alert.cancel, style: .cancel))
210+
let cancelButton = UIAlertAction(title: .adamant.alert.cancel, style: .default)
211+
alert.addAction(cancelButton)
211212
alert.modalPresentationStyle = .overFullScreen
212213
dialogService.present(alert, animated: true, completion: nil)
213214
}

Adamant/Modules/Chat/ViewModel/ChatViewModel.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,6 @@ final class ChatViewModel: NSObject {
311311
}
312312

313313
Task {
314-
if apiServiceCompose.get(.adm)?.hasEnabledNode == false {
315-
dialog.send(.noActiveNodesAlert)
316-
}
317-
318314
if !(filesPicked?.isEmpty ?? true) {
319315
do {
320316
try await sendFiles(with: text)
@@ -714,11 +710,6 @@ final class ChatViewModel: NSObject {
714710
return false
715711
}
716712

717-
guard apiServiceCompose.get(.adm)?.hasEnabledNode == true else {
718-
dialog.send(.noActiveNodesAlert)
719-
return false
720-
}
721-
722713
return true
723714
}
724715

@@ -987,6 +978,12 @@ final class ChatViewModel: NSObject {
987978
func updateSwipingOffset(_ offset: CGFloat) {
988979
swipeableMessage.state = .offset(offset)
989980
}
981+
982+
func checkForADMNodesAvailability() {
983+
if apiServiceCompose.get(.adm)?.hasEnabledNode == false {
984+
dialog.send(.noActiveNodesAlert)
985+
}
986+
}
990987
}
991988

992989
extension ChatViewModel {

CommonKit/Sources/CommonKit/Assets/Localization/de.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,7 @@
13791379
"Chat.unknown.title" = "Unbekannt";
13801380

13811381
/* No active nodes */
1382+
"Chat.Alert.Title.NoActiveNodes" = "Keine aktiven ADM-Knoten";
13821383
"Chat.Alert.NoActiveNodes" = "Es können keine neuen Nachrichten angefordert werden - Keine aktiven ADM-Blockchain-Knoten. Da Sie einige von ihnen deaktiviert haben, sollten Sie die Knotenliste überprüfen.";
13831384

13841385
/* Review Nodes List */

CommonKit/Sources/CommonKit/Assets/Localization/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,8 @@
13551355
"Chat.unknown.title" = "Unknown";
13561356

13571357
/* No active nodes */
1358-
"Chat.Alert.NoActiveNodes" = "Unable to request new messages — No active ADM blockchain nodes. As you’ve deactivated some of them, consider reviewing the node list.";
1358+
"Chat.Alert.Title.NoActiveNodes" = "No active ADM nodes";
1359+
"Chat.Alert.NoActiveNodes" = "Unable to request new messages—No active ADM blockchain nodes. As you’ve deactivated some of them, consider reviewing the node list.";
13591360

13601361
/* Review Nodes List */
13611362
"Chat.Alert.ReviewNodesList" = "Review ADM node list";

CommonKit/Sources/CommonKit/Assets/Localization/ru.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,7 @@
13561356
"Chat.unknown.title" = "Неизвестный";
13571357

13581358
/* No active nodes */
1359+
"Chat.Alert.Title.NoActiveNodes" = "Нет активных узлов ADM";
13591360
"Chat.Alert.NoActiveNodes" = "Не удается получить новые сообщения — нет активных узлов блокчейна ADM. Поскольку вы отключили некоторые из них, посмотрите список узлов еще раз.";
13601361

13611362
/* Review Nodes List */

CommonKit/Sources/CommonKit/Assets/Localization/zh.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@
13461346
"Chat.unknown.title" = "未知";
13471347

13481348
/* No active nodes */
1349+
"Chat.Alert.Title.NoActiveNodes" = "無活動 ADM 節點";
13491350
"Chat.Alert.NoActiveNodes" = "无法请求新消息 - 没有活动的 ADM 区块链节点。由于您已停用部分节点,请考虑查看节点列表。";
13501351

13511352
/* Review Nodes List */

0 commit comments

Comments
 (0)