diff --git a/TetrisUI/BundleHelper.swift b/TetrisUI/BundleHelper.swift new file mode 100644 index 0000000..93ba7b5 --- /dev/null +++ b/TetrisUI/BundleHelper.swift @@ -0,0 +1,16 @@ +// +// BundleHelper.swift +// Tetris +// +// Created by Shadowfacts on 10/17/19. +// Copyright © 2019 Shadowfacts. All rights reserved. +// + +import Foundation + +fileprivate class BundleHelper {} +extension Bundle { + static var tetrisUI: Bundle { + Bundle(for: BundleHelper.self) + } +} diff --git a/Tetris Mac/Assets.xcassets/Background.colorset/Contents.json b/TetrisUI/Media.xcassets/Background.colorset/Contents.json similarity index 100% rename from Tetris Mac/Assets.xcassets/Background.colorset/Contents.json rename to TetrisUI/Media.xcassets/Background.colorset/Contents.json diff --git a/TetrisUI/Media.xcassets/Contents.json b/TetrisUI/Media.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/TetrisUI/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoAqua.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoAqua.colorset/Contents.json new file mode 100644 index 0000000..5358ebd --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoAqua.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0", + "alpha" : "1.000", + "blue" : "211", + "green" : "214" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoBlue.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoBlue.colorset/Contents.json new file mode 100644 index 0000000..52854ef --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoBlue.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0", + "alpha" : "1.000", + "blue" : "214", + "green" : "79" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoGreen.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoGreen.colorset/Contents.json new file mode 100644 index 0000000..8e7fb2d --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoGreen.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0", + "alpha" : "1.000", + "blue" : "71", + "green" : "214" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoOrange.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoOrange.colorset/Contents.json new file mode 100644 index 0000000..95662fa --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoOrange.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "255", + "alpha" : "1.000", + "blue" : "0", + "green" : "128" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoPurple.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoPurple.colorset/Contents.json new file mode 100644 index 0000000..d8cd354 --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoPurple.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "168", + "alpha" : "1.000", + "blue" : "214", + "green" : "0" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoRed.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoRed.colorset/Contents.json new file mode 100644 index 0000000..5714708 --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoRed.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "214", + "alpha" : "1.000", + "blue" : "61", + "green" : "0" + } + } + } + ] +} \ No newline at end of file diff --git a/TetrisUI/Media.xcassets/TetrominoYellow.colorset/Contents.json b/TetrisUI/Media.xcassets/TetrominoYellow.colorset/Contents.json new file mode 100644 index 0000000..4ac8cd1 --- /dev/null +++ b/TetrisUI/Media.xcassets/TetrominoYellow.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "255", + "alpha" : "1.000", + "blue" : "71", + "green" : "229" + } + } + } + ] +} \ No newline at end of file diff --git a/Tetris/Assets.xcassets/Background.colorset/Contents.json b/TetrisUI/Media.xcassets/TileBorder.colorset/Contents.json similarity index 75% rename from Tetris/Assets.xcassets/Background.colorset/Contents.json rename to TetrisUI/Media.xcassets/TileBorder.colorset/Contents.json index 021c433..40df838 100644 --- a/Tetris/Assets.xcassets/Background.colorset/Contents.json +++ b/TetrisUI/Media.xcassets/TileBorder.colorset/Contents.json @@ -9,10 +9,10 @@ "color" : { "color-space" : "srgb", "components" : { - "red" : "0xDD", + "red" : "0.800", "alpha" : "1.000", - "blue" : "0xDD", - "green" : "0xDD" + "blue" : "0.800", + "green" : "0.800" } } }, @@ -27,10 +27,10 @@ "color" : { "color-space" : "srgb", "components" : { - "red" : "0x22", + "red" : "0.157", "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22" + "blue" : "0.157", + "green" : "0.157" } } } diff --git a/TetrisUI/Tetromino+Color.swift b/TetrisUI/Tetromino+Color.swift index 8d5c09a..41b77a0 100644 --- a/TetrisUI/Tetromino+Color.swift +++ b/TetrisUI/Tetromino+Color.swift @@ -9,33 +9,23 @@ import SwiftUI import TetrisKit -fileprivate extension Color { - static let tetrominoAqua = Color(red: 0, green: 214/255, blue: 211/255) - static let tetrominoBlue = Color(red: 0, green: 79/255, blue: 214/255) - static let tetrominoOrange = Color(red: 255/255, green: 128/255, blue: 0) - static let tetrominoYellow = Color(red: 255/255, green: 229/255, blue: 0) - static let tetrominoGreen = Color(red: 0, green: 214/255, blue: 71/255) - static let tetrominoPurple = Color(red: 168/255, green: 0, blue: 214/255) - static let tetrominoRed = Color(red: 214/255, green: 0, blue: 61/255) -} - extension Tetromino { var color: Color { switch self { case .i: - return .tetrominoAqua + return Color("TetrominoAqua", bundle: .tetrisUI) case .o: - return .tetrominoYellow + return Color("TetrominoYellow", bundle: .tetrisUI) case .t: - return .tetrominoPurple + return Color("TetrominoPurple", bundle: .tetrisUI) case .j: - return .tetrominoOrange + return Color("TetrominoOrange", bundle: .tetrisUI) case .l: - return .tetrominoBlue + return Color("TetrominoBlue", bundle: .tetrisUI) case .s: - return .tetrominoRed + return Color("TetrominoRed", bundle: .tetrisUI) case .z: - return .tetrominoGreen + return Color("TetrominoGreen", bundle: .tetrisUI) } } } diff --git a/TetrisUI/TilesView.swift b/TetrisUI/TilesView.swift index 3f4edc8..34f850f 100644 --- a/TetrisUI/TilesView.swift +++ b/TetrisUI/TilesView.swift @@ -14,9 +14,16 @@ struct TilesView: View { var body: some View { GridView(rows: board.height, columns: board.width) { (col, row, size) in - Rectangle() - .frame(width: size, height: size) - .foregroundColor(self.board[col, row]?.color ?? Color("Background")) + if self.board[col, row] { + Rectangle() + .frame(width: size, height: size) + .foregroundColor(self.board[col, row]?.color ?? Color("Background", bundle: .tetrisUI)) + } else { + Rectangle() + .frame(width: size, height: size) + .foregroundColor(Color("Background", bundle: .tetrisUI)) + .border(Color("TileBorder"), width: 1) + } } } }