Skip to content

Commit

Permalink
Update readme with documentation link
Browse files Browse the repository at this point in the history
Add documentation for Autograph
  • Loading branch information
Jens Troest committed Mar 17, 2024
1 parent 12bafca commit 2817352
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Autograph",
platforms: [.iOS(SupportedPlatform.IOSVersion.v15)],
platforms: [.iOS(.v15)],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ To display the autograph in a view you can use the provided ``AutographShape`` i

Since the view accepts the type ``Binding<[[CGPoint]]`` any [``Published``](https://developer.apple.com/documentation/combine/published) reference of that type can be used by accesing its binding with the `$` operator.

## Documentation

The latest documentation is [hosted here](https://jensmoes.github.io/swift-ui-autograph/documentation/autograph/autograph/)

## See also

The [Demo Project](https://github.com/jensmoes/swift-ui-autograph/tree/main/AutographDemo) included in this package has usage examples based on a SwiftData model scheme, showing how to create and display autographs.
20 changes: 15 additions & 5 deletions Sources/Autograph/Autograph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import SwiftUIHelpers

public struct Autograph: View {

/// Initializer for the Autograph view.
/// - Parameter data: Provide the binding to the destination of the user input data (the autograph)
/// - Parameter canvasSize: If provided this will contain the size of the drawing canvas at any given time during the views lifecycle. Use this to capture the aspect ratio for any future reproduction of the data.
/// - Parameter isActive: If provided this will provide the user activity state of the view. It will be true while input is being actively recorded.
/// - Parameter strokeWidth: The displayed with of the strokes. Defaults to 2.0
/// - Parameter strokeColor: The color of the strokes. Defaults to black.
public init(_ data: Binding<[[CGPoint]]>,
canvasSize: Binding<CGRect>? = nil,
isActive: Binding<Bool>? = nil,
Expand All @@ -22,6 +28,7 @@ public struct Autograph: View {
}

/// Adds a view under the created strokes.
/// - Parameter under: The view to display underneath the strokes. For example a dotted signature line, or a background.
public func underlay<U: View>(@ViewBuilder under: @escaping () -> U) -> some View {
ZStack {
under()
Expand Down Expand Up @@ -143,23 +150,26 @@ public struct Autograph: View {

}


/// A [``Shape``](https://developer.apple.com/documentation/swiftui/shape) representing the autograph from captured data
public struct AutographShape: Shape {

/// - Parameter data: The strokes data to render
public init(data: [[CGPoint]]) {
self.data = data
}

/// The strokes
let data: [[CGPoint]]

/// Created a [``Path``](https://developer.apple.com/documentation/swiftui/path) of the shape.
/// - Parameter rect: The [``CGRect``](9https://developer.apple.com/documentation/corefoundation/cgrect) for the path.
public func path(in rect: CGRect) -> Path {
return data.path(in: rect.size)
}


}


//#Preview {
// Autograph(data: AutoGraphData())
//}
#Preview {
Autograph(.constant([]))
}

0 comments on commit 2817352

Please sign in to comment.