From 35a6fa4fc2db7f8ec91111c54289d96ef0850585 Mon Sep 17 00:00:00 2001 From: Claire Davis Date: Tue, 29 May 2018 18:28:25 -0400 Subject: [PATCH 1/2] Changing enums to camel case --- Turbolinks/Action.swift | 6 +++--- Turbolinks/ScriptMessage.swift | 22 +++++++++++----------- Turbolinks/Session.swift | 6 +++--- Turbolinks/WebView.swift | 22 +++++++++++----------- 4 files changed, 28 insertions(+), 28 deletions(-) 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 ?? "") } From 63736a9d02725d593adc19511ad84efcf0dda5b5 Mon Sep 17 00:00:00 2001 From: Claire Davis Date: Tue, 29 May 2018 18:38:51 -0400 Subject: [PATCH 2/2] updating demo project to use camel case action enum --- TurbolinksDemo/ApplicationController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) }