Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-8424 Receive screen layout #4259

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions BlockchainSdk/Common/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,34 @@ public indirect enum Blockchain: Equatable, Hashable {
}
}

public var hasMemo: Bool {
switch self {
case .stellar,
.binance,
.ton,
.cosmos,
.terraV1,
.terraV2,
.algorand,
.hedera,
.sei,
.internetComputer,
.casper:
true
default:
false
}
}

public var hasDestinationTag: Bool {
switch self {
case .xrp:
true
default:
false
}
}

public var feePaidCurrency: FeePaidCurrency {
switch self {
case .terraV1:
Expand Down
6 changes: 5 additions & 1 deletion Tangem/Modules/Main/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ extension MainCoordinator: MultiWalletMainContentRoutable {

extension MainCoordinator: SingleTokenBaseRoutable {
func openReceiveScreen(tokenItem: TokenItem, addressInfos: [ReceiveAddressInfo]) {
receiveBottomSheetViewModel = .init(tokenItem: tokenItem, addressInfos: addressInfos)
receiveBottomSheetViewModel = .init(
tokenItem: tokenItem,
addressInfos: addressInfos,
hasMemo: tokenItem.blockchain.hasMemo
)
}

func openBuyCrypto(at url: URL, action: @escaping () -> Void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ extension MarketsTokenDetailsCoordinator {
)
}

receiveBottomSheetViewModel = .init(tokenItem: walletModel.tokenItem, addressInfos: infos)
receiveBottomSheetViewModel = .init(
tokenItem: walletModel.tokenItem,
addressInfos: infos,
hasMemo: walletModel.tokenItem.blockchain.hasMemo
)
}

func openBuyCryptoIfPossible(for walletModel: WalletModel, with userWalletModel: UserWalletModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@ enum SendDestinationAdditionalFieldType {

static func type(for blockchain: Blockchain) -> SendDestinationAdditionalFieldType? {
switch blockchain {
case .stellar,
.binance,
.ton,
.cosmos,
.terraV1,
.terraV2,
.algorand,
.hedera,
.sei,
.internetComputer,
.casper:
case let value where value.hasMemo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может тут value на _ заменить, наверное икскод начнет ворнинги сыпать

return .memo
case .xrp:
case let value where value.hasDestinationTag:
return .destinationTag
default:
return .none
Expand Down
6 changes: 5 additions & 1 deletion Tangem/Modules/TokenDetails/TokenDetailsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ extension TokenDetailsCoordinator: PendingExpressTxStatusRoutable {

extension TokenDetailsCoordinator: SingleTokenBaseRoutable {
func openReceiveScreen(tokenItem: TokenItem, addressInfos: [ReceiveAddressInfo]) {
receiveBottomSheetViewModel = .init(tokenItem: tokenItem, addressInfos: addressInfos)
receiveBottomSheetViewModel = .init(
tokenItem: tokenItem,
addressInfos: addressInfos,
hasMemo: tokenItem.blockchain.hasMemo
)
}

func openBuyCrypto(at url: URL, action: @escaping () -> Void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Settings";
"qr_scanner_camera_denied_text" = "You have not given access to your camera";
"qr_scanner_camera_denied_title" = "Camera access denied";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ (%2$@) on %3$@ network";
"receive_bottom_sheet_warning_message_description" = "Sending any other currency will result in its irreversible loss.";
"receive_bottom_sheet_warning_message_full" = "Send only %@ to this address. Sending any other currency will result in its irreversible loss.";
"receive_bottom_sheet_warning_message_title" = "Send only %@ to this address.";
"receive_token_description" = "Transfer funds from any wallet or exchange";
"referral_button_participate" = "參與";
"referral_error_failed_to_load_info" = "無法加載有關推薦計劃的消息。請稍後再試";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,35 @@ struct ReceiveBottomSheetView: View {

Image(uiImage: info.addressQRImage)
.resizable()
.aspectRatio(1.0, contentMode: .fit)
.padding(.horizontal, 48)
.frame(width: 220, height: 220)
.padding(.top, 18)

SUILabel(viewModel.stringForAddress(info.address))
.padding(.horizontal, 60)
.padding(.top, 20)
.onTapGesture {
viewModel.copyToClipboard()
}

Text(viewModel.warningMessageFull)
.multilineTextAlignment(.center)
.padding(.horizontal, 44)
.padding(.top, 12)
.padding(.bottom, 28)
.style(Fonts.Bold.caption1, color: Colors.Text.tertiary)
if let memoWarningMessage = viewModel.memoWarningMessage {
Text(memoWarningMessage)
.padding(.top, 12)
.style(Fonts.Bold.caption1, color: Colors.Text.tertiary)
}

NotificationView(
input: .init(
style: .plain,
severity: .info,
settings: .init(
event: ReceiveNotificationEvent(currencySymbol: viewModel.currencySymbol),
dismissAction: nil
)
)
)
.padding(.top, 12)
.padding(.bottom, 28)
.padding(.horizontal, 16)
}
}
.padding(.top, 24)
Expand Down Expand Up @@ -97,7 +112,8 @@ struct ReceiveBottomSheet_Previews: PreviewProvider {
localizedName: "legacy",
addressQRImage: QrCodeGenerator.generateQRCode(from: "18VEbRSEASi1npnXnoJ6pVVBrhT5zE6qRz")
),
]
],
hasMemo: false
)
}

Expand All @@ -111,7 +127,8 @@ struct ReceiveBottomSheet_Previews: PreviewProvider {
localizedName: "default",
addressQRImage: QrCodeGenerator.generateQRCode(from: "0xEF08EA3531D219EDE813FB521e6D89220198bcB1")
),
]
],
hasMemo: false
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import CombineExt

class ReceiveBottomSheetViewModel: ObservableObject, Identifiable {
let addressInfos: [ReceiveAddressInfo]
let networkWarningMessage: String
let memoWarningMessage: String?

let id = UUID()
let addressIndexUpdateNotifier = PassthroughSubject<Int, Never>()
Expand All @@ -34,16 +34,16 @@ class ReceiveBottomSheetViewModel: ObservableObject, Identifiable {
Localization.receiveBottomSheetWarningMessageFull(tokenItem.currencySymbol)
}

init(tokenItem: TokenItem, addressInfos: [ReceiveAddressInfo]) {
var currencySymbol: String {
tokenItem.currencySymbol
}

init(tokenItem: TokenItem, addressInfos: [ReceiveAddressInfo], hasMemo: Bool) {
self.tokenItem = tokenItem
iconURL = tokenItem.id != nil ? IconURLBuilder().tokenIconURL(id: tokenItem.id!) : nil
self.addressInfos = addressInfos

networkWarningMessage = Localization.receiveBottomSheetWarningMessage(
tokenItem.name,
tokenItem.currencySymbol,
tokenItem.networkName
)
memoWarningMessage = hasMemo ? Localization.receiveBottomSheetNoMemoRequiredMessage : nil

bind()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// ReceiveNotificationEvent.swift
// Tangem
//
// Created by Dmitry Fedorov on 21.11.2024.
// Copyright © 2024 Tangem AG. All rights reserved.
//

import Foundation

struct ReceiveNotificationEvent {
let currencySymbol: String
}

extension ReceiveNotificationEvent: NotificationEvent {
var id: NotificationViewId {
currencySymbol.hashValue
}

var title: NotificationView.Title {
.string(Localization.receiveBottomSheetWarningMessageTitle(currencySymbol))
}

var description: String? {
Localization.receiveBottomSheetWarningMessageDescription
}

var colorScheme: NotificationView.ColorScheme {
.secondary
}

var icon: NotificationView.MessageIcon {
.init(iconType: .image(Assets.blueCircleWarning.image))
}

var severity: NotificationView.Severity {
.info
}

var isDismissable: Bool {
false
}

var buttonAction: NotificationButtonAction? {
nil
}

var analyticsEvent: Analytics.Event? {
nil
}

var analyticsParams: [Analytics.ParameterKey: String] {
[:]
}

var isOneShotAnalyticsEvent: Bool {
false
}
}
4 changes: 4 additions & 0 deletions TangemApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
0AC9EFF72CAE857C005F868F /* StakingSingleActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC9EFF62CAE857C005F868F /* StakingSingleActionModel.swift */; };
0AC9EFF92CAE9B2C005F868F /* CommonStakingSingleActionStepsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC9EFF82CAE9B2C005F868F /* CommonStakingSingleActionStepsManager.swift */; };
0AD13F952C8AD76800C2EE16 /* CommonStakingAnalyticsLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AD13F942C8AD76800C2EE16 /* CommonStakingAnalyticsLogger.swift */; };
0AEA96BB2CEF8D9700395617 /* ReceiveNotificationEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEA96BA2CEF8D9700395617 /* ReceiveNotificationEvent.swift */; };
2D0E4F532A8D114E00001D8E /* GenericWalletManagerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D0E4F522A8D114E00001D8E /* GenericWalletManagerFactory.swift */; };
2D1400CA2C43F79F00B75A42 /* MarketsPortfolioContextActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1400C82C43F4FD00B75A42 /* MarketsPortfolioContextActions.swift */; };
2D1400CE2C44090400B75A42 /* MarketsPortfolioContainerRoutable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1400CD2C44090400B75A42 /* MarketsPortfolioContainerRoutable.swift */; };
Expand Down Expand Up @@ -3135,6 +3136,7 @@
0AC9EFF82CAE9B2C005F868F /* CommonStakingSingleActionStepsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonStakingSingleActionStepsManager.swift; sourceTree = "<group>"; };
0AD13F942C8AD76800C2EE16 /* CommonStakingAnalyticsLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonStakingAnalyticsLogger.swift; sourceTree = "<group>"; };
0AD9EF0E2CC2A9B600466191 /* UnstakingSendAmountValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnstakingSendAmountValidator.swift; sourceTree = "<group>"; };
0AEA96BA2CEF8D9700395617 /* ReceiveNotificationEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveNotificationEvent.swift; sourceTree = "<group>"; };
0BE949936543D22F51E09DBD /* Pods-Tangem-TangemUITests.release(alpha).xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tangem-TangemUITests.release(alpha).xcconfig"; path = "Target Support Files/Pods-Tangem-TangemUITests/Pods-Tangem-TangemUITests.release(alpha).xcconfig"; sourceTree = "<group>"; };
0F0F54769EDEAC846B6BF43B /* Pods_Tangem_TangemUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tangem_TangemUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
136B5829321AB7962F0F8960 /* Pods-TangemTests.release(beta).xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TangemTests.release(beta).xcconfig"; path = "Target Support Files/Pods-TangemTests/Pods-TangemTests.release(beta).xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8879,6 +8881,7 @@
B0E7489B2A3C130B0015E3FC /* ReceiveBottomSheetView.swift */,
B0F7D7612A404907007FEB2E /* ReceiveBottomSheetViewModel.swift */,
B0F7D75D2A4048D5007FEB2E /* ReceiveAddressInfo.swift */,
0AEA96BA2CEF8D9700395617 /* ReceiveNotificationEvent.swift */,
);
path = ReceiveBottomSheetView;
sourceTree = "<group>";
Expand Down Expand Up @@ -17776,6 +17779,7 @@
B6DF90592CA302280099FED5 /* MainCoordinatorNavigationAssertion.swift in Sources */,
B09BB85F259A075600B92000 /* TangemButton.swift in Sources */,
B0DB73FC2A8CA28800F6376E /* UnlockUserWalletBottomSheetViewModel.swift in Sources */,
0AEA96BB2CEF8D9700395617 /* ReceiveNotificationEvent.swift in Sources */,
B03FF89E2B5E4FC000202EC0 /* AppVisaBalances.swift in Sources */,
B012A11D2AA617000079BAB4 /* UserWalletNotificationManager.swift in Sources */,
DA5CD0992A25F4F2008FD876 /* PromotionCoordinatorView.swift in Sources */,
Expand Down
Loading