Files
damus/damus/Shared/Components/QRScanNSECView.swift
ericholguin 65a22813a3 refactor: Adding structure
Huge refactor to add better structure to the project.
Separating features with their associated view and model structure.
This should be better organization and will allow us to improve the
overall architecture in the future.

I forsee many more improvements that can follow this change. e.g. MVVM Arch
As well as cleaning up duplicate, unused, functionality.
Many files have global functions that can also be moved or be renamed.

damus/
├── Features/
│   ├── <Feature>/
│   │   ├── Views/
│   │   └── Models/
├── Shared/
│   ├── Components/
│   ├── Media/
│   ├── Buttons/
│   ├── Extensions/
│   ├── Empty Views/
│   ├── ErrorHandling/
│   ├── Modifiers/
│   └── Utilities/
├── Core/
│   ├── Nostr/
│   ├── NIPs/
│   ├── DIPs/
│   ├── Types/
│   ├── Networking/
│   └── Storage/

Signed-off-by: ericholguin <ericholguin@apache.org>
2025-08-06 10:24:00 -07:00

71 lines
2.3 KiB
Swift

//
// QRScanNSECView.swift
// damus
//
// Created by Jericho Hasselbush on 9/29/23.
//
import CodeScanner
import SwiftUI
import VisionKit
struct QRScanNSECView: View {
@Binding var showQR: Bool
@Binding var privKeyFound: Bool
var codeScannerCompletion: (Result<ScanResult, ScanError>) -> Void
var body: some View {
ZStack {
ZStack {
DamusGradient()
}
VStack {
Text("Scan Your Private Key QR",
comment: "Text to prompt scanning a QR code of a user's privkey to login to their profile.")
.padding(.top, 50)
.font(.system(size: 24, weight: .heavy))
Spacer()
CodeScannerView(codeTypes: [.qr],
scanMode: .continuous,
scanInterval: 2.0,
showViewfinder: false,
simulatedData: "",
shouldVibrateOnSuccess: false,
isTorchOn: false,
isGalleryPresented: .constant(false),
videoCaptureDevice: .default(for: .video),
completion: codeScannerCompletion)
.scaledToFit()
.frame(width: 300, height: 300)
.cornerRadius(10)
.overlay(RoundedRectangle(cornerRadius: 10).stroke(DamusColors.white, lineWidth: 5.0))
.shadow(radius: 10)
Button(action: { showQR = false }) {
VStack {
Image(systemName: privKeyFound ? "sparkle.magnifyingglass" : "magnifyingglass")
.font(privKeyFound ? .title : .title3)
}}
.padding(.top)
.buttonStyle(GradientButtonStyle())
Spacer()
Spacer()
}
}
}
}
struct QRScanNSECView_Previews: PreviewProvider {
@State static var showQR = true
@State static var privKeyFound = false
@State static var shouldSaveKey = true
static var previews: some View {
QRScanNSECView(showQR: $showQR,
privKeyFound: $privKeyFound,
codeScannerCompletion: { _ in })
}
}