Skip to content

Commit

Permalink
Updated Podfile (and added Fabric), Readme, compliance to swift 3.0z
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrollin committed Sep 12, 2016
1 parent feda4ac commit 466c680
Show file tree
Hide file tree
Showing 24 changed files with 350 additions and 258 deletions.
184 changes: 151 additions & 33 deletions Drivecast.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions Drivecast/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UIKit
import IQKeyboardManagerSwift
import KVNProgress
import Alamofire
import Fabric
import Crashlytics

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -19,48 +21,50 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
appearanceSetup()
progressSetup()


Fabric.with([Crashlytics.self])

return true
}

// Setting up the general look and feel of the app
private func appearanceSetup() {
let mainColor = UIColor(named: .Main)
let fontSize:CGFloat = UIFont.systemFontSize()

if #available(iOS 8.2, *) {
let font = UIFont.systemFontOfSize(fontSize, weight: UIFontWeightLight)

UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font]
} else {
let font = UIFont.systemFontOfSize(fontSize)

UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font]
}

let backImage = UIImage(asset: .Back)

UINavigationBar.appearance().backIndicatorImage = backImage
UINavigationBar.appearance().backIndicatorTransitionMaskImage = backImage

self.window?.tintColor = mainColor
UIWindow.appearance().tintColor = mainColor
UIAlertView.appearance().tintColor = mainColor
UIActionSheet.appearance().tintColor = mainColor
UIButton.appearance().tintColor = mainColor
UITabBar.appearance().translucent = false
UINavigationBar.appearance().translucent = false

// Handles all keyboard events
IQKeyboardManager.sharedManager().enable = true
}

// Configurating the progress activity screen
private func progressSetup() {
let configuration:KVNProgressConfiguration = KVNProgressConfiguration()
let backgroundColor = UIColor(named: .Background)
let mainColor = UIColor(named: .Main)

configuration.backgroundType = .Blurred
configuration.backgroundFillColor = backgroundColor.colorWithAlphaComponent(0.7)
configuration.backgroundTintColor = backgroundColor.colorWithAlphaComponent(0.8)
Expand All @@ -69,7 +73,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
configuration.successColor = mainColor
configuration.errorColor = mainColor
configuration.fullScreen = true;

KVNProgress.setConfiguration(configuration)
}
}
Expand Down
4 changes: 4 additions & 0 deletions Drivecast/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ extension UIColor {
case .Text: return 0x333333ff
}
}

var color: UIColor {
return UIColor(named: self)
}
}

