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.

111 lines
3.8 KiB

import SwiftUI
// MARK: - Location Input Component
struct LocationInputView: View {
@Binding var latitude: String
@Binding var longitude: String
@Binding var locationName: String
@FocusState var focusedField: LocationField?
// Location field enum
enum LocationField: Hashable {
case latitude, longitude, locationName
}
var body: some View {
VStack(spacing: 16) {
// Location name
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("location_name".localized)
.font(.subheadline)
.foregroundColor(.primary)
Spacer()
}
TextField("location_name_placeholder".localized, text: $locationName)
.textFieldStyle(RoundedBorderTextFieldStyle())
.focused($focusedField, equals: .locationName)
}
// Coordinate input
HStack(spacing: 12) {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("latitude".localized)
.font(.subheadline)
.foregroundColor(.primary)
Text("*")
.foregroundColor(.red)
Spacer()
}
TextField("latitude_placeholder".localized, text: $latitude)
.textFieldStyle(RoundedBorderTextFieldStyle())
.keyboardType(.decimalPad)
.focused($focusedField, equals: .latitude)
}
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("longitude".localized)
.font(.subheadline)
.foregroundColor(.primary)
Text("*")
.foregroundColor(.red)
Spacer()
}
TextField("longitude_placeholder".localized, text: $longitude)
.textFieldStyle(RoundedBorderTextFieldStyle())
.keyboardType(.decimalPad)
.focused($focusedField, equals: .longitude)
}
}
// Coordinate format instructions
VStack(alignment: .leading, spacing: 8) {
HStack {
Image(systemName: "info.circle")
.font(.caption)
.foregroundColor(.blue)
Text("coordinate_format_help".localized)
.font(.caption)
.foregroundColor(.primary)
Spacer()
}
Text("coordinate_format_details".localized)
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(nil)
}
.padding(.horizontal, 12)
.padding(.vertical, 8)
.background(
RoundedRectangle(cornerRadius: 8)
.fill(Color.blue.opacity(0.1))
)
}
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button("done".localized) {
focusedField = nil
}
.foregroundColor(.blue)
.font(.system(size: 16, weight: .medium))
}
}
}
}
#Preview {
LocationInputView(
latitude: .constant(""),
longitude: .constant(""),
locationName: .constant("")
)
}