Skip to content

Commit

Permalink
Utilities readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
borut-t committed May 20, 2024
1 parent 5aa24d4 commit 122c290
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Resources/Utilities/AttributedStringBuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ We've shown how we can configure a couple of attributed parameters, like color,
The methods shown through examples above are actually just convenience methods calling generic `addAttribute(key: NSAttributedString.Key, object: Any?)` method. We can use this method instead to configure any other attributes we'd like.

## Source code
You can find source code [here](/Sources/Core/Utilities/AttributedStringBuilder).
You can find source code [here](/Sources/Utilities/AttributedStringBuilder).
2 changes: 1 addition & 1 deletion Resources/Utilities/Broadcast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class ViewController: UIViewController, AppEventObserver {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/Broadcast/Broadcast.swift).
You can find source code [here](/Sources/Utilities/Broadcast/Broadcast.swift).
86 changes: 86 additions & 0 deletions Resources/Utilities/Camera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Camera

A UI component that simplifies handling with camera. `PhotoCamera` & `QRCodeScanner`.

## Usage

### PhotoCamera Example:
```swift
let camera = PhotoCamera()
func prepareCamera() {
do {
try await camera.prepare()
} catch {
// error handling
}

// add previewLayer to any view
view.layer.addSublayer(camera.previewLayer)
camera.previewLayer.frame = self.view.bounds

// set camera delegate
camera.delegate = self

// request authorization status
let granted = await camera.requestAuthorizationStatus()

switch granted {
case true:
self.camera.startSession()
case false:
// handle denied status
break
}
}
```
#### Photo Camera functions
`func takePhoto()`

We can also switch from front facing to back camera:

`func changeCamera(position: CameraPosition)`


#### Photo Camera delegate

`func photoCamera(photoCamera: PhotoCamera, didTakePhoto image: UIImage)`

`func photoCamera(photoCamera: PhotoCamera, didTriggerError error: Camera.Error)`

### QRCodeScanner Example:
```swift
let scanner = QRCodeScanner()
func prepareQRCodeSCanner() {
do {
try await camera.prepare()
} catch {
// error handling
}

// add previewLayer to any view
view.layer.addSublayer(scanner.previewLayer)
scanner.previewLayer.frame = self.view.bounds

// set camera delegate
scanner.delegate = self

// request authorization status
let granted = await scanner.requestAuthorizationStatus()

switch granted {
case true:
self.scanner.startSession()
case false:
// handle denied status
break
}
}
```

#### QRCodeScanner delegate
`func codeScanned(code: String, boundingRect: CGRect)`

`func scanFailure()`

## Source code
You can find source code [here](/Sources/Utilities/Camera).
2 changes: 1 addition & 1 deletion Resources/Utilities/ColorInterpolator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ try? colorInterpolator.interpolate(colorPoints: colors, percentage: percentage)
```

## Source code
You can find source code [here](/Sources/Core/Utilities/ColorInterpolator/ColorInterpolator.swift).
You can find source code [here](/Sources/Utilities/ColorInterpolator/ColorInterpolator.swift).
2 changes: 1 addition & 1 deletion Resources/Utilities/Delegated/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ class Controller: UIViewController, UITableViewDataSource {
https://medium.com/anysuggestion/preventing-memory-leaks-with-swift-compile-time-safety-49b845df4dc6

## Source code
You can find source code [here](/Sources/Core/Utilities/Delegated/Delegated.swift).
You can find source code [here](/Sources/Utilities/Delegated/Delegated.swift).
2 changes: 1 addition & 1 deletion Resources/Utilities/DispatchTimer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ myTimer.stop() // you could eventually just nillify reference and the timer is t
```

## Source code
You can find source code [here](/Sources/Core/Utilities/DispatchTimer/DispatchTimer.swift).
You can find source code [here](/Sources/Utilities/DispatchTimer/DispatchTimer.swift).
2 changes: 1 addition & 1 deletion Resources/Utilities/Exif/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ do {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/Exif/Exif.swift).
You can find source code [here](/Sources/Utilities/Exif/Exif.swift).
2 changes: 1 addition & 1 deletion Resources/Utilities/InAppPurchase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ Task {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/InAppPurchase).
You can find source code [here](/Sources/Utilities/InAppPurchase).
2 changes: 1 addition & 1 deletion Resources/Utilities/Money/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ print(money2 < money3) // true
```

## Source code
You can find source code [here](/Sources/Core/Utilities/Money).
You can find source code [here](/Sources/Utilities/Money).
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ extension UserDefault {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/PropertyWrapper/UserDefault.swift).
You can find source code [here](/Sources/Utilities/PropertyWrapper/UserDefault.swift).
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ enum Environment {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/PropertyWrapper/XCConfigValue.swift).
You can find source code [here](/Sources/Utilities/PropertyWrapper/XCConfigValue.swift).
2 changes: 1 addition & 1 deletion Resources/Utilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Core package including utility tools.
| [AttributedStringBuilder](AttributedStringBuilder) |
| [Broadcast](Broadcast) |
| [BundleReader](/Sources/Utilities/BundleReader/BundleReader.swift) |
| [Camera](/Sources/Utilities/Camera) |
| [Camera](Camera) |
| [ColorInterpolator](ColorInterpolator) |
| [Delegated](Delegated) |
| [DispatchTimer](DispatchTimer) |
Expand Down
2 changes: 1 addition & 1 deletion Resources/Utilities/StartupService/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ public final class FacebookSetupProcess: StartupProcess {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/StartupService).
You can find source code [here](/Sources/Utilities/StartupService).
2 changes: 1 addition & 1 deletion Resources/Utilities/Throttler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class SearchWorker {
```

## Source code
You can find source code [here](/Sources/Core/Utilities/Throttler/Throttler.swift).
You can find source code [here](/Sources/Utilities/Throttler/Throttler.swift).

0 comments on commit 122c290

Please sign in to comment.