Skip to content
Open
8 changes: 4 additions & 4 deletions Adamant/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -766,16 +766,16 @@ private enum TabScreens {
private func makeSplitController() -> UISplitViewController {
let controller = UISplitViewController()
controller.preferredDisplayMode = .oneBesideSecondary

// Set the default ratio to 1:2
controller.preferredPrimaryColumnWidthFraction = 0.3337

let minimumPrimaryColumnWidth: CGFloat = UIScreen.main.bounds.width * 0.2
// Set the minimum ratio to 1:5, or to 300px if 1:5 results in a smaller value
controller.minimumPrimaryColumnWidth = minimumPrimaryColumnWidth > 300 ? minimumPrimaryColumnWidth : 300

// Set the maximum ratio to 3:1
controller.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.75

return controller
}
5 changes: 3 additions & 2 deletions Adamant/App/DI/AppAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ struct AppAssembly: MainThreadAssembly {
adamantCore: r.resolve(AdamantCore.self)!,
accountsProvider: r.resolve(AccountsProvider.self)!,
transactionService: r.resolve(ChatTransactionService.self)!,
SecureStore: r.resolve(SecureStore.self)!,
walletServiceCompose: r.resolve(WalletServiceCompose.self)!
secureStore: r.resolve(SecureStore.self)!,
walletServiceCompose: r.resolve(WalletServiceCompose.self)!,
timeouts: AdmWalletService.timeouts
)
}.inObjectScope(.container)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ final class AccountViewController: FormViewController {
}()

private var walletViewControllers: [WalletViewController] = []

private lazy var currentSelectedWallet: AccountWalletCellState? = {
viewModel.state.wallets.first(where: { $0.model.index == 0 })
}()
Expand Down Expand Up @@ -189,7 +189,7 @@ final class AccountViewController: FormViewController {
pagingViewController.indicatorOptions = .visible(height: 2, zIndex: Int.max, spacing: UIEdgeInsets.zero, insets: UIEdgeInsets.zero)
pagingViewController.dataSource = self
pagingViewController.delegate = self

accountHeaderView.walletViewContainer.addSubview(pagingViewController.view)
pagingViewController.view.snp.makeConstraints {
$0.directionalEdges.equalToSuperview()
Expand All @@ -200,7 +200,7 @@ final class AccountViewController: FormViewController {
updatePagingItemHeight()

pagingViewController.borderColor = UIColor.clear

// MARK: Rows&Sections

// MARK: Application
Expand Down Expand Up @@ -963,11 +963,13 @@ final class AccountViewController: FormViewController {

@objc private func handleRefresh(_ refreshControl: UIRefreshControl) {
guard let currencyNetwork = currentSelectedWallet?.model.currencyNetwork else { return }

let unavailableNodes: Set<NodeGroup> = Set(NodeGroup.allCases.filter {
!(apiServiceCompose.get($0)?.hasSupportedNode ?? true)
})


let unavailableNodes: Set<NodeGroup> = Set(
NodeGroup.allCases.filter {
!(apiServiceCompose.get($0)?.hasSupportedNode ?? true)
}
)

if unavailableNodes.contains(where: {
$0.name == currencyNetwork
}) {
Expand All @@ -977,7 +979,7 @@ final class AccountViewController: FormViewController {
).localizedDescription
)
}

Task { @MainActor in
accountService.updateWithRefreshUI()
}
Expand Down Expand Up @@ -1073,7 +1075,7 @@ extension AccountViewController: PagingViewControllerDataSource, PagingViewContr
wallet.model.index == pagingItem.identifier
})
}

DispatchQueue.onMainThreadSyncSafe {
guard transitionSuccessful,
let first = startingViewController as? WalletViewController,
Expand All @@ -1098,7 +1100,6 @@ extension AccountViewController: PagingViewControllerDataSource, PagingViewContr
}
}


