/LSToast

Toast for SwiftUI

Primary LanguageSwiftGNU General Public License v2.0GPL-2.0

Requirements

  • Xcode 13.x
  • Swift 5.x

Installation

  1. File -> Swift Packages -> Add Package Dependency...
  2. Enter package URL :https://gitee.com/sandsn123/LSToast.git, choose the latest release

Usage

LSToast easy way to show toast in SwitUI:

Used in view:

Add ```@Toast var toast``` in your SwiftUI view
    struct ContentView: View {     
        //  custom style
        //  @Toast([
            // regiular message
            // .message(titleColor: .blue, textColor: .red),
            // loading
            // .loading(tintColor: .blue)
        //  ])
         @Toast var toast  // default      
         ...
    }
Add ```.toast(with: $toast)``` at the end of the view you want to show toast.
    ZStack { ... }.toast(with: $toast)
Assign a value to toast.
    toast(.loading(.large, "Loading..."))
    // toast(.mesage("title", text: "text"))

Used in ObservableObject:

Used in ObservableObject
 class DemoModel: ObservableObject {
    @ToastProvider([
        .complete(titleColor: .blue)
    ]) var toast
}
struct DemoView: View {
	 var body: some View {
				// your view
			 .toast(with: $vm.toast)
	 }
}