Skip to content

Commit

Permalink
Merge pull request #538 from Adamant-im/dev/trello.com/c/Kv0L5rYH
Browse files Browse the repository at this point in the history
[trello.com/c/Kv0L5rYH] Feat: Add read/unread quick action
  • Loading branch information
IanaaDvlp authored Sep 16, 2024
2 parents 95256ce + 09390ac commit 9609211
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
33 changes: 23 additions & 10 deletions Adamant/Modules/ChatsList/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1210,14 +1210,19 @@ extension ChatListViewController {
return
}

let closeAction: (() -> Void)? = { [completionHandler] in
completionHandler(true)
}

let share = self.makeShareAction(
for: address,
encodedAddress: encodedAddress,
sender: view
sender: view,
completion: closeAction
)

let rename = self.makeRenameAction(for: address)
let cancel = self.makeCancelAction()
let rename = self.makeRenameAction(for: address, completion: closeAction)
let cancel = self.makeCancelAction(completion: closeAction)

self.dialogService.showAlert(
title: nil,
Expand All @@ -1226,8 +1231,6 @@ extension ChatListViewController {
actions: [share, rename, cancel],
from: .view(view)
)

completionHandler(true)
}

more.image = .asset(named: "swipe_more")
Expand All @@ -1238,7 +1241,8 @@ extension ChatListViewController {
private func makeShareAction(
for address: String,
encodedAddress: String,
sender: UIView
sender: UIView,
completion: (() -> Void)? = nil
) -> UIAlertAction {
.init(
title: ShareType.share.localized,
Expand All @@ -1260,19 +1264,23 @@ extension ChatListViewController {
excludedActivityTypes: ShareContentType.address.excludedActivityTypes,
animated: true,
from: sender,
completion: nil
completion: completion
)
}
}

private func makeRenameAction(for address: String) -> UIAlertAction {
private func makeRenameAction(
for address: String,
completion: (() -> Void)? = nil
) -> UIAlertAction {
.init(
title: .adamant.chat.rename,
style: .default
) { [weak self] _ in
guard let alert = self?.makeRenameAlert(for: address) else { return }
self?.dialogService.present(alert, animated: true) {
self?.dialogService.selectAllTextFields(in: alert)
completion?()
}
}
}
Expand Down Expand Up @@ -1311,8 +1319,13 @@ extension ChatListViewController {
return alert
}

private func makeCancelAction() -> UIAlertAction {
.init(title: .adamant.alert.cancel, style: .cancel, handler: nil)
private func makeCancelAction(completion: (() -> Void)? = nil) -> UIAlertAction {
.init(
title: .adamant.alert.cancel,
style: .cancel
) { _ in
completion?()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: a30619b79caa4b5a7497b0600d449f34b5620eec

COCOAPODS: 1.15.2
COCOAPODS: 1.12.1

0 comments on commit 9609211

Please sign in to comment.