Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #29 from amiantos/swiftlint-happiness
Browse files Browse the repository at this point in the history
Adhere to Swiftlint & Update Pods & Fix Artist Screen Crash
  • Loading branch information
amiantos committed Nov 22, 2018
2 parents 49527a7 + af4d721 commit 84de5a9
Show file tree
Hide file tree
Showing 74 changed files with 419 additions and 402 deletions.
3 changes: 0 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
disabled_rules:
- trailing_whitespace
- force_cast
opt_in_rules:
- empty_count
- empty_string
Expand Down
Binary file added Design/app-screenshots/12.9-inch Screenshot 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/12.9-inch Screenshot 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/12.9-inch Screenshot 3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/12.9-inch Screenshot 4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/3.5-inch Screenshot 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/3.5-inch Screenshot 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/3.5-inch Screenshot 3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/3.5-inch Screenshot 4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/3.5-inch Screenshot 5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4-inch Screenshot 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4-inch Screenshot 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4-inch Screenshot 3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4-inch Screenshot 4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4-inch Screenshot 5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4.7-inch Screenshot 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4.7-inch Screenshot 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4.7-inch Screenshot 3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4.7-inch Screenshot 4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/4.7-inch Screenshot 5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.5-inch Screenshot 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.5-inch Screenshot 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.5-inch Screenshot 3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.5-inch Screenshot 4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.5-inch Screenshot 5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Design/app-screenshots/5.8-inch Screenshot 1.png
Binary file added Design/app-screenshots/5.8-inch Screenshot 2.png
Binary file added Design/app-screenshots/5.8-inch Screenshot 3.png
Binary file added Design/app-screenshots/5.8-inch Screenshot 4.png
Binary file added Design/app-screenshots/5.8-inch Screenshot 5.png
Binary file added Design/app-screenshots/9.7-inch Screenshot 1.png
Binary file added Design/app-screenshots/9.7-inch Screenshot 2.png
Binary file added Design/app-screenshots/9.7-inch Screenshot 3.png
Binary file added Design/app-screenshots/9.7-inch Screenshot 4.png
Binary file added Design/app-screenshots/9.7-inch Screenshot 5.png
4 changes: 2 additions & 2 deletions Numu Tracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "Numu Tracker/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.numutracker.Numu-Tracker";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -830,7 +830,7 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "Numu Tracker/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.numutracker.Numu-Tracker";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
24 changes: 12 additions & 12 deletions Numu Tracker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// Development
//let pusher = Pusher(key: "")

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

Fabric.with([Crashlytics.self])

NumuReviewHelper.incrementActivityCount()

let redirectURL: URL = URL(string: "numu://")!
SpotifyLogin.shared.configure(clientID: "SPOTIFY_CLIENT_ID", clientSecret: "SPOTIFY_CLIENT_SECRET", redirectURL: redirectURL)

