|
|
import SwiftUI
|
|
|
|
|
|
// MARK: - 扫描界面覆盖层
|
|
|
struct ScanningOverlayView: View {
|
|
|
let showPreviewPause: Bool
|
|
|
@Binding var selectedStyle: ScanningLineStyle
|
|
|
let detectedCodesCount: Int
|
|
|
|
|
|
var body: some View {
|
|
|
VStack {
|
|
|
Spacer()
|
|
|
|
|
|
// 扫描线组件
|
|
|
if !showPreviewPause {
|
|
|
ScanningLineView(style: selectedStyle)
|
|
|
}
|
|
|
|
|
|
// 提示文本
|
|
|
ScanningInstructionView(
|
|
|
showPreviewPause: showPreviewPause,
|
|
|
detectedCodesCount: detectedCodesCount
|
|
|
)
|
|
|
|
|
|
Spacer()
|
|
|
|
|
|
// 底部按钮区域
|
|
|
ScanningBottomButtonsView(
|
|
|
showPreviewPause: showPreviewPause,
|
|
|
selectedStyle: $selectedStyle
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// MARK: - 扫描指令视图
|
|
|
struct ScanningInstructionView: View {
|
|
|
let showPreviewPause: Bool
|
|
|
let detectedCodesCount: Int
|
|
|
|
|
|
var body: some View {
|
|
|
if showPreviewPause {
|
|
|
VStack(spacing: 8) {
|
|
|
Text("detected_codes".localized)
|
|
|
.foregroundColor(.white)
|
|
|
.font(.headline)
|
|
|
|
|
|
if detectedCodesCount == 1 {
|
|
|
Text("auto_result_1s".localized)
|
|
|
.foregroundColor(.green)
|
|
|
.font(.subheadline)
|
|
|
} else {
|
|
|
Text("select_code_instruction".localized)
|
|
|
.foregroundColor(.white.opacity(0.8))
|
|
|
.font(.subheadline)
|
|
|
}
|
|
|
}
|
|
|
.padding(.top, 20)
|
|
|
} else {
|
|
|
Text("scan_instruction".localized)
|
|
|
.foregroundColor(.white)
|
|
|
.font(.headline)
|
|
|
.padding(.top, 20)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// MARK: - 扫描底部按钮视图
|
|
|
struct ScanningBottomButtonsView: View {
|
|
|
let showPreviewPause: Bool
|
|
|
@Binding var selectedStyle: ScanningLineStyle
|
|
|
|
|
|
var body: some View {
|
|
|
VStack(spacing: 15) {
|
|
|
// 扫描线样式选择器
|
|
|
if !showPreviewPause {
|
|
|
ScanningStyleSelectorView(selectedStyle: $selectedStyle)
|
|
|
}
|
|
|
|
|
|
// 移除关闭按钮,因为现在使用导航返回
|
|
|
}
|
|
|
.padding(.bottom, 50)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// MARK: - 扫描线样式选择器
|
|
|
struct ScanningStyleSelectorView: View {
|
|
|
@Binding var selectedStyle: ScanningLineStyle
|
|
|
|
|
|
var body: some View {
|
|
|
HStack(spacing: 10) {
|
|
|
ForEach(ScanningLineStyle.allCases, id: \.self) { style in
|
|
|
Button(style.localizedName) {
|
|
|
selectedStyle = style
|
|
|
}
|
|
|
.foregroundColor(.white)
|
|
|
.padding(.horizontal, 8)
|
|
|
.padding(.vertical, 4)
|
|
|
.background(selectedStyle == style ? Color.green : Color.gray.opacity(0.6))
|
|
|
.cornerRadius(8)
|
|
|
.font(.caption)
|
|
|
}
|
|
|
}
|
|
|
.padding(.bottom, 10)
|
|
|
}
|
|
|
} |