Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format Eidolon using Prettier Swift plugin #1

Closed
wants to merge 6 commits into from
Closed
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
20 changes: 13 additions & 7 deletions Kiosk/Admin/AdminCardTestingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ class AdminCardTestingViewController: UIViewController {

@IBOutlet weak var logTextView: UITextView!

override func viewDidLoad() {
override func viewDidLoad() {
super.viewDidLoad()


self.logTextView.text = ""

if AppSetup.sharedState.useStaging {
cardHandler = CardHandler(apiKey: self.keys.cardflightStagingAPIClientKey, accountToken: self.keys.cardflightStagingMerchantAccountToken)
cardHandler = CardHandler(
apiKey: self.keys.cardflightStagingAPIClientKey,
accountToken: self.keys.cardflightStagingMerchantAccountToken
)
} else {
cardHandler = CardHandler(apiKey: self.keys.cardflightProductionAPIClientKey, accountToken: self.keys.cardflightProductionMerchantAccountToken)
cardHandler = CardHandler(
apiKey: self.keys.cardflightProductionAPIClientKey,
accountToken: self.keys.cardflightProductionMerchantAccountToken
)
}

cardHandler.cardStatus
.subscribe { (event) in
.subscribe { event in
switch event {
case .next(let message):
self.log("\(message)")
case .error(let error):
self.log("\n====Error====\n\(error)\nThe card reader may have become disconnected.\n\n")
self.log(
"\n====Error====\n\(error)\nThe card reader may have become disconnected.\n\n"
)
if self.cardHandler.card != nil {
self.log("==\n\(self.cardHandler.card!)\n\n")
}
Expand All @@ -44,7 +51,6 @@ class AdminCardTestingViewController: UIViewController {
}
.addDisposableTo(rx_disposeBag)


cardHandler.startSearching()
}

Expand Down
5 changes: 4 additions & 1 deletion Kiosk/Admin/AdminLogViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ class AdminLogViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
textView.text = try? NSString(contentsOf: logPath(), encoding: String.Encoding.ascii.rawValue) as String
textView.text = try? NSString(
contentsOf: logPath(),
encoding: String.Encoding.ascii.rawValue
) as String
}

@IBOutlet weak var textView: UITextView!
Expand Down
17 changes: 6 additions & 11 deletions Kiosk/Admin/AdminPanelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class AdminPanelViewController: UIViewController {

@IBOutlet weak var auctionIDLabel: UILabel!


@IBAction func backTapped(_ sender: AnyObject) {
self.presentingViewController?.dismiss(animated: true, completion: nil)
appDelegate().setHelpButtonHidden(false)
Expand Down Expand Up @@ -40,7 +39,9 @@ class AdminPanelViewController: UIViewController {
if APIKeys.sharedKeys.stubResponses {
auctionIDLabel.text = "STUBBING API RESPONSES\nNOT CONTACTING ARTSY API"
} else {
let version = (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String) ?? "Unknown"
let version = (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
as? String)
?? "Unknown"
auctionIDLabel.text = "\(state.auctionID), Kiosk version: \(version)"
}

Expand All @@ -63,9 +64,7 @@ class AdminPanelViewController: UIViewController {
defaults.removeObject(forKey: XAppToken.DefaultsKeys.TokenExpiry.rawValue)

defaults.synchronize()
delayToMainThread(1){
exit(1)
}
delayToMainThread(1) { exit(1) }

}

Expand All @@ -74,9 +73,7 @@ class AdminPanelViewController: UIViewController {
let defaults = UserDefaults.standard
defaults.set(!AppSetup.sharedState.showDebugButtons, forKey: "KioskShowDebugButtons")
defaults.synchronize()
delayToMainThread(1){
exit(1)
}
delayToMainThread(1) { exit(1) }

}

Expand All @@ -86,8 +83,6 @@ class AdminPanelViewController: UIViewController {
let defaults = UserDefaults.standard
defaults.set(!AppSetup.sharedState.disableCardReader, forKey: "KioskDisableCardReader")
defaults.synchronize()
delayToMainThread(1){
exit(1)
}
delayToMainThread(1) { exit(1) }
}
}
19 changes: 14 additions & 5 deletions Kiosk/Admin/AuctionWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ class AuctionWebViewController: WebViewController {

override func viewDidLoad() {
super.viewDidLoad()

let flexibleSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)


let flexibleSpace = UIBarButtonItem(
barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace,
target: nil,
action: nil
)

let exitImage = UIImage(named: "toolbar_close")
let backwardBarItem = UIBarButtonItem(image: exitImage, style: .plain, target: self, action: #selector(exit));
let backwardBarItem = UIBarButtonItem(
image: exitImage,
style: .plain,
target: self,
action: #selector(exit)
)
let allItems = self.toolbarItems! + [flexibleSpace, backwardBarItem]
toolbarItems = allItems
}
Expand All @@ -18,6 +27,6 @@ class AuctionWebViewController: WebViewController {
_ = self?.navigationController?.popViewController(animated: true)
return
}
self.present(passwordVC, animated: true) {}
self.present(passwordVC, animated: true) { }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In JS we'd not put a space here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now I deliberately add one to make the "do nothing" more visible. In JS you have have more around it: function(){} or () => {}.

Don't have a strong preference on this though.

@orta What's your take?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't have a strong preference - had I not see it I'd have gone with no space, but I kinda like the space now that I see it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space "feels" more "Swift" to me, but I don't know why.

}
}
22 changes: 14 additions & 8 deletions Kiosk/Admin/ChooseAuctionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ChooseAuctionViewController: UIViewController {

let endpoint: ArtsyAPI = ArtsyAPI.activeAuctions

provider.request(endpoint)
provider
.request(endpoint)
.filterSuccessfulStatusCodes()
.mapJSON()
.mapTo(arrayOf: Sale.self)
Expand All @@ -31,20 +32,25 @@ class ChooseAuctionViewController: UIViewController {
button.setTitle(title, for: .normal)
button.setTitleColor(.black, for: .normal)
button.tag = i
button.rx.tap.subscribe(onNext: { (_) in
let defaults = UserDefaults.standard
defaults.set(sale.id, forKey: "KioskAuctionID")
defaults.synchronize()
exit(1)
button.rx.tap
.subscribe(onNext: { _ in
let defaults = UserDefaults.standard
defaults.set(sale.id, forKey: "KioskAuctionID")
defaults.synchronize()
exit(1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.

})
.addDisposableTo(self.rx_disposeBag)

self.stackScrollView.stackView.addSubview(button, withTopMargin: "12", sideMargin: "0")
self.stackScrollView.stackView.addSubview(
button,
withTopMargin: "12",
sideMargin: "0"
)
button.constrainHeight("50")
}
})
.addDisposableTo(rx_disposeBag)

}

@IBOutlet weak var stackScrollView: ORStackScrollView!
Expand Down
19 changes: 13 additions & 6 deletions Kiosk/Admin/PasswordAlertViewController.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

import UIKit

class PasswordAlertViewController: UIAlertController {

class func alertView(completion: @escaping () -> ()) -> PasswordAlertViewController {
let alertController = PasswordAlertViewController(title: "Exit Kiosk", message: nil, preferredStyle: .alert)
let exitAction = UIAlertAction(title: "Exit", style: .default) { (_) in
let alertController = PasswordAlertViewController(
title: "Exit Kiosk",
message: nil,
preferredStyle: .alert
)
let exitAction = UIAlertAction(title: "Exit", style: .default) { _ in
completion()
return
}
Expand All @@ -16,12 +19,16 @@ class PasswordAlertViewController: UIAlertController {
exitAction.isEnabled = false
}

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (_) in }
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { _ in }

alertController.addTextField { (textField) in
alertController.addTextField { textField in
textField.placeholder = "Exit Password"

NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextFieldTextDidChange, object: textField, queue: OperationQueue.main) { (notification) in
NotificationCenter.default.addObserver(
forName: NSNotification.Name.UITextFieldTextDidChange,
object: textField,
queue: OperationQueue.main
) { notification in
// compiler crashes when using weak
exitAction.isEnabled = textField.text == "Genome401"
}
Expand Down
Loading