Skip to content

Commit 987f1bd

Browse files
authored
iOS-320 (#148)
* Tonkeeper - Bump version to 5.1.1 * iOS-320
1 parent 5d0478d commit 987f1bd

File tree

7 files changed

+159
-13
lines changed

7 files changed

+159
-13
lines changed

LocalPackages/AppModules/SignRaw/Sources/SignRaw/Modules/SignRawConfirmation/SignRawConfirmationViewModel.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,23 @@ public final class SignRawConfirmationViewModelImplementation: SignRawConfirmati
185185

186186
private func createSliderItem() -> TKPopUp.Item {
187187
let isEnable: Bool
188+
let isWarning: Bool
188189
switch state.emulationState {
189190
case .emulating:
190191
isEnable = false
192+
isWarning = false
191193
case .success:
192194
isEnable = true
195+
isWarning = false
193196
case .fail:
194197
isEnable = true
198+
isWarning = true
195199
}
196200

197201
let sliderItem = TKPopUp.Component.Slider(
198202
title: TKLocales.Actions.confirm,
199203
isEnable: isEnable,
204+
appearance: isWarning ? .warning : .standart,
200205
didConfirm: { [weak self] in
201206
self?.confirmTransaction()
202207
}
@@ -210,6 +215,16 @@ public final class SignRawConfirmationViewModelImplementation: SignRawConfirmati
210215
)
211216
}
212217

218+
private func createWarningBanner() -> TKPopUp.Item {
219+
let banner = TKPopUp.Component.WarningBanner(title: TKLocales.ConfirmSend.FailedEmulationWarning.title)
220+
return TKPopUp.Component.GroupComponent(
221+
padding: UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16),
222+
items: [
223+
banner
224+
]
225+
)
226+
}
227+
213228
private func createRiskItem() -> TKPopUp.Item {
214229
let failedItem: () -> TKPopUp.Item = {
215230
return TKPopUp.Component.LabelComponent(
@@ -269,15 +284,7 @@ public final class SignRawConfirmationViewModelImplementation: SignRawConfirmati
269284
)]
270285
)
271286
case .fail:
272-
return TKPopUp.Component.LabelComponent(
273-
text: "Emulation failed".withTextStyle(
274-
.label1,
275-
color: .Text.primary,
276-
alignment: .center,
277-
lineBreakMode: .byTruncatingTail
278-
),
279-
numberOfLines: 1
280-
)
287+
return createWarningBanner()
281288
}
282289
}
283290

LocalPackages/TKLocalize/Sources/TKLocalize/Resources/Locales/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@
299299
"confirm_send.risk.total_nft" = "Total: %@ + %ld NFT";
300300
"confirm_send.risk.caption_without_nft" = "The total value of tokens that will be sent from your wallet. Refunds are not included in the total value.";
301301
"confirm_send.risk.nft_caption" = "The total value of tokens, excluding the cost of NFTs, that will be sent from your wallet. Refunds are not included in the total value.";
302-
"confirm_send.risk.action_button_title = OK";
302+
"confirm_send.risk.action_button_title" = "OK";
303+
"confirm_send.failed_emulation_warning.title" = "After confirmation, anything can happen, including losing all your funds. All transactions are irreversible. We couldn’t emulate the transaction and don’t know what will happen next.";
303304

304305
"customize_wallet.title" = "Customize your Wallet";
305306
"customize_wallet.description" = "Wallet name and icon are stored locally on your device.";

LocalPackages/TKLocalize/Sources/TKLocalize/Resources/Locales/ru.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@
296296
"confirm_send.risk.total_nft" = "Всего: %@ + %ld NFT";
297297
"confirm_send.risk.caption_without_nft" = "Общая стоимость токенов, которые будут отправлены с вашего кошелька. Возвраты не учитываются в общей стоимости.";
298298
"confirm_send.risk.nft_caption" = "Общая стоимость токенов, за исключением стоимости NFT, которые будут отправлены с вашего кошелька. Возвраты не учитываются в общей стоимости.";
299-
"confirm_send.risk.action_button_title = Понятно";
299+
"confirm_send.risk.action_button_title" = "Понятно";
300+
"confirm_send.failed_emulation_warning.title" = "После подтверждения может произойти что угодно, включая потерю всех ваших средств. Все транзакции необратимы. Мы не смогли проэмулировать транзакцию и не знаем, что произойдёт дальше.";
300301

