feat(ios): tab tabanlı navigasyon ve okuma durumu takibi ekle

This commit is contained in:
2026-02-11 18:26:17 +03:00
parent 52212f015b
commit 362b9b7d1b
16 changed files with 976 additions and 442 deletions

View File

@@ -4,20 +4,62 @@ import VisionKit
struct BarcodeScannerView: View {
let onScanned: (String) -> Void
@State private var cameraAuthorized = AVCaptureDevice.authorizationStatus(for: .video) == .authorized
var body: some View {
Group {
if DataScannerViewController.isSupported, DataScannerViewController.isAvailable {
DataScannerRepresentable(onScanned: onScanned)
if cameraAuthorized {
if DataScannerViewController.isSupported, DataScannerViewController.isAvailable {
DataScannerRepresentable(onScanned: onScanned)
} else {
AVScannerRepresentable(onScanned: onScanned)
}
} else {
AVScannerRepresentable(onScanned: onScanned)
scannerUnavailableView
}
}
.background(Color.black.opacity(0.85))
.overlay {
RoundedRectangle(cornerRadius: 16)
.stroke(Color.white.opacity(0.75), lineWidth: 2)
}
.accessibilityLabel("ISBN barkod tarayıcı")
.onAppear {
requestCameraPermissionIfNeeded()
}
}
private var scannerUnavailableView: some View {
VStack(spacing: 10) {
Image(systemName: "camera.viewfinder")
.font(.system(size: 30))
.foregroundStyle(.white.opacity(0.9))
Text("Kamera erişimi gerekli")
.font(.headline)
.foregroundStyle(.white)
Text("Barkod taramak için Ayarlar > Gizlilik > Kamera üzerinden izin verin.")
.font(.footnote)
.foregroundStyle(.white.opacity(0.85))
.multilineTextAlignment(.center)
.padding(.horizontal, 12)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
private func requestCameraPermissionIfNeeded() {
let status = AVCaptureDevice.authorizationStatus(for: .video)
switch status {
case .authorized:
cameraAuthorized = true
case .notDetermined:
AVCaptureDevice.requestAccess(for: .video) { granted in
DispatchQueue.main.async {
cameraAuthorized = granted
}
}
default:
cameraAuthorized = false
}
}
}