private func updateHeaderSize(with walletViewController: WalletViewController, animated: Bool) {
guard case let .fixed(_, menuHeight) = pagingViewController.menuItemSize else {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import Parchment

struct AccountWalletsState {
var wallets: [AccountWalletCellState]

static let `default` = Self(wallets: [])
}

struct AccountWalletCellState {
@ObservableValue var model: WalletCollectionViewCellModel

init(model: WalletCollectionViewCellModel) {
self.model = model
}

static let `default` = Self(model: .default)
}

Expand All @@ -31,14 +31,14 @@ extension AccountWalletCellState: Equatable {
}
}

extension AccountWalletCellState: PagingItem{
extension AccountWalletCellState: PagingItem {
var identifier: Int { model.index }

func isBefore(item: PagingItem) -> Bool {
guard let other = item as? Self else { return false }
return self.model.index < other.model.index
}

func isEqual(to item: PagingItem) -> Bool {
guard let other = item as? Self else { return false }
return self == other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
@MainActor
final class AccountWalletsViewModel {
var state: AccountWalletsState = .default

private let walletsStoreService: WalletStoreServiceProviderProtocol
private var subscriptions = Set<AnyCancellable>()

Expand Down
4 changes: 2 additions & 2 deletions Adamant/Modules/Account/WalletCollectionViewCell+Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2025 Adamant. All rights reserved.
//

import Parchment
import CommonKit
import Parchment
import UIKit

struct WalletCollectionViewCellModel {
Expand All @@ -19,7 +19,7 @@ struct WalletCollectionViewCellModel {
var isBalanceInitialized: Bool
var balance: Decimal?
var notificationBadgeCount: Int

static let `default` = WalletCollectionViewCellModel(
index: 0,
coinID: "",
Expand Down
14 changes: 7 additions & 7 deletions Adamant/Modules/Account/WalletCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class WalletCollectionViewCell: PagingCell {
@IBOutlet weak var balanceLabel: UILabel!
@IBOutlet weak var currencySymbolLabel: UILabel!
@IBOutlet weak var accessoryContainerView: AccessoryContainerView!

private var cancellables = Set<AnyCancellable>()

override func prepareForReuse() {
cancellables.removeAll()
}

override func setPagingItem(
_ pagingItem: PagingItem,
selected: Bool,
Expand All @@ -33,9 +33,9 @@ class WalletCollectionViewCell: PagingCell {
return
}
update(item: item.model)

cancellables.removeAll()

item.$model
.removeDuplicates()
.receive(on: DispatchQueue.main)
Expand All @@ -46,9 +46,9 @@ class WalletCollectionViewCell: PagingCell {
}
}

private extension WalletCollectionViewCell {
extension WalletCollectionViewCell {
@MainActor
func update(item: WalletCollectionViewCellModel) {
fileprivate func update(item: WalletCollectionViewCellModel) {
currencyImageView.image = item.currencyImage
if item.currencyNetwork == item.currencySymbol {
currencySymbolLabel.text = item.currencySymbol
Expand Down
33 changes: 20 additions & 13 deletions Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ final class ChatViewController: MessagesViewController {
: chatMessagesCollectionView.bottomOffset
)
}

override func collectionView(
_ collectionView: UICollectionView,
canPerformAction action: Selector,
Expand All @@ -199,14 +199,14 @@ final class ChatViewController: MessagesViewController {
) -> Bool {
return false
}

override func collectionView(
_ collectionView: UICollectionView,
shouldShowMenuForItemAt indexPath: IndexPath
) -> Bool {
return false
}

override func scrollViewDidEndDecelerating(_: UIScrollView) {
scrollDidStop()
}
Expand Down Expand Up @@ -309,7 +309,7 @@ extension ChatViewController {
self.viewModel.updatePreviewFor(indexes: indexes)
}
.store(in: &subscriptions)

NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)
.sink { [weak self] _ in
self?.state.isAppActive = false
Expand Down Expand Up @@ -936,7 +936,12 @@ extension ChatViewController {
}

@MainActor
fileprivate func scrollToPosition(_ position: ChatStartPosition, animated: Bool = false, setExtraOffset: Bool = false, scrollAt: UICollectionView.ScrollPosition = .centeredVertically) {
fileprivate func scrollToPosition(
_ position: ChatStartPosition,
animated: Bool = false,
setExtraOffset: Bool = false,
scrollAt: UICollectionView.ScrollPosition = .centeredVertically
) {
chatMessagesCollectionView.fixedBottomOffset = nil

switch position {
Expand Down Expand Up @@ -1268,30 +1273,32 @@ extension ChatViewController {
state.isAutoScrolling = false
state.isScrollingToBottom = false
updateUnreadMessages()

guard !state.isAnimatingCellHighlight else { return }
guard let messageId = viewModel.cellIdForAnimation,
let index = viewModel.messages.firstIndex(where: { $0.messageId == messageId }) else {
let index = viewModel.messages.firstIndex(where: { $0.messageId == messageId })
else {
return
}

let indexPath = IndexPath(item: 0, section: index)
animateCell(at: indexPath)
}

private func animateCell(at indexPath: IndexPath) {
state.isAnimatingCellHighlight = true

//0.2 sec delay that all methods that can interrupt the animation have time to execute
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in
guard let self = self else { return }

guard self.messagesCollectionView.indexPathsForVisibleItems.contains(indexPath),
let cell = self.messagesCollectionView.cellForItem(at: indexPath) as? ChatCellProtocol else {
let cell = self.messagesCollectionView.cellForItem(at: indexPath) as? ChatCellProtocol
else {
self.state.isAnimatingCellHighlight = false
return
}

cell.animateMessageHighlight()
self.viewModel.shortVibro()
self.viewModel.cellIdForAnimation = nil
Expand Down
2 changes: 1 addition & 1 deletion Adamant/Modules/Chat/View/ChatViewControllerState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ChatViewControllerState {
var isAutoScrolling = false
var isAppActive = true
var isScrollingToBottom = false

//calculation for animation, might use for something else in the future
var isAnimationAllowed: Bool {
isMessagesLoaded && !isAutoScrolling && !isScrollingToBottom
Expand Down
46 changes: 28 additions & 18 deletions Adamant/Modules/Chat/View/Helpers/AdamantCellAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@ extension UIView {
layer.masksToBounds = masksToBounds
layer.cornerRadius = cornerRadius
}

func animateHighlight(
highlightColor: UIColor = UIColor.adamant.active.withAlphaComponent(0.5),
duration: TimeInterval = 2.5
) {
let originalColor = self.backgroundColor

UIView.animate(withDuration: 0.35, animations: {
self.backgroundColor = highlightColor
}, completion: { _ in
UIView.animate(withDuration: duration - 0.35) {
self.backgroundColor = originalColor

UIView.animate(
withDuration: 0.35,
animations: {
self.backgroundColor = highlightColor
},
completion: { _ in
UIView.animate(withDuration: duration - 0.35) {
self.backgroundColor = originalColor
}
}
})
)
}

func animateHighlightOverlay(
overlayColor: UIColor = UIColor.adamant.active.withAlphaComponent(0.5)
) {
Expand All @@ -59,24 +63,30 @@ extension UIView {
overlay.isUserInteractionEnabled = false
overlay.layer.cornerRadius = layer.cornerRadius
overlay.layer.masksToBounds = true

addSubview(overlay)
bringSubviewToFront(overlay)

UIView.animate(withDuration: 1.5, delay: 0.5, options: [.curveEaseOut], animations: {
overlay.alpha = 0
}, completion: { _ in
overlay.removeFromSuperview()
})

UIView.animate(
withDuration: 1.5,
delay: 0.5,
options: [.curveEaseOut],
animations: {
overlay.alpha = 0
},
completion: { _ in
overlay.removeFromSuperview()
}
)
}

func animatePressDown(duration: TimeInterval = 0.1) {
UIView.animate(withDuration: duration) {
self.transform = CGAffineTransform(scaleX: 0.96, y: 0.96)
self.alpha = 0.5
}
}

func animatePressUp(duration: TimeInterval = 0.1) {
UIView.animate(withDuration: duration) {
self.transform = .identity
Expand Down
Loading
Loading