Show alert with a network name when there are no other networks to select from on macOS

This commit is contained in:
Ivan Grachev 2022-08-25 20:25:33 +03:00
parent 924fc986a6
commit bb05355a6d
2 changed files with 8 additions and 4 deletions

View File

@ -11,7 +11,7 @@ extension CoinType {
case .ethereum:
return "Ethereum & L2s"
case .near:
return "Near"
return "NEAR"
default:
fatalError(Strings.somethingWentWrong)
}

View File

@ -163,8 +163,7 @@ class AccountsListViewController: NSViewController {
websiteNameStackView.isHidden = true
}
let canSelectNetworkForCurrentProvider = selectAccountAction?.coinType == .ethereum || selectAccountAction?.coinType == nil
if canSelectAccount, networkButton.isHidden, canSelectNetworkForCurrentProvider {
if canSelectAccount, networkButton.isHidden {
networkButton.isHidden = false
let menu = NSMenu()
let titleItem = NSMenuItem(title: Strings.selectNetworkOptionally, action: nil, keyEquivalent: "")
@ -193,7 +192,7 @@ class AccountsListViewController: NSViewController {
if let network = selectAccountAction?.initialNetwork, network != self.network {
selectNetwork(network)
}
} else if !(canSelectAccount && canSelectNetworkForCurrentProvider), !networkButton.isHidden {
} else if !canSelectAccount, !networkButton.isHidden {
networkButton.isHidden = true
}
}
@ -216,6 +215,11 @@ class AccountsListViewController: NSViewController {
}
@IBAction func networkButtonTapped(_ sender: NSButton) {
guard selectAccountAction?.coinType == nil || selectAccountAction?.coinType == .ethereum else {
Alert.showWithMessage(selectAccountAction?.coinType?.name ?? Strings.unknownNetwork, style: .informational)
return
}
var origin = sender.frame.origin
origin.x += sender.frame.width
origin.y += sender.frame.height