Move colors to TetrisUI asset catalog
This commit is contained in:
parent
68fab068d9
commit
758de0c1f3
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue