Skip to content

antoniokly/HandySwiftUI

Repository files navigation

Latest Stable Version Platforms iOS | watchOS | tvOS | macOS GitHub

HandySwiftUI

A library of handy SwiftUI components. Keep growing.

Installation

Add Swift Package Dependency in Xcode, and enter URL https://github.com/antoniokly/HandySwiftUI

  .package(url: "https://github.com/antoniokly/HandySwiftUI.git", from: "0.0.1")

Usage

Import HandySwiftUI

Push

Text("text").push {
  SomeView()
}.foregroundColor(.red)

// is equivalent to

NavigationLink(destination: SomeView()) {
    Text("text").foregroundColor(.red)
}

Platform Specific

VStack {
  Text("text")
  Text("text1")
}.watchOS { $0
  .font(.system(size: 12, weight: .light))
  .foregroundColor(.blue)
}.iOS { $0
  .font(.system(size: 16, weight: .bold))
}

CustomToggleStyle

Toggle(isOn: .constant(true)) {
  Text("Text")
}.toggleStyle(CustomToggleStyle(onText: "", offText: "", onColor: .red))

PageView

PageView(pageCount: 5, currentPage: $currentPage, isNavigating: $isNavigating) { index in
    if index == 0 {
        Color.gray.edgesIgnoringSafeArea(.all)
    } else if index == 1 {
        Text("Page 2")
    } else {
        Text("More Page")
    }
}.indicator(currentPageSize: 10, defaultSize: 5, currentPageColor: .accentColor, defaultColor: .orange, opacity: 0.8)

Known Issues

watchOS and tvOS may have some issues using Swift Package, the supplied framework project is a solution to that at the moment.

Donation