From b8be5a6666317e3cb49f3e20dac79fa4619e03eb Mon Sep 17 00:00:00 2001 From: Jaymon Date: Sat, 30 Apr 2022 13:16:27 +0900 Subject: [PATCH] Add view my profile page menu (#21) --- Sources/AppDelegate.swift | 14 +++++++++++++- Sources/Consts/Localized.swift | 1 + Supporting FIles/en.lproj/Localizable.strings | 1 + Supporting FIles/ko.lproj/Localizable.strings | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index 6add4da..e52900c 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -80,13 +80,19 @@ class AppDelegate: NSObject, NSApplicationDelegate { $0.keyEquivalent = "s" $0.tag = 7 } - + private let goalMenuItem = NSMenuItem().then { $0.title = Localized.setGoal $0.action = #selector(onChangeGoalClick) $0.keyEquivalent = "g" $0.tag = 8 } + + private let viewMyProfileItem = NSMenuItem().then { + $0.title = Localized.viewMyProfile + $0.action = #selector(viewMyProfileClick) + $0.tag = 10 + } func applicationDidFinishLaunching(_: Notification) { @@ -113,6 +119,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(.separator()) menu.addItem(userMenuItem) + menu.addItem(viewMyProfileItem) menu.addItem(.separator()) menu.addItem(helpMenuItem) menu.addItem(.separator()) @@ -279,6 +286,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { NSWorkspace.shared.open(url) } + @objc func viewMyProfileClick() { + let url = URL(string: "https://github.com/" + (UserDefaults.standard.string(forKey: Consts.usernameDefaultKey) ?? ""))! + NSWorkspace.shared.open(url) + } + @objc func onSettingClick() { showSettingAlert() } diff --git a/Sources/Consts/Localized.swift b/Sources/Consts/Localized.swift index 35d854a..c4e9bc0 100644 --- a/Sources/Consts/Localized.swift +++ b/Sources/Consts/Localized.swift @@ -28,6 +28,7 @@ enum Localized { static let goalInformation = NSLocalizedString("goal_information", comment: "Enter your GitHub username. We’ll fetch the number of contributions.") static let setting = NSLocalizedString("setting", comment: "Preferences") static let settingTitle = NSLocalizedString("setting_title", comment: "Preferences Title") + static let viewMyProfile = NSLocalizedString("view_my_profile", comment: "View my profile") static let streakFristStage = NSLocalizedString("streak_first_stage", comment: "streak stage 1") static let streakSecondStage = NSLocalizedString("streak_second_stage", comment: "streak stage 2") diff --git a/Supporting FIles/en.lproj/Localizable.strings b/Supporting FIles/en.lproj/Localizable.strings index 625c640..8525c1a 100644 --- a/Supporting FIles/en.lproj/Localizable.strings +++ b/Supporting FIles/en.lproj/Localizable.strings @@ -8,6 +8,7 @@ "wellcome_user_message" = "πŸ‘‹ Hello, @${username} ${withFriend}"; "with_friend" = "\nwith @${username}"; +"view_my_profile" = "🏑 View my profile"; "refresh" = "⏳ Refresh"; "change_username" = "πŸͺ„ Change username"; "change_friend_username" = "🀝 Change Friend username"; diff --git a/Supporting FIles/ko.lproj/Localizable.strings b/Supporting FIles/ko.lproj/Localizable.strings index 91dc84a..69b499d 100644 --- a/Supporting FIles/ko.lproj/Localizable.strings +++ b/Supporting FIles/ko.lproj/Localizable.strings @@ -8,6 +8,7 @@ "wellcome_user_message" = "πŸ‘‹ μ•ˆλ…•, @${username} ${withFriend}"; "with_friend" = "\n @${username}와 ν•¨κ»˜"; +"view_my_profile" = "🏑 λ‚΄ ν”„λ‘œν•„ 보기"; "refresh" = "⏳ μƒˆλ‘œκ³ μΉ¨"; "change_username" = "πŸͺ„ 아이디 λ³€κ²½"; "change_friend_username" = "🀝 친ꡬ 아이디 λ³€κ²½";