mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
Login with QR UI components (#6790)
* Display QR button on login screen if HS supports * Create start screen * Add build flag * Connect start screen to the login * QR display screen * Move `LabelledDividerView` into separate file * Show display QR screen on button tap * Add swift concurreny to CameraAccessManager * Introduce `QRLoginServiceProtocol` * Use new service in screens * Introduce scan QR code screen * Remove hardcoded service availability * Remove unnecessary import * Add confirmation screen * Add loading screen * Fix ZXingObjc targets * Add failure screen * Add strings * Various UI tweaks, navigation according to the service state * Fix tests * Add string for invalid QR error * Add QR login service mode
This commit is contained in:
@@ -16,13 +16,17 @@
|
||||
|
||||
import Foundation
|
||||
import ZXingObjC
|
||||
import UIKit
|
||||
|
||||
final class QRCodeGenerator {
|
||||
enum Error: Swift.Error {
|
||||
case cannotCreateImage
|
||||
}
|
||||
|
||||
func generateCode(from data: Data, with size: CGSize) throws -> UIImage {
|
||||
func generateCode(from data: Data,
|
||||
with size: CGSize,
|
||||
onColor: UIColor = .black,
|
||||
offColor: UIColor = .white) throws -> UIImage {
|
||||
let writer = ZXMultiFormatWriter()
|
||||
let endodedString = String(data: data, encoding: .isoLatin1)
|
||||
let scale = UIScreen.main.scale
|
||||
@@ -33,8 +37,10 @@ final class QRCodeGenerator {
|
||||
height: Int32(size.height * scale),
|
||||
hints: ZXEncodeHints()
|
||||
)
|
||||
|
||||
guard let cgImage = ZXImage(matrix: bitMatrix).cgimage else {
|
||||
|
||||
guard let cgImage = ZXImage(matrix: bitMatrix,
|
||||
on: onColor.cgColor,
|
||||
offColor: offColor.cgColor).cgimage else {
|
||||
throw Error.cannotCreateImage
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user