diff --git a/caffeine.xcodeproj/project.pbxproj b/caffeine.xcodeproj/project.pbxproj index 198e38f..3cd8e10 100644 --- a/caffeine.xcodeproj/project.pbxproj +++ b/caffeine.xcodeproj/project.pbxproj @@ -921,7 +921,7 @@ CODE_SIGN_ENTITLEMENTS = caffeine/caffeine.entitlements; CODE_SIGN_IDENTITY = "Apple Development: Simon Krüger (ZHJYL9DGF3)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = T2MU43SWN2; FRAMEWORK_SEARCH_PATHS = "$(inherited)/**"; @@ -946,7 +946,7 @@ CODE_SIGN_ENTITLEMENTS = caffeine/caffeine.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: Simon Krüger (T2MU43SWN2)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = T2MU43SWN2; FRAMEWORK_SEARCH_PATHS = "$(inherited)/**"; INFOPLIST_FILE = caffeine/Info.plist; diff --git a/caffeine/Generated/Scenes.swift b/caffeine/Generated/Scenes.swift index 5e734bf..a94bc64 100644 --- a/caffeine/Generated/Scenes.swift +++ b/caffeine/Generated/Scenes.swift @@ -12,15 +12,27 @@ import UIKit // swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name internal enum StoryboardScene { - internal enum LaunchScreen: StoryboardType { - internal static let storyboardName = "LaunchScreen" + internal enum Consumption: StoryboardType { + internal static let storyboardName = "Consumption" - internal static let initialScene = InitialSceneType(storyboard: LaunchScreen.self) + internal static let initialScene = InitialSceneType(storyboard: Consumption.self) } - internal enum Main: StoryboardType { - internal static let storyboardName = "Main" + internal enum Input: StoryboardType { + internal static let storyboardName = "Input" - internal static let initialScene = InitialSceneType(storyboard: Main.self) + internal static let initialScene = InitialSceneType(storyboard: Input.self) + } + internal enum Settings: StoryboardType { + internal static let storyboardName = "Settings" + + internal static let initialScene = InitialSceneType(storyboard: Settings.self) + + internal static let settingsWebViewController = SceneType(storyboard: Settings.self, identifier: "SettingsWebViewController") + } + internal enum Statistics: StoryboardType { + internal static let storyboardName = "Statistics" + + internal static let initialScene = InitialSceneType(storyboard: Statistics.self) } } // swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name diff --git a/caffeine/ViewController/Settings/Settings.storyboard b/caffeine/ViewController/Settings/Settings.storyboard index 9ca972a..f3137d6 100644 --- a/caffeine/ViewController/Settings/Settings.storyboard +++ b/caffeine/ViewController/Settings/Settings.storyboard @@ -123,7 +123,7 @@ - + @@ -181,16 +181,15 @@ - + - + - - - - - + + + + @@ -198,16 +197,16 @@ - - - - + + + + - + diff --git a/caffeine/ViewController/Settings/SettingsViewController.swift b/caffeine/ViewController/Settings/SettingsViewController.swift index 5e02667..c7d33fa 100644 --- a/caffeine/ViewController/Settings/SettingsViewController.swift +++ b/caffeine/ViewController/Settings/SettingsViewController.swift @@ -46,4 +46,11 @@ class SettingsViewController: UIViewController { animated: animated ) } + + @IBAction private func didPressInfoButton() { + guard let url = URL(string: "https://caffeine.cr0ss.org/medical-information/") else { return } + let webViewController = StoryboardScene.Settings.settingsWebViewController.instantiate() + webViewController.url = url + navigationController?.pushViewController(webViewController, animated: true) + } } diff --git a/caffeine/ViewController/Settings/SettingsWebViewController.swift b/caffeine/ViewController/Settings/SettingsWebViewController.swift index dc3e959..6923c00 100644 --- a/caffeine/ViewController/Settings/SettingsWebViewController.swift +++ b/caffeine/ViewController/Settings/SettingsWebViewController.swift @@ -3,14 +3,49 @@ import WebKit class SettingsWebViewController: UIViewController { @IBOutlet private weak var webView: WKWebView? + var url: URL? { + didSet { + guard let url = self.url else { return } + + webView?.load(.init(url: url)) + } + } override func viewDidLoad() { super.viewDidLoad() - guard - let url = URL(string: "https://caffeine.cr0ss.org/medical-information/") - else { return } + webView?.navigationDelegate = self + + guard let url = self.url else { return } webView?.load(.init(url: url)) } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + guard let url = self.url else { return } + + webView?.load(.init(url: url)) + } +} + +extension SettingsWebViewController: WKNavigationDelegate { + + func webView( + _ webView: WKWebView, + decidePolicyFor navigationAction: WKNavigationAction, + decisionHandler: @escaping (WKNavigationActionPolicy) -> Void + ) { + if navigationAction.navigationType == .linkActivated { + guard let url = navigationAction.request.url else { return decisionHandler(.allow) } + let webViewController = StoryboardScene.Settings.settingsWebViewController.instantiate() + webViewController.url = url + navigationController?.pushViewController(webViewController, animated: true) + decisionHandler(.cancel) + } else { + decisionHandler(.allow) + } + } + } diff --git a/swiftgen.yml b/swiftgen.yml index 773d3bd..daf4d57 100644 --- a/swiftgen.yml +++ b/swiftgen.yml @@ -10,7 +10,7 @@ xcassets: - templateName: swift5 output: caffeine/Generated/Assets.swift ib: - inputs: caffeine/Scenes + inputs: caffeine/ViewController outputs: - templateName: scenes-swift5 output: caffeine/Generated/Scenes.swift