diff --git a/Turbolinks/Action.swift b/Turbolinks/Action.swift index f83e0b2..8d3e65e 100644 --- a/Turbolinks/Action.swift +++ b/Turbolinks/Action.swift @@ -1,7 +1,7 @@ import Foundation public enum Action: String { - case Advance = "advance" - case Replace = "replace" - case Restore = "restore" + case advance = "advance" + case replace = "replace" + case restore = "restore" } diff --git a/Turbolinks/ScriptMessage.swift b/Turbolinks/ScriptMessage.swift index 5170098..ed9d329 100644 --- a/Turbolinks/ScriptMessage.swift +++ b/Turbolinks/ScriptMessage.swift @@ -1,17 +1,17 @@ import WebKit enum ScriptMessageName: String { - case PageLoaded = "pageLoaded" - case ErrorRaised = "errorRaised" - case VisitProposed = "visitProposed" - case VisitStarted = "visitStarted" - case VisitRequestStarted = "visitRequestStarted" - case VisitRequestCompleted = "visitRequestCompleted" - case VisitRequestFailed = "visitRequestFailed" - case VisitRequestFinished = "visitRequestFinished" - case VisitRendered = "visitRendered" - case VisitCompleted = "visitCompleted" - case PageInvalidated = "pageInvalidated" + case pageLoaded = "pageLoaded" + case errorRaised = "errorRaised" + case visitProposed = "visitProposed" + case visitStarted = "visitStarted" + case visitRequestStarted = "visitRequestStarted" + case visitRequestCompleted = "visitRequestCompleted" + case visitRequestFailed = "visitRequestFailed" + case visitRequestFinished = "visitRequestFinished" + case visitRendered = "visitRendered" + case visitCompleted = "visitCompleted" + case pageInvalidated = "pageInvalidated" } class ScriptMessage { diff --git a/Turbolinks/Session.swift b/Turbolinks/Session.swift index 2d62c26..f6b4f79 100644 --- a/Turbolinks/Session.swift +++ b/Turbolinks/Session.swift @@ -57,7 +57,7 @@ open class Session: NSObject { } open func visit(_ visitable: Visitable) { - visitVisitable(visitable, action: .Advance) + visitVisitable(visitable, action: .advance) } fileprivate func visitVisitable(_ visitable: Visitable, action: Action) { @@ -204,14 +204,14 @@ extension Session: VisitableDelegate { if topmostVisit.state == .completed { currentVisit.cancel() } else { - visitVisitable(visitable, action: .Advance) + visitVisitable(visitable, action: .advance) } } else if visitable === currentVisit.visitable && currentVisit.state == .started { // Navigating forward - complete navigation early completeNavigationForCurrentVisit() } else if visitable !== topmostVisit.visitable { // Navigating backward - visitVisitable(visitable, action: .Restore) + visitVisitable(visitable, action: .restore) } } diff --git a/Turbolinks/WebView.swift b/Turbolinks/WebView.swift index 04645b8..cb7de91 100644 --- a/Turbolinks/WebView.swift +++ b/Turbolinks/WebView.swift @@ -125,27 +125,27 @@ extension WebView: WKScriptMessageHandler { guard let message = ScriptMessage.parse(message) else { return } switch message.name { - case .PageLoaded: + case .pageLoaded: pageLoadDelegate?.webView(self, didLoadPageWithRestorationIdentifier: message.restorationIdentifier!) - case .PageInvalidated: + case .pageInvalidated: delegate?.webViewDidInvalidatePage(self) - case .VisitProposed: + case .visitProposed: delegate?.webView(self, didProposeVisitToLocation: message.location!, withAction: message.action!) - case .VisitStarted: + case .visitStarted: visitDelegate?.webView(self, didStartVisitWithIdentifier: message.identifier!, hasCachedSnapshot: message.data["hasCachedSnapshot"] as! Bool) - case .VisitRequestStarted: + case .visitRequestStarted: visitDelegate?.webView(self, didStartRequestForVisitWithIdentifier: message.identifier!) - case .VisitRequestCompleted: + case .visitRequestCompleted: visitDelegate?.webView(self, didCompleteRequestForVisitWithIdentifier: message.identifier!) - case .VisitRequestFailed: + case .visitRequestFailed: visitDelegate?.webView(self, didFailRequestForVisitWithIdentifier: message.identifier!, statusCode: message.data["statusCode"] as! Int) - case .VisitRequestFinished: + case .visitRequestFinished: visitDelegate?.webView(self, didFinishRequestForVisitWithIdentifier: message.identifier!) - case .VisitRendered: + case .visitRendered: visitDelegate?.webView(self, didRenderForVisitWithIdentifier: message.identifier!) - case .VisitCompleted: + case .visitCompleted: visitDelegate?.webView(self, didCompleteVisitWithIdentifier: message.identifier!, restorationIdentifier: message.restorationIdentifier!) - case .ErrorRaised: + case .errorRaised: let error = message.data["error"] as? String NSLog("JavaScript error: %@", error ?? "") } diff --git a/TurbolinksDemo/ApplicationController.swift b/TurbolinksDemo/ApplicationController.swift index 668bab1..4f92af7 100644 --- a/TurbolinksDemo/ApplicationController.swift +++ b/TurbolinksDemo/ApplicationController.swift @@ -33,12 +33,12 @@ class ApplicationController: UINavigationController { presentVisitableForSession(session, url: url) } - fileprivate func presentVisitableForSession(_ session: Session, url: URL, action: Action = .Advance) { + fileprivate func presentVisitableForSession(_ session: Session, url: URL, action: Action = .advance) { let visitable = DemoViewController(url: url) - if action == .Advance { + if action == .advance { pushViewController(visitable, animated: true) - } else if action == .Replace { + } else if action == .replace { popViewController(animated: false) pushViewController(visitable, animated: false) }