diff --git a/iOS/BaseballApp/BaseballApp/Controllers/LobbyViewController.swift b/iOS/BaseballApp/BaseballApp/Controllers/LobbyViewController.swift index 7b45a83ac..843e5062f 100644 --- a/iOS/BaseballApp/BaseballApp/Controllers/LobbyViewController.swift +++ b/iOS/BaseballApp/BaseballApp/Controllers/LobbyViewController.swift @@ -11,23 +11,34 @@ import Combine class LobbyViewController: UIViewController { @IBOutlet weak var roomsTableView: UITableView! - var viewModel: RoomsViewModel? - var cancelBag = Set() + var viewModel: RoomsViewModel! override func viewDidLoad() { super.viewDidLoad() + roomsTableView.dataSource = self viewModel = RoomsViewModel() - bind() + viewModel.load { + DispatchQueue.main.async { + self.roomsTableView.reloadData() + } + } + } + +} + +extension LobbyViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return viewModel.rooms.data.count } - func bind() { - viewModel?.$rooms - .receive(on: DispatchQueue.main) - .sink(receiveValue: { [weak self] _ in - self?.roomsTableView.reloadData() - }) - .store(in: &self.cancelBag) + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: RoomTableViewCell.identifier, for: indexPath) as? RoomTableViewCell else { + return UITableViewCell() + } + + let data = viewModel.rooms.data[indexPath.row] + cell.fill(data: data) + return cell } } - diff --git a/iOS/BaseballApp/BaseballApp/Controllers/PlayViewController.swift b/iOS/BaseballApp/BaseballApp/Controllers/PlayViewController.swift index e70873eed..bd3bcac6f 100644 --- a/iOS/BaseballApp/BaseballApp/Controllers/PlayViewController.swift +++ b/iOS/BaseballApp/BaseballApp/Controllers/PlayViewController.swift @@ -18,11 +18,11 @@ class PlayViewController: UIViewController { @IBOutlet weak var playInformationStackView: UIStackView! @IBOutlet weak var scoreHeaderView: ScoreHeaderView! - var cancelBag = Set() + var currentPlayerView: CurrentPlayerView! var count: Int = 0 - var viewModel: GameViewModel? { + var viewModel: GameViewModel! { didSet { - count = viewModel?.game?.pitcherHistory.count ?? 0 + count = viewModel?.game?.data.pitchHistories.count ?? 0 } } @@ -40,17 +40,16 @@ class PlayViewController: UIViewController { viewModel = GameViewModel() configureUI() - } - - // MARK: - Private Functions - private func bind() { - viewModel?.$game - .receive(on: DispatchQueue.main) - .sink(receiveValue: { [weak self] game in - self?.scoreHeaderView.configureAway(score: game?.away.score ?? 0) - self?.scoreHeaderView.configureHome(score: game?.home.score ?? 0) - }) - .store(in: &self.cancelBag) + viewModel.load { game in + DispatchQueue.main.async { [weak self] in + self?.scoreHeaderView.configureAway(score: game.awayTeam.score) + self?.scoreHeaderView.configureHome(score: game.homeTeam.score) + self?.currentPlayerView.configure(batter: game.batter, status: game.batterStatus) + self?.currentPlayerView.configure(pitcher: game.pitcher, status: game.pitcherStatus) + self?.currentPlayerView.configure(playerRole: game.myRole) + self?.pitcherHistoryTableView.reloadData() + } + } } private func configureUI() { @@ -62,7 +61,7 @@ class PlayViewController: UIViewController { options: nil)?.first as? CurrentPlayerView else { return } - + self.currentPlayerView = currentPlayerView playInformationStackView.addArrangedSubview(groundView) playInformationStackView.addArrangedSubview(currentPlayerView) playInformationStackView.addArrangedSubview(pitcherHistoryTableView) @@ -79,12 +78,15 @@ class PlayViewController: UIViewController { extension PlayViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return viewModel?.game?.pitcherHistory.count ?? 0 + return viewModel?.game?.data.pitchHistories.count ?? 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: PitcherRecordTableViewCell.identifier, for: indexPath) as! PitcherRecordTableViewCell - cell.backgroundColor = .systemRed + guard let cell = tableView.dequeueReusableCell(withIdentifier: PitcherRecordTableViewCell.identifier, for: indexPath) as? PitcherRecordTableViewCell, + let record = viewModel.game?.data.pitchHistories[indexPath.row] else { + return UITableViewCell() + } + cell.configure(record: record) return cell } } diff --git a/iOS/BaseballApp/BaseballApp/Entity/Game.swift b/iOS/BaseballApp/BaseballApp/Entity/Game.swift index 861979474..c7d59162e 100644 --- a/iOS/BaseballApp/BaseballApp/Entity/Game.swift +++ b/iOS/BaseballApp/BaseballApp/Entity/Game.swift @@ -7,36 +7,69 @@ import Foundation +struct GameResponse: Decodable { + let data: Game +} + struct Game: Decodable { - let home: Team - let away: Team let strike: Int let ball: Int let out: Int + let awayTeam: Team + let homeTeam: Team let inning: String - let myRole: String + let halves: String + let pitcher: Player + let pitcherStatus: String + let batter: Player + let batterStatus: String let base1: String? let base2: String? let base3: String? - let pitcherHistory: [Record] + let pitchHistories: [Record] + let myRole: String + + enum CodingKeys: String, CodingKey { + case strike, ball, out, inning, halves, pitcher, batter, base1, base2, base3 + case awayTeam = "away_team" + case homeTeam = "home_team" + case pitcherStatus = "pitcher_status" + case batterStatus = "batter_status" + case pitchHistories = "pitch_histories" + case myRole = "my_role" + } +} + +struct Player: Decodable { + let teamId: Int + let uniformNumber: Int + let name: String + + enum CodingKeys: String, CodingKey { + case name + case teamId = "team_id" + case uniformNumber = "uniform_number" + } } struct Record: Decodable { + let pitcher: Player + let batter: Player let result: String - let pitchStrikeCount: String + let strikeCount: Int + let ballCount: Int enum CodingKeys: String, CodingKey { - case result - case pitchStrikeCount = "log" + case pitcher, batter, result + case strikeCount = "strike_count" + case ballCount = "ball_count" } } struct Team: Decodable { let name: String let score: Int - let position: String - let player: String - let playerStatus: String + let role: String } struct Scoreboard: Decodable { diff --git a/iOS/BaseballApp/BaseballApp/Entity/Room.swift b/iOS/BaseballApp/BaseballApp/Entity/Room.swift index bc2440f4b..e947c406c 100644 --- a/iOS/BaseballApp/BaseballApp/Entity/Room.swift +++ b/iOS/BaseballApp/BaseballApp/Entity/Room.swift @@ -8,13 +8,13 @@ import Foundation struct RoomResponse: Decodable { - let rooms: [Room] + let data: [Room] } struct Room: Decodable { let id: Int - let number: String - let away: String - let home: String - let available: Bool + let awayTeam: String? + let homeTeam: String? + let awayUserEmail: String? + let homeUserEmail: String? } diff --git a/iOS/BaseballApp/BaseballApp/Network/APIRequestManager.swift b/iOS/BaseballApp/BaseballApp/Network/APIRequestManager.swift index 28eba8f7d..1dd390f39 100644 --- a/iOS/BaseballApp/BaseballApp/Network/APIRequestManager.swift +++ b/iOS/BaseballApp/BaseballApp/Network/APIRequestManager.swift @@ -9,7 +9,6 @@ import Foundation import Combine class APIRequestManager { - private var cancelBag = Set() private func createRequest(url: URL, method: HTTPMethod, httpBody: Data? = nil) -> URLRequest { var request = URLRequest(url: url) @@ -17,33 +16,27 @@ class APIRequestManager { request.httpBody = httpBody return request } - - func fetchRooms(url: URL, method: HTTPMethod, httpBody: Data? = nil) { + + func fetch(url: URL, method: HTTPMethod, httpBody: Data? = nil) -> AnyPublisher { let request = createRequest(url: url, method: method) - URLSession.shared.dataTaskPublisher(for: request) + return URLSession.shared.dataTaskPublisher(for: request) .map(\.data) - .decode(type: RoomResponse.self, decoder: JSONDecoder()) - .replaceError(with: RoomResponse(rooms: [])) - .assign(to: \.rooms, on: RoomsViewModel()) - .store(in: &self.cancelBag) - } - - func fetchGame(url: URL, method: HTTPMethod, httpBody: Data? = nil) { - let request = createRequest(url: url, method: method) - URLSession.shared.dataTaskPublisher(for: request) - .map(\.data) - .decode(type: Game?.self, decoder: JSONDecoder()) - .replaceError(with: nil) - .assign(to: \.game, on: GameViewModel()) - .store(in: &self.cancelBag) + .decode(type: T.self, decoder: JSONDecoder()) + .eraseToAnyPublisher() } } struct Endpoint { + enum Path { + static let gameList = "/game/list" + static let gameStatus = "/game/status" + } + static func url(path: String) -> URL? { var components = URLComponents() - components.scheme = "https" - components.host = "api.github.com" + components.scheme = "http" + components.host = "52.78.19.43" + components.port = 8080 components.path = path return components.url } diff --git a/iOS/BaseballApp/BaseballApp/UseCases/GameUseCase.swift b/iOS/BaseballApp/BaseballApp/UseCases/GameUseCase.swift index c6be13327..16b74b9f0 100644 --- a/iOS/BaseballApp/BaseballApp/UseCases/GameUseCase.swift +++ b/iOS/BaseballApp/BaseballApp/UseCases/GameUseCase.swift @@ -6,11 +6,12 @@ // import Foundation +import Combine class GameUseCase { let apiRequestManager = APIRequestManager() - func start(url: URL) { - apiRequestManager.fetchGame(url: url, method: .get) + func start(url: URL) -> AnyPublisher { + return apiRequestManager.fetch(url: url, method: .get) } } diff --git a/iOS/BaseballApp/BaseballApp/UseCases/RoomsUseCase.swift b/iOS/BaseballApp/BaseballApp/UseCases/RoomsUseCase.swift index 1a52d9b3c..9c70c8de5 100644 --- a/iOS/BaseballApp/BaseballApp/UseCases/RoomsUseCase.swift +++ b/iOS/BaseballApp/BaseballApp/UseCases/RoomsUseCase.swift @@ -6,11 +6,12 @@ // import Foundation +import Combine class RoomsUseCase { let apiRequestManager = APIRequestManager() - func start(url: URL) { - apiRequestManager.fetchRooms(url: url, method: .get) + func start(url: URL) -> AnyPublisher { + return apiRequestManager.fetch(url: url, method: .get) } } diff --git a/iOS/BaseballApp/BaseballApp/ViewModel/GameViewModel.swift b/iOS/BaseballApp/BaseballApp/ViewModel/GameViewModel.swift index 90684d924..bf4675ad9 100644 --- a/iOS/BaseballApp/BaseballApp/ViewModel/GameViewModel.swift +++ b/iOS/BaseballApp/BaseballApp/ViewModel/GameViewModel.swift @@ -6,22 +6,27 @@ // import Foundation +import Combine class GameViewModel { - @Published var game: Game? - + @Published var game: GameResponse? let gameUseCase = GameUseCase() + var cancelBag = Set() - func load() { - guard let url = Endpoint.url(path: "/room/playInfo") else { return } - gameUseCase.start(url: url) - } - - func getAwayScore() -> Int { - return game?.away.score ?? 0 - } - - func getHomeScore() -> Int { - return game?.home.score ?? 0 + func load(completionHandler: @escaping (Game) -> Void) { + guard let url = Endpoint.url(path: Endpoint.Path.gameStatus) else { return } + let publisher = gameUseCase.start(url: url) + publisher.sink { (completion) in + switch completion { + case .finished: + break + case .failure(let error): + print(error.localizedDescription) + } + } receiveValue: { (response) in + self.game = response + completionHandler(response.data) + } + .store(in: &cancelBag) } } diff --git a/iOS/BaseballApp/BaseballApp/ViewModel/RoomsViewModel.swift b/iOS/BaseballApp/BaseballApp/ViewModel/RoomsViewModel.swift index 84d24d211..91a720768 100644 --- a/iOS/BaseballApp/BaseballApp/ViewModel/RoomsViewModel.swift +++ b/iOS/BaseballApp/BaseballApp/ViewModel/RoomsViewModel.swift @@ -6,13 +6,26 @@ // import Foundation +import Combine class RoomsViewModel { - @Published var rooms: RoomResponse = RoomResponse(rooms: []) + @Published var rooms: RoomResponse = RoomResponse(data: []) + var cancelBag = Set() let roomsUseCase = RoomsUseCase() - - func load() { - guard let url = Endpoint.url(path: "/room/list") else { return } - roomsUseCase.start(url: url) + + func load(completionHandler: @escaping () -> Void) { + guard let url = Endpoint.url(path: Endpoint.Path.gameList) else { return } + let publisher = roomsUseCase.start(url: url) + publisher.sink { (completion) in + switch completion { + case .finished: + completionHandler() + case .failure(let error): + print(error.localizedDescription) + } + } receiveValue: { (response) in + self.rooms = response + } + .store(in: &cancelBag) } } diff --git a/iOS/BaseballApp/BaseballApp/Views/Base.lproj/Main.storyboard b/iOS/BaseballApp/BaseballApp/Views/Base.lproj/Main.storyboard index f5be3b90b..5d25b24cd 100644 --- a/iOS/BaseballApp/BaseballApp/Views/Base.lproj/Main.storyboard +++ b/iOS/BaseballApp/BaseballApp/Views/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -30,7 +30,7 @@ - + diff --git a/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.swift b/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.swift index d31a9d533..93e8693ba 100644 --- a/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.swift +++ b/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.swift @@ -7,4 +7,35 @@ import UIKit -class CurrentPlayerView: UIView { } +class CurrentPlayerView: UIView { + @IBOutlet weak var pitcher: UILabel! + @IBOutlet weak var pitcherStatus: UILabel! + @IBOutlet weak var isPitcher: UIImageView! + @IBOutlet weak var batter: UILabel! + @IBOutlet weak var batterStatus: UILabel! + @IBOutlet weak var isBatter: UIImageView! + + enum Role { + static let DEFENSE = "DEFENSE" + } + + func configure(pitcher: Player, status: String) { + self.pitcher.text = pitcher.name + self.pitcherStatus.text = status + } + + func configure(batter: Player, status: String) { + self.batter.text = batter.name + self.batterStatus.text = status + } + + func configure(playerRole: String) { + if playerRole == Role.DEFENSE { + isBatter.isHidden = true + isPitcher.isHidden = false + } else { + isBatter.isHidden = false + isPitcher.isHidden = true + } + } +} diff --git a/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.xib b/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.xib index 949c11027..f2ab9549e 100644 --- a/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.xib +++ b/iOS/BaseballApp/BaseballApp/Views/CurrentPlayerView.xib @@ -1,8 +1,8 @@ - + - + @@ -108,6 +108,14 @@ + + + + + + + + diff --git a/iOS/BaseballApp/BaseballApp/Views/GroundView.swift b/iOS/BaseballApp/BaseballApp/Views/GroundView.swift index f23721431..06863b3a1 100644 --- a/iOS/BaseballApp/BaseballApp/Views/GroundView.swift +++ b/iOS/BaseballApp/BaseballApp/Views/GroundView.swift @@ -8,89 +8,99 @@ import UIKit class GroundView: UIView { - let infieldSquareLayer = CAShapeLayer() - let homePlateLayer = CAShapeLayer() - let firstBaseLayer = CAShapeLayer() - let secondBaseLayer = CAShapeLayer() - let thirdBaseLayer = CAShapeLayer() + enum Constant { + static let infieldSquareLineWidth: CGFloat = 5.0 + static let baseLineWidth: CGFloat = 1.0 + static let padding: CGFloat = 50.0 + static let baseDiagonalLength: CGFloat = 30.0 + } + + private let infieldSquareLayer = CAShapeLayer() + private let homePlateLayer = CAShapeLayer() + private var firstBaseLayer = CAShapeLayer() + private var secondBaseLayer = CAShapeLayer() + private var thirdBaseLayer = CAShapeLayer() override func awakeFromNib() { self.backgroundColor = .systemGray3 - addLine() } - func addLine() { + override func layoutSubviews() { + super.layoutSubviews() + + configureInfieldSquareLayer() + configureHomePlateLayer() + configureLayerForBases() + } + + private func configureInfieldSquareLayer() { + infieldSquareLayer.frame = CGRect(x: bounds.minX + Constant.padding, + y: bounds.minY + Constant.padding, + width: bounds.width - (Constant.padding * 2), + height: bounds.height - (Constant.padding * 2)) layer.addSublayer(infieldSquareLayer) infieldSquareLayer.strokeColor = UIColor.systemGray.cgColor infieldSquareLayer.fillColor = UIColor.clear.cgColor - infieldSquareLayer.lineWidth = 5.0 - //shapeLayer.strokeEnd = 1 - + infieldSquareLayer.lineWidth = Constant.infieldSquareLineWidth + } + + private func configureHomePlateLayer() { + homePlateLayer.frame = CGRect(x: bounds.midX - 15.0, + y: bounds.maxY - 70.0, + width: 30.0, + height: 45.0) layer.addSublayer(homePlateLayer) homePlateLayer.fillColor = UIColor.white.cgColor - - layer.addSublayer(firstBaseLayer) - firstBaseLayer.strokeColor = UIColor.systemGray.cgColor - firstBaseLayer.fillColor = UIColor.white.cgColor - firstBaseLayer.lineWidth = 1.0 - - layer.addSublayer(secondBaseLayer) - secondBaseLayer.strokeColor = UIColor.systemGray.cgColor - secondBaseLayer.fillColor = UIColor.white.cgColor - secondBaseLayer.lineWidth = 1.0 - - layer.addSublayer(thirdBaseLayer) - thirdBaseLayer.strokeColor = UIColor.systemGray.cgColor - thirdBaseLayer.fillColor = UIColor.white.cgColor - thirdBaseLayer.lineWidth = 1.0 } - override func layoutSubviews() { - super.layoutSubviews() - - let squarePath = UIBezierPath() - /// Home Plate - squarePath.move(to: CGPoint(x: bounds.midX, y: bounds.maxY - 50.0)) - /// First Plate - squarePath.addLine(to: CGPoint(x: bounds.maxX - 50.0, y: bounds.midY)) - /// Second Plate - squarePath.addLine(to: CGPoint(x: bounds.midX, y: bounds.minY + 50.0)) - /// Third Plate - squarePath.addLine(to: CGPoint(x: bounds.minX + 50.0, y: bounds.midY)) - squarePath.close() - infieldSquareLayer.path = squarePath.cgPath + private func configureLayerForBases() { + firstBaseLayer = createBaseLayer(origin: CGPoint(x: bounds.maxX - Constant.padding - Constant.baseDiagonalLength / 2, + y: bounds.midY - Constant.baseDiagonalLength / 2)) + secondBaseLayer = createBaseLayer(origin: CGPoint(x: bounds.midX - Constant.baseDiagonalLength / 2, + y: bounds.minY + Constant.padding - Constant.baseDiagonalLength / 2)) + thirdBaseLayer = createBaseLayer(origin: CGPoint(x: bounds.minX + Constant.padding - Constant.baseDiagonalLength / 2, + y: bounds.midY - Constant.baseDiagonalLength / 2)) + infieldSquareLayer.path = createRhombusPath(for: infieldSquareLayer) + homePlateLayer.path = createPlatePath(for: homePlateLayer) + firstBaseLayer.path = createRhombusPath(for: firstBaseLayer) + secondBaseLayer.path = createRhombusPath(for: secondBaseLayer) + thirdBaseLayer.path = createRhombusPath(for: thirdBaseLayer) + } + + private func createRhombusPath(for layer: CAShapeLayer) -> CGPath { + let rhombusPath = UIBezierPath() + rhombusPath.move(to: CGPoint(x: layer.bounds.midX, y: layer.bounds.maxY)) + rhombusPath.addLine(to: CGPoint(x: layer.bounds.minX, y: layer.bounds.midY)) + rhombusPath.addLine(to: CGPoint(x: layer.bounds.midX, y: layer.bounds.minY)) + rhombusPath.addLine(to: CGPoint(x: layer.bounds.maxX, y: layer.bounds.midY)) + rhombusPath.close() + return rhombusPath.cgPath + } + + private func createPlatePath(for layer: CAShapeLayer) -> CGPath { let platePath = UIBezierPath() - platePath.move(to: CGPoint(x: bounds.midX, y: bounds.maxY - 70.0)) - platePath.addLine(to: CGPoint(x: bounds.midX - 15.0, y: bounds.maxY - 55.0)) - platePath.addLine(to: CGPoint(x: bounds.midX - 15.0, y: bounds.maxY - 25.0)) - platePath.addLine(to: CGPoint(x: bounds.midX + 15.0, y: bounds.maxY - 25.0)) - platePath.addLine(to: CGPoint(x: bounds.midX + 15.0, y: bounds.maxY - 55.0)) + platePath.move(to: CGPoint(x: layer.bounds.midX, y: layer.bounds.minY)) + platePath.addLine(to: CGPoint(x: layer.bounds.minX, y: layer.bounds.minY + 15.0)) + platePath.addLine(to: CGPoint(x: layer.bounds.minX, y: layer.bounds.minY + 15.0 + 30.0)) + platePath.addLine(to: CGPoint(x: layer.bounds.midX + 15.0, y: layer.bounds.minY + 15.0 + 30.0)) + platePath.addLine(to: CGPoint(x: layer.bounds.midX + 15.0, y: layer.bounds.minY + 15.0)) platePath.close() - homePlateLayer.path = platePath.cgPath - - let firstBasePath = UIBezierPath() - firstBasePath.move(to: CGPoint(x: bounds.maxX - 65.0, y: bounds.midY)) - firstBasePath.addLine(to: CGPoint(x: bounds.maxX - 50.0, y: bounds.midY - 15.0)) - firstBasePath.addLine(to: CGPoint(x: bounds.maxX - 35.0, y: bounds.midY)) - firstBasePath.addLine(to: CGPoint(x: bounds.maxX - 50.0, y: bounds.midY + 15.0)) - firstBasePath.close() - firstBaseLayer.path = firstBasePath.cgPath - - let secondBasePath = UIBezierPath() - secondBasePath.move(to: CGPoint(x: bounds.midX - 15.0, y: bounds.minY + 50.0)) - secondBasePath.addLine(to: CGPoint(x: bounds.midX, y: bounds.minY + 35.0)) - secondBasePath.addLine(to: CGPoint(x: bounds.midX + 15.0, y: bounds.minY + 50.0)) - secondBasePath.addLine(to: CGPoint(x: bounds.midX, y: bounds.minY + 65.0)) - secondBasePath.close() - secondBaseLayer.path = secondBasePath.cgPath - - let thirdBasePath = UIBezierPath() - thirdBasePath.move(to: CGPoint(x: bounds.minX + 35.0, y: bounds.midY)) - thirdBasePath.addLine(to: CGPoint(x: bounds.minX + 50.0, y: bounds.midY - 15.0)) - thirdBasePath.addLine(to: CGPoint(x: bounds.minX + 65.0, y: bounds.midY)) - thirdBasePath.addLine(to: CGPoint(x: bounds.minX + 50.0, y: bounds.midY + 15.0)) - thirdBasePath.close() - thirdBaseLayer.path = thirdBasePath.cgPath + return platePath.cgPath + } + + private func createBaseLayer(origin: CGPoint) -> CAShapeLayer { + let baseLayer = CAShapeLayer() + baseLayer.frame = CGRect(origin: origin, + size: CGSize(width: Constant.baseDiagonalLength, height: Constant.baseDiagonalLength)) + layer.addSublayer(baseLayer) + baseLayer.strokeColor = UIColor.systemGray.cgColor + baseLayer.fillColor = UIColor.white.cgColor + baseLayer.lineWidth = Constant.baseLineWidth + return baseLayer + } + + @IBAction func pitchButtonPressed(_ sender: UIButton) { + } } diff --git a/iOS/BaseballApp/BaseballApp/Views/GroundView.xib b/iOS/BaseballApp/BaseballApp/Views/GroundView.xib index f5ad926a8..be6e0e4e4 100644 --- a/iOS/BaseballApp/BaseballApp/Views/GroundView.xib +++ b/iOS/BaseballApp/BaseballApp/Views/GroundView.xib @@ -11,7 +11,7 @@ - + @@ -107,19 +107,19 @@ diff --git a/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.swift b/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.swift index 50a486f7a..37fc4b9eb 100644 --- a/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.swift +++ b/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.swift @@ -9,6 +9,8 @@ import UIKit class PitcherRecordTableViewCell: UITableViewCell { @IBOutlet weak var numberLabel: UILabel! + @IBOutlet weak var result: UILabel! + @IBOutlet weak var count: UILabel! static func nib() -> UINib { return UINib(nibName: self.identifier, bundle: nil) @@ -18,4 +20,11 @@ class PitcherRecordTableViewCell: UITableViewCell { numberLabel.layer.masksToBounds = true numberLabel.layer.cornerRadius = numberLabel.frame.width / 2 } + + func configure(record: Record) { + result.text = record.result + let strike = record.strikeCount + let ball = record.ballCount + count.text = "\(strike)-\(ball)" + } } diff --git a/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.xib b/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.xib index fec0bb19a..9c87c4222 100644 --- a/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.xib +++ b/iOS/BaseballApp/BaseballApp/Views/PitcherRecordTableViewCell.xib @@ -1,8 +1,8 @@ - + - + @@ -51,7 +51,9 @@ + + diff --git a/iOS/BaseballApp/BaseballApp/Views/RoomTableViewCell.swift b/iOS/BaseballApp/BaseballApp/Views/RoomTableViewCell.swift index 5fb904cc8..0721efca4 100644 --- a/iOS/BaseballApp/BaseballApp/Views/RoomTableViewCell.swift +++ b/iOS/BaseballApp/BaseballApp/Views/RoomTableViewCell.swift @@ -13,4 +13,9 @@ class RoomTableViewCell: UITableViewCell { @IBOutlet weak var awayTeamName: UILabel! @IBOutlet weak var homeTeamName: UILabel! + func fill(data: Room) { + roomNumber.text = "\(data.id)" + awayTeamName.text = data.awayTeam + homeTeamName.text = data.homeTeam + } }