Skip to content

Commit

Permalink
prelayout of the amount in the send SwiftUI send
Browse files Browse the repository at this point in the history
Signed-off-by: kcw-grunt <[email protected]>
  • Loading branch information
kcw-grunt committed Jan 14, 2024
1 parent a07f920 commit f82ed3d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 550 deletions.
72 changes: 61 additions & 11 deletions litewallet/SendAddressCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,39 @@ struct SendAddressCellView: View {
var viewModel = SendAddressCellViewModel()

@State
private var didReceiveLTCfromUD: Bool = false
private var didStartEditing: Bool = false

@State
private var shouldDisableLookupButton: Bool = true

@State
private var didStartEditing: Bool = false
private var amountToggleTitle = "LTC (Ł)"

let actionButtonWidth: CGFloat = 45.0
let toggleButtonWidth: CGFloat = 60.0

let textFieldHeight: CGFloat = 45.0

let actionButtonA: CGFloat = 5.0
let actionButtonB: CGFloat = 18.0
private let currencyToggleConstant: CGFloat = 20.0
private let amountFont: UIFont = UIFont.barlowMedium(size: 14.0)

var body: some View {
GeometryReader { _ in
ZStack {
VStack {
Spacer()

/// Send Address Field
HStack {
VStack {
AddressFieldView(placeholder: S.Send.enterLTCAddressLabel.localize(), text: $viewModel.addressString)
.onTapGesture {
didStartEditing = true
}
.frame(height: 45.0, alignment: .leading)
.frame(height: textFieldHeight, alignment: .leading)
}
.padding(.leading, swiftUICellPadding)

Spacer()

// Paste Address
/// Paste Address button
Button(action: {
viewModel.shouldPasteAddress?()
}) {
Expand All @@ -61,7 +63,7 @@ struct SendAddressCellView: View {
}
}

// Scan Address
/// Scan Address
Button(action: {
viewModel.shouldScanAddress?()
}) {
Expand All @@ -70,7 +72,10 @@ struct SendAddressCellView: View {
RoundedRectangle(cornerRadius: 4)
.frame(width: actionButtonWidth, height: 30, alignment: .center)
.foregroundColor(Color(UIColor.secondaryButton))
.shadow(color: Color(UIColor.grayTextTint), radius: 3, x: 0, y: 4).padding(.trailing, 8.0)
.shadow(color: Color(UIColor.grayTextTint),
radius: 3,
x: 0, y: 4)
.padding(.trailing, 8.0)

Text(S.Send.scanLabel.localize())
.frame(width: actionButtonWidth, height: 30, alignment: .center)
Expand All @@ -89,6 +94,51 @@ struct SendAddressCellView: View {
Color.white.clipShape(RoundedRectangle(cornerRadius: 8.0))
)
.padding([.leading, .trailing], swiftUICellPadding)

/// Amount Field
HStack {
VStack {
AmountFieldView(placeholder: S.Send.amountLabel.localize(), text: $viewModel.amountString)
.onTapGesture {
didStartEditing = true
}
.frame(height: textFieldHeight, alignment: .leading)
}
.padding(.leading, swiftUICellPadding)

Spacer()

// Fiat LTC Switch Button
Button(action: {
viewModel.shouldScanAddress?()
}) {
HStack {
ZStack {
RoundedRectangle(cornerRadius: 4)
.frame(width: toggleButtonWidth, height: 30, alignment: .center)
.foregroundColor(Color(UIColor.secondaryButton))
.shadow(color: Color(UIColor.grayTextTint),
radius: 3, x: 0, y: 4)
.padding(.all, 8.0)

Text(amountToggleTitle)
.frame(width: toggleButtonWidth, height: 30, alignment: .center)
.font(Font(UIFont.customMedium(size: 15.0)))
.foregroundColor(Color(UIColor.grayTextTint))
.overlay(
RoundedRectangle(cornerRadius: 4)
.stroke(Color(UIColor.secondaryBorder))
.frame(width: toggleButtonWidth, height: 30, alignment: .center)
)
.padding(.all, 8.0)
}
}
}
}
.background(
Color.white.clipShape(RoundedRectangle(cornerRadius: 8.0))
)
.padding([.leading, .trailing], swiftUICellPadding)
Spacer()
}
}
Expand Down
34 changes: 34 additions & 0 deletions litewallet/SendAddressCellViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class SendAddressCellViewModel: ObservableObject {
@Published
var addressString: String = ""

@Published
var amountString: String = ""

@Published
var didUpdatePaste: Bool = false

Expand All @@ -15,6 +18,37 @@ class SendAddressCellViewModel: ObservableObject {

var shouldScanAddress: (() -> Void)?

var balanceTextForAmount: ((Satoshis?, Rate?) -> (NSAttributedString?, NSAttributedString?)?)?
var didUpdateAmount: ((Satoshis?) -> Void)?
var didChangeFirstResponder: ((Bool) -> Void)?
var didShowFiat: ((_ isShowingFiat: Bool) -> Void)?

init()
{}

// amountView.balanceTextForAmount = { [weak self] amount, rate in
// self?.balanceTextForAmount(amount: amount, rate: rate)
// }
//
// amountView.didUpdateAmount = { [weak self] amount in
// self?.amount = amount
// }
// amountView.didUpdateFee = strongify(self) { myself, feeType in
// myself.feeType = feeType
// let fees = myself.store.state.fees
//
// switch feeType {
// case .regular: myself.walletManager.wallet?.feePerKb = fees.regular
// case .economy: myself.walletManager.wallet?.feePerKb = fees.economy
// case .luxury: myself.walletManager.wallet?.feePerKb = fees.luxury
// }
//
// myself.amountView.updateBalanceLabel()
// }
//
// amountView.didChangeFirstResponder = { [weak self] isFirstResponder in
// if isFirstResponder {
// self?.memoCell.textView.resignFirstResponder()
// }
// }
}
Loading

0 comments on commit f82ed3d

Please sign in to comment.