From 572e20471d81c812f5e78a8ef25864e710ddda13 Mon Sep 17 00:00:00 2001 From: Mijin Jeon Date: Mon, 14 May 2018 16:51:45 +0900 Subject: [PATCH] Refactor: Declare static constants or use enum value for setting frames of View #26 --- CardGameApp/CardGameApp/View/CardDeckView.swift | 6 +++--- .../CardGameApp/View/CardStacksView.swift | 16 +++++++++------- .../CardGameApp/View/FoundationView.swift | 4 ++-- CardGameApp/CardGameApp/ViewController.swift | 11 +++++++---- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CardGameApp/CardGameApp/View/CardDeckView.swift b/CardGameApp/CardGameApp/View/CardDeckView.swift index d28c74b8..ff6fbd69 100644 --- a/CardGameApp/CardGameApp/View/CardDeckView.swift +++ b/CardGameApp/CardGameApp/View/CardDeckView.swift @@ -23,11 +23,11 @@ class CardDeckView: UIView { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - self.frame = CGRect(x: 0, y: 0, width: 414, height: 100) + self.frame = CGRect(x: 0, y: 0, width: ViewController.widthOfRootView, height: PositionY.bottom.value) } convenience init() { - self.init(frame: CGRect(x: 0, y: 0, width: 414, height: 100)) + self.init(frame: CGRect(x: 0, y: 0, width: ViewController.widthOfRootView, height: PositionY.bottom.value)) self.deckManager = gameManager.getDeckDelegate() } @@ -83,7 +83,7 @@ class CardDeckView: UIView { @objc func cardDoubleTapped(sender: UITapGestureRecognizer) { if sender.state == .ended { let deckview = sender.view?.superview as! CardDeckView - NotificationCenter.default.post(name: .doubleTappedOpenedDeck, object: self, userInfo: ["from": deckview]) + NotificationCenter.default.post(name: .doubleTappedOpenedDeck, object: self, userInfo: [ViewController.fromViewKey: deckview]) } } diff --git a/CardGameApp/CardGameApp/View/CardStacksView.swift b/CardGameApp/CardGameApp/View/CardStacksView.swift index 26327534..48ed60de 100644 --- a/CardGameApp/CardGameApp/View/CardStacksView.swift +++ b/CardGameApp/CardGameApp/View/CardStacksView.swift @@ -9,6 +9,7 @@ import UIKit class CardStacksView: UIView { + static let numberOfStacks: Int = 7 private var wholeStackManager: (CardStackDelegate & Stackable)! private var oneStackViews = [OneStack]() @@ -19,7 +20,7 @@ class CardStacksView: UIView { convenience init() { self.init(frame: CGRect(x: 0, y: PositionY.bottom.value, - width: 414, height: 736 - PositionY.bottom.value)) + width: ViewController.widthOfRootView, height: ViewController.heightOfRootView - PositionY.bottom.value)) self.wholeStackManager = CardGameManager.shared().getWholeStackDelegate() } @@ -28,7 +29,7 @@ class CardStacksView: UIView { } func setup() { - for i in 0...6 { + for i in 0..