Skip to content

Commit c8aa3a1

Browse files
Merge pull request #14 from OutSystems/development
Push `development` into `main`
2 parents 719e281 + 53e0a61 commit c8aa3a1

24 files changed

+826
-206
lines changed

.github/workflows/github_actions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717
- name: Setup Java 17
18-
uses: actions/setup-java@v3
18+
uses: actions/setup-java@v4
1919
with:
2020
distribution: 'zulu'
2121
java-version: '17'
@@ -30,7 +30,7 @@ jobs:
3030
- name: Lint
3131
run: bundle exec fastlane lint
3232
- name: Setup sonarqube
33-
uses: warchant/setup-sonar-scanner@v7
33+
uses: warchant/setup-sonar-scanner@v8
3434
- name: Send to Sonarcloud
3535
run: bundle exec fastlane sonarqube
3636
env:

docs/CHANGELOG.md renamed to CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
### [1.0.0]
7+
## [Unreleased]
88

9+
### Chores
10+
- Update `github_actions.yml` file steps versions (https://outsystemsrd.atlassian.net/browse/RMET-2568).
11+
12+
### Features
13+
- Add zooming out feature (https://outsystemsrd.atlassian.net/browse/RMET-2986).
14+
- Add zooming in feature (https://outsystemsrd.atlassian.net/browse/RMET-2986).
15+
16+
## [1.0.0]
17+
18+
### Features
919
- Implement iPad user interface (https://outsystemsrd.atlassian.net/browse/RMET-2911).
1020
- Implement iPhone user interface (https://outsystemsrd.atlassian.net/browse/RMET-2771).
1121
- Add Scan Orientation Selection feature (https://outsystemsrd.atlassian.net/browse/RMET-2753).

OSBarcodeLib.xcodeproj/project.pbxproj

Lines changed: 52 additions & 8 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// Protocol that is used to signal a modification on a camera property or setting.
2+
protocol OSBARCCameraChange {
3+
associatedtype ValueType
4+
5+
/// Property to apply the change to. If `nil` it indicates a change to the camera itself.
6+
var property: OSBARCCameraProperty? { get }
7+
/// The new value to apply.
8+
var value: ValueType { get set }
9+
}
10+
11+
struct OSBARCCameraZoomFactorChange: OSBARCCameraChange {
12+
var property: OSBARCCameraProperty? { .zoomFactor }
13+
var value: Float
14+
}
15+
16+
struct OSBARCCameraTorchChange: OSBARCCameraChange {
17+
var property: OSBARCCameraProperty? { .torch }
18+
var value: Bool
19+
}
20+
21+
struct OSBARCCameraRotationChange: OSBARCCameraChange {
22+
var property: OSBARCCameraProperty? { nil }
23+
var value: (height: Int, width: Int)
24+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import QuartzCore
2+
3+
/// Protocol that contains all the methods required for camera management.
4+
protocol OSBARCCameraManager {
5+
/// The layer to display video on
6+
var videoPreview: CALayer? { get }
7+
8+
/// Setup camera
9+
/// - Parameter type: The type of camera to setup. `Nil` value offers the possibility to setup a default camera provided by the implementations.
10+
func setup(type: OSBARCCameraType?) throws
11+
12+
/// Apply changes to the camera.
13+
/// - Parameter change: The change to apply to the camera. It can be made to a property or to the camera itself.
14+
func apply(change: any OSBARCCameraChange) throws
15+
16+
/// Initialises the camera display.
17+
func start()
18+
19+
/// Terminates the camera display.
20+
func stop()
21+
22+
/// Verifies if the camera passed by parameter is available for selection.
23+
/// - Parameter cameraType: The camera to be checked.
24+
/// - Returns: Indicates if the camera is available.
25+
func isAvailable(_ cameraType: OSBARCCameraType) throws -> Bool
26+
27+
/// Retrieves the value associated with the passed property.
28+
/// - Parameter property: The property to fetch the value from (e.g. torch, zoom factors, ...).
29+
/// - Returns: The value associated with the passed property.
30+
func getValue<T>(forProperty property: OSBARCCameraProperty) throws -> T?
31+
}
32+
33+
/// Accelerators.
34+
extension OSBARCCameraManager {
35+
func setup() throws {
36+
try self.setup(type: nil)
37+
}
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// Errors related to the `OSBARCCameraManager`
2+
enum OSBARCCameraManagerError: Error {
3+
case cameraNotConfigured(_: OSBARCCameraType)
4+
}
5+
6+
/// Indicates the camera properties that can be retrieved and changed.
7+
enum OSBARCCameraProperty {
8+
case zoomFactor
9+
case torch
10+
}
11+
12+
/// Indicates the two types of cameras that can be used based on the selected zoom factor.
13+
enum OSBARCCameraType {
14+
case regular
15+
case zoomOut
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AVFoundation
2+
3+
extension OSBARCCameraType {
4+
/// Fetches the `AVCaptureDevice.DeviceType` equivalent values.
5+
var deviceType: AVCaptureDevice.DeviceType {
6+
switch self {
7+
case .regular: return .builtInWideAngleCamera
8+
case .zoomOut: return .builtInUltraWideCamera
9+
}
10+
}
11+
}

OSBarcodeLib/Scanner/OSBARCScannerViewControllerCoordinator.swift renamed to OSBarcodeLib/Scanner/CameraManager/OSBARCCaptureOutputDecoder.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import Combine
33
import SwiftUI
44
import Vision
55

6-
/// Manages the sample buffers received from the video data output to return the desired information.
7-
final class OSBARCScannerViewControllerCoordinator: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
6+
/// Class responsible for decoding the scanning output (in this case, barcodes).
7+
final class OSBARCCaptureOutputDecoder: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
88
/// The object containing the value to return.
99
@Binding private var scanResult: String
1010
/// Indicates if scanning should be done only after a button click or automatically.
1111
private let scanThroughButton: Bool
1212
/// Indicates if scanning is enabled (when there's a Scan Button).
13-
@Binding private var scanButtonEnabled: Bool
13+
private var scanButtonEnabled: Bool
1414

1515
/// The publisher's cancellable instance collector.
1616
private var cancellables: Set<AnyCancellable> = []
@@ -29,10 +29,10 @@ final class OSBARCScannerViewControllerCoordinator: NSObject, AVCaptureVideoData
2929
/// - scanResult: Binding object with the value to return.
3030
/// - scanThroughButton: Boolean indicating if scanning should be performed automatically or after clicking the Scan Button.
3131
/// - scanButtonEnabled: Indicates if scanning has already been set on.
32-
init(_ scanResult: Binding<String>, _ scanThroughButton: Bool, _ scanButtonEnabled: Binding<Bool>) {
32+
init(_ scanResult: Binding<String>, _ scanThroughButton: Bool, _ scanButtonEnabled: Bool = false) {
3333
self._scanResult = scanResult
3434
self.scanThroughButton = scanThroughButton
35-
self._scanButtonEnabled = scanButtonEnabled
35+
self.scanButtonEnabled = scanButtonEnabled
3636
super.init()
3737

3838
NotificationCenter.default
@@ -44,6 +44,16 @@ final class OSBARCScannerViewControllerCoordinator: NSObject, AVCaptureVideoData
4444
}
4545
}
4646
.store(in: &cancellables)
47+
48+
NotificationCenter.default
49+
.publisher(for: .scanButtonSelection)
50+
.receive(on: RunLoop.main) // receive this on the main thread
51+
.sink { // performed this when `scanButtonSelection` gets triggered.
52+
if let enabled = $0.object as? Bool {
53+
self.scanButtonEnabled = enabled
54+
}
55+
}
56+
.store(in: &cancellables)
4757
}
4858

4959
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
@@ -75,8 +85,8 @@ final class OSBARCScannerViewControllerCoordinator: NSObject, AVCaptureVideoData
7585
}()
7686
}
7787

78-
// MARK: - Private coordinator methods
79-
private extension OSBARCScannerViewControllerCoordinator {
88+
// MARK: - Private methods
89+
private extension OSBARCCaptureOutputDecoder {
8090
/// Processes the Vision request to return the desired barcode value.
8191
/// - Parameter request: Vision request handler that performs image analysis.
8292
func processClassification(for request: VNRequest) {

0 commit comments

Comments
 (0)