diff --git a/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift b/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift index afbd15c60..77e085e65 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift @@ -36,6 +36,8 @@ struct SignatureCaptureViewExample2: View { .drawingViewBackgroundColor(.yellow) .xmarkColor(.green) .signatureLineColor(.orange) + .hidesXmark(false) + .hidesSignatureLine(true) ._drawingViewMaxHeight(300) .restartActionModifier { $0.font(.callout).foregroundColor(.red) diff --git a/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift b/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift index 49fcd9456..42861f9b1 100644 --- a/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift +++ b/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift @@ -281,6 +281,8 @@ public protocol UserConsentPageModel: TitleComponent, BodyAttributedTextComponen // sourcery: virtualPropCropsImage = "var cropsImage = false" // sourcery: virtualPropDrawingViewMinHeight = "let _drawingViewMinHeight: CGFloat = 256" // sourcery: virtualPropDrawingViewMaxHeight = "var _drawingViewMaxHeight: CGFloat?" +// sourcery: virtualPropHidesXmark = "var hidesXmark = false" +// sourcery: virtualPropHidesSignatureLine = "var hidesSignatureLine = false" // sourcery: generated_component_composite public protocol SignatureCaptureViewModel: AnyObject { // sourcery: default.value = nil diff --git a/Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift b/Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift index d53e0035a..c24281e19 100644 --- a/Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift +++ b/Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift @@ -172,9 +172,11 @@ extension SignatureCaptureView: View { Image(systemName: "xmark") .foregroundColor(xmarkColor) .font(.body) + .setHidden(self.hidesXmark) Rectangle() .foregroundColor(signatureLineColor) .frame(height: 1) + .setHidden(self.hidesSignatureLine) } .padding([.leading, .trailing]).padding(.bottom, 30) } @@ -197,9 +199,11 @@ extension SignatureCaptureView: View { Image(systemName: "xmark") .foregroundColor(xmarkColor.opacity(0.4)) .font(.body) + .setHidden(self.hidesXmark) Rectangle() .foregroundColor(signatureLineColor.opacity(0.4)) .frame(height: 1) + .setHidden(self.hidesSignatureLine) } .padding([.leading, .trailing]).padding(.bottom, 30) } @@ -348,6 +352,28 @@ public extension SignatureCaptureView { newSelf.signatureLineColor = color return newSelf } + + /** + A view modify to indicate to hide XMark or not. + + - parameter hidesXmark: Set this to true to hide the X Mark. + */ + func hidesXmark(_ hidesXmark: Bool) -> Self { + var newSelf = self + newSelf.hidesXmark = hidesXmark + return newSelf + } + + /** + A view modify to indicate to hide XMark or not. + + - parameter hidesSignatureLine: Set this to true to hide the signature line. + */ + func hidesSignatureLine(_ hidesSignatureLine: Bool) -> Self { + var newSelf = self + newSelf.hidesSignatureLine = hidesSignatureLine + return newSelf + } } private struct VStackPreferenceKey: PreferenceKey { @@ -367,3 +393,13 @@ private struct VStackPreferenceSetter: View { } } } + +extension View { + @ViewBuilder func setHidden(_ isHidden: Bool) -> some View { + if isHidden { + self.hidden() + } else { + self + } + } +} diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift index 0ee352064..82632c262 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift @@ -19,23 +19,25 @@ public struct SignatureCaptureView Void)? let _onDelete: (() -> Void)? - @State var currentDrawing = Drawing() - var drawingViewBackgroundColor = Color.preferredColor(.primaryBackground) - @State var drawings = [Drawing]() - @State var isReenterTapped = false var signatureLineColor = Color.preferredColor(.quarternaryLabel) + public private(set) var _heightDidChangePublisher = CurrentValueSubject(0) + var drawingViewBackgroundColor = Color.preferredColor(.primaryBackground) + var xmarkColor = Color.preferredColor(.quarternaryLabel) + var hidesXmark = false @State var isEditing = false - var strokeWidth: CGFloat = 3.0 - @State var isSaved = false + let _drawingViewMinHeight: CGFloat = 256 var _drawingViewMaxHeight: CGFloat? - public private(set) var _heightDidChangePublisher = CurrentValueSubject(0) @State var fullSignatureImage: UIImage? var cropsImage = false + @State var isSaved = false + var hidesSignatureLine = false + @State var currentDrawing = Drawing() + var strokeColor = Color.preferredColor(.primaryLabel) var titleColor = Color.preferredColor(.primaryLabel) + var strokeWidth: CGFloat = 3.0 + @State var isReenterTapped = false var titleFont = Font.fiori(forTextStyle: .subheadline).weight(.semibold) - var strokeColor = Color.preferredColor(.primaryLabel) - let _drawingViewMinHeight: CGFloat = 256 - var xmarkColor = Color.preferredColor(.quarternaryLabel) + @State var drawings = [Drawing]() private var isModelInit: Bool = false private var isTitleNil: Bool = false