Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 Signature: new APIs to hide xmark and underline #370

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Sources/FioriSwiftUICore/Models/ModelDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand All @@ -367,3 +393,13 @@ private struct VStackPreferenceSetter: View {
}
}
}

extension View {
@ViewBuilder func setHidden(_ isHidden: Bool) -> some View {
if isHidden {
self.hidden()
} else {
self
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@ public struct SignatureCaptureView<StartActionView: View, RestartActionView: Vie
let _signatureImage: UIImage?
let _onSave: ((UIImage) -> 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<CGFloat, Never>(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<CGFloat, Never>(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
Expand Down