diff --git a/Corona/Generated/Assets.swift b/Corona/Generated/Assets.swift index 1ef68eb..5eb6992 100644 --- a/Corona/Generated/Assets.swift +++ b/Corona/Generated/Assets.swift @@ -23,6 +23,7 @@ internal enum Asset { internal static let info = ImageAsset(name: "Info") internal static let layers = ImageAsset(name: "Layers") internal static let more = ImageAsset(name: "More") + internal static let persons = ImageAsset(name: "Persons") internal static let reload = ImageAsset(name: "Reload") internal static let search = ImageAsset(name: "Search") internal static let shareCircle = ImageAsset(name: "Share-Circle") diff --git a/Corona/Generated/Strings.swift b/Corona/Generated/Strings.swift index 84244b2..cbea5be 100644 --- a/Corona/Generated/Strings.swift +++ b/Corona/Generated/Strings.swift @@ -85,6 +85,10 @@ internal enum L10n { internal enum Menu { /// Copy internal static let copy = L10n.tr("Localizable", "menu.copy") + /// Release Notes + internal static let releaseNotes = L10n.tr("Localizable", "menu.releaseNotes") + /// Report an Issue + internal static let reportIssue = L10n.tr("Localizable", "menu.reportIssue") /// Search internal static let search = L10n.tr("Localizable", "menu.search") /// Share diff --git a/Corona/Localization/Base.lproj/Localizable.strings b/Corona/Localization/Base.lproj/Localizable.strings index fa85609..619cf8b 100644 --- a/Corona/Localization/Base.lproj/Localizable.strings +++ b/Corona/Localization/Base.lproj/Localizable.strings @@ -36,5 +36,7 @@ "menu.update" = "Update"; "menu.share" = "Share"; "menu.search" = "Search"; +"menu.releaseNotes" = "Release Notes"; +"menu.reportIssue" = "Report an Issue"; "share.current" = "Coronavirus live update"; "share.chartHistory" = "Coronavirus growth chart"; diff --git a/Corona/Main/App.swift b/Corona/Main/App.swift index edcf814..a24f98f 100644 --- a/Corona/Main/App.swift +++ b/Corona/Main/App.swift @@ -18,10 +18,13 @@ class App { return topController } + static let repoURL = URL(string: "https://github.com/mhdhejazi/CoronaTracker")! + static let releaseNotesURL = URL(string: "https://github.com/mhdhejazi/CoronaTracker/releases")! + static let newIssueURL = URL(string: "https://github.com/mhdhejazi/CoronaTracker/issues/new")! #if targetEnvironment(macCatalyst) static let updateURL = URL(string: "https://coronatracker.samabox.com/")! #else - static let updateURL = URL(string: "https://github.com/mhdhejazi/CoronaTracker")! + static let updateURL = repoURL #endif static let version = Bundle.main.version @@ -48,12 +51,16 @@ class App { }.resume() } - public static func openUpdatePage(viewController: UIViewController) { - let safariController = SFSafariViewController(url: updateURL) + public static func openWebPage(url: URL, viewController: UIViewController) { + let safariController = SFSafariViewController(url: url) safariController.modalPresentationStyle = .pageSheet viewController.present(safariController, animated: true) } + public static func openUpdatePage(viewController: UIViewController) { + openWebPage(url: updateURL, viewController: viewController) + } + public static func upgrade() { let appVersionKey = "appVersion" let oldAppVersion = UserDefaults.standard.string(forKey: appVersionKey) @@ -65,4 +72,16 @@ class App { UserDefaults.standard.set(newAppVersion, forKey: appVersionKey) } + + public static func openHelpPage() { + openWebPage(url: repoURL, viewController: topViewController) + } + + public static func openReleaseNotesPage() { + openWebPage(url: releaseNotesURL, viewController: topViewController) + } + + public static func openNewIssuePage() { + openWebPage(url: newIssueURL, viewController: topViewController) + } } diff --git a/Corona/Main/AppMenu.swift b/Corona/Main/AppMenu.swift index 61b9990..2a7fa42 100644 --- a/Corona/Main/AppMenu.swift +++ b/Corona/Main/AppMenu.swift @@ -19,7 +19,10 @@ extension AppMenu { switch action { case #selector(searchAction(_:)), #selector(reloadAction(_:)), - #selector(shareAction(_:)): + #selector(shareAction(_:)), + #selector(releaseNotesAction(_:)), + #selector(reportIssueAction(_:)), + #selector(showHelp(_:)): return true default: @@ -35,6 +38,7 @@ extension AppMenu { builder.insertSibling(searchMenu(), afterMenu: .standardEdit) builder.insertChild(reloadMenu(), atStartOfMenu: .view) builder.insertChild(shareMenu(), atStartOfMenu: .file) + builder.insertChild(helpMenu(), atStartOfMenu: .help) } private func searchMenu() -> UIMenu { @@ -61,6 +65,21 @@ extension AppMenu { return UIMenu(title: "", options: .displayInline, children: [command]) } + private func helpMenu() -> UIMenu { + UIMenu(title: "", options: .displayInline, children: [ + UICommand(title: L10n.Menu.releaseNotes, + action: #selector(releaseNotesAction(_:))), + UICommand(title: L10n.Menu.reportIssue, + action: #selector(reportIssueAction(_:))) + ]) + } + + private func reportIssueMenu() -> UIMenu { + let command = UICommand(title: L10n.Menu.reportIssue, + action: #selector(reportIssueAction(_:))) + return UIMenu(title: "", options: .displayInline, children: [command]) + } + // MARK: - Actions @objc @@ -77,4 +96,19 @@ extension AppMenu { private func shareAction(_ sender: UICommand) { MapController.shared.showShareButtons() } + + @objc + private func releaseNotesAction(_ sender: UICommand) { + App.openReleaseNotesPage() + } + + @objc + private func reportIssueAction(_ sender: UICommand) { + App.openNewIssuePage() + } + + @objc + private func showHelp(_ sender: UICommand) { + App.openHelpPage() + } }