Skip to content

Commit

Permalink
Merge pull request #487 from Adamant-im/develop
Browse files Browse the repository at this point in the history
Release 3.6.1
  • Loading branch information
StanislavDevIOS authored May 15, 2024
2 parents c187d78 + d927ac3 commit b038d03
Show file tree
Hide file tree
Showing 44 changed files with 512 additions and 310 deletions.
16 changes: 10 additions & 6 deletions Adamant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
265AA1622B74E6B900CF98B0 /* ChatPreservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 265AA1612B74E6B900CF98B0 /* ChatPreservation.swift */; };
269E13522B594B2D008D1CA7 /* AccountFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269E13512B594B2D008D1CA7 /* AccountFooterView.swift */; };
26A975FF2B7E843E0095C367 /* SelectTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A975FE2B7E843E0095C367 /* SelectTextView.swift */; };
26A976012B7E852E0095C367 /* ChatSelectTextViewFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */; };
3A20D93B2AE7F316005475A6 /* AdamantTransactionDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A20D93A2AE7F316005475A6 /* AdamantTransactionDetails.swift */; };
3A2F55F92AC6F308000A3F26 /* CoinTransaction+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2F55F72AC6F308000A3F26 /* CoinTransaction+CoreDataClass.swift */; };
3A2F55FA2AC6F308000A3F26 /* CoinTransaction+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2F55F82AC6F308000A3F26 /* CoinTransaction+CoreDataProperties.swift */; };
Expand Down Expand Up @@ -130,7 +132,6 @@
6416B1A321AD7EA1006089AC /* LskTransactionDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6416B1A221AD7EA1006089AC /* LskTransactionDetailsViewController.swift */; };
6416B1A721B024B6006089AC /* LskWalletService+Send.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6416B1A621B024B6006089AC /* LskWalletService+Send.swift */; };
644793C32166314A00FC4CF5 /* OnboardPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 644793C22166314A00FC4CF5 /* OnboardPage.swift */; };
644793C52166315900FC4CF5 /* OnboardPage.xib in Resources */ = {isa = PBXBuildFile; fileRef = 644793C42166315900FC4CF5 /* OnboardPage.xib */; };
6448C291235CA6E100F3F15B /* ERC20WalletService+RichMessageProviderWithStatusCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA64235CA0930033B936 /* ERC20WalletService+RichMessageProviderWithStatusCheck.swift */; };
6449BA68235CA0930033B936 /* ERC20WalletService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA5E235CA0930033B936 /* ERC20WalletService.swift */; };
6449BA69235CA0930033B936 /* ERC20TransferViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6449BA5F235CA0930033B936 /* ERC20TransferViewController.swift */; };
Expand Down Expand Up @@ -655,6 +656,8 @@
/* Begin PBXFileReference section */
265AA1612B74E6B900CF98B0 /* ChatPreservation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatPreservation.swift; sourceTree = "<group>"; };
269E13512B594B2D008D1CA7 /* AccountFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountFooterView.swift; sourceTree = "<group>"; };
26A975FE2B7E843E0095C367 /* SelectTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTextView.swift; sourceTree = "<group>"; };
26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatSelectTextViewFactory.swift; sourceTree = "<group>"; };
33975C0D891698AA7E74EBCC /* Pods_Adamant.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Adamant.framework; sourceTree = BUILT_PRODUCTS_DIR; };
36AB8CE9537B3B873972548B /* Pods_AdmCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdmCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3A20D93A2AE7F316005475A6 /* AdamantTransactionDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdamantTransactionDetails.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -771,7 +774,6 @@
6416B1A221AD7EA1006089AC /* LskTransactionDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LskTransactionDetailsViewController.swift; sourceTree = "<group>"; };
6416B1A621B024B6006089AC /* LskWalletService+Send.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LskWalletService+Send.swift"; sourceTree = "<group>"; };
644793C22166314A00FC4CF5 /* OnboardPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardPage.swift; sourceTree = "<group>"; };
644793C42166315900FC4CF5 /* OnboardPage.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OnboardPage.xib; sourceTree = "<group>"; };
6449BA5E235CA0930033B936 /* ERC20WalletService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20WalletService.swift; sourceTree = "<group>"; };
6449BA5F235CA0930033B936 /* ERC20TransferViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20TransferViewController.swift; sourceTree = "<group>"; };
6449BA60235CA0930033B936 /* ERC20Wallet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC20Wallet.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1705,6 +1707,8 @@
93996A9829682690008D080B /* Subviews */,
938F7D592955C8CB001915CA /* Managers */,
938F7D632955C94F001915CA /* ChatViewController.swift */,
26A975FE2B7E843E0095C367 /* SelectTextView.swift */,
26A976002B7E852E0095C367 /* ChatSelectTextViewFactory.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -2165,7 +2169,6 @@
645FEB32213E72C100D6BA2D /* OnboardViewController.swift */,
645FEB33213E72C100D6BA2D /* OnboardViewController.xib */,
644793C22166314A00FC4CF5 /* OnboardPage.swift */,
644793C42166315900FC4CF5 /* OnboardPage.xib */,
E96BBE3021F70F5E009AA738 /* ReadonlyTextView.swift */,
);
path = Onboard;
Expand Down Expand Up @@ -2803,7 +2806,6 @@
4198D57F28C8B834009337F2 /* short-success.mp3 in Resources */,
4198D57D28C8B7FA009337F2 /* relax-message-tone.mp3 in Resources */,
E983AE2D20E6720D00497E1A /* AccountFooter.xib in Resources */,
644793C52166315900FC4CF5 /* OnboardPage.xib in Resources */,
E95F85C8200A9B070070534A /* ChatTableViewCell.xib in Resources */,
E913C8F91FFFA51D001A83F7 /* Assets.xcassets in Resources */,
93496BB42A6CAED100DD062F /* Roboto_400_italic.ttf in Resources */,
Expand Down Expand Up @@ -3010,6 +3012,7 @@
648CE3A6229AD1CD0070A2CC /* DashWalletService+Send.swift in Sources */,
E987024920C2B1F700E393F4 /* AdamantChatsProvider+fakeMessages.swift in Sources */,
6403F5E222723F7500D58779 /* DashWallet.swift in Sources */,
26A975FF2B7E843E0095C367 /* SelectTextView.swift in Sources */,
93294B822AAD0BB400911109 /* BtcWalletFactory.swift in Sources */,
648DD7A42237DB9E00B811FD /* DogeWalletService+Send.swift in Sources */,
93294B7D2AAD067000911109 /* AppContainer.swift in Sources */,
Expand Down Expand Up @@ -3117,6 +3120,7 @@
9399F5ED29A85A48006C3E30 /* ChatCacheService.swift in Sources */,
3A9015A92A615893002A2464 /* ChatMessagesListViewModel.swift in Sources */,
936658952B0AC15300BDB2D3 /* Node+UI.swift in Sources */,
26A976012B7E852E0095C367 /* ChatSelectTextViewFactory.swift in Sources */,
41A1995429D56E340031AD75 /* ChatMessageReplyCell.swift in Sources */,
93294B872AAD0E0A00911109 /* AdmWallet.swift in Sources */,
6449BA6B235CA0930033B936 /* ERC20TransactionDetailsViewController.swift in Sources */,
Expand Down Expand Up @@ -3754,7 +3758,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.6.1;
PRODUCT_BUNDLE_IDENTIFIER = "im.adamant.adamant-messenger-dev";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -3785,7 +3789,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.6.0;
MARKETING_VERSION = 3.6.1;
PRODUCT_BUNDLE_IDENTIFIER = "im.adamant.adamant-messenger";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
3 changes: 3 additions & 0 deletions Adamant/Helpers/String+localized.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ extension String.adamant {
static var unknownError: String {
String.localized("Error.UnknownError", comment: "Shared unknown error")
}
static func admNodeErrorMessage(_ coin: String) -> String {
String.localizedStringWithFormat(.localized("ApiService.InternalError.NoAdmNodesAvailable", comment: "No active ADM nodes to fetch the partner's %@ address"), coin)
}

static var notEnoughMoney: String {
String.localized("WalletServices.SharedErrors.notEnoughMoney", comment: "Wallet Services: Shared error, user do not have enought money.")
Expand Down
3 changes: 3 additions & 0 deletions Adamant/Modules/Chat/ChatLocalization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ extension String.adamant {
static var report: String {
String.localized("Chats.Report", comment: "Report")
}
static var selectText: String {
String.localized("Chats.SelectText", comment: "Select Text")
}
static var reply: String {
String.localized("Chats.Reply", comment: "Reply")
}
Expand Down
23 changes: 23 additions & 0 deletions Adamant/Modules/Chat/View/ChatSelectTextViewFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ChatSelectTextViewFactory.swift
// Adamant
//
// Created by Yana Silosieva on 13.02.2024.
// Copyright © 2024 Adamant. All rights reserved.
//

import Foundation
import Swinject
import UIKit
import SwiftUI

struct ChatSelectTextViewFactory {
@MainActor
func makeViewController(text: String) -> UIViewController {
let view = SelectTextView(text: text)

return UIHostingController(
rootView: view
)
}
}
21 changes: 20 additions & 1 deletion Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ final class ChatViewController: MessagesViewController {
configureGestures()
setupObservers()
viewModel.loadFirstMessagesIfNeeded()
viewModel.presentKeyboardOnStartIfNeeded()
}

override func viewWillLayoutSubviews() {
Expand All @@ -124,12 +123,21 @@ final class ChatViewController: MessagesViewController {
)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
viewModel.updatePartnerName()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
defer { viewAppeared = true }
inputBar.isUserInteractionEnabled = true
chatMessagesCollectionView.fixedBottomOffset = nil

if !viewAppeared {
viewModel.presentKeyboardOnStartIfNeeded()
}

guard isMacOS, !viewAppeared else { return }
focusInputBarWithoutAnimation()
}
Expand Down Expand Up @@ -371,6 +379,12 @@ private extension ChatViewController {
viewModel.didTapPartnerQR
.sink { [weak self] in self?.didTapPartenerQR(partner: $0) }
.store(in: &subscriptions)

viewModel.didTapSelectText
.sink { [weak self] text in
self?.didTapSelectText(text: text)
}
.store(in: &subscriptions)
}
}

Expand Down Expand Up @@ -684,6 +698,11 @@ private extension ChatViewController {
navigationController?.pushViewController(vc, animated: true)
}

func didTapSelectText(text: String) {
let vc = screensFactory.makeChatSelectTextView(text: text)
present(vc, animated: true)
}

func didTapRichMessageTransaction(_ transaction: RichMessageTransaction) {
guard
let type = transaction.richType,
Expand Down
1 change: 1 addition & 0 deletions Adamant/Modules/Chat/View/Managers/ChatAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum ChatAction {
case scrollTo(message: ChatMessageReplyCell.Model)
case swipeState(state: SwipeableView.State)
case copy(text: String)
case copyInPart(text:String)
case report(id: String)
case remove(id: String)
case react(id: String, emoji: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ private extension ChatDataSourceManager {
viewModel.reactAction(id, emoji: emoji)
case let .presentMenu(arg):
viewModel.presentMenu(arg: arg)
case .copyInPart(text: let text):
viewModel.copyTextInPartAction(text)
}
}
}
2 changes: 1 addition & 1 deletion Adamant/Modules/Chat/View/Managers/ChatMenuManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class ChatMenuManager: NSObject {
self.delegate = delegate
}

func setup(for contentView: UIView ) {
func setup(for contentView: UIView) {
guard !isiOSAppOnMac else {
let interaction = UIContextMenuInteraction(delegate: self)
contentView.addInteraction(interaction)
Expand Down
64 changes: 64 additions & 0 deletions Adamant/Modules/Chat/View/SelectTextView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// SelectTextView.swift
// Adamant
//
// Created by Yana Silosieva on 13.02.2024.
// Copyright © 2024 Adamant. All rights reserved.
//

import Foundation
import SwiftUI

struct SelectTextView: View {
let text: String
@Environment(\.dismiss) private var dismiss

var body: some View {
if #available(iOS 16.0, *) {
NavigationStack {
contentView
}
} else {
NavigationView {
contentView
}
}
}

var contentView: some View {
VStack {
TextView(text: text)
.accentColor(.blue)
.padding()

Spacer()
}
.navigationBarTitle(String.adamant.chat.selectText, displayMode: .inline)
.navigationBarItems(
trailing:
Button(
action: { dismiss() }
) {
Image(systemName: "xmark")
}
)
.navigationViewStyle(.stack)
}
}

private struct TextView: UIViewRepresentable {
let text: String

func makeUIView(context: Context) -> UITextView {
let textView = UITextView()
textView.isEditable = false
textView.text = text
textView.font = .systemFont(ofSize: 17)
textView.selectAll(nil)
return textView
}

func updateUIView(_ textView: UITextView, context: Context) {
textView.text = text
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,18 @@ extension ChatMessageCell {
actionHandler(.copy(text: model.text.string))
}

let copyInPart = AMenuItem.action(
title: .adamant.chat.selectText,
systemImageName: "selection.pin.in.out"
) { [actionHandler, model] in
actionHandler(.copyInPart(text: model.text.string))
}

guard !model.isFake else {
return AMenuSection([copy])
}

return AMenuSection([reply, copy, report, remove])
return AMenuSection([reply, copyInPart, copy, report, remove])
}

@objc func tapReactionAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,14 @@ extension ChatMessageReplyCell {
actionHandler(.copy(text: model.message.string))
}

return AMenuSection([reply, copy, report, remove])
let copyInPart = AMenuItem.action(
title: .adamant.chat.selectText,
systemImageName: "selection.pin.in.out"
) { [actionHandler, model] in
actionHandler(.copyInPart(text: model.message.string))
}

return AMenuSection([reply, copyInPart, copy, report, remove])
}

@objc func tapReactionAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
let stack = UIStackView()
stack.alignment = .center
stack.axis = .horizontal
stack.spacing = 12
stack.spacing = horizontalStackSpacing
return stack
}()

Expand All @@ -57,7 +57,7 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
stack.alignment = .center
stack.axis = .vertical
stack.spacing = 12

stack.addArrangedSubview(statusButton)
stack.addArrangedSubview(ownReactionLabel)
stack.addArrangedSubview(opponentReactionLabel)
Expand Down Expand Up @@ -118,9 +118,12 @@ final class ChatTransactionContainerView: UIView, ChatModelView {
private lazy var chatMenuManager = ChatMenuManager(delegate: self)

private let ownReactionSize = CGSize(width: 40, height: 27)
private let opponentReactionSize = CGSize(width: 55, height: 27)
private let opponentReactionSize = CGSize(width: opponentReactionWidth, height: 27)
private let opponentReactionImageSize = CGSize(width: 12, height: 12)

static let opponentReactionWidth: CGFloat = 55
static let horizontalStackSpacing: CGFloat = 12

var isSelected: Bool = false {
didSet {
contentView.isSelected = isSelected
Expand Down Expand Up @@ -154,7 +157,7 @@ private extension ChatTransactionContainerView {
addSubview(horizontalStack)
horizontalStack.snp.makeConstraints {
$0.top.bottom.equalToSuperview()
$0.leading.trailing.equalToSuperview().inset(12)
$0.horizontalEdges.equalToSuperview()
}

swipeView.swipeStateAction = { [actionHandler] state in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ final class ChatTransactionContentView: UIView {

extension ChatTransactionContentView.Model {
func height(for width: CGFloat) -> CGFloat {
let maxSize = CGSize(width: width, height: .infinity)
let opponentReactionWidth = ChatTransactionContainerView.opponentReactionWidth
let containerHorizontalOffset = ChatTransactionContainerView.horizontalStackSpacing * 2
let contentHorizontalOffset = horizontalInsets * 2

let maxSize = CGSize(
width: width
- opponentReactionWidth
- containerHorizontalOffset
- contentHorizontalOffset,
height: .infinity
)
let titleString = NSAttributedString(string: title, attributes: [.font: titleFont])
let dateString = NSAttributedString(string: date, attributes: [.font: dateFont])

Expand Down Expand Up @@ -181,7 +191,7 @@ private extension ChatTransactionContentView {
addSubview(verticalStack)
verticalStack.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(verticalInsets)
$0.leading.trailing.equalToSuperview().inset(12)
$0.leading.trailing.equalToSuperview().inset(horizontalInsets)
}
}

Expand Down Expand Up @@ -237,4 +247,5 @@ private let commentFont = UIFont.systemFont(ofSize: 14)
private let iconSize: CGFloat = 55
private let verticalStackSpacing: CGFloat = 6
private let verticalInsets: CGFloat = 8
private let horizontalInsets: CGFloat = 12
private let replyViewHeight: CGFloat = 25
Loading

0 comments on commit b038d03

Please sign in to comment.