diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be0fc5..4724d3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,19 @@ +## 2.8.1 - 2022-04-06 + +### Changed +- Updated App icon +- Updated App Font +- Updated menubar icon +- Show hosts status with icons + +--- + ## 2.8.0 - 2022-01-14 ### Changed - Updated App name from **HostsToolForMac** to **HostsX** - Updated App icon -- Updadted menu items in the menubar +- Updated menu items in the menubar ### Added - Added about view diff --git a/CHANGELOG_SC.md b/CHANGELOG_SC.md index b50a19a..67a7a16 100644 --- a/CHANGELOG_SC.md +++ b/CHANGELOG_SC.md @@ -1,3 +1,13 @@ +## 2.8.1 - 2022-04-06 + +### Changed +- 更新应用图标 +- 更新应用字体 +- 更新菜单栏图标 +- 用图标显示 hosts 状态 + +--- + ## 2.8.0 - 2022-01-14 ### Changed diff --git a/HostsX.xcodeproj/project.pbxproj b/HostsX.xcodeproj/project.pbxproj index e815624..1dc2c76 100644 --- a/HostsX.xcodeproj/project.pbxproj +++ b/HostsX.xcodeproj/project.pbxproj @@ -466,7 +466,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 2.8.0; + MARKETING_VERSION = 2.8.1; PRODUCT_BUNDLE_IDENTIFIER = com.alpha.hostsx; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -497,7 +497,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 2.8.0; + MARKETING_VERSION = 2.8.1; PRODUCT_BUNDLE_IDENTIFIER = com.alpha.hostsx; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/HostsX/AppDelegate.swift b/HostsX/AppDelegate.swift index 02bc9c6..be9e01d 100644 --- a/HostsX/AppDelegate.swift +++ b/HostsX/AppDelegate.swift @@ -11,15 +11,18 @@ import Cocoa @main class AppDelegate: NSObject, NSApplicationDelegate { - private let statusItem = NSStatusItem.system + private lazy var statusItem = NSStatusItem.system + @IBOutlet weak var menu: AppMenu! + + func applicationDidFinishLaunching(_ aNotification: Notification) { - statusItem.setAttributedTitle(Bundle.main.bundleName) + statusItem.setMenuBarIcon() statusItem.menu = menu - //RemoteSource.restore() + } diff --git a/HostsX/AppMenu.swift b/HostsX/AppMenu.swift index 1cf164b..cbc1d06 100644 --- a/HostsX/AppMenu.swift +++ b/HostsX/AppMenu.swift @@ -24,14 +24,14 @@ class AppMenu: NSMenu { private var wc: NSWindowController? override func awakeFromNib() { - localItem.setAttributedTitle(Localization.Menu.local) - remoteItem.setAttributedTitle(Localization.Menu.remote) - downloadItem.setAttributedTitle(Localization.Menu.remoteDownload) - configItem.setAttributedTitle(Localization.Menu.remoteConfig) - helpItem.setAttributedTitle(Localization.Menu.help) - checkItem.setAttributedTitle(Localization.Menu.helpCheck) - aboutItem.setAttributedTitle(Localization.Menu.helpAbout) - quitItem.setAttributedTitle(Localization.Menu.quit) + localItem.title = Localization.Menu.local + remoteItem.title = Localization.Menu.remote + downloadItem.title = Localization.Menu.remoteDownload + configItem.title = Localization.Menu.remoteConfig + helpItem.title = Localization.Menu.help + checkItem.title = Localization.Menu.helpCheck + aboutItem.title = Localization.Menu.helpAbout + quitItem.title = Localization.Menu.quit } @IBAction func onLoacl(_ sender: NSMenuItem) { diff --git a/HostsX/Assets.xcassets/AccentColor.colorset/Contents.json b/HostsX/Assets.xcassets/AccentColor.colorset/Contents.json index 16c8b03..b330944 100644 --- a/HostsX/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/HostsX/Assets.xcassets/AccentColor.colorset/Contents.json @@ -1,15 +1,6 @@ { "colors" : [ { - "color" : { - "color-space" : "display-p3", - "components" : { - "alpha" : "1.000", - "blue" : "0.808", - "green" : "0.635", - "red" : "0.294" - } - }, "idiom" : "mac" } ], diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128.png index 42ce435..8d1f8f2 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png index 3ec5315..a4debef 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16.png index 7dabe0b..85b71d9 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png index 4281796..63858fb 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256.png index 3ec5315..a4debef 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png index 84fc0a4..3a0dbde 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32.png index 4281796..63858fb 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png index c612fd2..e8b82fd 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512.png index 84fc0a4..3a0dbde 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png index 1ea06c8..c4c5aa4 100644 Binary files a/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png and b/HostsX/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/HostsX/Assets.xcassets/back.imageset/back.png b/HostsX/Assets.xcassets/back.imageset/back.png deleted file mode 100644 index 5d8df6d..0000000 Binary files a/HostsX/Assets.xcassets/back.imageset/back.png and /dev/null differ diff --git a/HostsX/Assets.xcassets/link.imageset/Contents.json b/HostsX/Assets.xcassets/link.imageset/Contents.json index 370f7bc..c9416c6 100644 --- a/HostsX/Assets.xcassets/link.imageset/Contents.json +++ b/HostsX/Assets.xcassets/link.imageset/Contents.json @@ -5,7 +5,7 @@ "scale" : "1x" }, { - "filename" : "link.png", + "filename" : "link@2x.png", "idiom" : "mac", "scale" : "2x" } diff --git a/HostsX/Assets.xcassets/link.imageset/link.png b/HostsX/Assets.xcassets/link.imageset/link.png deleted file mode 100644 index 3087a3d..0000000 Binary files a/HostsX/Assets.xcassets/link.imageset/link.png and /dev/null differ diff --git a/HostsX/Assets.xcassets/link.imageset/link@2x.png b/HostsX/Assets.xcassets/link.imageset/link@2x.png new file mode 100644 index 0000000..7b02315 Binary files /dev/null and b/HostsX/Assets.xcassets/link.imageset/link@2x.png differ diff --git a/HostsX/Assets.xcassets/back.imageset/Contents.json b/HostsX/Assets.xcassets/menuBarIcon.imageset/Contents.json similarity index 66% rename from HostsX/Assets.xcassets/back.imageset/Contents.json rename to HostsX/Assets.xcassets/menuBarIcon.imageset/Contents.json index 8a68cb8..015044b 100644 --- a/HostsX/Assets.xcassets/back.imageset/Contents.json +++ b/HostsX/Assets.xcassets/menuBarIcon.imageset/Contents.json @@ -5,7 +5,7 @@ "scale" : "1x" }, { - "filename" : "back.png", + "filename" : "rocket.png", "idiom" : "mac", "scale" : "2x" } @@ -13,8 +13,5 @@ "info" : { "author" : "xcode", "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" } } diff --git a/HostsX/Assets.xcassets/menuBarIcon.imageset/rocket.png b/HostsX/Assets.xcassets/menuBarIcon.imageset/rocket.png new file mode 100644 index 0000000..95aac39 Binary files /dev/null and b/HostsX/Assets.xcassets/menuBarIcon.imageset/rocket.png differ diff --git a/HostsX/Base.lproj/Remote.storyboard b/HostsX/Base.lproj/Remote.storyboard index 515aad2..0d6a8e5 100644 --- a/HostsX/Base.lproj/Remote.storyboard +++ b/HostsX/Base.lproj/Remote.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -36,86 +37,82 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -173,33 +170,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -229,28 +227,28 @@ - + - + - + - + - + - + - + @@ -313,7 +311,7 @@ - + @@ -323,16 +321,14 @@ + + + - - - - - @@ -343,7 +339,7 @@ - + @@ -358,7 +354,11 @@ - + + + + + diff --git a/HostsX/Component/Dialog/ConfirmDialogController.xib b/HostsX/Component/Dialog/ConfirmDialogController.xib index 8e0edd0..4757511 100644 --- a/HostsX/Component/Dialog/ConfirmDialogController.xib +++ b/HostsX/Component/Dialog/ConfirmDialogController.xib @@ -1,8 +1,8 @@ - + - + @@ -18,14 +18,14 @@ - + - + - + @@ -69,7 +69,7 @@ Gw - + diff --git a/HostsX/Component/Dialog/InfoDialogController.xib b/HostsX/Component/Dialog/InfoDialogController.xib index d9210da..735bab2 100644 --- a/HostsX/Component/Dialog/InfoDialogController.xib +++ b/HostsX/Component/Dialog/InfoDialogController.xib @@ -1,8 +1,8 @@ - + - + @@ -17,14 +17,14 @@ - + - + - + @@ -53,7 +53,7 @@ - + diff --git a/HostsX/Constant.swift b/HostsX/Constant.swift index e95f4e3..6d97ddc 100644 --- a/HostsX/Constant.swift +++ b/HostsX/Constant.swift @@ -48,20 +48,12 @@ extension NSSize { } extension NSImage.Name { - static let backward = "back" static let star = "star" static let add = "add" static let link = "link" static let trash = "trash" } -enum Attributes { - static let menu: [NSAttributedString.Key: NSFont] = [.font: .menu] -} - -extension NSFont { - static let menu = NSFont(name: "HannotateSC-W5", size: 13)! -} extension NSStoryboard { static let remote = NSStoryboard(name: "Remote", bundle: .none) @@ -71,6 +63,4 @@ extension NSStoryboard { extension NSColor { @available(macOS 10.13, *) static let backgroud = NSColor(named: "backgroudColor") - static let accent = NSColor(displayP3Red: 0.294, green: 0.635, blue: 0.808, alpha: 1) - } diff --git a/HostsX/Extension/AppKit+.swift b/HostsX/Extension/AppKit+.swift index 7f8abb7..7df9471 100644 --- a/HostsX/Extension/AppKit+.swift +++ b/HostsX/Extension/AppKit+.swift @@ -107,15 +107,6 @@ extension NSView { } } -extension NSImageView { - func addShadow() { - let shadow = NSShadow() - shadow.shadowOffset = .init(width: 2, height: -2) - shadow.shadowColor = .lightGray - shadow.shadowBlurRadius = 3 - self.shadow = shadow - } -} extension NSViewController { @@ -141,26 +132,26 @@ extension NSStoryboard { } extension NSMenu { - func addImageItem(_ name: NSImage.Name, action: Selector?) { + func addItemIcon(_ name: String, action: Selector?) { let item = NSMenuItem(title: "", action: action, keyEquivalent: "") - let image = NSImage(named: name) - image?.isTemplate = true - item.image = image + let icon = NSImage(named: name) + icon?.isTemplate = true + item.image = icon addItem(item) } } -extension NSMenuItem { - func setAttributedTitle(_ title: String) { - attributedTitle = NSAttributedString(string: title, attributes: Attributes.menu) - } -} + extension NSStatusItem { - func setAttributedTitle(_ title: String?) { - guard title != nil else { return } - button?.attributedTitle = NSAttributedString(string: title!, attributes: Attributes.menu) + + func setMenuBarIcon() { + guard let icon = NSImage(named: NSImage.Name("menuBarIcon")) else { return } + icon.isTemplate = true + icon.size = CGSize(width: 16, height: 16) + button?.image = icon } + } extension Optional where Wrapped == NSWindowController { diff --git a/HostsX/Help.storyboard b/HostsX/Help.storyboard index 7742d3b..b04d1cc 100644 --- a/HostsX/Help.storyboard +++ b/HostsX/Help.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -40,17 +41,17 @@ - + - + - + - + @@ -64,32 +65,32 @@ - + - + - + - + @@ -110,5 +111,8 @@ + + + diff --git a/HostsX/Menu.xib b/HostsX/Menu.xib index 0abe626..e912815 100644 --- a/HostsX/Menu.xib +++ b/HostsX/Menu.xib @@ -1,8 +1,8 @@ - + - + diff --git a/HostsX/Model/Hosts.swift b/HostsX/Model/Hosts.swift index 4cab313..2200344 100644 --- a/HostsX/Model/Hosts.swift +++ b/HostsX/Model/Hosts.swift @@ -12,21 +12,14 @@ enum HostsStatus: Codable { case unknown, available, unavailable - var color: NSColor { + var icon: NSImage { switch self { - case .unknown: return .systemGray - case .available: return .accent - case .unavailable: return .systemPink - } - } - - var description: String { - switch self { - case .unknown: return Localization.Hosts.unknown - case .available: return Localization.Hosts.available - case .unavailable: return Localization.Hosts.unavailable + case .unknown: return .init(named: NSImage.statusNoneName)! + case .available: return .init(named: NSImage.statusAvailableName)! + case .unavailable: return .init(named: NSImage.statusUnavailableName)! } } + } diff --git a/HostsX/Module/Help/AboutViewController.swift b/HostsX/Module/Help/AboutViewController.swift index d10e5fb..1ad9dba 100644 --- a/HostsX/Module/Help/AboutViewController.swift +++ b/HostsX/Module/Help/AboutViewController.swift @@ -27,8 +27,6 @@ class AboutViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() iconImageView.image = NSApp.applicationIconImage - iconImageView.addShadow() - nameLabel.stringValue = name versionLabel.stringValue = version copyrightLabel.stringValue = copyright diff --git a/HostsX/Module/Remote/RemoteConfigController.swift b/HostsX/Module/Remote/RemoteConfigController.swift index 0d5fab2..8a05029 100644 --- a/HostsX/Module/Remote/RemoteConfigController.swift +++ b/HostsX/Module/Remote/RemoteConfigController.swift @@ -12,8 +12,8 @@ class RemoteConfigController: NSViewController { @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var aliasLabel: NSTextField! - - @IBOutlet weak var statusLabel: NSTextField! + + @IBOutlet weak var statusIcon: NSImageView! @IBOutlet weak var originButton: NSButton! @@ -22,7 +22,6 @@ class RemoteConfigController: NSViewController { override func viewDidDisappear() { super.viewDidDisappear() RemoteSource.cancel() - } override func viewDidLoad() { @@ -66,9 +65,9 @@ class RemoteConfigController: NSViewController { extension RemoteConfigController { private func setupMenu() { - remoteMenu.addImageItem(.link, action: #selector(open)) - remoteMenu.addImageItem(.add, action: #selector(insert)) - remoteMenu.addImageItem(.trash, action: #selector(remove)) + remoteMenu.addItemIcon(.link, action: #selector(open)) + remoteMenu.addItemIcon(.add, action: #selector(insert)) + remoteMenu.addItemIcon(.trash, action: #selector(remove)) } private func showHosts() { @@ -76,8 +75,7 @@ extension RemoteConfigController { DispatchQueue.main.async { [weak self] in guard let strong = self else { return } strong.aliasLabel.stringValue = hosts.alias - strong.statusLabel.backgroundColor = hosts.status.color - strong.statusLabel.stringValue = hosts.status.description + strong.statusIcon.image = hosts.status.icon strong.originButton.isHidden = !RemoteSource.canSetAsOrigin } } diff --git a/HostsX/Service/Network.swift b/HostsX/Service/Network.swift index 6fa9103..5453b8b 100644 --- a/HostsX/Service/Network.swift +++ b/HostsX/Service/Network.swift @@ -21,6 +21,7 @@ struct Network { return completion(.unavailable) } + let request = URLRequest(url: url, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 30) task = URLSession.shared.dataTask(with: request) { data, response, error in diff --git a/README.md b/README.md index 67768b5..bedb233 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ A lightweight macOS App for updating local hosts - [English](CHANGELOG.md) ## Snapshots -- Menu +- Menubar diff --git a/assets/m1.png b/assets/m1.png index fbd140a..5f96d57 100644 Binary files a/assets/m1.png and b/assets/m1.png differ diff --git a/assets/m2.png b/assets/m2.png index 3426684..3c35d89 100644 Binary files a/assets/m2.png and b/assets/m2.png differ diff --git a/assets/m3.png b/assets/m3.png index 5fa1c5a..523cfbd 100644 Binary files a/assets/m3.png and b/assets/m3.png differ diff --git a/assets/r1.png b/assets/r1.png index d17e4d9..ef85c7b 100644 Binary files a/assets/r1.png and b/assets/r1.png differ diff --git a/assets/r2.png b/assets/r2.png index a3d6389..51acd31 100644 Binary files a/assets/r2.png and b/assets/r2.png differ diff --git a/assets/r3.png b/assets/r3.png index 8f0abc6..5890360 100644 Binary files a/assets/r3.png and b/assets/r3.png differ