mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-05 20:16:25 +03:00
Fix status bar glitches when showing alerts
This commit is contained in:
parent
2aa0cc94cd
commit
43675d6f87
@ -30,6 +30,7 @@
|
||||
2C208A9F26813408005BA500 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C208A9E26813408005BA500 /* Secrets.swift */; };
|
||||
2C528A16267FA8EB00CA3ADD /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C528A15267FA8EB00CA3ADD /* Defaults.swift */; };
|
||||
2C6706A5267A6BFE006AAEF2 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6706A4267A6BFE006AAEF2 /* Bundle.swift */; };
|
||||
2C78F8282683BDCC00C10670 /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C78F8272683BDCC00C10670 /* Alert.swift */; };
|
||||
2C797E7E267BB88800F2CE2D /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C797E7D267BB88800F2CE2D /* WelcomeViewController.swift */; };
|
||||
2C8A09B52675101300993638 /* AccountsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09B42675101300993638 /* AccountsService.swift */; };
|
||||
2C8A09C6267513FC00993638 /* Agent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09C5267513FC00993638 /* Agent.swift */; };
|
||||
@ -73,6 +74,7 @@
|
||||
2C208A9E26813408005BA500 /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
|
||||
2C528A15267FA8EB00CA3ADD /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
|
||||
2C6706A4267A6BFE006AAEF2 /* Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = "<group>"; };
|
||||
2C78F8272683BDCC00C10670 /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
|
||||
2C797E7D267BB88800F2CE2D /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = "<group>"; };
|
||||
2C8A09B42675101300993638 /* AccountsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsService.swift; sourceTree = "<group>"; };
|
||||
2C8A09C5267513FC00993638 /* Agent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Agent.swift; sourceTree = "<group>"; };
|
||||
@ -217,6 +219,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2C8A09E226757FC000993638 /* AccountCellView.swift */,
|
||||
2C78F8272683BDCC00C10670 /* Alert.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -391,6 +394,7 @@
|
||||
2C8A09E326757FC000993638 /* AccountCellView.swift in Sources */,
|
||||
0DB729202674E2DB0011F7A1 /* EIP712Domain.swift in Sources */,
|
||||
0DB729182674E2DB0011F7A1 /* EIP712Signer.swift in Sources */,
|
||||
2C78F8282683BDCC00C10670 /* Alert.swift in Sources */,
|
||||
2C8A09EE2675965F00993638 /* WaitingViewController.swift in Sources */,
|
||||
2C797E7E267BB88800F2CE2D /* WelcomeViewController.swift in Sources */,
|
||||
0DB729192674E2DB0011F7A1 /* EIP712TypedData.swift in Sources */,
|
||||
|
@ -13,6 +13,7 @@ class Agent: NSObject {
|
||||
private var statusBarItem: NSStatusItem!
|
||||
private var hasPassword = Keychain.password != nil
|
||||
private var didEnterPasswordOnStart = false
|
||||
var statusBarButtonIsBlocked = false
|
||||
|
||||
func start() {
|
||||
checkPasteboardAndOpen(onAppStart: true)
|
||||
@ -107,7 +108,7 @@ class Agent: NSObject {
|
||||
|
||||
func warnBeforeQuitting() {
|
||||
Window.activateWindow(nil)
|
||||
let alert = NSAlert()
|
||||
let alert = Alert()
|
||||
alert.messageText = "Quit Encrypted Ink?"
|
||||
alert.informativeText = "You won't be able to sign requests."
|
||||
alert.alertStyle = .warning
|
||||
@ -116,6 +117,7 @@ class Agent: NSObject {
|
||||
if alert.runModal() == .alertFirstButtonReturn {
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
setupStatusBarItem()
|
||||
}
|
||||
|
||||
@objc private func didSelectQuitMenuItem() {
|
||||
@ -132,6 +134,7 @@ class Agent: NSObject {
|
||||
}
|
||||
|
||||
@objc private func statusBarButtonClicked(sender: NSStatusBarButton) {
|
||||
guard !statusBarButtonIsBlocked else { return }
|
||||
if let event = NSApp.currentEvent, event.type == .rightMouseUp {
|
||||
statusBarItem.menu = statusBarMenu
|
||||
statusBarItem.button?.performClick(nil)
|
||||
|
@ -32,7 +32,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
@IBAction func didCmdQ(_ sender: Any) {
|
||||
Window.closeAll()
|
||||
Window.closeAll(updateStatusBarItem: false)
|
||||
agent.warnBeforeQuitting()
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class AccountsListViewController: NSViewController {
|
||||
@objc private func didClickRemoveAccount(_ sender: AnyObject) {
|
||||
let row = tableView.clickedRow
|
||||
|
||||
let alert = NSAlert()
|
||||
let alert = Alert()
|
||||
alert.messageText = "Removed accounts can't be recovered."
|
||||
alert.alertStyle = .critical
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
@ -89,7 +89,7 @@ class AccountsListViewController: NSViewController {
|
||||
}
|
||||
|
||||
private func showInstructionsAlert() {
|
||||
let alert = NSAlert()
|
||||
let alert = Alert()
|
||||
alert.messageText = "How to start?"
|
||||
alert.informativeText = "1. Open your favourite dapp.\n\n2. Press “Copy to clipboard”\nunder WalletConnect QR code.\n\n3. Launch Encrypted Ink."
|
||||
alert.alertStyle = .informational
|
||||
|
15
Encrypted Ink/Views/Alert.swift
Normal file
15
Encrypted Ink/Views/Alert.swift
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
||||
|
||||
import Cocoa
|
||||
|
||||
class Alert: NSAlert {
|
||||
|
||||
override func runModal() -> NSApplication.ModalResponse {
|
||||
defer {
|
||||
Agent.shared.statusBarButtonIsBlocked = false
|
||||
}
|
||||
Agent.shared.statusBarButtonIsBlocked = true
|
||||
return super.runModal()
|
||||
}
|
||||
|
||||
}
|
@ -26,9 +26,11 @@ struct Window {
|
||||
activateBrowser()
|
||||
}
|
||||
|
||||
static func closeAll() {
|
||||
static func closeAll(updateStatusBarItem: Bool = true) {
|
||||
NSApplication.shared.windows.forEach { $0.close() }
|
||||
Agent.shared.setupStatusBarItem()
|
||||
if updateStatusBarItem {
|
||||
Agent.shared.setupStatusBarItem()
|
||||
}
|
||||
}
|
||||
|
||||
static func activateBrowser() {
|
||||
|
Loading…
Reference in New Issue
Block a user