omnivore/apple/OmnivoreKit/Sources/Views/TextFields/TextFieldStyles.swift

38 lines
958 B
Swift
Raw Permalink Normal View History

2022-02-11 17:24:33 +00:00
import SwiftUI
public struct StandardTextFieldStyle: TextFieldStyle {
2022-06-14 20:37:07 +00:00
let textColor: Color?
public init(textColor: Color = .appGrayText) {
self.textColor = textColor
}
2022-02-11 17:24:33 +00:00
// swiftlint:disable:next identifier_name
public func _body(configuration: TextField<_Label>) -> some View {
2022-02-11 17:24:33 +00:00
configuration
.textFieldStyle(PlainTextFieldStyle())
.multilineTextAlignment(.leading)
2022-06-14 20:37:07 +00:00
.foregroundColor(textColor)
2022-02-11 17:24:33 +00:00
.font(.appBody)
.padding(.vertical, 12)
.padding(.horizontal, 16)
.background(border)
}
public var border: some View {
2022-06-14 20:37:07 +00:00
RoundedRectangle(cornerRadius: 8)
2022-02-11 17:24:33 +00:00
.strokeBorder(Color.appGrayBorder, lineWidth: 1)
2022-06-14 20:37:07 +00:00
.background(RoundedRectangle(cornerRadius: 8).fill(Color.systemBackground))
2022-02-11 17:24:33 +00:00
}
}
#if os(macOS)
extension NSTextField {
override open var focusRingType: NSFocusRingType {
get { .none }
// swiftlint:disable:next unused_setter_value
set {}
}
}
#endif