From 36888ee50c1f903e93902b7dfef79122a6d39f66 Mon Sep 17 00:00:00 2001 From: greyder Date: Sun, 5 Jun 2022 10:55:25 +0800 Subject: [PATCH] feat: add colors --- ...Validator.swift => String+Extension.swift} | 0 .../Background.colorset/Contents.json | 38 +++++++++++++++++++ .../CoffeeUI/Assets.xcassets/Contents.json | 6 +++ .../Foreground.colorset/Contents.json | 38 +++++++++++++++++++ Sources/CoffeeUI/BackgroundView.swift | 26 +++++++++++++ Sources/CoffeeUI/Color+Extension.swift | 19 ++++++++++ 6 files changed, 127 insertions(+) rename Sources/CoffeeBeans/{StringValidator.swift => String+Extension.swift} (100%) create mode 100644 Sources/CoffeeUI/Assets.xcassets/Background.colorset/Contents.json create mode 100644 Sources/CoffeeUI/Assets.xcassets/Contents.json create mode 100644 Sources/CoffeeUI/Assets.xcassets/Foreground.colorset/Contents.json create mode 100644 Sources/CoffeeUI/BackgroundView.swift create mode 100644 Sources/CoffeeUI/Color+Extension.swift diff --git a/Sources/CoffeeBeans/StringValidator.swift b/Sources/CoffeeBeans/String+Extension.swift similarity index 100% rename from Sources/CoffeeBeans/StringValidator.swift rename to Sources/CoffeeBeans/String+Extension.swift diff --git a/Sources/CoffeeUI/Assets.xcassets/Background.colorset/Contents.json b/Sources/CoffeeUI/Assets.xcassets/Background.colorset/Contents.json new file mode 100644 index 0000000..5760f40 --- /dev/null +++ b/Sources/CoffeeUI/Assets.xcassets/Background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.934", + "green" : "0.934", + "red" : "0.934" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.070", + "green" : "0.070", + "red" : "0.070" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/CoffeeUI/Assets.xcassets/Contents.json b/Sources/CoffeeUI/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/CoffeeUI/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/CoffeeUI/Assets.xcassets/Foreground.colorset/Contents.json b/Sources/CoffeeUI/Assets.xcassets/Foreground.colorset/Contents.json new file mode 100644 index 0000000..0425637 --- /dev/null +++ b/Sources/CoffeeUI/Assets.xcassets/Foreground.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/CoffeeUI/BackgroundView.swift b/Sources/CoffeeUI/BackgroundView.swift new file mode 100644 index 0000000..439c39f --- /dev/null +++ b/Sources/CoffeeUI/BackgroundView.swift @@ -0,0 +1,26 @@ +import SwiftUI + +struct BackgroundView: View { + let color: Color + var content: () -> Content + + init(color: Color = .background, @ViewBuilder content: @escaping () -> Content) { + self.color = color + self.content = content + } + + var body: some View { + ZStack { + color.edgesIgnoringSafeArea(.all) + content() + } + } +} + + struct BackgroundView_Previews: PreviewProvider { + static var previews: some View { + BackgroundView() { + Text("Hello") + } + } + } diff --git a/Sources/CoffeeUI/Color+Extension.swift b/Sources/CoffeeUI/Color+Extension.swift new file mode 100644 index 0000000..b71f476 --- /dev/null +++ b/Sources/CoffeeUI/Color+Extension.swift @@ -0,0 +1,19 @@ +// +// File.swift +// +// +// Created by Yhanco Grey Esteban on 6/5/22. +// + +import SwiftUI + +public extension Color { + + static var background: Color { + return Color("Background") + } + + static var foreground: Color { + return Color("Foreground") + } +}