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

Commit

Permalink
switch to symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
atfinke committed May 6, 2020
1 parent 5eb4172 commit a2b1040
Show file tree
Hide file tree
Showing 27 changed files with 144 additions and 93 deletions.
2 changes: 1 addition & 1 deletion WKRKit/WKRKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>10381</string>
<string>10415</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion WKRKit/WKRKit/Players/Container/WKRResultsInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public struct WKRResultsInfo: Codable {
internal func raceRewardPoints(for player: WKRPlayer) -> Int {
return racePoints[player.profile] ?? 0
}

internal func pagesViewed(for player: WKRPlayer) -> [WKRPage] {
return playersSortedByState.first(where: { $0 == player })?
.raceHistory?
Expand Down
4 changes: 4 additions & 0 deletions WKRUIKit/WKRUIKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
140ADB7724628E320080F825 /* WKRUIBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 140ADB7624628E320080F825 /* WKRUIBarButtonItem.swift */; };
1410DB401F4F51AC00F5CAD7 /* WKRStyleScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 1410DB3E1F4F51AC00F5CAD7 /* WKRStyleScript.js */; };
1410DB411F4F51AC00F5CAD7 /* WKRCleanScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 1410DB3F1F4F51AC00F5CAD7 /* WKRCleanScript.js */; };
1413AB1E1F364F2400873ACA /* WKRUIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413AB1D1F364F2000873ACA /* WKRUIKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -64,6 +65,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
140ADB7624628E320080F825 /* WKRUIBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKRUIBarButtonItem.swift; sourceTree = "<group>"; };
1410DB3E1F4F51AC00F5CAD7 /* WKRStyleScript.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = WKRStyleScript.js; sourceTree = "<group>"; };
1410DB3F1F4F51AC00F5CAD7 /* WKRCleanScript.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = WKRCleanScript.js; sourceTree = "<group>"; };
1413AB1D1F364F2000873ACA /* WKRUIKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKRUIKit.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -214,6 +216,7 @@
149FF89C1F362C05000A5D96 /* WKRUIAlertView.swift */,
149FF89E1F362C05000A5D96 /* WKRUIBottomOverlayView.swift */,
149FF8AD1F362D16000A5D96 /* WKRUIThinLineView.swift */,
140ADB7624628E320080F825 /* WKRUIBarButtonItem.swift */,
1410DB421F4F51B200F5CAD7 /* Web View */,
);
path = Views;
Expand Down Expand Up @@ -405,6 +408,7 @@
149FF8AC1F362CF6000A5D96 /* WKRUIKit+Colors.swift in Sources */,
1413AB221F364FC100873ACA /* WKRUIAlertView.swift in Sources */,
1413AB2A1F364FF100873ACA /* WKRUIProgressView.swift in Sources */,
140ADB7724628E320080F825 /* WKRUIBarButtonItem.swift in Sources */,
144C221E241BEEBD00176EB5 /* WKRUIWindow.swift in Sources */,
144C221D241BEEBD00176EB5 /* WKRUIKit+Common.swift in Sources */,
1413AB271F364FE400873ACA /* WKRUILabel.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion WKRUIKit/WKRUIKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>11039</string>
<string>11073</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
17 changes: 17 additions & 0 deletions WKRUIKit/WKRUIKit/Views/WKRUIBarButtonItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// WKRUIBarButtonItem.swift
// WKRUIKit
//
// Created by Andrew Finke on 5/6/20.
// Copyright © 2020 Andrew Finke. All rights reserved.
//

import UIKit

public class WKRUIBarButtonItem: UIBarButtonItem {
public convenience init(systemName: String, weight: UIImage.SymbolWeight = .medium, target: Any?, action: Selector?) {
let config = UIImage.SymbolConfiguration(weight: weight)
guard let image = UIImage(systemName: systemName, withConfiguration: config) else { fatalError() }
self.init(image: image, style: .plain, target: target, action: action)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class ConnectViewController: UIViewController {
func showError(title: String, message: String, showSettingsButton: Bool = false) {
guard !isShowingError else { return }
isShowingError = true

onQuit?()

let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
Expand Down Expand Up @@ -197,7 +197,7 @@ class ConnectViewController: UIViewController {

guard !isShowingError else { return }
isShowingError = true

guard !isShowingMatch else { return }
isShowingMatch = true

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// CustomRaceController.swift
// WikiRaces
//
// Created by Andrew Finke on 5/6/20.
// Copyright © 2020 Andrew Finke. All rights reserved.
//

import UIKit
import WKRUIKit

class CustomRaceController: UITableViewController {

// MARK: - Initalization -

override init(style: UITableView.Style) {
super.init(style: style)
navigationItem.leftBarButtonItem = WKRUIBarButtonItem(systemName: "chevron.left",
target: self,
action: #selector(back))
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Helpers -

@objc func back() {
navigationController?.popViewController(animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import WKRKit

final class CustomRaceNotificationsController: UITableViewController {
final class CustomRaceNotificationsController: CustomRaceController {

// MARK: - Types -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import WKRKit

final class CustomRaceNumericalViewController: UITableViewController {
final class CustomRaceNumericalViewController: CustomRaceController {

// MARK: - Types -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import WKRKit

final class CustomRaceOtherController: UITableViewController {
final class CustomRaceOtherController: CustomRaceController {

// MARK: - Types -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import WKRKit

final class CustomRacePageViewController: UITableViewController {
final class CustomRacePageViewController: CustomRaceController {

// MARK: - Types -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import WKRKit

final class CustomRaceViewController: UITableViewController {
final class CustomRaceViewController: CustomRaceController {

// MARK: - Types -

Expand All @@ -33,7 +33,6 @@ final class CustomRaceViewController: UITableViewController {
self.settings = settings
super.init(style: .grouped)
title = "Customize Race".uppercased()
navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
}

required init?(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ final internal class MPCConnectViewController: ConnectViewController {
nav.isModalInPresentation = true
present(nav, animated: true, completion: nil)
}

override func showError(title: String, message: String, showSettingsButton: Bool = false) {
activeInvite?(false, session)
invites.forEach { $0.handler?(false, session) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ final internal class MPCHostViewController: UITableViewController, MCSessionDele
browser?.delegate = self
session?.delegate = self

navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(cancelMatch(_:)))
navigationItem.leftBarButtonItem = WKRUIBarButtonItem(systemName: "xmark",
target: self,
action: #selector(cancelMatch(_:)))

let startButton = UIBarButtonItem(barButtonSystemItem: .play,
target: self,
action: #selector(startMatch(_:)))
let startButton = WKRUIBarButtonItem(systemName: "play.fill",
target: self,
action: #selector(startMatch(_:)))
startButton.isEnabled = false
navigationItem.rightBarButtonItem = startButton

Expand Down Expand Up @@ -148,6 +148,9 @@ final internal class MPCHostViewController: UITableViewController, MCSessionDele
func startMatch(_ sender: Any) {
PlayerAnonymousMetrics.log(event: .userAction(#function))

browser?.stopBrowsingForPeers()
browser?.delegate = nil

tableView.isUserInteractionEnabled = false

activityView.sizeToFit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import WKRUIKit

final class DebugInfoTableViewController: UITableViewController {

Expand All @@ -25,11 +26,12 @@ final class DebugInfoTableViewController: UITableViewController {
forCellReuseIdentifier: DebugInfoTableViewCell.reuseIdentifier)

navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action,
target: self,
action: #selector(share(_:)))
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(done))
target: self,
action: #selector(share(_:)))
navigationItem.rightBarButtonItem = WKRUIBarButtonItem(
systemName: "xmark",
target: self,
action: #selector(done))
}

// MARK: - Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import WKRUIKit

class StatsViewController: UITableViewController {

Expand Down Expand Up @@ -121,8 +122,8 @@ class StatsViewController: UITableViewController {
init() {
super.init(style: .grouped)
title = "Stats".uppercased()
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .stop,
navigationItem.rightBarButtonItem = WKRUIBarButtonItem(
systemName: "xmark",
target: self,
action: #selector(done))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class PlusStore: NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserv

static let shared = PlusStore()
static let productsUpdatedNotificationName = Notification.Name("productsUpdatedNotificationName")
static let plusStatusUpdatedNotificationName = Notification.Name("plusStatusUpdatedNotificationName")

private let queue = SKPaymentQueue.default()
var products: (standard: MagicSubscription, ultimate: MagicSubscription)?
Expand All @@ -55,7 +54,6 @@ class PlusStore: NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserv
var isPlus: Bool {
set {
UserDefaults.standard.set(newValue, forKey: "isPlus")
NotificationCenter.default.post(name: PlusStore.plusStatusUpdatedNotificationName, object: nil)
}
get {
UserDefaults.standard.bool(forKey: "isPlus")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ extension GameViewController {
fatalError("No navigation controller view")
}

helpBarButtonItem = UIBarButtonItem(image: UIImage(named: "HelpFlag")!,
style: .plain,
target: self,
action: #selector(helpButtonPressed))

quitBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(quitButtonPressed))
helpBarButtonItem = WKRUIBarButtonItem(
systemName: "questionmark",
target: self,
action: #selector(helpButtonPressed))

quitBarButtonItem = WKRUIBarButtonItem(
systemName: "xmark",
target: self,
action: #selector(quitButtonPressed))

navigationItem.hidesBackButton = true
navigationItem.leftBarButtonItem = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ final internal class HistoryViewController: UITableViewController, SFSafariViewC
tableView.register(HistoryTableViewStatsCell.self,
forCellReuseIdentifier: HistoryTableViewStatsCell.reuseIdentifier)

navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(doneButtonPressed))
navigationItem.rightBarButtonItem = WKRUIBarButtonItem(
systemName: "xmark",
target: self,
action: #selector(doneButtonPressed))
}

override func viewWillLayoutSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ final internal class HelpViewController: UIViewController, WKNavigationDelegate
NSLayoutConstraint.activate(constraints)

guard let url = url else {
return // When would this happen?
return // When would this happen?
}

webView.startedPageLoad()
webView.load(URLRequest(url: url))

navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(doneButtonPressed))
navigationItem.rightBarButtonItem = WKRUIBarButtonItem(
systemName: "xmark",
target: self,
action: #selector(doneButtonPressed))
}

override func viewWillLayoutSubviews() {
Expand Down
Loading

0 comments on commit a2b1040

Please sign in to comment.