OCErrorStateView: UI component
The OCErrorStateView
is a full-screen view that centrally presents its content. It serves the purpose of displaying when a specific view or the complete content of a screen is unavailable or encounters loading issues. This view comprises an image view for showcasing icons, illustrations, or animations, along with a title, description, and an optional button to reload.
Features
- User can pass the desired details to show like image or animation, title, information and reload button title.
- In style, user can change card style like background, image, title, information and buttons etc
Installation
-
Copy the
ErrorState
component folder into your Xcode project. -
Use the
OCErrorStateView
view in your SwiftUI code:
Parameters:
errorStateInformation
: User can send the informations for error state as OCErrorStateInformationerrorStateStyle
: User can change card style like backgroundColor, styles, colors of UIElements.onButtonTap
: Will give the callback with error state information for the button selection.
Information Parameters:
contentAlignment
: Users have the flexibility to customize the vertical or horizontal alignment of images and other content according to their preferences.image
: Users have the flexibility to customize the content for image like icons, illustrations, or animationstitle
: Title contentdescription
: Description contentisButtonRequired
: Bool to show/hide buttonbuttonTitle
: Title for button
import SwiftUI
struct OCErrorStateTemplate: View {
var body: some View {
let errorStateData = OCErrorStateInformation(contentAlignment: .vertical, image: .image(image: .local(image: Image("ErrorStateIcon")), title: "Error State title", description: "Brief explanation of why content cannot be shown and instructions on how to interact with the view.", isButtonRequired: true, buttonTitle: "Neu laden")
let errorStateView = OCErrorStateView(errorStateInformation: errorStateData) { _ in }
VStack {
}.ocErrorState(isShowing: .constant(true), errorStateView: errorStateView)
}
}