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
The built-in default error handling behaviour is simple and straight forward and exactly what I believe most projects will want most of the time. However, the displayed error view is uncustomisable without duplicating most of the ErrorPresenter extension code. It would be fantastic if we could add a way to hook into the construction of the ErrorView that gets presented so projects could provide their own - to provide fonts, images, branding etc. I know we could hook into visitableDidFailRequest(_:error:retryHandler) and provide a custom implementation, but it feels wasteful when the implementation is almost exactly what we want, just with our own app's branding.
As a first pass, something like this might suffice?
// Turbo/Navigator/Helpers/ErrorPresenter.swift
extension ErrorPresenter {
func presentError(_ error: Error, retryHandler: Handler?, errorView: AnyClass) {
let errorView = buildErrorView(error: error, shouldShowRetryButton: retryHandler != nil) {
retryHandler?()
self.removeErrorViewController()
}
let controller = UIHostingController(rootView: errorView)
addChild(controller)
addFullScreenSubview(controller.view)
controller.didMove(toParent: self)
}
// Allow for projects to hook into the error view construction and override to provide their own?
func buildErrorView(error: Error, shouldShowRetryButton: Bool, handler: @escaping ErrorPresenter.Handler) -> any View {
ErrorView(error: error, shouldShowRetryButton: shouldShowRetryButton, handler: handler)
}
}
The text was updated successfully, but these errors were encountered:
The built-in default error handling behaviour is simple and straight forward and exactly what I believe most projects will want most of the time. However, the displayed error view is uncustomisable without duplicating most of the
ErrorPresenter
extension code. It would be fantastic if we could add a way to hook into the construction of the ErrorView that gets presented so projects could provide their own - to provide fonts, images, branding etc. I know we could hook intovisitableDidFailRequest(_:error:retryHandler)
and provide a custom implementation, but it feels wasteful when the implementation is almost exactly what we want, just with our own app's branding.As a first pass, something like this might suffice?
The text was updated successfully, but these errors were encountered: