Coder Social home page Coder Social logo

open-bytes / swiftuichipgroup Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 4.0 2.06 MB

A chip group (tag view) for SwiftUI.

License: Other

Ruby 3.69% Swift 96.31%
tag tags tagview tagging chip chipview chipgroup swift swiftui ios ios-app ios-swift ios13 macos tvos ui ui-components material-ui material-design

swiftuichipgroup's Introduction

ChipView


ChipGroup is a simple and highly customizable chip group for iOS, in SwiftUI.

SwiftUINavigator Demo

SwiftUINavigator Diagram

swift v5.3 iOS 13 macOS tvOS License


Table of contents


Installation

Xcode Projects

Select File -> Swift Packages -> Add Package Dependency and enter https://github.com/Open-Bytes/ChipGroup.

Swift Package Manager Projects

You can add ChipGroup as a package dependency in your Package.swift file:

let package = Package(
//...
dependencies: [
.package(url: "https://github.com/Open-Bytes/ChipGroup", .upToNextMajor(from: "0.1.0"))
]
//...
)

From there, refer to ChipGroup in target dependencies:

targets: [
.target(
name: "YourLibrary",
dependencies: [
"ChipGroup"
]
//...
),
// ...
]

Then simply import ChipGroup wherever you’d like to use the library.


⚡ Usage

  1. Import ChipGroup.
import ChipGroup
  1. Create an array of ChipItem that conform to ChipItemProtocol.
let items = [
    ChipItem(name: "Red"),
    ChipItem(name: "Green"),
    ChipItem(name: "Blue"),
    ChipItem(name: "Purple"),
    ChipItem(name: "Orange")
]
  1. You can add chip to the ChipGroup , or set custom background for both selected and deselected state, Selection type, Size and font through this code:
ChipGroup(
    chips: items,
    width: UIScreen.main.bounds.width - 120,
    selection: .none,
    selectedBackground: Capsule().fill(Color.orange),
    deselectedBackground: Capsule().fill(Color.pink.opacity(0.8)),
    selectedTextColor: .white,
    deselectedTextColor: .white,
    font: .system(size: 20, weight: .bold, design: .default)
)

⚡ Custom background

You can provide your own custom background through this code:

struct CircleBackground: View {
    var color: Color
    var body: some View {
        content()
    }

    private func content() -> some View {
        VStack(spacing: 6) {
            Circle().fill(color)
                    .frame(width: 70, height: 70)
        }
    }
}

Demo

ChipGroup
is an example app demonstrates how you can use the library.


👏 Contribution

  • PRs are welcome, let's make this library better. 🙌

  • Please ⭐ if you like the idea!

License

Apache License, Version 2.0

click to reveal License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

swiftuichipgroup's People

Contributors

shoroukelgazar avatar

Stargazers

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

Watchers

 avatar  avatar

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.