From 66e1fe8412eca2843ea6fb60253a0918b0cdd584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Ates=CC=A7=20=EF=A3=BF?= Date: Sun, 3 Mar 2024 01:31:41 +0300 Subject: [PATCH] add public init methods --- .../Abstract/ErrorableViewModifier.swift | 2 +- Sources/ErrorableView/Views/DefaultErrorView.swift | 14 +++++++++++--- .../ErrorableView/Views/DefaultLoadingView.swift | 9 ++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Sources/ErrorableView/Abstract/ErrorableViewModifier.swift b/Sources/ErrorableView/Abstract/ErrorableViewModifier.swift index 3daa40f..7bd1968 100644 --- a/Sources/ErrorableView/Abstract/ErrorableViewModifier.swift +++ b/Sources/ErrorableView/Abstract/ErrorableViewModifier.swift @@ -12,7 +12,7 @@ public struct ErrorableViewModifier: ViewModifier { @Binding var pageState: PageStates var errorContent: ErrorContent - init(pageState: Binding, + public init(pageState: Binding, @ViewBuilder errorContent: () -> ErrorContent) { self._pageState = pageState self.errorContent = errorContent() diff --git a/Sources/ErrorableView/Views/DefaultErrorView.swift b/Sources/ErrorableView/Views/DefaultErrorView.swift index 93b71f3..98943f6 100644 --- a/Sources/ErrorableView/Views/DefaultErrorView.swift +++ b/Sources/ErrorableView/Views/DefaultErrorView.swift @@ -12,9 +12,17 @@ public protocol ErrorableView: View { } @frozen public struct DefaultErrorView: ErrorableView { - var uimodel: DefaultErrorPageUIModel = .Builder().build() - public var type: ErrorPresentTypes = .sheet - var buttonAction: (() -> Void)? = nil + var uimodel: DefaultErrorPageUIModel + public var type: ErrorPresentTypes + var buttonAction: (() -> Void)? + + public init(uimodel: DefaultErrorPageUIModel = .Builder().build(), + type: ErrorPresentTypes = .sheet, + buttonAction: (() -> Void)? = nil) { + self.uimodel = uimodel + self.type = type + self.buttonAction = buttonAction + } public var body: some View { VStack { diff --git a/Sources/ErrorableView/Views/DefaultLoadingView.swift b/Sources/ErrorableView/Views/DefaultLoadingView.swift index f904fad..af69c36 100644 --- a/Sources/ErrorableView/Views/DefaultLoadingView.swift +++ b/Sources/ErrorableView/Views/DefaultLoadingView.swift @@ -9,7 +9,14 @@ import SwiftUI @frozen public struct DefaultLoadingView: View { var loadingText: LocalizedStringKey - var progressViewColor: Color = .accentColor + var progressViewColor: Color + + public init(loadingText: LocalizedStringKey, + progressViewColor: Color = .accentColor + ) { + self.loadingText = loadingText + self.progressViewColor = progressViewColor + } public var body: some View { VStack {