From f734e658a7665f4211b1e39ce2084b755d8670ca Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Sat, 17 Jul 2021 18:16:56 +0300 Subject: [PATCH] Move accounts menu setup in a separate function --- .../Screens/AccountsListViewController.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Encrypted Ink/Screens/AccountsListViewController.swift b/Encrypted Ink/Screens/AccountsListViewController.swift index 3caa8411..053bf7f9 100644 --- a/Encrypted Ink/Screens/AccountsListViewController.swift +++ b/Encrypted Ink/Screens/AccountsListViewController.swift @@ -34,13 +34,7 @@ class AccountsListViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - let menu = NSMenu() - menu.delegate = self - menu.addItem(NSMenuItem(title: "Copy address", action: #selector(didClickCopyAddress(_:)), keyEquivalent: "")) - menu.addItem(.separator()) - menu.addItem(NSMenuItem(title: "Show private key", action: #selector(didClickExportAccount(_:)), keyEquivalent: "")) // TODO: show different texts for secret words export - menu.addItem(NSMenuItem(title: "Remove account", action: #selector(didClickRemoveAccount(_:)), keyEquivalent: "")) - tableView.menu = menu + setupAccountsMenu() if accounts.isEmpty { reloadAccounts() @@ -50,6 +44,16 @@ class AccountsListViewController: NSViewController { NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActive), name: NSApplication.didBecomeActiveNotification, object: nil) } + private func setupAccountsMenu() { + let menu = NSMenu() + menu.delegate = self + menu.addItem(NSMenuItem(title: "Copy address", action: #selector(didClickCopyAddress(_:)), keyEquivalent: "")) + menu.addItem(.separator()) + menu.addItem(NSMenuItem(title: "Show private key", action: #selector(didClickExportAccount(_:)), keyEquivalent: "")) // TODO: show different texts for secret words export + menu.addItem(NSMenuItem(title: "Remove account", action: #selector(didClickRemoveAccount(_:)), keyEquivalent: "")) + tableView.menu = menu + } + private func reloadAccounts() { accounts = AccountsService.getAccounts() }