Skip to content

Commit

Permalink
Add view my profile page menu (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
stomx committed Apr 30, 2022
1 parent 6544ca9 commit b8be5a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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())
Expand Down Expand Up @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Consts/Localized.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions Supporting FIles/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions Supporting FIles/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"wellcome_user_message" = "πŸ‘‹ μ•ˆλ…•, @${username} ${withFriend}";
"with_friend" = "\n @${username}와 ν•¨κ»˜";
"view_my_profile" = "🏑 λ‚΄ ν”„λ‘œν•„ 보기";
"refresh" = "⏳ μƒˆλ‘œκ³ μΉ¨";
"change_username" = "πŸͺ„ 아이디 λ³€κ²½";
"change_friend_username" = "🀝 친ꡬ 아이디 λ³€κ²½";
Expand Down

0 comments on commit b8be5a6

Please sign in to comment.