Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Changing enums to camel case #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Turbolinks/Action.swift
Original file line number Diff line number Diff line change
@@ -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"
}
22 changes: 11 additions & 11 deletions Turbolinks/ScriptMessage.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions Turbolinks/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}

Expand Down
22 changes: 11 additions & 11 deletions Turbolinks/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "<unknown error>")
}
Expand Down
6 changes: 3 additions & 3 deletions TurbolinksDemo/ApplicationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down