alpha-wallet-ios
alpha-wallet-ios copied to clipboard
NSAttributedString Foreground Colours being overridden and not used in TransactionHeaderView

Problem
The foreground color in amountTextColor (first snippet of code) is being overridden by Configuration.Color.Semantic.defaultHeadlineText (fourth snippet of code). The Colors.appHighlightGreen and Colors.appRed never show up.
First code snippet
var amountTextColor: UIColor {
switch direction {
case .incoming: return Colors.appHighlightGreen
case .outgoing: return Colors.appRed
}
}
This code snippet colours the text for incoming and outgoing amounts.
Second code snippet
func amountAttributedString(for value: TransactionValue) -> NSAttributedString {
let amount = NSAttributedString(string: amountWithSign(for: value.amount), attributes: [
.font: Fonts.regular(size: 24) as Any,
.foregroundColor: amountTextColor,
])
let currency = NSAttributedString(string: " " + value.symbol, attributes: [
.font: Fonts.regular(size: 16) as Any
])
return amount + currency
}
This code snippet uses the colours generated by amountTextColor.
Third code snippet
var fullAmountAttributedString: NSAttributedString {
return amountAttributedString(for: fullValue)
}
Fourth code snippet
var amount: NSAttributedString {
NSAttributedString(string: transactionViewModel.fullAmountAttributedString.string, attributes: [
.font: Fonts.semibold(size: 20) as Any,
.foregroundColor: Configuration.Color.Semantic.defaultHeadlineText,
])
}
@eviltofu do we address this issue by removing the relevant code? Or are you saying there is a bug?
@eviltofu do we address this issue by removing the relevant code? Or are you saying there is a bug?
The colours from previous call are overridden and not used. So we can:
- change the code to allow the colours to come through
- remove the code that generates these colours
- do nothing.
Waiting on your decision.
@eviltofu ah, I see. For this, take the general approach: remove redundant code so the app looks like it does before the change.