You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
5.4 KiB
124 lines
5.4 KiB
import SwiftUI
|
|
|
|
// MARK: - 数据类型选择界面
|
|
struct CodeTypeSelectionView: View {
|
|
@State private var selectedDataType: DataType = .qrcode
|
|
@State private var selectedBarcodeType: BarcodeType = .ean13
|
|
@State private var selectedQRCodeType: QRCodeType = .text
|
|
|
|
var body: some View {
|
|
VStack(spacing: 30) {
|
|
// 数据类型选择
|
|
VStack(spacing: 20) {
|
|
|
|
HStack(spacing: 0) {
|
|
ForEach(DataType.allCases, id: \.self) { type in
|
|
Button(action: {
|
|
selectedDataType = type
|
|
// 添加触觉反馈
|
|
let impactFeedback = UIImpactFeedbackGenerator(style: .light)
|
|
impactFeedback.impactOccurred()
|
|
}) {
|
|
HStack(spacing: 6) {
|
|
Image(systemName: type.icon)
|
|
.font(.system(size: 16, weight: .medium))
|
|
.foregroundColor(selectedDataType == type ? .white : .primary)
|
|
|
|
Text(type.displayName)
|
|
.font(.system(size: 15, weight: .medium))
|
|
.foregroundColor(selectedDataType == type ? .white : .primary)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical, 12)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(selectedDataType == type ? Color.blue : Color(.systemGray6))
|
|
)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
}
|
|
}
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(Color(.systemGray6))
|
|
)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.stroke(Color(.systemGray4), lineWidth: 0.5)
|
|
)
|
|
}
|
|
.padding(.horizontal, 20)
|
|
|
|
// 具体类型选择
|
|
VStack(spacing: 20) {
|
|
if selectedDataType == .barcode {
|
|
VStack(spacing: 12) {
|
|
|
|
Picker("barcode_type".localized, selection: $selectedBarcodeType) {
|
|
ForEach(BarcodeType.allCases, id: \.self) { type in
|
|
HStack {
|
|
Image(systemName: type.icon)
|
|
Text(type.displayName)
|
|
}
|
|
.tag(type)
|
|
}
|
|
}
|
|
.pickerStyle(WheelPickerStyle())
|
|
}
|
|
} else {
|
|
VStack(spacing: 12) {
|
|
Picker("qrcode_type".localized, selection: $selectedQRCodeType) {
|
|
ForEach(QRCodeType.allCases, id: \.self) { type in
|
|
HStack {
|
|
Image(systemName: type.icon)
|
|
Text(type.displayName)
|
|
}
|
|
.tag(type)
|
|
}
|
|
}
|
|
.pickerStyle(WheelPickerStyle())
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, 20)
|
|
|
|
Spacer()
|
|
|
|
// 下一步按钮
|
|
NavigationLink(
|
|
destination: selectedDataType == .qrcode ?
|
|
AnyView(CreateQRCodeView(selectedQRCodeType: selectedQRCodeType)) :
|
|
AnyView(CreateCodeView(
|
|
selectedDataType: selectedDataType,
|
|
selectedBarcodeType: selectedBarcodeType,
|
|
selectedQRCodeType: selectedQRCodeType
|
|
))
|
|
) {
|
|
HStack(spacing: 8) {
|
|
Text("next".localized)
|
|
.font(.system(size: 18, weight: .semibold))
|
|
.foregroundColor(.white)
|
|
|
|
Image(systemName: "arrow.right")
|
|
.font(.system(size: 16, weight: .medium))
|
|
.foregroundColor(.white)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical, 16)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 12)
|
|
.fill(Color.blue)
|
|
)
|
|
}
|
|
.padding(.horizontal, 20)
|
|
.padding(.bottom, 30)
|
|
}
|
|
.navigationTitle("select_type".localized)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
CodeTypeSelectionView()
|
|
}
|