Skip to content

Commit

Permalink
Merge pull request #1270 from novasamatech/fix/warnings
Browse files Browse the repository at this point in the history
fix warnings
  • Loading branch information
svojsu authored Nov 8, 2024
2 parents 879fb06 + 6655ab1 commit bb81ad0
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ extension KingfisherIconRetrieveOperationFactory: IconRetrieveOperationFactoryPr
return
}

let sizeBeforeProcessing = resultImage.size

if case .remoteTransparent = iconInfo.type {
resultImage = resultImage.redrawWithBackground(
color: R.color.colorTextPrimaryOnWhite()!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private extension QRCodeWithLogoFactory {
qrSize: CGSize,
partialResultClosure: @escaping (Result<QRCreationResult, Error>) -> Void
) -> CompoundOperationWrapper<QRCreationResult> {
var checkCacheOperation = checkCacheOperation(using: logoInfo)
let checkCacheOperation = checkCacheOperation(using: logoInfo)

let wrapper: CompoundOperationWrapper<QRCreationResult> = OperationCombiningService.compoundNonOptionalWrapper(
operationManager: OperationManager(operationQueue: operationQueue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ final class AssetDetailsViewLayout: UIView {
}

private func setupLayout() {
balanceTableView.addArrangedSubview(headerCell)
balanceTableView.addArrangedSubview(totalCell)
balanceTableView.addArrangedSubview(transferrableCell)
balanceTableView.addArrangedSubview(lockCell)
setupBalanceTableViewLayout()

addSubview(backgroundView)
backgroundView.snp.makeConstraints {
Expand Down Expand Up @@ -143,7 +140,6 @@ final class AssetDetailsViewLayout: UIView {
$0.leading.greaterThanOrEqualTo(assetView.snp.trailing).offset(8)
$0.centerY.equalTo(assetView.snp.centerY)
}

addSubview(containerView)
containerView.snp.makeConstraints {
$0.leading.trailing.bottom.equalToSuperview()
Expand All @@ -155,6 +151,13 @@ final class AssetDetailsViewLayout: UIView {
containerView.stackView.addArrangedSubview(buttonsRow)
}

private func setupBalanceTableViewLayout() {
balanceTableView.addArrangedSubview(headerCell)
balanceTableView.addArrangedSubview(totalCell)
balanceTableView.addArrangedSubview(transferrableCell)
balanceTableView.addArrangedSubview(lockCell)
}

func set(locale: Locale) {
let languages = locale.rLanguages

Expand Down
48 changes: 29 additions & 19 deletions novawallet/Modules/AssetList/AssetListPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ final class AssetListPresenter {
self.localizationManager = localizationManager
self.appearanceFacade = appearanceFacade
}
}

// MARK: Private

private func providePolkadotStakingPromotion() {
private extension AssetListPresenter {
func providePolkadotStakingPromotion() {
guard shouldShowPolkadotPromotion else {
return
}
Expand All @@ -53,7 +57,7 @@ final class AssetListPresenter {
view?.didReceivePromotion(viewModel: viewModel)
}

private func provideHeaderViewModel() {
func provideHeaderViewModel() {
guard let walletType = walletType, let name = name else {
return
}
Expand Down Expand Up @@ -87,7 +91,7 @@ final class AssetListPresenter {
)
}

private func createAssetAccountPrice(
func createAssetAccountPrice(
chainAssetId: ChainAssetId,
priceData: PriceData
) -> Either<SuccessAssetListAssetAccountPrice, FailedAssetListAssetAccountPrice>? {
Expand Down Expand Up @@ -117,7 +121,7 @@ final class AssetListPresenter {
))
}

private func createAssetAccountPriceLock(
func createAssetAccountPriceLock(
chainAssetId: ChainAssetId,
priceData: PriceData
) -> AssetListAssetAccountPrice? {
Expand All @@ -140,7 +144,7 @@ final class AssetListPresenter {
)
}

private func provideHeaderViewModel(
func provideHeaderViewModel(
with priceMapping: [ChainAssetId: PriceData],
walletIdenticon: Data?,
walletType: MetaAccountModelType,
Expand Down Expand Up @@ -169,7 +173,7 @@ final class AssetListPresenter {
view?.didReceiveHeader(viewModel: viewModel)
}

private func createHeaderPriceState(
func createHeaderPriceState(
from priceMapping: [ChainAssetId: PriceData],
externalBalances: [AssetListAssetAccountPrice]
) -> LoadableViewModelState<[AssetListAssetAccountPrice]> {
Expand Down Expand Up @@ -209,7 +213,7 @@ final class AssetListPresenter {
return priceState + externalBalances
}

private func createHeaderLockState(
func createHeaderLockState(
from priceMapping: [ChainAssetId: PriceData],
externalBalances: [AssetListAssetAccountPrice]
) -> [AssetListAssetAccountPrice]? {
Expand All @@ -226,7 +230,7 @@ final class AssetListPresenter {
return locks + externalBalances
}

private func checkNonZeroLocks() -> Bool {
func checkNonZeroLocks() -> Bool {
let locks = model.balances.map { (try? $0.value.get())?.locked ?? 0 }

if locks.contains(where: { $0 > 0 }) {
Expand All @@ -242,7 +246,7 @@ final class AssetListPresenter {
return false
}

private func provideAssetViewModels() {
func provideAssetViewModels() {
guard let hidesZeroBalances, let assetListStyle else {
return
}
Expand All @@ -266,7 +270,7 @@ final class AssetListPresenter {
}
}

private func externalBalanceModel(prices: [ChainAssetId: PriceData]) -> [AssetListAssetAccountPrice] {
func externalBalanceModel(prices: [ChainAssetId: PriceData]) -> [AssetListAssetAccountPrice] {
switch model.externalBalanceResult {
case .failure, .none:
return []
Expand Down Expand Up @@ -296,7 +300,7 @@ final class AssetListPresenter {
}
}

private func createGroupViewModels() -> [AssetListGroupType] {
func createGroupViewModels() -> [AssetListGroupType] {
guard let hidesZeroBalances, let assetListStyle else {
return []
}
Expand All @@ -323,7 +327,7 @@ final class AssetListPresenter {
}
}

private func filterZeroBalances(_ assets: [AssetListAssetModel]) -> [AssetListAssetModel] {
func filterZeroBalances(_ assets: [AssetListAssetModel]) -> [AssetListAssetModel] {
let filteredAssets: [AssetListAssetModel]

filteredAssets = assets.filter { asset in
Expand All @@ -337,7 +341,7 @@ final class AssetListPresenter {
return filteredAssets
}

private func createAssetGroupViewModel(
func createAssetGroupViewModel(
from groupModel: AssetListAssetGroupModel,
maybePrices: [ChainAssetId: PriceData]?,
hidesZeroBalances: Bool
Expand Down Expand Up @@ -365,7 +369,7 @@ final class AssetListPresenter {
}
}

private func createNetworkGroupViewModel(
func createNetworkGroupViewModel(
from groupModel: AssetListChainGroupModel,
maybePrices: [ChainAssetId: PriceData]?,
hidesZeroBalances: Bool
Expand Down Expand Up @@ -401,7 +405,7 @@ final class AssetListPresenter {
)
}

private func provideNftViewModel() {
func provideNftViewModel() {
guard !model.nfts.isEmpty else {
view?.didReceiveNft(viewModel: nil)
return
Expand All @@ -411,20 +415,20 @@ final class AssetListPresenter {
view?.didReceiveNft(viewModel: nftViewModel)
}

private func updateAssetsView() {
func updateAssetsView() {
provideHeaderViewModel()
provideAssetViewModels()
}

private func updateHeaderView() {
func updateHeaderView() {
provideHeaderViewModel()
}

private func updateNftView() {
func updateNftView() {
provideNftViewModel()
}

private func presentAssetDetails(for chainAssetId: ChainAssetId) {
func presentAssetDetails(for chainAssetId: ChainAssetId) {
// get chain from interactor that includes also disabled assets
let optChain = interactor.getFullChain(for: chainAssetId.chainId) ?? model.allChains[chainAssetId.chainId]

Expand All @@ -438,6 +442,8 @@ final class AssetListPresenter {
}
}

// MARK: AssetListPresenterProtocol

extension AssetListPresenter: AssetListPresenterProtocol {
func setup() {
interactor.setup()
Expand Down Expand Up @@ -556,6 +562,8 @@ extension AssetListPresenter: AssetListPresenterProtocol {
}
}

// MARK: AssetListInteractorOutputProtocol

extension AssetListPresenter: AssetListInteractorOutputProtocol {
func didReceive(result: AssetListBuilderResult) {
guard result.walletId != nil, result.walletId == walletId else {
Expand Down Expand Up @@ -638,6 +646,8 @@ extension AssetListPresenter: AssetListInteractorOutputProtocol {
}
}

// MARK: Localizable

extension AssetListPresenter: Localizable {
func applyLocalization() {
if let view = view, view.isSetup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum AssetListAssetModelComparator {
return nil
}
}

static func byChain(
lhs: AssetListAssetModel,
rhs: AssetListAssetModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class AssetListCollectionManager {
private var promotionBannerViewModel: PromotionBannerView.ViewModel?

private let collectionViewDataSource: AssetListCollectionViewDataSource
// swiftlint:disable weak_delegate
private let collectionViewDelegate: AssetListCollectionViewDelegate

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,11 @@ private extension AssetListCollectionViewDataSource {
action: #selector(actionManage),
for: .touchUpInside
)

settingsCell.searchButton.addTarget(
self,
action: #selector(actionSearch),
for: .touchUpInside
)

settingsCell.styleSwitcher.addTarget(
self,
action: #selector(actionSwitchStyle),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private extension AssetListStyleSwitcherView {
newText: R.string.localizable.commonTokens(
preferredLanguages: locale.rLanguages
),
direction: .up
direction: .top
)
animateIndicators(
squareColor: Constants.indicatorInactiveColor,
Expand All @@ -204,7 +204,7 @@ private extension AssetListStyleSwitcherView {
newText: R.string.localizable.commonNetworks(
preferredLanguages: locale.rLanguages
),
direction: .down
direction: .bottom
)
animateIndicators(
squareColor: Constants.indicatorActiveColor,
Expand Down Expand Up @@ -357,13 +357,13 @@ private extension AssetListStyleSwitcherView {

private extension AssetListStyleSwitcherView {
enum AnimationDirection {
case up
case down
case top
case bottom

var yOffset: CGFloat {
switch self {
case .up: return -1
case .down: return 1
case .top: return -1
case .bottom: return 1
}
}
}
Expand Down
Loading

0 comments on commit bb81ad0

Please sign in to comment.