Giter Club home page Giter Club logo

swiftuicolor's Introduction

SwiftUIColor

Make system color defined in UIColor/NSColor available to SwiftUI Color.

Usage

  1. import

    import SwiftUIColor
  2. Use

    Get the color for each platform

    // universal system colors
    let color = Color.universal.systemRed
    
    // iOS system colors
    let color = Color.iOS.systemBackground
    
    // macOS system colors
    let color = Color.macOS.secondarySystemFillColor
    
    // and watchOS, tvOS...

    Another Style

    // universal system colors
    let color: Color = .universal(.systemRed)
    
    // iOS system colors
    let color: Color = .iOS(systemBackground)
    
    // macOS system colors
    let color: Color = macOS(.secondarySystemFillColor)
    
    // and watchOS, tvOS...

    list of colors

    // universal color list
    let colors: [Color] = Color.universal.colors
    
    list of color names
    ```swift
    // universal color name list
    let colors: [Color] = Color.universal.colorNames

Example

universal iOS macOS
universal iOS macOS
tvOS watchOS
tvOS watchOS

Development

In this library, colors are defined in an asset file. image

Based on this asset file, the following code is generated.

image

If you have updated the asset file, use the following command to update the code

swift run -c release --package-path . prepare-swiftui-color Sources/SwiftUIColor/Assets/Media.xcassets/ Sources/SwiftUIColor/

License

SwiftUIColor is released under the MIT License. See LICENSE

swiftuicolor's People

Contributors

p-x9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

swiftuicolor's Issues

New Writing Style

Consider the following writing style

let color: Color = .iOS(.label)

To achieve this kind of writing, it is necessary to change the structure from defining static properties in the enum.

Following is a proposed new way to define it

extension Color: String {
    enum iOSConstant {
        case label = "iOS/label"
        case systemBackground = "iOS/systemBackground"

        var color: Color { Color(rawValue, bundle: .myModule) }
    }


    static func iOS(_ constant: iOSConstant) -> Color { constant.color }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.