|
@ -34,6 +34,38 @@ class ExchangeRateCustomView: UIView { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var dropdownIcon: UIImageView = { |
|
|
|
|
|
let dropdownIconImageView = UIImageView() |
|
|
|
|
|
dropdownIconImageView.image = UIImage.init(named: "dropdown") |
|
|
|
|
|
dropdownIconImageView.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
|
|
dropdownIconImageView.clipsToBounds = true |
|
|
|
|
|
dropdownIconImageView.contentMode = .top |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dropdownIconImageView.ima |
|
|
|
|
|
// dropdownIconImageView.leadingAnchor.constraint(lessThanOrEqualTo: dropdownIconImageView.trailingAnchor, constant: 4).isActive = true |
|
|
|
|
|
// dropdownIconImageView.leadingAnchor.constraint(lessThanOrEqualTo: dropdownIconImageView.trailingAnchor, constant: 4).isActive = true |
|
|
|
|
|
// dropdownIconImageView.anchor(paddingTop: 4, paddingBottom: 4, paddingLeft: 4, paddingRight: 4, width: 16, height: 16) |
|
|
|
|
|
// dropdownIconImageView.topAnchor.constraint(equalToConstant: 4).isActive = true |
|
|
|
|
|
// dropdownIconImageView.bottomAnchor.constraint(equalToConstant: 4).isActive = true |
|
|
|
|
|
// dropdownIconImageView.leftAnchor.constraint(equalToConstant: 4).isActive = true |
|
|
|
|
|
// dropdownIconImageView.rightAnchor.constraint(equalToConstant: 4).isActive = true |
|
|
|
|
|
dropdownIconImageView.heightAnchor.constraint(equalToConstant: 16).isActive = true |
|
|
|
|
|
dropdownIconImageView.widthAnchor.constraint(equalToConstant: 16).isActive = true |
|
|
|
|
|
|
|
|
|
|
|
return dropdownIconImageView |
|
|
|
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
var dropdownIconView: UIView = { |
|
|
|
|
|
let imageHolderView = UIView() |
|
|
|
|
|
imageHolderView.heightAnchor.constraint(equalToConstant: 24).isActive = true |
|
|
|
|
|
imageHolderView.widthAnchor.constraint(equalToConstant: 24).isActive = true |
|
|
|
|
|
imageHolderView.backgroundColor = .red |
|
|
|
|
|
return imageHolderView |
|
|
|
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
private var textfield: CurrencyTextField = { |
|
|
private var textfield: CurrencyTextField = { |
|
|
let textfield = CurrencyTextField() |
|
|
let textfield = CurrencyTextField() |
|
|
textfield.keyboardType = .numberPad |
|
|
textfield.keyboardType = .numberPad |
|
@ -62,8 +94,10 @@ class ExchangeRateCustomView: UIView { |
|
|
var flagImageView: UIImageView = { |
|
|
var flagImageView: UIImageView = { |
|
|
let imageView = UIImageView() |
|
|
let imageView = UIImageView() |
|
|
imageView.translatesAutoresizingMaskIntoConstraints = false |
|
|
imageView.translatesAutoresizingMaskIntoConstraints = false |
|
|
imageView.heightAnchor.constraint(equalToConstant: 40).isActive = true |
|
|
|
|
|
imageView.widthAnchor.constraint(equalToConstant: 40).isActive = true |
|
|
|
|
|
|
|
|
imageView.heightAnchor.constraint(equalToConstant: 52).isActive = true |
|
|
|
|
|
imageView.widthAnchor.constraint(equalToConstant: 36).isActive = true |
|
|
|
|
|
imageView.clipsToBounds = true |
|
|
|
|
|
imageView.contentMode = .scaleAspectFit |
|
|
return imageView |
|
|
return imageView |
|
|
}() |
|
|
}() |
|
|
|
|
|
|
|
@ -87,6 +121,7 @@ class ExchangeRateCustomView: UIView { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func uiSetup() { |
|
|
private func uiSetup() { |
|
|
|
|
|
|
|
|
leftStackView = UIStackView(arrangedSubviews: [titleLabel, textfield]) |
|
|
leftStackView = UIStackView(arrangedSubviews: [titleLabel, textfield]) |
|
|
leftStackView.translatesAutoresizingMaskIntoConstraints = false |
|
|
leftStackView.translatesAutoresizingMaskIntoConstraints = false |
|
|
leftStackView.axis = .vertical |
|
|
leftStackView.axis = .vertical |
|
@ -94,12 +129,31 @@ class ExchangeRateCustomView: UIView { |
|
|
leftStackView.spacing = 4 |
|
|
leftStackView.spacing = 4 |
|
|
leftStackView.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.size.width - 120).isActive = true |
|
|
leftStackView.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.size.width - 120).isActive = true |
|
|
|
|
|
|
|
|
rightStackView = UIStackView(arrangedSubviews: [currencyText, flagImageView]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isReciver) { |
|
|
|
|
|
let nameIconHolder = UIStackView(arrangedSubviews: [currencyText, dropdownIcon]) |
|
|
|
|
|
nameIconHolder.translatesAutoresizingMaskIntoConstraints = false |
|
|
|
|
|
nameIconHolder.axis = .vertical |
|
|
|
|
|
// nameIconHolder.distribution = .fill |
|
|
|
|
|
// nameIconHolder.spacing = 2 |
|
|
|
|
|
nameIconHolder.alignment = .center |
|
|
|
|
|
rightStackView = UIStackView(arrangedSubviews: [flagImageView, nameIconHolder]) |
|
|
|
|
|
rightStackView.backgroundColor = .red |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
rightStackView = UIStackView(arrangedSubviews: [flagImageView, currencyText]) |
|
|
|
|
|
} |
|
|
|
|
|
// var _imageHolderView = dropdownIconView |
|
|
|
|
|
// dropdownIcon.center = _imageHolderView.center |
|
|
|
|
|
// _imageHolderView.addSubview(dropdownIcon) |
|
|
|
|
|
|
|
|
rightStackView.translatesAutoresizingMaskIntoConstraints = false |
|
|
rightStackView.translatesAutoresizingMaskIntoConstraints = false |
|
|
rightStackView.axis = .horizontal |
|
|
rightStackView.axis = .horizontal |
|
|
rightStackView.distribution = .fillEqually |
|
|
|
|
|
|
|
|
rightStackView.distribution = .fill |
|
|
rightStackView.spacing = 8 |
|
|
rightStackView.spacing = 8 |
|
|
rightStackView.widthAnchor.constraint(equalToConstant: 120).isActive = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rightStackView.widthAnchor.constraint(equalToConstant: 96).isActive = true |
|
|
|
|
|
|
|
|
self.addSubviews(leftStackView, |
|
|
self.addSubviews(leftStackView, |
|
|
rightStackView |
|
|
rightStackView |
|
@ -123,7 +177,7 @@ class ExchangeRateCustomView: UIView { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
rightStackView.anchor(right: self.trailingAnchor, |
|
|
rightStackView.anchor(right: self.trailingAnchor, |
|
|
paddingRight: -8 |
|
|
|
|
|
|
|
|
paddingRight: 0 |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
rightStackView.center(centerX: nil, |
|
|
rightStackView.center(centerX: nil, |
|
@ -131,6 +185,9 @@ class ExchangeRateCustomView: UIView { |
|
|
centerY: self.centerYAnchor, |
|
|
centerY: self.centerYAnchor, |
|
|
paddingY: 0) |
|
|
paddingY: 0) |
|
|
|
|
|
|
|
|
|
|
|
rightStackView.heightAnchor.constraint(equalToConstant: 66).isActive = true |
|
|
|
|
|
rightStackView.topAnchor.constraint(equalTo: self.topAnchor, constant: 0).isActive = true |
|
|
|
|
|
// rightStackView.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0).isActive = true |
|
|
rightStackView.leadingAnchor.constraint(greaterThanOrEqualTo: leftStackView.trailingAnchor, constant: 8).isActive = true |
|
|
rightStackView.leadingAnchor.constraint(greaterThanOrEqualTo: leftStackView.trailingAnchor, constant: 8).isActive = true |
|
|
|
|
|
|
|
|
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) |
|
|
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) |
|
@ -141,7 +198,7 @@ class ExchangeRateCustomView: UIView { |
|
|
private func propertiesSetup() { |
|
|
private func propertiesSetup() { |
|
|
flagImageView.image = UIImage(named: "flag_japan") |
|
|
flagImageView.image = UIImage(named: "flag_japan") |
|
|
currencyText.text = "JPY" |
|
|
currencyText.text = "JPY" |
|
|
currencyText.textColor = .themeBlack |
|
|
|
|
|
|
|
|
currencyText.textColor = isReciver ? .white : .themeBlack |
|
|
currencyText.font = .sanfrancisco(.semibold, size: 16) |
|
|
currencyText.font = .sanfrancisco(.semibold, size: 16) |
|
|
|
|
|
|
|
|
titleLabel.textColor = .themeBlack.withAlphaComponent(0.6) |
|
|
titleLabel.textColor = .themeBlack.withAlphaComponent(0.6) |
|
|