Skip to content

yarspirin/TagCloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

TagCloud ๐Ÿท๏ธ

TagCloud is a powerful, flexible and stylish package for integrating tag clouds into your iOS apps. From basic setups to fully customizable collections with your custom views, TagCloud provides an intuitive interface that blends seamlessly with SwiftUI's design paradigms.

๐Ÿš€ Features

  • Effortless Integration: Set up your tag cloud with a single line of code using the default TagCloudView.
  • Fully Customizable: Use any data type that conforms to RandomAccessCollection and create your own custom views.
  • Automatic Resizing: Flow layout for optimal use of space that automatically adjusts as tags are added or removed.
  • Stylish and Modern: Built entirely with SwiftUI for modern and stylish UIs.

๐Ÿ”ง Requirements

  • iOS 13.0+
  • Xcode 14.0+
  • Swift 5.7+

๐Ÿ’ป Installation

Using the Swift Package Manager, add TagCloud as a dependency to your Package.swift file:

dependencies: [
  .package(url: "https://github.com/yarspirin/TagCloud.git", .upToNextMajor(from: "1.0.0"))
]

๐ŸŽˆ Usage

๐ŸŽฏ Default TagCloudView

For a quick and beautiful tag cloud, simply provide an array of strings. TagCloud will use the default TagView to generate a standard tag cloud:

import SwiftUI
import TagCloud

struct DefaultExampleView: View {
  let tags = ["Hello", "World", "I", "love", "Swift", "and", "tag", "clouds"]
  
  var body: some View {
    TagCloudView(tags: tags)
  }
}
Default Example

๐Ÿ”จ Custom TagCloudView

For more advanced usage, TagCloud allows you to fully customize the tag cloud. You can provide your own collection of data and a closure to generate custom views from your data:

import SwiftUI
import TagCloud

struct SelectableTag: View {
  @State var isSelected = false
  let title: String
  
  var body: some View {
    Button {
      isSelected.toggle()
    } label: {
      Text(title)
        .foregroundColor(isSelected ? .white : .black)
        .padding(EdgeInsets(top: 5, leading: 10, bottom: 5, trailing: 10))
        .background(
          RoundedRectangle(cornerRadius: 10)
            .foregroundColor(isSelected ? .black : .white)
        )
        .overlay(
          RoundedRectangle(cornerRadius: 10)
            .stroke(isSelected ? .white : .black, lineWidth: 1)
        )
    }
  }
}

struct CustomExampleView: View {
  let titles = ["Hello", "World", "I", "Love", "Swift", "And", "Tag", "Clouds"]
  
  var body: some View {
    TagCloudView(data: titles) { title in
      SelectableTag(title: title)
    }
  }
}
Custom Example

๐Ÿ’ผ Contributing

We love contributions! Whether it's fixing bugs, improving documentation, or proposing new features, your efforts are welcome.

๐Ÿ“„ License

TagCloud is available under the MIT license. See the LICENSE.md file for more info.

About

TagCloud ๐Ÿท๏ธ: A flexible SwiftUI package for creating customizable tag clouds in iOS apps.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages