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 2 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
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,6 +30,19 @@ enum SendDestinationAdditionalFieldType {

static func type(for blockchain: Blockchain) -> SendDestinationAdditionalFieldType? {
switch blockchain {
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 let value where value.hasDestinationTag:
return .destinationTag
default:
return .none
}
}
}

extension Blockchain {
var hasMemo: Bool {
tureck1y marked this conversation as resolved.
Show resolved Hide resolved
switch self {
case .stellar,
.binance,
.ton,
Expand All @@ -41,11 +54,18 @@ enum SendDestinationAdditionalFieldType {
.sei,
.internetComputer,
.casper:
return .memo
true
default:
false
}
}

var hasDestinationTag: Bool {
switch self {
case .xrp:
return .destinationTag
true
default:
return .none
false
}
}
}
6 changes: 5 additions & 1 deletion Tangem/Modules/TokenDetails/TokenDetailsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Einstellungen";
"qr_scanner_camera_denied_text" = "Du hast keinen Zugriff auf deine Kamera gewährt";
"qr_scanner_camera_denied_title" = "Kamerazugriff verweigert";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ ( %2$@ ) im %3$@ Netzwerk";
"receive_bottom_sheet_warning_message_description" = "Der Versand einer anderen Währung führt zu ihrem unwiderruflichen Verlust.";
"receive_bottom_sheet_warning_message_full" = "Sende nur %@ an diese Adresse. Der Versand einer anderen Währung führt zu ihrem unwiderruflichen Verlust.";
"receive_bottom_sheet_warning_message_title" = "Sende nur %@ an diese Adresse.";
"receive_token_description" = "Überweise Geld von einem anderen Wallet oder einer anderen Börse";
"referral_button_participate" = "Teilnehmen";
"referral_error_failed_to_load_info" = "Die Informationen zum Empfehlungsprogramm konnten nicht geladen werden. Bitte versuche es später noch einmal.";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/en.lproj/Localizable.strings
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" = "Participate";
"referral_error_failed_to_load_info" = "Failed to load the information about the referral program. Please try again later.";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Ajustes";
"qr_scanner_camera_denied_text" = "No ha dado acceso a su cámara";
"qr_scanner_camera_denied_title" = "Acceso a la cámara denegado";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ (%2$@) en la red %3$@";
"receive_bottom_sheet_warning_message_description" = "Enviar cualquier otra moneda resultará en su pérdida irreversible.";
"receive_bottom_sheet_warning_message_full" = "Envíe solo %@ a esta dirección. Enviar cualquier otra moneda resultará en su pérdida irreversible.";
"receive_bottom_sheet_warning_message_title" = "Envíe solo %@ a esta dirección.";
"receive_token_description" = "Transfiera fondos desde otra billetera o intercambio";
"referral_button_participate" = "Participar";
"referral_error_failed_to_load_info" = "Error al cargar la información sobre el programa de referidos. Por favor, inténtelo de nuevo más tarde.";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Paramètres";
"qr_scanner_camera_denied_text" = "Vous n'avez pas donné accès à votre caméra";
"qr_scanner_camera_denied_title" = "Accès à la caméra refusé";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ (%2$@) sur le réseau %3$@";
"receive_bottom_sheet_warning_message_description" = "L'envoi de toute autre devise entraînera sa perte irréversible.";
"receive_bottom_sheet_warning_message_full" = "Envoyez uniquement %@ à cette adresse. L'envoi de toute autre devise entraînera sa perte irréversible.";
"receive_bottom_sheet_warning_message_title" = "Envoyez uniquement %@ à cette adresse.";
"receive_token_description" = "Transférez des fonds depuis un autre portefeuille ou une autre bourse";
"referral_button_participate" = "Participer";
"referral_error_failed_to_load_info" = "Échec du chargement des informations sur le programme de parrainage. Veuillez réessayer plus tard.";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/it.lproj/Localizable.strings
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" = "Participate";
"referral_error_failed_to_load_info" = "Failed to load the information about the referral program. Please try again later.";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "設定";
"qr_scanner_camera_denied_text" = "カメラへのアクセスを許可していません。";
"qr_scanner_camera_denied_title" = "カメラへのアクセスが拒否されました";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%3$@ネットワーク上の%1$@ ( %2$@ )";
"receive_bottom_sheet_warning_message_description" = "他のトークンを送信すると、取り返しのつかない損失が発生します。";
"receive_bottom_sheet_warning_message_full" = "このアドレスには%@のみを送金してください。他のトークンを送信すると、取り返しのつかない損失が発生します。";
"receive_bottom_sheet_warning_message_title" = "このアドレスには%@のみを送金してください。";
"receive_token_description" = "ウォレットや取引所から資金を送金する";
"referral_button_participate" = "参加する";
"referral_error_failed_to_load_info" = "紹介プログラムに関する情報を読み込めませんでした。しばらくしてからもう一度お試しください。";
Expand Down
3 changes: 3 additions & 0 deletions Tangem/Resources/Localizations/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Настройки";
"qr_scanner_camera_denied_text" = "Вы не предоставили доступ к вашей камере";
"qr_scanner_camera_denied_title" = "Доступ к камере запрещен";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ (%2$@) в сети %3$@";
"receive_bottom_sheet_warning_message_description" = "Использование другой сети может привести к утрате средств.";
"receive_bottom_sheet_warning_message_full" = "Отправляйте только %@ на этот адрес. Использование другой сети может привести к утрате средств.";
"receive_bottom_sheet_warning_message_title" = "Отправляйте только %@ на этот адрес.";
"receive_token_description" = "Переводите средства с любого кошелька или биржи";
"referral_button_participate" = "Участвовать";
"referral_error_failed_to_load_info" = "Не удалось загрузить информацию по реферальной программе. Пожалуйста, попробуйте позже.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,11 @@
"qr_scanner_camera_denied_settings_button" = "Налаштування";
"qr_scanner_camera_denied_text" = "Ви не надали доступ до своєї камери";
"qr_scanner_camera_denied_title" = "Доступ до камери заборонено";
"receive_bottom_sheet_no_memo_required_message" = "No memo required";
"receive_bottom_sheet_warning_message" = "%1$@ (%2$@) у мережі %3$@";
"receive_bottom_sheet_warning_message_description" = "Надсилання будь-якої іншої валюти призведе до її незворотної втрати.";
"receive_bottom_sheet_warning_message_full" = "Надсилайте лише %@ на цю адресу. Надсилання будь-якої іншої валюти призведе до її незворотної втрати.";
"receive_bottom_sheet_warning_message_title" = "Надсилайте лише %@ на цю адресу.";
"receive_token_description" = "Переказуйте кошти з будь-якого гаманця або біржі";
"referral_button_participate" = "Взяти участь";
"referral_error_failed_to_load_info" = "Не вдалося завантажити інформацію по реферальній програмі. Будь ласка, спробуйте пізніше.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,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
}
}
Loading
Loading