Giter Club home page Giter Club logo

juiceui's Introduction

JuiceUI

A small collection of what I thought would be useful SwiftUI wrappers for common views in the iOS SDK. The goal is to fill in the gap a bit between what Apple integrated into SwiftUI and the components iOS developers actually use.

This was also an excuse for me to play around with SwiftUI and release my first Swift Package, so there's that.

Installation

Simply go into your Xcode project, go to File > Swift Packages > Add Package Dependency and provide the URL to this repository (https://github.com/mattwyskiel/JuiceUI.git) and have it pull from master.

Components

Sign In With Apple button

Sign In With Apple button

Relevant code:

AppleIDAuthButton(requestedScopes: [.fullName, .email])
    .onSuccess({ /* success handler */ })
    .frame(height: 55)

Share Sheet

Share Sheet

Relevant code:

.sheet(isPresented: $showShareSheet) {
    ShareSheet(items: [URL(string: self.url)!])
    .onComplete { (activityType, completed, returnedItems, activityError) in
        /* completion handler */
    }
}

Font Picker

Font Picker

Relevant code:

.sheet(isPresented: $showPicker) {
    NavigationView {
        FontPicker(didPickFont: { font in
            self.fontName = font.postscriptName // self.fontName is @State, so the text font updates automatically
        })
    }
}

Image Picker

Image Picker

Relevant code:

.sheet(isPresented: $showPicker) {
    ImagePicker(sourceType: .photoLibrary) { info in
        self.imageURL = info[.imageURL] as? URL // updates the image automatically
    }
    .onCancel {
        self.imageURL = nil
    }
}

Page View

Page View

Relevant code:

ZStack{
    Color.veryLightGray.edgesIgnoringSafeArea(.all) // so you can see the page indicator; also, veryLightGray is a custom color.
    PageView {
        Page {
            ZStack {
                Color.blue
                Text("Hello")
            }
        }
        Page {
            ZStack {
                Color.red
                Text("World")
            }
        }
        Page {
            Text("This Works!!!")
        }
    }
}

Mail Composer

(no preview because this doesn't work in the simulator, and I've deleted the mail app on all my devices ๐Ÿ˜ฌ)

.sheet(isPresented: $isPresenting) {
    MailComposeView()
    .message(self.message)
    .didCancel {
        self.text = "cancelled"
    }
    .didSend {
        self.text = "sent"
    }
    .didFail { error in
        self.text = "Error: " + error.localizedDescription
    }
    .didSaveDraft {
        self.text = "saved draft"
    }
}

Demo

Want to see all of this in more detail? See the JuiceUI Previews.xcodeproj in the Demo folder.

License

This software is published under the MIT License. See LICENSE for more details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.