NotificationCenter.default.addObserver(
self, selector: #selector(self.runLogInOperations), name: .LoggedOut, object: nil)

NotificationCenter.default.addObserver(
self, selector: #selector(self.ckDataChange), name: Notification.Name.CKAccountChanged, object: nil)

runLogInOperations()

return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = SpotifyLogin.shared.applicationOpenURL(url) { (error) in }

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
let handled = SpotifyLogin.shared.applicationOpenURL(url) { (_) in }
return handled
}

@objc func ckDataChange() {
// Need to re-run authorization procedure here.
runLogInOperations()
Expand Down Expand Up @@ -93,14 +93,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

@objc fileprivate func runLogInOperations() {
let queue = OperationQueue()

// Get and store CK record ID if available
let getCKUserOperation = GetCKUserOperation()
// If user account exists already, link it to CK or create new account
let registerWithCKOperation = RegisterWithCKOperation()
// Try to auth with any credentials
let authOperation = AuthOperation()

registerWithCKOperation.addDependency(getCKUserOperation)
authOperation.addDependency(registerWithCKOperation)
authOperation.completionBlock = {
Expand Down
2 changes: 1 addition & 1 deletion Numu Tracker/Classes/Interface/NumuUIButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class NumuUIButton: UIButton {
self.backgroundColor = isHighlighted ? .black : .clear
}
}

}
4 changes: 2 additions & 2 deletions Numu Tracker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.3.1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>814</string>
<string>854</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
12 changes: 6 additions & 6 deletions Numu Tracker/Operations/AsyncOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class AsyncOperation: Operation {
enum State: String {
case isReady, isExecuting, isFinished
}

override var isAsynchronous: Bool {
return true
}

var state = State.isReady {
willSet {
willChangeValue(forKey: state.rawValue)
Expand All @@ -27,21 +27,21 @@ class AsyncOperation: Operation {
didChangeValue(forKey: state.rawValue)
}
}

override var isExecuting: Bool {
return state == .isExecuting
}

override var isFinished: Bool {
return state == .isFinished
}

override func start() {
guard !self.isCancelled else {
state = .isFinished
return
}

state = .isExecuting
main()
}
Expand Down
24 changes: 13 additions & 11 deletions Numu Tracker/Operations/Auth/AuthOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
import Crashlytics

class AuthOperation: AsyncOperation {

let queue = OperationQueue()

override func main() {
Expand Down Expand Up @@ -42,24 +42,26 @@ class AuthOperation: AsyncOperation {
self.showLogRegPrompt()
}
}

func sendNotifcations() {
DispatchQueue.main.async(execute: {
NotificationCenter.default.post(name: .LoggedIn, object: self)
NotificationCenter.default.post(name: .UpdatedArtists, object: self)
})
}

func showLogRegPrompt() {
let loginViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(
withIdentifier: "LogRegPrompt") as! UINavigationController
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
rootViewController.present(loginViewController, animated: false, completion: nil)
if let loginViewController = UIStoryboard(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "LogRegPrompt") as? UINavigationController {
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
rootViewController.present(loginViewController, animated: false, completion: nil)
}
}
} else {
// Display error message?
}
}

}
4 changes: 2 additions & 2 deletions Numu Tracker/Operations/Auth/GetCKUserOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import CloudKit

class GetCKUserOperation: AsyncOperation {

override func main() {
print("Running CKUserRecordIDOperation..")
if UserDefaults.standard.string(forKey: "userRecordID") == nil {
Expand All @@ -28,5 +28,5 @@ class GetCKUserOperation: AsyncOperation {
self.state = .isFinished
}
}

}
12 changes: 6 additions & 6 deletions Numu Tracker/Operations/FetchJSONOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import Foundation
import SwiftyJSON

final class FetchOperation: AsyncOperation {

private(set) var dataFetched: Data?

private let session = URLSession(configuration: .default)
private var dataTask: URLSessionDataTask?
private var url: String
public var json: JSON

init(_ url: String) {
self.url = url
self.json = JSON.null
}

override func main() {

let url = URL(string: self.url)!
dataTask = session.dataTask(with: url) {[unowned self] (data, _, _) in
guard let data = data else { return }

do {
self.json = try JSON(data: data)
} catch {
Expand Down
32 changes: 16 additions & 16 deletions Numu Tracker/Operations/ImportAppleMusicOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import UIKit
import Crashlytics

class ImportAppleMusicOperation: AsyncOperation {

private let session = URLSession(configuration: .default)
private var dataTask: URLSessionDataTask?

var artistsImported: Int = 0

override func main() {
print("Running ImportAppleMusicOperation...")
if !defaults.logged {
self.state = .isFinished
return
}

MPMediaLibrary.requestAuthorization { (status) in
if status == .authorized {
self.runImportArtists()
Expand All @@ -34,7 +34,7 @@ class ImportAppleMusicOperation: AsyncOperation {
}
}
}

func runImportArtists() {
// Build list of artists to be imported.
let query = MPMediaQuery.artists()
Expand All @@ -49,25 +49,25 @@ class ImportAppleMusicOperation: AsyncOperation {
}
let uniques = Array(Set(artistsFound))
let json = ["artists": uniques]

do {
let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)

// create post request
let url = URL(string: "https://www.numutracker.com/v2/json.php?import")!
let request = NSMutableURLRequest(url: url)
request.httpMethod = "POST"

// insert json data to the request
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData

dataTask = session.dataTask(with: request as URLRequest) {[unowned self] (data, _, error) in
guard let data = data else { return }
do {
if let returnedJSON = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
if let success = returnedJSON["success"] {
self.artistsImported = success as! Int
if let success = returnedJSON["success"] as? Int {
self.artistsImported = success
NumuReviewHelper.incrementAndAskForReview()
self.displaySuccessMessage()
DispatchQueue.main.async(execute: {
Expand All @@ -83,16 +83,16 @@ class ImportAppleMusicOperation: AsyncOperation {
print(self.artistsImported)
self.state = .isFinished
}

dataTask?.resume()

} catch {
print(error.localizedDescription)
self.state = .isFinished
}

}

func displaySuccessMessage() {
DispatchQueue.main.async {
let alertView = NumuAlertView()
Expand All @@ -108,7 +108,7 @@ class ImportAppleMusicOperation: AsyncOperation {
}
}
}

func displayAMError() {
var error: String
switch MPMediaLibrary.authorizationStatus() {
Expand Down

0 comments on commit 84de5a9

Please sign in to comment.