Skip to content

Examples

Zach Eriksen edited this page Mar 21, 2020 · 3 revisions

Examples

// MARK: Button Example
Button("Say Hello") {
    print("Hello! 👋")
}
        
// MARK: Divider Example
HStack(withSpacing: 8) {
    [
        Label("Amount Left"),
        Divider(.vertical),
        Spacer(),
        Label("4")
    ]
}

// MARK: Field Example
HStack {
    [
        field,
        Button("Save") {
            field.resignFirstResponder()
        }
        .frame(width: 60)
    ]
}

// MARK: Image Example
HStack(distribution: .fillEqually) {
    [
        Image(.blue),
        Image(.green),
        Image(.red)
    ]
}

// MARK: LoadingImage Example
LoadingImage(URL(string: "https://github.com/zmeriksen/SwiftUIKit/blob/master/assets/SwiftUIKit_logo_v1.png?raw=true")!)
    .contentMode(.scaleAspectFit)

// MARK: LoadingView Example
LoadingView(forStyle: .large).start()


// MARK: MultiLineField Example
HStack {
    [
        multiLineField,
        Button("Save") {
            field.resignFirstResponder()
        }
        .frame(width: 60)
    ]
}

// MARK: NavButton Example
NavButton("Navigate to SomeVC",
          destination: someViewController,
          style: .push)


// MARK: ScrollView Example
ScrollView {
    View(backgroundColor: .systemOrange)
        .frame(height: 44, width: 1000)
}

// MARK: Slider Example
Slider(value: 0.5, from: 0, to: 1) { value in
    print("Value is \(value)")
}

// MARK: Spacer Example
HStack {
    [
        Image(.brown).frame(width: 60),
        Spacer(),
        Image(.brown).frame(width: 60)
    ]
}

// MARK: Switch Example
Switch(isOn: false) { value in
    print("Value is \(value)")
}


// MARK: WebView Example
WebView(url: URL(string: "https://github.com/oneleif")!)
Clone this wiki locally