301302
"customize_wallet.title" = "Кастомизируйте свой кошелёк";
302303
"customize_wallet.description" = "Имя и иконка кошелька хранятся локально на вашем устройстве.";

LocalPackages/TKLocalize/Sources/TKLocalize/TKLocales.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,19 @@ public enum TKLocales {
520520
public static let refund = TKLocales.tr("Localizable", "confirm_send.refund", fallback: "Refund")
521521
/// Wallet
522522
public static let wallet = TKLocales.tr("Localizable", "confirm_send.wallet", fallback: "Wallet")
523+
public enum FailedEmulationWarning {
524+
/// After confirmation, anything can happen, including losing all your funds. All transactions are irreversible. We couldn’t emulate the transaction and don’t know what will happen next.
525+
public static let title = TKLocales.tr("Localizable", "confirm_send.failed_emulation_warning.title", fallback: "After confirmation, anything can happen, including losing all your funds. All transactions are irreversible. We couldn’t emulate the transaction and don’t know what will happen next.")
526+
}
523527
public enum Recipient {
524528
/// Recipient address
525529
public static let address = TKLocales.tr("Localizable", "confirm_send.recipient.address", fallback: "Recipient address")
526530
/// Recipient
527531
public static let title = TKLocales.tr("Localizable", "confirm_send.recipient.title", fallback: "Recipient")
528532
}
529533
public enum Risk {
530-
/// confirm_send.risk.action_button_title = OK
531-
public static let actionButtonTitleOK = TKLocales.tr("Localizable", "confirm_send.risk.action_button_title = OK", fallback: "confirm_send.risk.action_button_title = OK")
534+
/// OK
535+
public static let actionButtonTitle = TKLocales.tr("Localizable", "confirm_send.risk.action_button_title", fallback: "OK")
532536
/// The total value of tokens that will be sent from your wallet. Refunds are not included in the total value.
533537
public static let captionWithoutNft = TKLocales.tr("Localizable", "confirm_send.risk.caption_without_nft", fallback: "The total value of tokens that will be sent from your wallet. Refunds are not included in the total value.")
534538
/// The total value of tokens, excluding the cost of NFTs, that will be sent from your wallet. Refunds are not included in the total value.

LocalPackages/TKUIKit/TKUIKit/Sources/TKUIKit/UIKit/Components/PopUp/TKPopUpComponents.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,23 +344,53 @@ public extension TKPopUp.Component {
344344
let slider = TKSlider()
345345
slider.title = title
346346
slider.isEnable = isEnable
347+
slider.appearance = appearance
347348
slider.didConfirm = didConfirm
348349
return slider
349350
}
350351

351352
private let title: String?
352353
private let isEnable: Bool
354+
private let appearance: TKSlider.Appearance
353355
private let didConfirm: () -> Void
354356
public var bottomSpace: CGFloat
355357

356358
public init(title: String?,
357359
isEnable: Bool,
360+
appearance: TKSlider.Appearance = .standart,
358361
didConfirm: @escaping () -> Void,
359362
bottomSpace: CGFloat = 0) {
360363
self.title = title
361364
self.isEnable = isEnable
365+
self.appearance = appearance
362366
self.didConfirm = didConfirm
363367
self.bottomSpace = bottomSpace
364368
}
365369
}
366370
}
371+
372+
public extension TKPopUp.Component {
373+
struct WarningBanner: TKPopUp.Item {
374+
375+
public func getView() -> UIView {
376+
let banner = TKWarningBannerView()
377+
banner.configure(
378+
model: TKWarningBannerView.Model(
379+
text: title,
380+
image: .TKUIKit.Icons.Size28.exclamationmarkTriangle
381+
)
382+
)
383+
return banner
384+
}
385+
386+
private let title: String
387+
public var bottomSpace: CGFloat
388+
389+
public init(title: String,
390+
bottomSpace: CGFloat = 0) {
391+
self.title = title
392+
self.bottomSpace = bottomSpace
393+
}
394+
}
395+
}
396+

