// // TilesView.swift // Tetris // // Created by Shadowfacts on 10/14/19. // Copyright © 2019 Shadowfacts. All rights reserved. // import SwiftUI import TetrisKit struct TilesView: View { @Binding var board: GameBoard var body: some View { GridView(rows: board.height, columns: board.width) { (col, row, size) in if self.board[col, row] { Rectangle() .frame(width: size, height: size) .foregroundColor(self.board[col, row]!.color) .border(self.board[col, row]!.borderColor, width: 6) } else { Rectangle() .frame(width: size, height: size) .foregroundColor(Color("Background", bundle: .tetrisUI)) .border(Color("TileBorder", bundle: .tetrisUI), width: 2) } } } } struct TilesView_Previews: PreviewProvider { @State static var board: GameBoard = { var b = GameBoard(width: 10, height: 16) var piece = GamePiece(tetromino: .z) piece.topLeft = (0, 14) b.set(piece: piece) return b }() static var previews: some View { TilesView(board: $board) } }