convenience init(named name: Name) {
Expand Down
3 changes: 1 addition & 2 deletions Drivecast/Extensions/UIImage.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen

import Foundation
import UIKit

extension UIImage {
enum Asset : String {
enum Asset: String {
case Dot = "Dot"
case Header = "Header"
case Back = "Back"
Expand Down
28 changes: 14 additions & 14 deletions Drivecast/Extensions/UIStoryboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
import UIKit

protocol StoryboardSceneType {
static var storyboardName : String { get }
static var storyboardName: String { get }
}

extension StoryboardSceneType {
Expand All @@ -26,37 +26,37 @@ extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == Str
}
}

protocol StoryboardSegueType : RawRepresentable { }
protocol StoryboardSegueType: RawRepresentable { }

extension UIViewController {
func performSegue<S : StoryboardSegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) {
func performSegue<S: StoryboardSegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) {
performSegueWithIdentifier(segue.rawValue, sender: sender)
}
}

struct StoryboardScene {
enum Main : String, StoryboardSceneType {
enum Main: String, StoryboardSceneType {
static let storyboardName = "Main"

case About = "About"
static func aboutViewController() -> UINavigationController {
return Main.About.viewController() as! UINavigationController
case AboutScene = "About"
static func instantiateAbout() -> UINavigationController {
return StoryboardScene.Main.AboutScene.viewController() as! UINavigationController
}

case Menu = "Menu"
static func menuViewController() -> UITabBarController {
return Main.Menu.viewController() as! UITabBarController
case MenuScene = "Menu"
static func instantiateMenu() -> UITabBarController {
return StoryboardScene.Main.MenuScene.viewController() as! UITabBarController
}

case Record = "Record"
static func recordViewController() -> UINavigationController {
return Main.Record.viewController() as! UINavigationController
case RecordScene = "Record"
static func instantiateRecord() -> UINavigationController {
return StoryboardScene.Main.RecordScene.viewController() as! UINavigationController
}
}
}

struct StoryboardSegue {
enum Main : String, StoryboardSegueType {
enum Main: String, StoryboardSegueType {
case OpenConsole = "OpenConsole"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Drivecast/Extensions/UITextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension UITextField {
public var rac_text: MutableProperty<String> {
return lazyAssociatedProperty(self, key: &AssociationKey.text) {

self.addTarget(self, action: "changed", forControlEvents: UIControlEvents.EditingChanged)
self.addTarget(self, action: #selector(UITextField.changed), forControlEvents: UIControlEvents.EditingChanged)

let property = MutableProperty<String>(self.text ?? "")

Expand Down
2 changes: 1 addition & 1 deletion Drivecast/Helpers/DCTLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

// Log function displaying details about the dumped object
func dlog<T>(object: T, filename: NSString = __FILE__, line: Int = __LINE__, funcname: String = __FUNCTION__) {
func dlog<T>(object: T, filename: NSString = #file, line: Int = #line, funcname: String = #function) {
#if DEBUG
print(">>> \(filename.lastPathComponent)(\(line)) \(funcname):")
dump(object)
Expand Down
16 changes: 15 additions & 1 deletion Drivecast/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down Expand Up @@ -49,6 +49,20 @@
<array>
<string>armv7</string>
</array>
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>358aba0b68b30486e45765ffa24670ae72b7755c</string>
<key>Kits</key>
<array>
<dict>
<key>KitInfo</key>
<dict/>
<key>KitName</key>
<string>Crashlytics</string>
</dict>
</array>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
17 changes: 15 additions & 2 deletions Drivecast/Models/SDCImport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,25 @@ extension SDCImportLog: JSONDecodable {
utcFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
utcFormatter.timeZone = NSTimeZone(name: "UTC")

dlog(json)

var value: Dictionary<String, AnyObject> = [:]

value["id"] = json["id"].intValue
value["userId"] = json["userId"].intValue
value["createdAt"] = utcFormatter.dateFromString(json["created_at"].stringValue)!
value["updatedAt"] = utcFormatter.dateFromString(json["updated_at"].stringValue)!

if let created = json["created_at"].string {
value["createdAt"] = utcFormatter.dateFromString(created) ?? NSDate()
} else {
value["createdAt"] = NSDate()
}

if let created = json["updated_at"].string {
value["updatedAt"] = utcFormatter.dateFromString(created) ?? NSDate()
} else {
value["updatedAt"] = NSDate()
}

value["name"] = json["name"].stringValue
value["cities"] = json["cities"].stringValue
value["credits"] = json["credits"].stringValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension SDCAboutTableViewController {
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .Done,
target: self,
action: Selector("closeAbout")
action: #selector(SDCAboutTableViewController.closeAbout)
)

donateButton.isRounded = true
Expand Down
14 changes: 7 additions & 7 deletions Drivecast/ViewControllers/SDCDashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension SDCDashboardTableViewController {
navigationItem.rightBarButtonItem = UIBarButtonItem(
image: UIImage.Asset.More.image,
style: UIBarButtonItemStyle.Plain,
target: self, action: Selector("openAboutModal")
target: self, action: #selector(SDCDashboardTableViewController.openAboutModal)
)

// Table view
Expand Down Expand Up @@ -121,7 +121,7 @@ extension SDCDashboardTableViewController {
}

func openAboutModal() {
let about = StoryboardScene.Main.aboutViewController()
let about = StoryboardScene.Main.instantiateAbout()

presentViewController(about, animated: true, completion: nil)
}
Expand All @@ -130,7 +130,7 @@ extension SDCDashboardTableViewController {
refreshControl?.tintColor = UIColor.clearColor()

if let refreshControl = refreshControl where !refreshControl.refreshing {
refreshControl.performSelector(Selector("beginRefreshing"), withObject: nil, afterDelay: 0.05)
refreshControl.performSelector(#selector(UIRefreshControl.beginRefreshing), withObject: nil, afterDelay: 0.05)
}

viewModel.getFirstPage { _ in }
Expand Down Expand Up @@ -183,7 +183,7 @@ extension SDCDashboardTableViewController {
self.tableView.reloadData()

if let refreshControl = self.refreshControl where refreshControl.refreshing {
refreshControl.performSelector(Selector("endRefreshing"), withObject: nil, afterDelay: 0.05)
refreshControl.performSelector(#selector(UIRefreshControl.endRefreshing), withObject: nil, afterDelay: 0.05)
}
}
}
Expand All @@ -209,7 +209,7 @@ extension SDCDashboardTableViewController {
recordButton.rac_signalForControlEvents(UIControlEvents.TouchUpInside)
.subscribeNext { _ in
// Presents the recording screen
let recordController = StoryboardScene.Main.recordViewController()
let recordController = StoryboardScene.Main.instantiateRecord()

self.tabBarController?.presentViewController(recordController, animated: true, completion: nil)
}
Expand Down Expand Up @@ -265,11 +265,11 @@ extension SDCDashboardTableViewController {
var count = 3

if importLog.details != "" {
count++
count += 1
}

if importLog.hasAction {
count++
count += 1
}

return count
Expand Down
4 changes: 2 additions & 2 deletions Drivecast/ViewControllers/SDCRecordViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension SDCRecordViewController {
self.navigationItem.leftBarButtonItem = UIBarButtonItem(
image: UIImage.Asset.Console.image,
style: UIBarButtonItemStyle.Plain,
target: self, action: Selector("openConsole")
target: self, action: #selector(SDCRecordViewController.openConsole)
)

// Add the activity monitor to the screen
Expand Down Expand Up @@ -221,7 +221,7 @@ extension SDCRecordViewController {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: ready ? .Done : .Cancel,
target: self,
action: Selector("cancelConnection")
action: #selector(SDCRecordViewController.cancelConnection)
)

// Switch views between connection and recording
Expand Down
4 changes: 2 additions & 2 deletions Drivecast/ViewControllers/SDCSignInViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension SDCSignInViewController {

// Center icons on the tabbar and remove titles
func configureTabBar() {
menuViewController = StoryboardScene.Main.menuViewController()
menuViewController = StoryboardScene.Main.instantiateMenu()

menuViewController?.delegate = self
navigationController?.delegate = self
Expand Down Expand Up @@ -313,7 +313,7 @@ extension SDCSignInViewController: UITabBarControllerDelegate {
return true
}

let recordController = StoryboardScene.Main.recordViewController()
let recordController = StoryboardScene.Main.instantiateRecord()

tabBarController.presentViewController(recordController, animated: true, completion: nil)

Expand Down
6 changes: 3 additions & 3 deletions Drivecast/ViewControllers/SDCUploadViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension SDCUploadViewController {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(
image: UIImage.Asset.More.image,
style: UIBarButtonItemStyle.Plain,
target: self, action: Selector("openAboutModal")
target: self, action: #selector(SDCUploadViewController.openAboutModal)
)

// Action Buttons
Expand Down Expand Up @@ -156,7 +156,7 @@ extension SDCUploadViewController {
}

func openAboutModal() {
let about = StoryboardScene.Main.aboutViewController()
let about = StoryboardScene.Main.instantiateAbout()

self.presentViewController(about, animated: true, completion: nil)
}
Expand Down Expand Up @@ -207,7 +207,7 @@ extension SDCUploadViewController {
recordButton.rac_signalForControlEvents(UIControlEvents.TouchUpInside)
.subscribeNext { _ in
// Presents the recording screen
let recordController = StoryboardScene.Main.recordViewController()
let recordController = StoryboardScene.Main.instantiateRecord()

self.tabBarController?.presentViewController(recordController, animated: true, completion: nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Drivecast/ViewModels/SDCDashboardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extension SDCDashboardViewModel {
}
}

self.page++
self.page += 1

self.updateImportLogs()
case .Failure(let error):
Expand Down
Loading

0 comments on commit 466c680

Please sign in to comment.