You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An extension that provides essential state modifiers to SwiftUI views.
Overview
ViewState is a SwiftUI extension that introduces state modifiers to manage common view states. ViewState simplifies the process of displaying loaders, representing empty states and showcasing errors.
Installation
You can add ViewState as a dependency to your project using Swift Package Manager by adding it to the dependencies value of your Package.swift.
Click on File -> Swift Packages -> Add Package Dependency...
Enter the repository URL: https://github.com/kevinhermawan/ViewState.git
Choose the version you want to add. You probably want to add the latest version.
Click Add Package.
Usage
import SwiftUI
import ViewState
structExample:View{@StateprivatevarviewState:ViewState?=.loading
varbody:someView{VStack{Text("This is the main content.")}.when(viewState, is:.loading){ProgressView().progressViewStyle(.circular)}.when(viewState, is:.empty){ContentUnavailableView{Text("There is no data to display.")}}.whenError(viewState){ message inContentUnavailableView{Text(message)}}}}