LocalPackages/TKUIKit/TKUIKit/Sources/TKUIKit/UIKit/Components/Slider/TKSlider.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import SnapKit
33

44
public final class TKSlider: UIView {
55

6+
public enum Appearance {
7+
case standart
8+
case warning
9+
10+
var dragViewBackgroundColor: UIColor {
11+
switch self {
12+
case .standart:
13+
.Button.primaryBackground
14+
case .warning:
15+
.Accent.orange
16+
}
17+
}
18+
}
19+
20+
public var appearance: Appearance = .standart {
21+
didSet { updateAppearance() }
22+
}
23+
624
public var isEnable = true {
725
didSet {
826
panGestureRecognizer.isEnabled = isEnable
@@ -94,6 +112,8 @@ private extension TKSlider {
94112
dragView.addGestureRecognizer(panGestureRecognizer)
95113

96114
setupConstraints()
115+
116+
updateAppearance()
97117
}
98118

99119
func setupConstraints() {
@@ -167,6 +187,10 @@ private extension TKSlider {
167187
}
168188

169189
}
190+
191+
func updateAppearance() {
192+
dragView.backgroundColor = appearance.dragViewBackgroundColor
193+
}
170194
}
171195

172196
private extension CGFloat {
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import UIKit
2+
import SnapKit
3+
4+
final class TKWarningBannerView: UIView, ConfigurableView {
5+
6+
let backgroundView: UIView = {
7+
let view = UIView()
8+
view.backgroundColor = .Accent.orange
9+
view.alpha = 0.24
10+
return view
11+
}()
12+
13+
let stackView: UIStackView = {
14+
let stackView = UIStackView()
15+
stackView.spacing = 16
16+
stackView.alignment = .top
17+
return stackView
18+
}()
19+
20+
let label = UILabel()
21+
let imageView = UIImageView()
22+
23+
override init(frame: CGRect) {
24+
super.init(frame: frame)
25+
setup()
26+
}
27+
28+
required init?(coder: NSCoder) {
29+
fatalError("init(coder:) has not been implemented")
30+
}
31+
32+
struct Model {
33+
let text: String
34+
let image: UIImage
35+
}
36+
37+
func configure(model: Model) {
38+
label.attributedText = model.text.withTextStyle(
39+
.body3,
40+
color: .Accent.orange,
41+
alignment: .left,
42+
lineBreakMode: .byWordWrapping
43+
)
44+
imageView.image = model.image
45+
}
46+
}
47+
48+
private extension TKWarningBannerView {
49+
func setup() {
50+
backgroundView.layer.cornerRadius = 16
51+
backgroundView.layer.cornerCurve = .continuous
52+
backgroundView.layer.masksToBounds = true
53+
54+
label.numberOfLines = 0
55+
56+
imageView.tintColor = .Accent.orange
57+
imageView.tintAdjustmentMode = .normal
58+
imageView.contentMode = .center
59+
imageView.setContentCompressionResistancePriority(.required, for: .horizontal)
60+
61+
addSubview(backgroundView)
62+
addSubview(stackView)
63+
stackView.addArrangedSubview(label)
64+
stackView.addArrangedSubview(imageView)
65+
66+
setupConstraints()
67+
}
68+
69+
func setupConstraints() {
70+
backgroundView.snp.makeConstraints { make in
71+
make.top.equalTo(self).offset(16)
72+
make.left.bottom.right.equalTo(self)
73+
}
74+
75+
stackView.snp.makeConstraints { make in
76+
make.edges.equalTo(backgroundView).inset(UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16))
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)