damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 8b020e2bd60eaeb902726eadea44b095e0c2ac4b
parent ad614f3e42b71db00f7983cbf0da4018a515dcb8
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 27 Aug 2024 14:24:33 +0300

Merge 'Fix broken QR code scanner'

Terry Yiu (1):
      Fix broken QR code scanner and fix landscape mode

Diffstat:
Mdamus/Views/CodeScanner/ScannerViewController.swift | 34+++++++++++++++-------------------
Mdamus/Views/QRCodeView.swift | 19++++++++++---------
2 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/damus/Views/CodeScanner/ScannerViewController.swift b/damus/Views/CodeScanner/ScannerViewController.swift @@ -182,25 +182,6 @@ extension CodeScannerView { delegate?.didFail(reason: .badOutput) return } - } - - override public func viewWillLayoutSubviews() { - previewLayer?.frame = view.layer.bounds - } - - @objc func updateOrientation() { - guard let orientation = view.window?.windowScene?.interfaceOrientation else { return } - guard let connection = captureSession.connections.last, connection.isVideoOrientationSupported else { return } - connection.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue) ?? .portrait - } - - override public func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - updateOrientation() - } - - override public func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) if previewLayer == nil { previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) @@ -220,6 +201,21 @@ extension CodeScannerView { } } + override public func viewWillLayoutSubviews() { + previewLayer?.frame = view.layer.bounds + } + + @objc func updateOrientation() { + guard let orientation = view.window?.windowScene?.interfaceOrientation else { return } + guard let connection = captureSession.connections.last, connection.isVideoOrientationSupported else { return } + connection.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue) ?? .portrait + } + + override public func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + updateOrientation() + } + private func addviewfinder() { guard showViewfinder, let imageView = viewFinder else { return } diff --git a/damus/Views/QRCodeView.swift b/damus/Views/QRCodeView.swift @@ -126,11 +126,11 @@ struct QRCodeView: View { if our_profile?.picture != nil { ProfilePicView(pubkey: pubkey, size: 90.0, highlight: .custom(DamusColors.white, 3.0), profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation) - .padding(.top, 50) + .padding(.top, 20) } else { Image(systemName: "person.fill") .font(.system(size: 60)) - .padding(.top, 50) + .padding(.top, 20) } if let display_name = profile?.display_name { @@ -150,17 +150,18 @@ struct QRCodeView: View { .interpolation(.none) .resizable() .scaledToFit() - .frame(width: 300, height: 300) + .frame(minWidth: 100, maxWidth: 300, minHeight: 100, maxHeight: 300) .cornerRadius(10) .overlay(RoundedRectangle(cornerRadius: 10) - .stroke(DamusColors.white, lineWidth: 5.0)) + .stroke(DamusColors.white, lineWidth: 5.0) + .scaledToFit()) .shadow(radius: 10) Spacer() Text("Follow me on Nostr", comment: "Text on QR code view to prompt viewer looking at screen to follow the user.") .font(.system(size: 24, weight: .heavy)) - .padding(.top) + .padding(.top, 10) .foregroundColor(.white) Text("Scan the code", comment: "Text on QR code view to prompt viewer to scan the QR code on screen with their device camera.") @@ -179,7 +180,7 @@ struct QRCodeView: View { .frame(minWidth: 300, maxWidth: .infinity, maxHeight: 12, alignment: .center) } .buttonStyle(GradientButtonStyle()) - .padding(50) + .padding(20) } } @@ -201,11 +202,11 @@ struct QRCodeView: View { } } .scaledToFit() - .frame(width: 300, height: 300) + .frame(maxWidth: 300, maxHeight: 300) .cornerRadius(10) - .overlay(RoundedRectangle(cornerRadius: 10).stroke(DamusColors.white, lineWidth: 5.0)) + .overlay(RoundedRectangle(cornerRadius: 10).stroke(DamusColors.white, lineWidth: 5.0).scaledToFit()) .overlay(RoundedRectangle(cornerRadius: 10).trim(from: 0.0, to: outerTrimEnd).stroke(DamusColors.black, lineWidth: 5.5) - .rotationEffect(.degrees(-90))) + .rotationEffect(.degrees(-90)).scaledToFit()) .shadow(radius: 10) Spacer()