Skip to content

An extension to the standard SwiftUI library (up-to-date with Xcode 11 beta 5).

License

Notifications You must be signed in to change notification settings

henryheleine/SwiftUIX

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUIX: An extension to the standard SwiftUI library.

SwiftUIX attempts to fill the gaps of the still nascent SwiftUI framework, providing an extensive suite of components, extensions and utilities to complement the standard library.

Installation

The preferred way of installing SwiftUIX is via the Swift Package Manager.

Xcode 11 integrates with libSwiftPM to provide support for iOS, watchOS, and tvOS platforms.

  1. In Xcode, open your project and navigate to FileSwift PackagesAdd Package Dependency...
  2. Paste the repository URL (https://github.com/swiftuix/SwiftUIX) and click Next.
  3. For Rules, select Branch (with branch set to master).
  4. Click Finish.

Usage

Controls:

SwiftUIX offers (opinionated) default implementations for commonly used UI controls.

Checkbox

A simple checkbox control. Its API mimics that of Toggle.

Data Representation

ProgressBar

A view that depicts the progress of a task over time.

public struct ProgressBar: View {
    public init(_ value: CGFloat)

    /// Declares the content and behavior of this view.
    public var body: some View { get }
}

Example usage:

ProgressBar(0.5)
    .foregroundColor(.blue)
    .frame(height: 20)

Control Flow:

SwiftUIX offers affordances for emulating certain types of control flow.

Switch Statements

Below is an example of a switch control flow being emulated.

The following, for example, will render a circle:

enum ShapeType {
    case capsule
    case circle
    case rectangle
    case squircle
}

struct ContentView: View {
    @State var shapeType: ShapeType = .circle

    var body: some View {
        SwitchOver(shapeType)
            .case(.capsule) {
                Capsule()
                    .frame(width: 50, height: 100)
                Text("Capsule 💊!")
            }
            .case(.circle) {
                Circle()
                    .frame(width: 50, height: 50)
                Text("Circle 🔴!")
            }
            .case(.rectangle) {
                Rectangle()
                    .frame(width: 50, height: 50)
                Text("Rectangle ⬛!")
            }
            .default {
                Text("Whoa!")
            }
    }
}

Whereas changing shapeType to .squircle would render the default case Text("Whoa!").

Text

TextView

SwiftUIX offers a port for UITextView, exposing an interface similar to that of TextField:

/// A control that displays an editable text interface.
public struct TextView<Label: View>: View {
    /// Declares the content and behavior of this view.
    public var body: some View { get }
}

extension TextView where Label == Text {
    public init<S: StringProtocol>(
        _ title: S,
        text: Binding<String>,
        onEditingChanged: @escaping (Bool) -> Void = { _ in },
        onCommit: @escaping () -> Void = { }
    )
}

Extensions:

Color

SwiftUIX ports the following UIColor named colors and exposes them as static type properties on Color:

  • systemRed
  • systemGreen
  • systemBlue
  • systemOrange
  • systemYellow
  • systemPink
  • systemPurple
  • systemTeal
  • systemIndigo
  • label
  • secondaryLabel
  • tertiaryLabel
  • quaternaryLabel
  • link
  • placeholderText
  • separator
  • opaqueSeparator
  • systemBackground
  • secondarySystemBackground
  • tertiarySystemBackground
  • systemGroupedBackground
  • secondarySystemGroupedBackground
  • tertiarySystemGroupedBackground
  • systemFill
  • secondarySystemFill
  • tertiarySystemFill
  • quaternarySystemFill

License

SwiftUIX is licensed under the MIT License.

About

An extension to the standard SwiftUI library (up-to-date with Xcode 11 beta 5).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%