- 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
struct TestView: View {
@State private var pageState: PageStates = .loading
var body: some View {
// YOUR CODES
.akErrorView(pageState: $pageState) {
// TRY AGAIN ACTION
}
}
}
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?
}