QRScanNSECView.swift (2288B)
1 // 2 // QRScanNSECView.swift 3 // damus 4 // 5 // Created by Jericho Hasselbush on 9/29/23. 6 // 7 8 import SwiftUI 9 import VisionKit 10 11 struct QRScanNSECView: View { 12 @Binding var showQR: Bool 13 @Binding var privKeyFound: Bool 14 var codeScannerCompletion: (Result<ScanResult, ScanError>) -> Void 15 var body: some View { 16 ZStack { 17 ZStack { 18 DamusGradient() 19 } 20 VStack { 21 Text("Scan Your Private Key QR", 22 comment: "Text to prompt scanning a QR code of a user's privkey to login to their profile.") 23 .padding(.top, 50) 24 .font(.system(size: 24, weight: .heavy)) 25 26 Spacer() 27 CodeScannerView(codeTypes: [.qr], 28 scanMode: .continuous, 29 scanInterval: 2.0, 30 showViewfinder: false, 31 simulatedData: "", 32 shouldVibrateOnSuccess: false, 33 isTorchOn: false, 34 isGalleryPresented: .constant(false), 35 videoCaptureDevice: .default(for: .video), 36 completion: codeScannerCompletion) 37 .scaledToFit() 38 .frame(width: 300, height: 300) 39 .cornerRadius(10) 40 .overlay(RoundedRectangle(cornerRadius: 10).stroke(DamusColors.white, lineWidth: 5.0)) 41 .shadow(radius: 10) 42 43 Button(action: { showQR = false }) { 44 VStack { 45 Image(systemName: privKeyFound ? "sparkle.magnifyingglass" : "magnifyingglass") 46 .font(privKeyFound ? .title : .title3) 47 }} 48 .padding(.top) 49 .buttonStyle(GradientButtonStyle()) 50 51 Spacer() 52 53 Spacer() 54 } 55 } 56 } 57 } 58 59 #Preview { 60 @State var showQR = true 61 @State var privKeyFound = false 62 @State var shouldSaveKey = true 63 return QRScanNSECView(showQR: $showQR, 64 privKeyFound: $privKeyFound, 65 codeScannerCompletion: { _ in }) 66 }