Skip to content

Commit

Permalink
Merge pull request #106 from OpenZesame/review_payment
Browse files Browse the repository at this point in the history
Adding a new scene `ReviewTransactionBeforeSigning` which presents a …
  • Loading branch information
Sajjon authored Jun 21, 2019
2 parents 7d2e07e + 2956c2e commit f538412
Show file tree
Hide file tree
Showing 18 changed files with 413 additions and 28 deletions.
1 change: 1 addition & 0 deletions Pods/Zesame/Source/Models/Manual/Payment/Payment.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 32 additions & 4 deletions Source/Application/Generated/SwiftGen/L10n-Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ internal enum L10n {
internal enum Button {
/// Max
internal static let maxAmount = L10n.tr("Localizable", "Scene.PrepareTransaction.Button.MaxAmount")
/// Send
internal static let send = L10n.tr("Localizable", "Scene.PrepareTransaction.Button.Send")
/// Review Payment
internal static let reviewPayment = L10n.tr("Localizable", "Scene.PrepareTransaction.Button.ReviewPayment")
}
internal enum Field {
/// Amount in %@
Expand All @@ -406,8 +406,6 @@ internal enum L10n {
internal static func gasInSmallUnits(_ p1: String) -> String {
return L10n.tr("Localizable", "Scene.PrepareTransaction.Label.GasInSmallUnits", p1)
}
/// Transaction Id
internal static let transactionId = L10n.tr("Localizable", "Scene.PrepareTransaction.Label.TransactionId")
}
internal enum Labels {
internal enum Balance {
Expand Down Expand Up @@ -484,6 +482,36 @@ internal enum L10n {
internal static let privateKey = L10n.tr("Localizable", "Scene.RestoreWallet.Segment.PrivateKey")
}
}
internal enum ReviewTransactionBeforeSigning {
/// Summary
internal static let title = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Title")
internal enum Button {
/// To signing
internal static let hasReviewedProceedToSigning = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Button.HasReviewedProceedToSigning")
}
internal enum Checkbox {
/// I've reviewed the payment and understand I'm responsible for any loss if anything is incorrect.
internal static let hasReviewedPayment = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Checkbox.HasReviewedPayment")
}
internal enum Label {
/// Amount
internal static let amount = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.Amount")
/// Amount to recipient
internal static let amountToSend = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.AmountToSend")
/// Recipient
internal static let recipient = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.Recipient")
/// Transaction total cost
internal static let totalCostOfTransaction = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.TotalCostOfTransaction")
/// Transaction fee
internal static let transactionFee = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.TransactionFee")
internal enum Address {
/// Address on new bech32 format
internal static let bech32 = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.Address.Bech32")
/// Address on old base16 format
internal static let legacy = L10n.tr("Localizable", "Scene.ReviewTransactionBeforeSigning.Label.Address.Legacy")
}
}
}
internal enum ScanQRCode {
/// Scan QR
internal static let title = L10n.tr("Localizable", "Scene.ScanQRCode.Title")
Expand Down
17 changes: 15 additions & 2 deletions Source/Application/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
"Scene.PrepareTransaction.Label.GasInSmallUnits" = "Gas price is measured in %@";
"Scene.PrepareTransaction.Field.GasPrice" = "Gas price (min %@)";
"Scene.PrepareTransaction.Field.EncryptionPassword" = "Encryption password";
"Scene.PrepareTransaction.Button.Send" = "Send";
"Scene.PrepareTransaction.Label.TransactionId" = "Transaction Id";
"Scene.PrepareTransaction.Button.ReviewPayment" = "Review Payment";
//"Scene.PrepareTransaction.Label.TransactionId" = "Transaction Id";
"Scene.PrepareTransaction.Labels.Balance.Title" = "Current balance";
"Scene.PrepareTransaction.Label.CostOfTransactionInZil" = "Transaction fee: %@";

Expand All @@ -180,6 +180,19 @@
"Scene.ScanQRCode.Event.Toast.IncompatibleQrCode.Title" = "QR code contains no compatible Zilliqa address";
"Scene.ScanQRCode.Event.Toast.IncompatibleQrCode.Dismiss" = "Dismiss";

// MARK: ReviewTransaction
"Scene.ReviewTransactionBeforeSigning.Title" = "Summary";
"Scene.ReviewTransactionBeforeSigning.Label.Recipient" = "Recipient";
"Scene.ReviewTransactionBeforeSigning.Label.Address.Legacy" = "Address on old base16 format";
"Scene.ReviewTransactionBeforeSigning.Label.Address.Bech32" = "Address on new bech32 format";
"Scene.ReviewTransactionBeforeSigning.Label.Amount" = "Amount";
"Scene.ReviewTransactionBeforeSigning.Label.AmountToSend" = "Amount to recipient";
"Scene.ReviewTransactionBeforeSigning.Label.TransactionFee" = "Transaction fee";
"Scene.ReviewTransactionBeforeSigning.Label.TotalCostOfTransaction" = "Transaction total cost";
"Scene.ReviewTransactionBeforeSigning.Checkbox.HasReviewedPayment" = "I've reviewed the payment and understand I'm responsible for any loss if anything is incorrect. ";
"Scene.ReviewTransactionBeforeSigning.Button.HasReviewedProceedToSigning" = "To signing";


// MARK: SignTransaction
"Scene.SignTransaction.Label.SignTransactionWithEncryptionPassword" = "Confirm transaction with your password";
"Scene.SignTransaction.Field.EncryptionPassword" = "Encryption password";
Expand Down
2 changes: 2 additions & 0 deletions Source/Extensions/UIKit/UIFont_Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import UIKit
extension UIFont {
// For `UITextField` floating placeholder
static let hint = Font(.𝟙𝟞, .medium).make()
static let valueTitle = Font(.𝟙𝟞, .regular).make()
static let value = Font(.𝟙𝟠, .bold).make()

/// For bread text
static let body = Font(.𝟙𝟠, .regular).make()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class PrepareTransactionView: ScrollableStackViewOwner, PullToRefreshCapab
private lazy var maxAmounButton = amountToSendField.addBottomAlignedButton(titled:.Button.maxAmount)
private lazy var gasMeasuredInSmallUnitsLabel = UILabel()
private lazy var gasPriceField = FloatingLabelTextField()
private lazy var sendButton = UIButton()
private lazy var toReviewButton = UIButton()
private lazy var costOfTransactionLabel = UILabel()

// MARK: - StackViewStyling
Expand All @@ -52,7 +52,7 @@ final class PrepareTransactionView: ScrollableStackViewOwner, PullToRefreshCapab
gasPriceField,
costOfTransactionLabel,
.spacer,
sendButton
toReviewButton
]

override func setup() {
Expand All @@ -73,7 +73,7 @@ extension PrepareTransactionView: ViewModelled {
viewModel.amountPlaceholder --> amountToSendField.rx.placeholder,
viewModel.amount --> amountToSendField.rx.text,
viewModel.recipient --> recipientAddressField.rx.text,
viewModel.isSendButtonEnabled --> sendButton.rx.isEnabled,
viewModel.isReviewButtonEnabled --> toReviewButton.rx.isEnabled,
viewModel.balance --> balanceValueLabel.rx.text,
viewModel.recipientAddressValidation --> recipientAddressField.rx.validation,
viewModel.amountValidation --> amountToSendField.rx.validation,
Expand All @@ -89,7 +89,7 @@ extension PrepareTransactionView: ViewModelled {
pullToRefreshTrigger: rx.pullToRefreshTrigger,
scanQRTrigger: scanQRButton.rx.tap.asDriver(),
maxAmountTrigger: maxAmounButton.rx.tap.asDriver(),
sendTrigger: sendButton.rx.tap.asDriver(),
toReviewTrigger: toReviewButton.rx.tap.asDriver(),

recepientAddress: recipientAddressField.rx.text.orEmpty.asDriver().skip(1),
didEndEditingRecipientAddress: recipientAddressField.rx.didEndEditing,
Expand Down Expand Up @@ -138,8 +138,8 @@ private extension PrepareTransactionView {

gasPriceField.withStyle(.number)

sendButton.withStyle(.primary) {
$0.title(.Button.send)
toReviewButton.withStyle(.primary) {
$0.title(.Button.reviewPayment)
.disabled()
}
}
Expand All @@ -150,7 +150,7 @@ private extension PrepareTransactionView {
func prefillValuesForDebugBuilds() {
#if DEBUG
recipientAddressField.text = "zil175grxdeqchwnc0qghj8qsh5vnqwww353msqj82"
amountToSendField.text = Int.random(in: 100...500).description
amountToSendField.text = Int.random(in: 1...5).description
gasPriceField.text = Int.random(in: 1000...2000).description

DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) { [unowned self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Zesame
// MARK: - PrepareTransactionUserAction
enum PrepareTransactionUserAction {
case cancel
case signPayment(Payment)
case reviewPayment(Payment)
case scanQRCode
}

Expand Down Expand Up @@ -189,8 +189,8 @@ final class PrepareTransactionViewModel: BaseViewModel<
.do(onNext: { userIntends(to: .scanQRCode) })
.drive(),

input.fromView.sendTrigger.withLatestFrom(payment.filterNil())
.do(onNext: { userIntends(to: .signPayment($0)) })
input.fromView.toReviewTrigger.withLatestFrom(payment.filterNil())
.do(onNext: { userIntends(to: .reviewPayment($0)) })
.drive()
]

Expand All @@ -213,7 +213,7 @@ final class PrepareTransactionViewModel: BaseViewModel<
}
})

let isSendButtonEnabled = payment.map { $0 != nil }
let isReviewButtonEnabled = payment.map { $0 != nil }

let gasPricePlaceholder = Driver.just(GasPrice.min).map {.Field.gasPrice(formatter.format(amount: $0, in: .li, formatThousands: true, showUnit: true)) }

Expand All @@ -237,7 +237,7 @@ final class PrepareTransactionViewModel: BaseViewModel<
return Output(
refreshControlLastUpdatedTitle: refreshControlLastUpdatedTitle,
isFetchingBalance: activityIndicator.asDriver(),
isSendButtonEnabled: isSendButtonEnabled,
isReviewButtonEnabled: isReviewButtonEnabled,
balance: balanceFormatted,

recipient: recipientFormatted,
Expand Down Expand Up @@ -271,7 +271,7 @@ extension PrepareTransactionViewModel {
let pullToRefreshTrigger: Driver<Void>
let scanQRTrigger: Driver<Void>
let maxAmountTrigger: Driver<Void>
let sendTrigger: Driver<Void>
let toReviewTrigger: Driver<Void>

let recepientAddress: Driver<String>
let didEndEditingRecipientAddress: Driver<Void>
Expand All @@ -286,7 +286,7 @@ extension PrepareTransactionViewModel {
struct Output {
let refreshControlLastUpdatedTitle: Driver<String>
let isFetchingBalance: Driver<Bool>
let isSendButtonEnabled: Driver<Bool>
let isReviewButtonEnabled: Driver<Bool>
let balance: Driver<String>

let recipient: Driver<String>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// MIT License
//
// Copyright (c) 2018-2019 Open Zesame (https://github.com/OpenZesame)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

import Foundation

private typealias= L10n.Scene.ReviewTransactionBeforeSigning
final class ReviewTransactionBeforeSigning: Scene<ReviewTransactionBeforeSigningView> {}

extension ReviewTransactionBeforeSigning {
static let title =.title
}
Loading

0 comments on commit f538412

Please sign in to comment.