Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakemarsh/CostumeKit
Base types for theming an app.
https://github.com/jakemarsh/CostumeKit
carthage colors fonts images ios ios-lib protocol svg swift themes
Last synced: 3 months ago
JSON representation
Base types for theming an app.
- Host: GitHub
- URL: https://github.com/jakemarsh/CostumeKit
- Owner: jakemarsh
- License: other
- Created: 2016-09-29T06:32:57.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-08T20:12:23.000Z (about 1 year ago)
- Last Synced: 2024-04-21T18:20:59.134Z (7 months ago)
- Topics: carthage, colors, fonts, images, ios, ios-lib, protocol, svg, swift, themes
- Language: Swift
- Size: 30.3 KB
- Stars: 298
- Watchers: 4
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - CostumeKit - Base types for theming an app. (Color / Linter)
- awesome-swift - CostumeKit - Base types for theming an app. (Libs / UI)
- awesome-ios-star - CostumeKit - Base types for theming an app. (Color / Linter)
- fucking-awesome-ios - CostumeKit - Base types for theming an app. (Color / Linter)
- fucking-awesome-ios - CostumeKit - Base types for theming an app. (Color / Linter)
- awesome-swift - CostumeKit - Base types for theming an app. (UI [🔝](#readme))
README
# CostumeKit :tophat:
> Base types for theming an app.
**CostumeKit** is made of up a set of Swift protocols. They are meant to be implemented by you in your app.
Featured in [_Little Bites of Cocoa Bite #270: Implementing Theming with CostumeKit_](https://littlebitesofcocoa.com/270-implementing-theming-with-costumekit)
## Color :art:
Includes `Color` and `ColorPalette` protocols.
Usage:
``` swift
public enum MyAppColors : Color, ColorPalette {
case white = "FFFFFF"
case lightTeal = "3CB39E"
case forestGreen = "216055"
case black = "000000"
}
```## Font :capital_abcd:
Includes `Font` protocol, and one concrete `SystemFont` implementation for **iOS** system fonts.
Usage:
``` swift
public struct MyAppFont : Font {
public init(size: FontSize = .textStyle(.body)) {
self.size = size
}// Font
public var size: FontSize
// FontConvertible
public var FontValue: UIFont {
return UIFont(name: "SomeCustomFont", size: pointSize)!
}
}
```## SVG :stars:
Includes `SVG` Protocol and `SVGMetadata` type.
Usage:
``` swift
enum MyAppSVGs {
case clockGlyph
case bird
}extension MyAppSVGs : SVG {
public func metadata() -> SVGMetadata {
switch self {
case .clockGlyph: return SVGMetadata(name: "clock", size: CGSize(width: 100, height: 100), fullColor: false)
case .bird: return SVGMetadata(name: "bird", size: CGSize(width: 58, height: 28), fullColor: true)
}
}
}
```What you do with `SVGMetadata` is up to you. I recommend [SwiftSVG](https://github.com/mchoe/SwiftSVG) from [Michael Choe](https://github.com/mchoe). [Read more here to learn how to use it](https://www.littlebitesofcocoa.com/198-parsing-rendering-svgs-with-swiftsvg).
**CostumeKit**'s goals are to be a generic solution, so no assumptions are made about how something should be retrieved from disk, parsed, etc. You'll need to implement these anyways, so nothing is forced on you.
## Costume :tophat:
Includes `Costume` protocol. Usage:
``` swift
open class MyAppCostume : Costume {
let spacing = CGFloat(8)public func wearRootBackground(_ view: UIView) {
view.backgroundColor = Color.black.colorValue
}public func wearHeadline(_ label: UILabel) {
label.font = MyAppFont(size: .textStyle(.title1)).fontValue
label.textColor = MyAppColors.forestGreen.colorValue
}public var name: String { return "Default" }
public var description: String { return "The default costume." }public init() { }
}
```Cheers.