68 lines
1.7 KiB
Swift
68 lines
1.7 KiB
Swift
//
|
|
// TextEntryFieldModel.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 10/3/22.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public enum TextEntryFieldType: String, CaseIterable {
|
|
case text, number, calendar, inlineAction, password, creditCard, tel, date, securityCode
|
|
}
|
|
|
|
public protocol TextEntryFieldModel: EntryFieldModel {
|
|
var type: TextEntryFieldType { get set }
|
|
var showSuccess: Bool { get set }
|
|
var successText: String? { get set }
|
|
}
|
|
|
|
extension TextEntryFieldModel {
|
|
|
|
public var successLabelModel: DefaultLabelModel? {
|
|
var model = DefaultLabelModel()
|
|
model.textPosition = .left
|
|
model.typograpicalStyle = .BodySmall
|
|
model.text = successText
|
|
model.surface = surface
|
|
model.disabled = disabled
|
|
return model
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public struct DefaultTextEntryField: TextEntryFieldModel {
|
|
public var id = UUID()
|
|
public var inputId: String?
|
|
|
|
public var type: TextEntryFieldType = .text
|
|
public var value: AnyHashable?
|
|
public var defaultVaue: AnyHashable?
|
|
public var required: Bool = false
|
|
public var readOnly: Bool = false
|
|
|
|
public var labelText: String?
|
|
|
|
public var helperText: String?
|
|
public var helperTextPlacement: HelperTextPlacement = .bottom
|
|
|
|
public var showError: Bool = false
|
|
public var errorText: String?
|
|
|
|
public var showSuccess: Bool = false
|
|
public var successText: String?
|
|
|
|
public var transparentBackground: Bool = false
|
|
public var width: CGFloat?
|
|
public var maxLength: Int?
|
|
|
|
public var tooltipTitle: String?
|
|
public var tooltipContent: String?
|
|
|
|
public var surface: Surface = .light
|
|
public var disabled: Bool = false
|
|
|
|
public init() { }
|
|
}
|