Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes round 3 #1063

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions RadixWallet/EngineKit/IsXRDResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ extension ResourceAddress {
static let mainnetXRDAddress: ResourceAddress = .xrd(on: .mainnet)
}

extension SpecificAddress {
var isOnMainnet: Bool {
networkID == NetworkID.mainnet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please out put this in another file. Please :D RadixWallet/EngineKit/ is verboten! :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh yes, forgoten it is verboten :D

}
}

extension EngineToolkit.Address {
static func xrd(_ networkId: UInt8) -> EngineToolkit.Address {
knownAddresses(networkId: networkId).resourceAddresses.xrd
Expand Down
3 changes: 3 additions & 0 deletions RadixWallet/Features/AssetsFeature/AssetsView+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ extension AssetsView {
}
}
}
#if !DEBUG
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In DEBUG the default value will be used, which is false. So Fiat value will always be shown in DEBUG mode.

.environment(\.resourceBalanceHideFiatValue, !viewStore.account.address.isOnMainnet)
#endif
.buttonStyle(.plain)
.scrollContentBackground(.hidden)
.listStyle(.insetGrouped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension DetailsContainerWithHeaderViewState {

// MARK: - DetailsContainerWithHeaderView
struct DetailsContainerWithHeaderView<ThumbnailView: View, DetailsView: View>: View {
@Environment(\.resourceBalanceHideFiatValue) var resourceBalanceHideFiatValue
let viewState: DetailsContainerWithHeaderViewState
let closeButtonAction: () -> Void

Expand Down Expand Up @@ -70,7 +71,7 @@ struct DetailsContainerWithHeaderView<ThumbnailView: View, DetailsView: View>: V
}
}

if let currencyWorth = viewState.currencyWorth {
if !resourceBalanceHideFiatValue, let currencyWorth = viewState.currencyWorth {
Text(currencyWorth)
.textStyle(.body2HighImportance)
.foregroundStyle(.app.gray2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@ extension EnvironmentValues {
private struct ResourceBalanceHideDetailsKey: EnvironmentKey {
static let defaultValue: Bool = false
}

extension EnvironmentValues {
var resourceBalanceHideFiatValue: Bool {
get { self[ResourceBalanceHideFiatValue.self] }
set { self[ResourceBalanceHideFiatValue.self] = newValue }
}
}

// MARK: - ResourceBalanceHideFiatValue
private struct ResourceBalanceHideFiatValue: EnvironmentKey {
static let defaultValue: Bool = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ extension ResourceBalanceView {
.padding(.leading, isSelected != nil ? .small2 : 0)

if let isSelected {
if !useSpacer, caption1 == nil {
Spacer(minLength: .small2)
}
CheckmarkView(appearance: .dark, isChecked: isSelected)
}
}
Expand All @@ -465,7 +468,7 @@ extension ResourceBalanceView {
}

private var useSpacer: Bool {
amount != nil || fallback != nil || caption1 == nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't a good place for the fix, it did push out completely the text field for amount entry.

amount != nil || fallback != nil
}
}

Expand Down Expand Up @@ -527,6 +530,7 @@ extension ResourceBalanceView {
}

struct AmountView: View {
@Environment(\.resourceBalanceHideFiatValue) var resourceBalanceHideFiatValue
let amount: ResourceBalance.Amount?
let fallback: String?
let compact: Bool
Expand Down Expand Up @@ -554,7 +558,7 @@ extension ResourceBalanceView {
Text(amount.amount.nominalAmount.formatted())
.textStyle(amountTextStyle)
.foregroundColor(.app.gray1)
if let fiatWorth = amount.amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
if !resourceBalanceHideFiatValue, let fiatWorth = amount.amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
Text(fiatWorth)
.textStyle(.body2HighImportance)
.foregroundStyle(.app.gray2)
Expand All @@ -575,7 +579,7 @@ extension ResourceBalanceView {
.textStyle(.secondaryHeader)
.foregroundColor(.app.gray1)

if let fiatWorth = amount.amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
if !resourceBalanceHideFiatValue, let fiatWorth = amount.amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
Text(fiatWorth)
.textStyle(.body2HighImportance)
.foregroundStyle(.app.gray2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public struct StakeSummaryView: View {
}
}

@Environment(\.resourceBalanceHideFiatValue) var resourceBalanceHideFiatValue
public let viewState: ViewState
public let onReadyToClaimTapped: () -> Void

Expand Down Expand Up @@ -77,7 +78,7 @@ extension StakeSummaryView {
Text("\(amount.nominalAmount.formatted()) XRD")
.textStyle(.body2HighImportance)
.foregroundColor(amountTextColor)
if let fiatWorth = amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
if !resourceBalanceHideFiatValue, let fiatWorth = amount.fiatWorth?.currencyFormatted(applyCustomFont: false) {
Text(fiatWorth)
.textStyle(.body2HighImportance)
.foregroundStyle(.app.gray2)
Expand Down
Loading