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.

70 lines
1.9 KiB

import SwiftUI
// MARK: - Input Hint Component
struct InputHintView: View {
let hint: String
let icon: String
let color: Color
init(hint: String, icon: String = "info.circle", color: Color = .blue) {
self.hint = hint
self.icon = icon
self.color = color
}
var body: some View {
VStack(spacing: 12) {
HStack {
Image(systemName: icon)
.font(.caption)
.foregroundColor(color)
Text("input_hint".localized)
.font(.caption)
.foregroundColor(.primary)
Spacer()
}
Text(hint)
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(nil)
}
.padding(.horizontal, 12)
.padding(.vertical, 8)
.background(
RoundedRectangle(cornerRadius: 8)
.fill(color.opacity(0.1))
)
}
}
// MARK: - Predefined Hint Styles
extension InputHintView {
static func info(hint: String) -> InputHintView {
InputHintView(hint: hint, icon: "info.circle", color: .blue)
}
static func warning(hint: String) -> InputHintView {
InputHintView(hint: hint, icon: "exclamationmark.triangle", color: .orange)
}
static func success(hint: String) -> InputHintView {
InputHintView(hint: hint, icon: "checkmark.circle", color: .green)
}
static func error(hint: String) -> InputHintView {
InputHintView(hint: hint, icon: "xmark.circle", color: .red)
}
}
#Preview {
VStack(spacing: 16) {
InputHintView.info(hint: "info_hint".localized)
InputHintView.warning(hint: "warning_hint".localized)
InputHintView.success(hint: "success_hint".localized)
InputHintView.error(hint: "error_hint".localized)
}
.padding()
}