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

Feature. Project update #15

Open
wants to merge 11 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
185 changes: 113 additions & 72 deletions MunchkinLevelCounter.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1F8F7481E4CA6B200B57DEB"
BuildableName = "MunchkinLevelCounter.app"
BlueprintName = "MunchkinLevelCounter"
ReferencedContainer = "container:MunchkinLevelCounter.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -49,17 +58,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A1F8F7481E4CA6B200B57DEB"
BuildableName = "MunchkinLevelCounter.app"
BlueprintName = "MunchkinLevelCounter"
ReferencedContainer = "container:MunchkinLevelCounter.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -81,8 +79,6 @@
ReferencedContainer = "container:MunchkinLevelCounter.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "App Store"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
52 changes: 25 additions & 27 deletions MunchkinLevelCounter/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import CoreData
import Swinject
import SwinjectStoryboard
import MagicalRecord
import Fabric
import Crashlytics
//import Fabric
//import Crashlytics

enum Storyboard: String {
case Main
Expand Down Expand Up @@ -113,23 +113,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return container
}()

func initFabric() {
let resourceURL: URL = Bundle.main.url(forResource: "fabric.apikey", withExtension: nil)!
let fabricAPIKey: String?
do {
fabricAPIKey = try String(contentsOf: resourceURL, encoding: String.Encoding.utf8)
} catch _ {
fabricAPIKey = nil
}
let whitespaceToTrim: CharacterSet = CharacterSet.whitespacesAndNewlines
let fabricAPIKeyTrimmed: String = fabricAPIKey!.trimmingCharacters(in: whitespaceToTrim )
loggingPrint("Key for Fabric: \(fabricAPIKeyTrimmed)")
Crashlytics.start(withAPIKey: fabricAPIKeyTrimmed)
Fabric.with([Crashlytics.self])
}
// func initFabric() {
// let resourceURL: URL = Bundle.main.url(forResource: "fabric.apikey", withExtension: nil)!
// let fabricAPIKey: String?
// do {
// fabricAPIKey = try String(contentsOf: resourceURL, encoding: String.Encoding.utf8)
// } catch _ {
// fabricAPIKey = nil
// }
// let whitespaceToTrim: CharacterSet = CharacterSet.whitespacesAndNewlines
// let fabricAPIKeyTrimmed: String = fabricAPIKey!.trimmingCharacters(in: whitespaceToTrim )
// loggingPrint("Key for Fabric: \(fabricAPIKeyTrimmed)")
// Crashlytics.start(withAPIKey: fabricAPIKeyTrimmed)
// Fabric.with([Crashlytics.self])
// }

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
initFabric()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// initFabric()
Appearance.setupUIAppearance()
MagicalRecord.setupCoreDataStack()
checkOnboarding()
Expand All @@ -148,15 +148,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func launchStoryboard(storyboard: Storyboard) {
switch storyboard {
case .Main:
let storyboard = SwinjectStoryboard.create(name: storyboard.rawValue, bundle: nil, container: container)
let rootViewController = storyboard.instantiateInitialViewController()! as UIViewController
let navigationController = UINavigationController(rootViewController: rootViewController)
window?.rootViewController = navigationController
break
case .Onboarding:
window?.rootViewController = container.resolve(OnboardingViewController.self)
break
case .Main:
let storyboard = SwinjectStoryboard.create(name: storyboard.rawValue, bundle: nil, container: container)
let rootViewController = storyboard.instantiateInitialViewController()! as UIViewController
let navigationController = UINavigationController(rootViewController: rootViewController)
window?.rootViewController = navigationController
case .Onboarding:
window?.rootViewController = container.resolve(OnboardingViewController.self)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
18 changes: 9 additions & 9 deletions MunchkinLevelCounter/Data/DataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ class DataManager {
}

func getPlayersByPosition() -> Observable<[Player]> {
return databaseHelper.getPlayersByPosition().toArray()
return databaseHelper.getPlayersByPosition().toArray().asObservable()
}

func getPlayingPlayers() -> Observable<[Player]> {
return databaseHelper.getPlayingPlayers().toArray()
return databaseHelper.getPlayingPlayers().toArray().asObservable()
}

func getPlayers(sortType: ScoreType) -> Observable<[Player]> {
switch sortType {
case .levelScore:
return databaseHelper.getPlayedPlayersByLevel().toArray()
case .strengthScore:
return databaseHelper.getPlayedPlayersByStrength().toArray()
case .totalScore:
return databaseHelper.getPlayedPlayersByTotal().toArray()
case .levelScore:
return databaseHelper.getPlayedPlayersByLevel().toArray().asObservable()
case .strengthScore:
return databaseHelper.getPlayedPlayersByStrength().toArray().asObservable()
case .totalScore:
return databaseHelper.getPlayedPlayersByTotal().toArray().asObservable()
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ class DataManager {
}
}

let lineDataSet = LineChartDataSet.init(values: entries, label: nil)
let lineDataSet = LineChartDataSet.init(entries: entries, label: nil)
lineDataSet.drawCirclesEnabled = false
lineDataSet.setColor(playerColors[index])
lineDataSet.formLineWidth = 3.0
Expand Down
14 changes: 7 additions & 7 deletions MunchkinLevelCounter/Data/Local/DatabaseHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DatabaseHelper {
} else {
subscriber.onCompleted()
}
}, completion: { _ in
}, completion: { _, _ in
subscriber.onNext(player)
subscriber.onCompleted()
})
Expand Down Expand Up @@ -137,7 +137,7 @@ class DatabaseHelper {
MagicalRecord.save({ (context) in
let predicate = NSPredicate(format: "id = '\(id)'")
PlayerEntity.mr_deleteAll(matching: predicate, in: context)
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand All @@ -154,7 +154,7 @@ class DatabaseHelper {
} else {
subscriber.onCompleted()
}
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand All @@ -170,7 +170,7 @@ class DatabaseHelper {
} else {
subscriber.onCompleted()
}
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand All @@ -186,7 +186,7 @@ class DatabaseHelper {
} else {
subscriber.onCompleted()
}
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand All @@ -201,7 +201,7 @@ class DatabaseHelper {
} else {
subscriber.onCompleted()
}
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand Down Expand Up @@ -234,7 +234,7 @@ class DatabaseHelper {
subscriber.onCompleted()
}
GameStepEntity.mr_truncateAll(in: context)
}, completion: { _ in
}, completion: { _, _ in
subscriber.onCompleted()
})
return Disposables.create()
Expand Down
8 changes: 4 additions & 4 deletions MunchkinLevelCounter/Data/Model/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ final class Player: Hashable {
var playerColor: String?
var isPlaying: Bool = false

var hashValue: Int {
return playerId.hashValue
}

init(playerId: String) {
self.playerId = playerId
}

func hash(into hasher: inout Hasher) {
hasher.combine(self.playerId)
}

func getTotalScore() -> Int {
return playerLevel + playerStrength
}
Expand Down
2 changes: 1 addition & 1 deletion MunchkinLevelCounter/UI/Charts/ChartsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension ChartsViewController: ChartsView {

// MARK: UITableViewDelegate & UITableViewDataSource

extension ChartsViewController : UITableViewDelegate, UITableViewDataSource {
extension ChartsViewController: UITableViewDelegate, UITableViewDataSource {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return playedPlayers.count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DashboardViewController: BaseViewController {
playingPlayersTableView.dataSource = self
presenter?.attachView(self)
presenter?.getPlayingPlayers()
playerViewController = self.childViewControllers.first as? PlayerViewController
playerViewController = self.children.first as? PlayerViewController
playerViewController?.scoreChangedDelegate = self
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GameResultViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
presenter?.attachView(self)
chartViewController = childViewControllers.first as? ChartsViewController
chartViewController = children.first as? ChartsViewController
presenter?.chooseScoreType(scoreType: 0)
self.navigationController?.viewControllers.remove(at: 1)
}
Expand Down Expand Up @@ -58,13 +58,13 @@ extension GameResultViewController: GameResultView {
if let link = URL(string: "https://itunes.apple.com/app/levels-for-munchkin/id1273260162") {
let activityViewController = UIActivityViewController(activityItems: ["text.share_message".localized, link], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.excludedActivityTypes = [UIActivityType.addToReadingList,
UIActivityType.assignToContact,
UIActivityType.openInIBooks,
UIActivityType.postToFlickr,
UIActivityType.postToVimeo,
UIActivityType.print,
UIActivityType.saveToCameraRoll]
activityViewController.excludedActivityTypes = [UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.openInIBooks,
UIActivity.ActivityType.postToFlickr,
UIActivity.ActivityType.postToVimeo,
UIActivity.ActivityType.print,
UIActivity.ActivityType.saveToCameraRoll]

self.present(activityViewController, animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OnboardingViewController: UIViewController {
pageThree.bgColor = Colors.cardCorner

let introView: EAIntroView = EAIntroView(frame: rootView!.bounds, andPages: [pageOne, pageTwo, pageThree])
introView.backgroundColor = UIColor(colorLiteralRed: 0, green: 0.49, blue: 0.96, alpha: 1)
introView.backgroundColor = UIColor(red: 0, green: 0.49, blue: 0.96, alpha: 1)
introView.delegate = self
introView.skipButton.setTitle("button.skip".localized, for: .normal)
introView.show(in: rootView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PlayersEditorViewController: BaseViewController {
return name != "" && !players.filter { $0.playerName != editingPlayerName }.contains(where: { player in player.playerName == name })
}

@objc fileprivate func validate(_ textField: UITextField) {
@objc fileprivate func validateInput(_ textField: UITextField) {
var responder: UIResponder! = textField
while !(responder is UIAlertController) {
responder = responder.next
Expand All @@ -81,7 +81,7 @@ class PlayersEditorViewController: BaseViewController {
alert.addTextField { textField in
textField.returnKeyType = .done
textField.placeholder = "text.player_name".localized
textField.addTarget(self, action: #selector(self.validate(_:)), for: .editingChanged)
textField.addTarget(self, action: #selector(self.validateInput(_:)), for: .editingChanged)
}
let addPlayerAction = UIAlertAction(title: "button.add_new_player".localized,
style: .default) { _ in
Expand All @@ -108,7 +108,7 @@ class PlayersEditorViewController: BaseViewController {
self.editingPlayerName = self.players[indexPath.row].playerName
textField.returnKeyType = .done
textField.text = self.editingPlayerName
textField.addTarget(self, action: #selector(self.validate(_:)), for: .editingChanged)
textField.addTarget(self, action: #selector(self.validateInput(_:)), for: .editingChanged)
}
let confirmEditPlayerAction = UIAlertAction(title: "button.edit".localized,
style: .default) { _ in
Expand Down Expand Up @@ -251,7 +251,7 @@ extension PlayersEditorViewController: PlayersEditorView {

// MARK: UITableViewDelegate & UITableViewDataSource

extension PlayersEditorViewController : UITableViewDelegate, UITableViewDataSource {
extension PlayersEditorViewController: UITableViewDelegate, UITableViewDataSource {

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = playersListTableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? PlayersEditorTableViewCell else { fatalError("Dequeuing reusable cell failed") }
Expand Down Expand Up @@ -283,11 +283,11 @@ extension PlayersEditorViewController : UITableViewDelegate, UITableViewDataSour
return [delete, edit]
}

func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
if playersListTableView.isEditing {
return UITableViewCellEditingStyle.none
return UITableViewCell.EditingStyle.none
} else {
return UITableViewCellEditingStyle.delete
return UITableViewCell.EditingStyle.delete
}
}

Expand Down
Loading