SwiftUIKit

3.0.1

📱 UIKit code that is fun to write
0xLet/SwiftUIKit

What's New

3.0.1

2021-06-18T16:42:12Z

3.0.1

Updated

3.0.0

Added

  • Better formatting
  • Basic Documentation (WIP)

📦 SPM

Updated

  • configure to use SwiftFu.configure
  • contract to observed
  • UIView.later to UIView.chain and UIView.background
  • ContractView to ObservedView
  • Some Parameter names

SwiftUIKit

UIKit code that is fun to write.

Getting Started

Basic Examples

Introduction

SwiftUIKit is mainly based off of two functions, embed and stack. Embedding a view inside another view is exactly what we did in the first two examples. Now we can add another to the view, but then we have to manage the constraints for the subviews! An easy way to handle this is to use UIStackViews, so in SwiftUIKit there are VStack, HStack, and ZStack. UIStackViews manage the constraints for you and do just as the name suggests, stack views you give it in the order you give them.

Example Code

import UIKit
import SwiftUIKit

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        Navigate.shared.configure(controller: navigationController)
            .set(title: "Hello SwiftUIKit")
            .setRight(barButton: BarButton {
                Button("Button 0") {
                    print("Tapped the barbutton")
                }
            })
        
        
        view.embed {
            SafeAreaView {
                List(defaultCellHeight: 60) {
                    [
                        Button("Say Hello") {
                            print("Hello World!")
                        },
                        
                        HStack(withSpacing: 8) {
                            [
                                Label("Name"),
                                
                                Divider(.vertical),
                                
                                Spacer(),
                                
                                TextField(value: "SwiftUIKit",
                                      placeholder: "Some Name",
                                      keyboardType: .default)
                                    .inputHandler { print("New Name: \($0)") }
                            ]
                        },
                        
                        Label.callout("This is some callout text!"),
                        
                        ZStack {
                            [
                                Image(.blue)
                                    .frame(height: 60, width: 60)
                                    .offset(x: 100)
                            ]
                        },
                        
                        NavButton(destination: {
                            UIViewController {
                                UIView(backgroundColor: .white) {
                                    LoadingImage(URL(string: "https://cdn11.bigcommerce.com/s-oe2q4reh/images/stencil/2048x2048/products/832/1401/Beige_Pekingese_Puppy__21677.1568609759.jpg")!)
                                        .contentMode(.scaleAspectFit)
                                }
                            }
                        }, style: .push) {
                            Label("Go see a puppy")
                        },
                        
                        Button("Show an Alert") {
                            Navigate.shared.alert(title: "Hello this is an Alert!",
                                                  message: "Just a test...",
                                                  secondsToPersist: 3)
                        },
                        
                        Button("Show an Alert w/ cancel") {
                            Navigate.shared.alert(title: "Hello World",
                                                  message: "This is an alert",
                                                  withActions: [.cancel],
                                                  secondsToPersist: 3)
                        },
                        
                        Button("Show a Toast Message") {
                            Navigate.shared.toast(style: .error, pinToTop: true, secondsToPersist: 4) {
                                Label("This is a test error message!")
                            }
                        }
                    ]
                }
            }
        }
    }
}

Example View

Example SwiftUIKit

GitHub Supporters

suzyfendrick


oneleif project

This means that the project is sponsored by the oneleif community, and the collaborators are team members from oneleif.

What is oneleif?

oneleif is a nonprofit community that supports tech minded individuals. We do this by offering a fun loving community that works on Open Sourced projects together. We love to give back through free resources and guidance.

How to join oneleif

Click on the link below to join the Discord server.

-OR-

Check out our website

Questions?

Feel free to email us at: oneleifdev@gmail.com

-OR-

Ask questions in the discord

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

Last updated: Sun Oct 20 2024 00:44:52 GMT-0900 (Hawaii-Aleutian Daylight Time)