Skip to content

Latest commit

 

History

History
63 lines (55 loc) · 2.08 KB

README.md

File metadata and controls

63 lines (55 loc) · 2.08 KB

ErrorableView-SwiftUI

How to install this package

  • Open your project on Xcode
  • Go to the Project Tab and select "Package Dependencies"
  • Click "+" and search this package with use git clone URL
  • Don't change anything and click Add Package
  • The package will be attached to the targeted application

How to use this package

Just use The "ErrorableViewModifier" with an $pageState property

struct TestView: View {
    @State private var pageState: PageStates = .loading

    var body: some View {
        // YOUR CODES
        .akErrorView(pageState: $pageState) {
            // TRY AGAIN ACTION
        }
    }
}

Useful Tips

This package allows you to manage your page error state easily. But actually, it's useful. What do you get to know?

  • Generic Error Page Support: The Package includes a DefaultErrorPage but you don't want to use it. Use the ErrorableView protocol, and create your error page.
protocol ErrorableView: View {
   var type: ErrorPresentTypes { get set }
}

This protocol only wants to create a type property for your error page presentation state. If your view comformed the protocol you'll use this modifier code block under the below.

.modifier(ErrorableViewModifier(pageState: $viewModel.pageState) { // Like this
    YourView() {
         viewModel.reload()
    }
})
  • Fully Customisable Error Page: The package includes a customizable ErrorPage named DefaultErrorPage. You can use that uiModel to update DefaultErrorPage.
@frozen public struct DefaultErrorPageUIModel {
    var title: LocalizedStringKey
    var subtitle: LocalizedStringKey?
    var icon: String?
    var systemName: String?
    var buttonTitle: LocalizedStringKey?
}

Examples

Sheet Type

Screen.Recording.2023-11-24.at.9.20.23.PM.mov

OnPage Type

Screen.Recording.2023-11-24.at.9.20.43.PM.mov

Fullscreen Type

Screen.Recording.2023-11-24.at.9.21.00.PM.mov