Skip to content

Commit

Permalink
Public release 1.2.0.
Browse files Browse the repository at this point in the history
Public release 1.2.0.
  • Loading branch information
dmytrokhl authored Mar 15, 2024
2 parents b889203 + 2f8f7b2 commit 9fb405d
Show file tree
Hide file tree
Showing 22 changed files with 1,193 additions and 37 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ workflows:
context:
- security-tools
- circleci

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "VGSShowSDK",
platforms: [
.iOS(.v10)
.iOS(.v13)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// VGSImageViewRepresentable.swift
// VGSShowSDK
//
import SwiftUI

@available(iOS 14.0, *)
/// An object that displays revealed image data.
public struct VGSImageViewRepresentable: VGSViewRepresentableProtocol, VGSViewRepresentableCallbacksProtocol {
weak var vgsShow: VGSShow?
/// Name that will be associated with `VGSImageViewRepresentable` and used as a decoding `contentPath` on request response with revealed data from your organization vault.
var contentPath: String
/// Image content mode, default is `.scaleToFill`.
var imageContentMode: UIView.ContentMode = .scaleToFill

// MARK: - VGSImageViewRepresentable interaction callbacks
/// Tells when Image View content did changed.
var onContentDidChange: (() -> Void)?
/// Tells when reveal data operation was failed for the Image View.
/// - Parameter error: `VGSShowError` object.
var onRevealError: ((VGSShowError) -> Void)?

// MARK: - Initialization
/// Initialization
///
/// - Parameters:
/// - contentPath: `String` path in reveal request response with revealed data that should be displayed in VGSImageViewRepresentable .
public init(vgsShow: VGSShow, contentPath: String) {
self.vgsShow = vgsShow
self.contentPath = contentPath
}

public func makeUIView(context: Context) -> VGSImageView {
let vgsImageView = VGSImageView()
vgsImageView.contentPath = contentPath
vgsImageView.imageContentMode = imageContentMode
vgsShow?.subscribe(vgsImageView)
return vgsImageView
}

public func updateUIView(_ uiView: VGSImageView, context: Context) {
uiView.imageContentMode = imageContentMode
}
/// Name that will be associated with `VGSImageViewRepresentable` and used as a decoding `contentPath` on request response with revealed data from your organization vault.
public func contentPath(_ path: String) -> VGSImageViewRepresentable {
var newRepresentable = self
newRepresentable.contentPath = path
return newRepresentable
}
/// Set mage content mode, default is `.scaleToFill`.
public func imageContentMode(_ mode: UIView.ContentMode) -> VGSImageViewRepresentable {
var newRepresentable = self
newRepresentable.imageContentMode = mode
return newRepresentable
}

// MARK: - Handle Image View events
public func onContentDidChange(_ action: (() -> Void)?) -> VGSImageViewRepresentable {
var newRepresentable = self
newRepresentable.onContentDidChange = action
return newRepresentable
}

/// Tells when reveal image operation was failed for the image view.
/// - action: `VGSShowError` object.
public func onRevealError(_ action: ((VGSShowError) -> Void)?) -> VGSImageViewRepresentable {
var newRepresentable = self
newRepresentable.onRevealError = action
return newRepresentable
}

// MARK: - Coordinator
public func makeCoordinator() -> Coordinator {
return Coordinator(self)
}

public class Coordinator: NSObject, VGSImageViewDelegate {
var parent: VGSImageViewRepresentable

init(_ parent: VGSImageViewRepresentable) {
self.parent = parent
}

public func imageDidChange(in imageView: VGSImageView) {
parent.onContentDidChange?()
}

public func imageView(_ imageView: VGSImageView, didFailWithError error: VGSShowError) {
parent.onRevealError?(error)
}
}
}
Loading

0 comments on commit 9fb405d

Please sign in to comment.