From 746d28f248aee265f24e189f9732b03dd65479e0 Mon Sep 17 00:00:00 2001 From: Hengyi Zhang Date: Tue, 7 Jan 2025 17:49:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20[JIRA:HCPSDKFIOR?= =?UTF-8?q?IUIKIT-2882]=20TextInput=20Refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/ActivationScreenSample.swift | 4 +- .../Onboarding/WelcomeScreenSample.swift | 4 +- .../Components/MultiPropertyComponents.swift | 2 +- .../Models/ModelDefinitions.swift | 10 ++- .../Views/TextInput+View.swift | 4 +- .../BaseComponentProtocols.swift | 9 +++ .../_FioriStyles/TextInputStyle.fiori.swift | 38 ++++++++++++ .../Component+Protocols.generated.swift | 14 ++--- .../EnvironmentKey+Styles.generated.swift | 6 +- .../EnvironmentValue+Styles.generated.swift | 20 +++--- .../TextInput/TextInput.generated.swift | 62 +++++++++++++++++++ .../TextInput/TextInputStyle.generated.swift | 27 ++++++++ ...entStyleProtocol+Extension.generated.swift | 14 +++++ .../EnvironmentVariables.generated.swift | 21 +++++++ .../ModifiedStyle.generated.swift | 28 +++++++++ .../ResolvedStyle.generated.swift | 16 +++++ .../View+Extension_.generated.swift | 17 +++++ ...iewEmptyChecking+Extension.generated.swift | 6 ++ .../API/ActivationScreen+API.generated.swift | 6 +- .../API/ObjectHeader+API.generated.swift | 2 +- .../OptionListPickerItem+API.generated.swift | 2 +- .../SearchListPickerItem+API.generated.swift | 18 +++--- .../SearchableListView+API.generated.swift | 2 +- .../SignatureCaptureView+API.generated.swift | 40 ++++++------ .../API/UserConsentView+API.generated.swift | 2 +- .../API/WelcomeScreen+API.generated.swift | 6 +- .../API/_SingleStep+API.generated.swift | 10 +-- ..._StepProgressIndicator+API.generated.swift | 4 +- ...d.swift => _TextInput+API.generated.swift} | 4 +- ....swift => _TextInput+View.generated.swift} | 14 ++--- ...tionScreenModel+Extensions.generated.swift | 2 +- ...comeScreenModel+Extensions.generated.swift | 2 +- .../.lib/Sources/utils/Type+Extensions.swift | 1 + 33 files changed, 330 insertions(+), 87 deletions(-) create mode 100644 Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift create mode 100644 Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift create mode 100644 Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift rename Sources/FioriSwiftUICore/_generated/ViewModels/API/{TextInput+API.generated.swift => _TextInput+API.generated.swift} (89%) rename Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/{TextInput+View.generated.swift => _TextInput+View.generated.swift} (68%) diff --git a/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/ActivationScreenSample.swift b/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/ActivationScreenSample.swift index eda53ef57..1a6a028e3 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/ActivationScreenSample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/ActivationScreenSample.swift @@ -4,7 +4,7 @@ import SwiftUI class ActivationScreenDataModel: ActivationScreenModel, ObservableObject { // Changes in nested observable object will not trigger refresh. Need to send notification by explicitly calling `send()` - @Published var textInput: TextInputModel? + @Published var textInput: _TextInputModel? lazy var action: _ActionModel? = ActionDataModel { [unowned self] in print("ActivationScreen Primary button clicked, email: \(self.textInput!.textInputValue)") } @@ -31,7 +31,7 @@ class ActivationScreenDataModel: ActivationScreenModel, ObservableObject { } extension ActivationScreenDataModel { - class TextInputDataModel: TextInputModel, ObservableObject { + class TextInputDataModel: _TextInputModel, ObservableObject { @Published var textInputValue: String = "" var onCommit: (() -> Void)? = { diff --git a/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/WelcomeScreenSample.swift b/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/WelcomeScreenSample.swift index c65a428f3..aa0dcde4c 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/WelcomeScreenSample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/Onboarding/WelcomeScreenSample.swift @@ -4,7 +4,7 @@ import SwiftUI class WelcomeScreenDataModel: WelcomeScreenModel, ObservableObject { // Changes in nested observable object will not trigger refresh. Need to send notification by explicitly calling `send()` - @Published var textInput: TextInputModel? + @Published var textInput: _TextInputModel? lazy var action: _ActionModel? = ActionDataModel { [unowned self] in print("Primary button clicked: \(self.textInput!.textInputValue)") } @@ -33,7 +33,7 @@ class WelcomeScreenDataModel: WelcomeScreenModel, ObservableObject { } extension WelcomeScreenDataModel { - class TextInputDataModel: TextInputModel, ObservableObject { + class TextInputDataModel: _TextInputModel, ObservableObject { @Published var textInputValue: String = "" var onCommit: (() -> Void)? = { diff --git a/Sources/FioriSwiftUICore/Components/MultiPropertyComponents.swift b/Sources/FioriSwiftUICore/Components/MultiPropertyComponents.swift index b99e2d495..a4e5eb39c 100644 --- a/Sources/FioriSwiftUICore/Components/MultiPropertyComponents.swift +++ b/Sources/FioriSwiftUICore/Components/MultiPropertyComponents.swift @@ -16,7 +16,7 @@ protocol __Action: _ComponentMultiPropGenerating { var didSelectAction_: (() -> Void)? { get } } -protocol _TextInput: _ComponentMultiPropGenerating, AnyObject { +protocol __TextInput: _ComponentMultiPropGenerating, AnyObject { // sourcery: bindingPropertyOptional = .constant("") var textInputValue_: String { get set } // sourcery: no_view diff --git a/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift b/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift index 3425864be..c78840018 100644 --- a/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift +++ b/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift @@ -94,7 +94,11 @@ public protocol _ActionModel: ActionComponent {} public protocol ActionModel: ActionComponent {} // sourcery: generated_component_not_configurable -public protocol TextInputModel: TextInputComponent {} +public protocol _TextInputModel: TextInputComponent {} + +/// Deprecated TextInputModel +@available(*, unavailable, renamed: "_TextInputModel", message: "Will be removed in the future release. Please create TextInput with other initializers instead.") +public protocol TextInputModel {} // sourcery: generated_component public protocol _ActivityItemModel: IconComponent, SubtitleComponent {} @@ -167,7 +171,7 @@ public protocol ContactItemModel: TitleComponent, SubtitleComponent, Description // sourcery: generated_component_composite public protocol WelcomeScreenModel: TitleComponent, DescriptionTextComponent, SubtitleComponent, FootnoteComponent, IconComponent { // sourcery: genericParameter.name = TextInputView - var textInput: TextInputModel? { get } + var textInput: _TextInputModel? { get } // sourcery: genericParameter.name = ActionView var action: _ActionModel? { get } @@ -185,7 +189,7 @@ public protocol ActivationScreenModel: TitleComponent, DescriptionTextComponent, var secondaryAction: _ActionModel? { get } // sourcery: genericParameter.name = TextInputView - var textInput: TextInputModel? { get } + var textInput: _TextInputModel? { get } } // sourcery: generated_component_composite diff --git a/Sources/FioriSwiftUICore/Views/TextInput+View.swift b/Sources/FioriSwiftUICore/Views/TextInput+View.swift index 7d5b6545f..eb3fc5249 100644 --- a/Sources/FioriSwiftUICore/Views/TextInput+View.swift +++ b/Sources/FioriSwiftUICore/Views/TextInput+View.swift @@ -6,13 +6,13 @@ import SwiftUI extension Fiori { - enum TextInput { + enum _TextInput { typealias TextInputValue = EmptyModifier static let textInputValue = TextInputValue() } } -extension TextInput: View { +extension _TextInput: View { public var body: some View { TextField("Default", text: self._textInputValue, diff --git a/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift b/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift index 970c7cd4c..335e09eca 100755 --- a/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift +++ b/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift @@ -484,6 +484,15 @@ protocol _ActivityItemsComponent { var activityItems: [ActivityItemDataType] { get } } +// sourcery: BaseComponent +protocol _TextInputComponent { + // sourcery: @Binding + // sourcery: defaultValue = ".constant("")" + var textInputValue: String { get } + // sourcery: no_view + var onCommit: (() -> Void)? { get } +} + // sourcery: BaseComponent protocol _LowerThumbComponent { // sourcery: @ViewBuilder diff --git a/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift new file mode 100644 index 000000000..ce64b964b --- /dev/null +++ b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift @@ -0,0 +1,38 @@ +import FioriThemeManager + +// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery +// DO NOT EDIT +import Foundation +import SwiftUI + +/** + This file provides default fiori style for the component. + + 1. Uncomment the following code. + 2. Implement layout and style in corresponding places. + 3. Delete `.generated` from file name. + 4. Move this file to `_FioriStyles` folder under `FioriSwiftUICore`. + */ + +// Base Layout style +public struct TextInputBaseStyle: TextInputStyle { + @ViewBuilder + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + // Add default layout here + TextField("Default", + text: configuration.$textInputValue, + onCommit: configuration.onCommit ?? {}) + } +} + +// Default fiori styles +public struct TextInputFioriStyle: TextInputStyle { + @ViewBuilder + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + TextInput(configuration) + .modifier(TextFieldClearButton(textValue: configuration.$textInputValue)) + .textFieldStyle(BottomTextFieldStyle()) + .font(.fiori(forTextStyle: .body)) + .foregroundColor(.preferredColor(.primaryLabel)) + } +} diff --git a/Sources/FioriSwiftUICore/_generated/Components/Component+Protocols.generated.swift b/Sources/FioriSwiftUICore/_generated/Components/Component+Protocols.generated.swift index 8a1f253fd..d66c03b9a 100644 --- a/Sources/FioriSwiftUICore/_generated/Components/Component+Protocols.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/Components/Component+Protocols.generated.swift @@ -237,13 +237,6 @@ public protocol SwitchPickerComponent : AnyObject { var hint: String? { get } } -public protocol TextInputComponent : AnyObject { - // sourcery: bindingPropertyOptional=.constant("") - var textInputValue: String { get set } - // sourcery: no_view - var onCommit: (() -> Void)? { get } -} - public protocol ActionComponent { var actionText: String? { get } // sourcery: no_view @@ -253,3 +246,10 @@ public protocol ActionComponent { public protocol ProgressIndicatorComponent { var progressIndicatorText: String? { get } } + +public protocol TextInputComponent : AnyObject { + // sourcery: bindingPropertyOptional=.constant("") + var textInputValue: String { get set } + // sourcery: no_view + var onCommit: (() -> Void)? { get } +} diff --git a/Sources/FioriSwiftUICore/_generated/Components/EnvironmentKey+Styles.generated.swift b/Sources/FioriSwiftUICore/_generated/Components/EnvironmentKey+Styles.generated.swift index 794134bda..b53a68fea 100644 --- a/Sources/FioriSwiftUICore/_generated/Components/EnvironmentKey+Styles.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/Components/EnvironmentKey+Styles.generated.swift @@ -158,15 +158,15 @@ struct ActionItemsModifierKey: EnvironmentKey { public static let defaultValue = AnyViewModifier { $0 } } -struct TextInputValueModifierKey: EnvironmentKey { +struct ActionTextModifierKey: EnvironmentKey { public static let defaultValue = AnyViewModifier { $0 } } -struct ActionTextModifierKey: EnvironmentKey { +struct ProgressIndicatorTextModifierKey: EnvironmentKey { public static let defaultValue = AnyViewModifier { $0 } } -struct ProgressIndicatorTextModifierKey: EnvironmentKey { +struct TextInputValueModifierKey: EnvironmentKey { public static let defaultValue = AnyViewModifier { $0 } } diff --git a/Sources/FioriSwiftUICore/_generated/Components/EnvironmentValue+Styles.generated.swift b/Sources/FioriSwiftUICore/_generated/Components/EnvironmentValue+Styles.generated.swift index c4c286b6c..545f058c7 100644 --- a/Sources/FioriSwiftUICore/_generated/Components/EnvironmentValue+Styles.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/Components/EnvironmentValue+Styles.generated.swift @@ -199,11 +199,6 @@ extension EnvironmentValues { set { self[ActionItemsModifierKey.self] = newValue } } - public var textInputValueModifier: AnyViewModifier { - get { return self[TextInputValueModifierKey.self] } - set { self[TextInputValueModifierKey.self] = newValue } - } - public var actionTextModifier: AnyViewModifier { get { return self[ActionTextModifierKey.self] } set { self[ActionTextModifierKey.self] = newValue } @@ -214,6 +209,11 @@ extension EnvironmentValues { set { self[ProgressIndicatorTextModifierKey.self] = newValue } } + public var textInputValueModifier: AnyViewModifier { + get { return self[TextInputValueModifierKey.self] } + set { self[TextInputValueModifierKey.self] = newValue } + } + public var actionModifier: AnyViewModifier { get { return self[ActionModifierKey.self] } set { self[ActionModifierKey.self] = newValue } @@ -498,11 +498,6 @@ public extension View { self.environment(\.actionItemsModifier, AnyViewModifier(transform)) } - @ViewBuilder - func textInputValueModifier(_ transform: @escaping (AnyViewModifier.Content) -> V) -> some View { - self.environment(\.textInputValueModifier, AnyViewModifier(transform)) - } - @ViewBuilder func actionTextModifier(_ transform: @escaping (AnyViewModifier.Content) -> V) -> some View { self.environment(\.actionTextModifier, AnyViewModifier(transform)) @@ -513,6 +508,11 @@ public extension View { self.environment(\.progressIndicatorTextModifier, AnyViewModifier(transform)) } + @ViewBuilder + func textInputValueModifier(_ transform: @escaping (AnyViewModifier.Content) -> V) -> some View { + self.environment(\.textInputValueModifier, AnyViewModifier(transform)) + } + @ViewBuilder func actionModifier(_ transform: @escaping (AnyViewModifier.Content) -> V) -> some View { self.environment(\.actionModifier, AnyViewModifier(transform)) diff --git a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift new file mode 100644 index 000000000..ddcabb5ef --- /dev/null +++ b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift @@ -0,0 +1,62 @@ +// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery +// DO NOT EDIT +import Foundation +import SwiftUI + +public struct TextInput { + @Binding var textInputValue: String + let onCommit: (() -> Void)? + + @Environment(\.textInputStyle) var style + + fileprivate var _shouldApplyDefaultStyle = true + + public init(textInputValue: Binding = .constant(""), + onCommit: (() -> Void)? = nil) + { + self._textInputValue = textInputValue + self.onCommit = onCommit + } +} + +public extension TextInput { + init(_ configuration: TextInputConfiguration) { + self.init(configuration, shouldApplyDefaultStyle: false) + } + + internal init(_ configuration: TextInputConfiguration, shouldApplyDefaultStyle: Bool) { + self._textInputValue = configuration.$textInputValue + self.onCommit = configuration.onCommit + self._shouldApplyDefaultStyle = shouldApplyDefaultStyle + } +} + +extension TextInput: View { + public var body: some View { + if self._shouldApplyDefaultStyle { + self.defaultStyle() + } else { + self.style.resolve(configuration: .init(textInputValue: self.$textInputValue, onCommit: self.onCommit)).typeErased + .transformEnvironment(\.textInputStyleStack) { stack in + if !stack.isEmpty { + stack.removeLast() + } + } + } + } +} + +private extension TextInput { + func shouldApplyDefaultStyle(_ bool: Bool) -> some View { + var s = self + s._shouldApplyDefaultStyle = bool + return s + } + + func defaultStyle() -> some View { + TextInput(.init(textInputValue: self.$textInputValue, onCommit: self.onCommit)) + .shouldApplyDefaultStyle(false) + .textInputStyle(.fiori) + .typeErased + } +} diff --git a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift new file mode 100644 index 000000000..bbb363d20 --- /dev/null +++ b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift @@ -0,0 +1,27 @@ +// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery +// DO NOT EDIT +import Foundation +import SwiftUI + +public protocol TextInputStyle: DynamicProperty { + associatedtype Body: View + + func makeBody(_ configuration: TextInputConfiguration) -> Body +} + +struct AnyTextInputStyle: TextInputStyle { + let content: (TextInputConfiguration) -> any View + + init(@ViewBuilder _ content: @escaping (TextInputConfiguration) -> any View) { + self.content = content + } + + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + self.content(configuration).typeErased + } +} + +public struct TextInputConfiguration { + @Binding public var textInputValue: String + public let onCommit: (() -> Void)? +} diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift index 2608ab812..9ac93dab2 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift @@ -5694,6 +5694,20 @@ public extension TextFieldFormViewStyle where Self == TextFieldFormViewTitleForm } } +// MARK: TextInputStyle + +public extension TextInputStyle where Self == TextInputBaseStyle { + static var base: TextInputBaseStyle { + TextInputBaseStyle() + } +} + +public extension TextInputStyle where Self == TextInputFioriStyle { + static var fiori: TextInputFioriStyle { + TextInputFioriStyle() + } +} + // MARK: TextInputFieldStyle public extension TextInputFieldStyle where Self == TextInputFieldBaseStyle { diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift index ff5545d8a..0f7c59ff5 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift @@ -2334,6 +2334,27 @@ extension EnvironmentValues { } } +// MARK: TextInputStyle + +struct TextInputStyleStackKey: EnvironmentKey { + static let defaultValue: [any TextInputStyle] = [] +} + +extension EnvironmentValues { + var textInputStyle: any TextInputStyle { + self.textInputStyleStack.last ?? .base + } + + var textInputStyleStack: [any TextInputStyle] { + get { + self[TextInputStyleStackKey.self] + } + set { + self[TextInputStyleStackKey.self] = newValue + } + } +} + // MARK: TextInputFieldStyle struct TextInputFieldStyleStackKey: EnvironmentKey { diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift index f58bda029..b8e6d370f 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift @@ -3116,6 +3116,34 @@ public extension TextFieldFormViewStyle { } } +// MARK: TextInputStyle + +extension ModifiedStyle: TextInputStyle where Style: TextInputStyle { + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + TextInput(configuration) + .textInputStyle(self.style) + .modifier(self.modifier) + } +} + +public struct TextInputStyleModifier: ViewModifier { + let style: Style + + public func body(content: Content) -> some View { + content.textInputStyle(self.style) + } +} + +public extension TextInputStyle { + func modifier(_ modifier: some ViewModifier) -> some TextInputStyle { + ModifiedStyle(style: self, modifier: modifier) + } + + func concat(_ style: some TextInputStyle) -> some TextInputStyle { + style.modifier(TextInputStyleModifier(style: self)) + } +} + // MARK: TextInputFieldStyle extension ModifiedStyle: TextInputFieldStyle where Style: TextInputFieldStyle { diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift index 3322c05d3..25263d384 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift @@ -1779,6 +1779,22 @@ extension TextFieldFormViewStyle { } } +// MARK: TextInputStyle + +struct ResolvedTextInputStyle: View { + let style: Style + let configuration: TextInputConfiguration + var body: some View { + self.style.makeBody(self.configuration) + } +} + +extension TextInputStyle { + func resolve(configuration: TextInputConfiguration) -> some View { + ResolvedTextInputStyle(style: self, configuration: configuration) + } +} + // MARK: TextInputFieldStyle struct ResolvedTextInputFieldStyle: View { diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift index c096b8477..541655a33 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift @@ -1890,6 +1890,23 @@ public extension View { } } +// MARK: TextInputStyle + +public extension View { + func textInputStyle(_ style: some TextInputStyle) -> some View { + self.transformEnvironment(\.textInputStyleStack) { stack in + stack.append(style) + } + } + + func textInputStyle(@ViewBuilder content: @escaping (TextInputConfiguration) -> some View) -> some View { + self.transformEnvironment(\.textInputStyleStack) { stack in + let style = AnyTextInputStyle(content) + stack.append(style) + } + } +} + // MARK: TextInputFieldStyle public extension View { diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift index 804ae14d6..5c77c728c 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift @@ -804,6 +804,12 @@ extension TextFieldFormView: _ViewEmptyChecking { } } +extension TextInput: _ViewEmptyChecking { + public var isEmpty: Bool { + false + } +} + extension TextInputField: _ViewEmptyChecking { public var isEmpty: Bool { false diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/ActivationScreen+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/ActivationScreen+API.generated.swift index 648ef4125..20dc728a9 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/ActivationScreen+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/ActivationScreen+API.generated.swift @@ -110,13 +110,13 @@ extension ActivationScreen where Title == Text, Footnote == _ConditionalContent, ActionView == _ConditionalContent<_Action, EmptyView>, SecondaryActionView == _ConditionalContent<_Action, EmptyView>, - TextInputView == _ConditionalContent { + TextInputView == _ConditionalContent<_TextInput, EmptyView> { public init(model: ActivationScreenModel) { - self.init(title: model.title, descriptionText: model.descriptionText, footnote: model.footnote, action: model.action != nil ? _Action(model: model.action!) : nil, secondaryAction: model.secondaryAction != nil ? _Action(model: model.secondaryAction!) : nil, textInput: model.textInput != nil ? TextInput(model: model.textInput!) : nil) + self.init(title: model.title, descriptionText: model.descriptionText, footnote: model.footnote, action: model.action != nil ? _Action(model: model.action!) : nil, secondaryAction: model.secondaryAction != nil ? _Action(model: model.secondaryAction!) : nil, textInput: model.textInput != nil ? _TextInput(model: model.textInput!) : nil) } - public init(title: String, descriptionText: String? = nil, footnote: String? = nil, action: _Action? = nil, secondaryAction: _Action? = nil, textInput: TextInput? = nil) { + public init(title: String, descriptionText: String? = nil, footnote: String? = nil, action: _Action? = nil, secondaryAction: _Action? = nil, textInput: _TextInput? = nil) { self._title = Text(title) self._descriptionText = descriptionText != nil ? ViewBuilder.buildEither(first: Text(descriptionText!)) : ViewBuilder.buildEither(second: EmptyView()) self._footnote = footnote != nil ? ViewBuilder.buildEither(first: Text(footnote!)) : ViewBuilder.buildEither(second: EmptyView()) diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/ObjectHeader+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/ObjectHeader+API.generated.swift index b0ec5d0ee..72c4ba555 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/ObjectHeader+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/ObjectHeader+API.generated.swift @@ -26,11 +26,11 @@ public struct ObjectHeader Void)? = nil - var updateSearchListPickerHeight: ((CGFloat) -> ())? = nil @State var _height: CGFloat = 0 var barItemFrame: CGRect = .zero + var updateSearchListPickerHeight: ((CGFloat) -> ())? = nil public init(model: OptionListPickerItemModel) { self.init(value: Binding<[Int]>(get: { model.value }, set: { model.value = $0 }), valueOptions: model.valueOptions, hint: model.hint, itemLayout: model.itemLayout, onTap: model.onTap) } diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchListPickerItem+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchListPickerItem+API.generated.swift index c77b1bfac..3c5211d71 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchListPickerItem+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchListPickerItem+API.generated.swift @@ -9,19 +9,19 @@ public struct SearchListPickerItem { var _valueOptions: [String] var _hint: String? = nil var _onTap: ((_ index: Int) -> Void)? = nil - var allowsMultipleSelection: Bool = false - var isSearchBarHidden: Bool = false + var disableListEntriesSection: Bool = false var selectAll: ((Bool) -> ())? = nil - @State var _keyboardHeight: CGFloat = 0.0 - var updateSearchListPickerHeight: ((CGFloat) -> ())? = nil @State var _searchText: String = "" - var allowsEmptySelection: Bool = false - var barItemFrame: CGRect = .zero - var disableListEntriesSection: Bool = false - let popoverWidth = 393.0 - @State var _searchViewCornerRadius: CGFloat = 18 var allowsDisplaySelectionCount: Bool = true + var barItemFrame: CGRect = .zero + var allowsMultipleSelection: Bool = false + var allowsEmptySelection: Bool = false + var updateSearchListPickerHeight: ((CGFloat) -> ())? = nil @State var _height: CGFloat = 44 + @State var _searchViewCornerRadius: CGFloat = 18 + var isSearchBarHidden: Bool = false + let popoverWidth = 393.0 + @State var _keyboardHeight: CGFloat = 0.0 public init(model: SearchListPickerItemModel) { self.init(value: Binding<[Int]>(get: { model.value }, set: { model.value = $0 }), valueOptions: model.valueOptions, hint: model.hint, onTap: model.onTap) } diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchableListView+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchableListView+API.generated.swift index cb2fea01a..6a16d441d 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchableListView+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SearchableListView+API.generated.swift @@ -13,8 +13,8 @@ public struct SearchableListView { let _cancelAction: CancelActionView let _doneAction: DoneActionView var isTopLevel: Bool = true - var dataHandler: (() -> ())? = nil var contentView: AnyView? = nil + var dataHandler: (() -> ())? = nil private var isModelInit: Bool = false private var isCancelActionNil: Bool = false diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift index 6a28f756e..3426b2795 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/SignatureCaptureView+API.generated.swift @@ -20,35 +20,35 @@ public struct SignatureCaptureView Void)? let _onDelete: (() -> Void)? - var addsTimestampInImage: Bool = false - var watermarkTextColor: Color = .preferredColor(.tertiaryLabel) - var watermarkText: String? var signatureLineColor = Color.preferredColor(.quaternaryLabel) - var watermarkTextAlignment: NSTextAlignment = .natural - var drawingViewBackgroundColor = Color.preferredColor(.primaryBackground) @State var isReenterTapped = false - var cropsImage = false - var strokeColor = Color.preferredColor(.primaryLabel) - var hidesSignatureLine = false + var strokeWidth: CGFloat = 3.0 + var timestampFormatter: DateFormatter? + var watermarkTextFont: UIFont = .preferredFont(forTextStyle: .caption1) var _drawingViewMaxHeight: CGFloat? + var titleFont = Font.fiori(forTextStyle: .subheadline).weight(.semibold) + var drawingViewBackgroundColor = Color.preferredColor(.primaryBackground) + var appliesTintColorToImage = true @State var fullSignatureImage: UIImage? - var indicatorColor = Color.preferredColor(.primaryLabel) - let _drawingViewMinHeight: CGFloat = 256 - @State var isEditing = false + var indicatorFont = Font.fiori(forTextStyle: .subheadline).weight(.semibold) + var strokeColor = Color.preferredColor(.primaryLabel) + var xmarkColor = Color.preferredColor(.quaternaryLabel) var titleColor = Color.preferredColor(.primaryLabel) + var watermarkTextColor: Color = .preferredColor(.tertiaryLabel) var isRequired = false - @State var drawings = [Drawing]() - var timestampFormatter: DateFormatter? - var watermarkTextFont: UIFont = .preferredFont(forTextStyle: .caption1) - var appliesTintColorToImage = true - var titleFont = Font.fiori(forTextStyle: .subheadline).weight(.semibold) @State var currentDrawing = Drawing() + var watermarkText: String? + var addsTimestampInImage: Bool = false + var cropsImage = false + var watermarkTextAlignment: NSTextAlignment = .natural + let _drawingViewMinHeight: CGFloat = 256 + @State var drawings = [Drawing]() + @State var isEditing = false + var indicatorColor = Color.preferredColor(.primaryLabel) + var hidesSignatureLine = false @State var isSaved = false - var xmarkColor = Color.preferredColor(.quaternaryLabel) - var hidesXmark = false - var indicatorFont = Font.fiori(forTextStyle: .subheadline).weight(.semibold) public private(set) var _heightDidChangePublisher = CurrentValueSubject(0) - var strokeWidth: CGFloat = 3.0 + var hidesXmark = false private var isModelInit: Bool = false private var isTitleNil: Bool = false diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/UserConsentView+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/UserConsentView+API.generated.swift index 54eff7dbf..9ec153cdf 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/UserConsentView+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/UserConsentView+API.generated.swift @@ -10,8 +10,8 @@ public struct UserConsentView { let _didDeny: ((Int, Bool) -> Void)? let _didCancel: ((Int) -> Void)? let _didFinish: (([Int]) -> Void)? - @State var _allowedFormIndexes: [Int] = [] @State var _formIndex = 0 + @State var _allowedFormIndexes: [Int] = [] private var isModelInit: Bool = false private var isDidAllowNil: Bool = false diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/WelcomeScreen+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/WelcomeScreen+API.generated.swift index d8ac1f26f..422f75a23 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/WelcomeScreen+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/WelcomeScreen+API.generated.swift @@ -143,15 +143,15 @@ extension WelcomeScreen where Title == Text, Subtitle == _ConditionalContent, Footnote == _ConditionalContent, Icon == _ConditionalContent, - TextInputView == _ConditionalContent, + TextInputView == _ConditionalContent<_TextInput, EmptyView>, ActionView == _ConditionalContent<_Action, EmptyView>, SecondaryActionView == _ConditionalContent<_Action, EmptyView> { public init(model: WelcomeScreenModel) { - self.init(title: model.title, descriptionText: model.descriptionText, subtitle: model.subtitle, footnote: model.footnote, icon: model.icon, textInput: model.textInput != nil ? TextInput(model: model.textInput!) : nil, action: model.action != nil ? _Action(model: model.action!) : nil, secondaryAction: model.secondaryAction != nil ? _Action(model: model.secondaryAction!) : nil) + self.init(title: model.title, descriptionText: model.descriptionText, subtitle: model.subtitle, footnote: model.footnote, icon: model.icon, textInput: model.textInput != nil ? _TextInput(model: model.textInput!) : nil, action: model.action != nil ? _Action(model: model.action!) : nil, secondaryAction: model.secondaryAction != nil ? _Action(model: model.secondaryAction!) : nil) } - public init(title: String, descriptionText: String? = nil, subtitle: String? = nil, footnote: String? = nil, icon: Image? = nil, textInput: TextInput? = nil, action: _Action? = nil, secondaryAction: _Action? = nil) { + public init(title: String, descriptionText: String? = nil, subtitle: String? = nil, footnote: String? = nil, icon: Image? = nil, textInput: _TextInput? = nil, action: _Action? = nil, secondaryAction: _Action? = nil) { self._title = Text(title) self._descriptionText = descriptionText != nil ? ViewBuilder.buildEither(first: Text(descriptionText!)) : ViewBuilder.buildEither(second: EmptyView()) self._subtitle = subtitle != nil ? ViewBuilder.buildEither(first: Text(subtitle!)) : ViewBuilder.buildEither(second: EmptyView()) diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/API/_SingleStep+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/_SingleStep+API.generated.swift index 0a7ea30d7..26c2fab16 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/_SingleStep+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/_SingleStep+API.generated.swift @@ -14,14 +14,14 @@ public struct _SingleStep var _onCommit: (() -> Void)? = nil - public init(model: TextInputModel) { + public init(model: _TextInputModel) { self.init(textInputValue: Binding(get: { model.textInputValue }, set: { model.textInputValue = $0 }), onCommit: model.onCommit) } diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/TextInput+View.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/_TextInput+View.generated.swift similarity index 68% rename from Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/TextInput+View.generated.swift rename to Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/_TextInput+View.generated.swift index 3461ffae9..9655c5b81 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/TextInput+View.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/Boilerplate/_TextInput+View.generated.swift @@ -1,7 +1,7 @@ // Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT -//TODO: Copy commented code to new file: `FioriSwiftUICore/Views/TextInput+View.swift` -//TODO: Implement TextInput `View` body +//TODO: Copy commented code to new file: `FioriSwiftUICore/Views/_TextInput+View.swift` +//TODO: Implement _TextInput `View` body /// - Important: to make `@Environment` properties (e.g. `horizontalSizeClass`), internally accessible /// to extensions, add as sourcery annotation in `FioriSwiftUICore/Models/ModelDefinitions.swift` @@ -13,21 +13,21 @@ import SwiftUI // FIXME: - Implement Fiori style definitions -// FIXME: - Implement TextInput View body +// FIXME: - Implement _TextInput View body -extension TextInput: View { +extension _TextInput: View { public var body: some View { <# View body #> } } -// FIXME: - Implement TextInput specific LibraryContentProvider +// FIXME: - Implement _TextInput specific LibraryContentProvider @available(iOS 14.0, macOS 11.0, *) -struct TextInputLibraryContent: LibraryContentProvider { +struct _TextInputLibraryContent: LibraryContentProvider { @LibraryContentBuilder var views: [LibraryItem] { - LibraryItem(TextInput(model: LibraryPreviewData.Person.laurelosborn), + LibraryItem(_TextInput(model: LibraryPreviewData.Person.laurelosborn), category: .control) } } diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/ActivationScreenModel+Extensions.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/ActivationScreenModel+Extensions.generated.swift index 7ff514023..e2f3574d2 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/ActivationScreenModel+Extensions.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/ActivationScreenModel+Extensions.generated.swift @@ -11,7 +11,7 @@ public extension ActivationScreenModel { return nil } - var textInput: TextInputModel? { + var textInput: _TextInputModel? { return nil } } diff --git a/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/WelcomeScreenModel+Extensions.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/WelcomeScreenModel+Extensions.generated.swift index 4fb2b0956..463779159 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/WelcomeScreenModel+Extensions.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/Model+Extensions/WelcomeScreenModel+Extensions.generated.swift @@ -3,7 +3,7 @@ import SwiftUI public extension WelcomeScreenModel { - var textInput: TextInputModel? { + var textInput: _TextInputModel? { return nil } diff --git a/sourcery/.lib/Sources/utils/Type+Extensions.swift b/sourcery/.lib/Sources/utils/Type+Extensions.swift index e6a0dce06..bcde00c3b 100644 --- a/sourcery/.lib/Sources/utils/Type+Extensions.swift +++ b/sourcery/.lib/Sources/utils/Type+Extensions.swift @@ -70,6 +70,7 @@ public extension Type { var name = name let deprecatedComponents = ["_ListPickerItemModel", "_ActionModel", + "_TextInputModel", "_ObjectItemModel", "_SideBarModel", "_SideBarListItemModel", From 87508d755917769078ca1b3e188a5cf5d60aa64b Mon Sep 17 00:00:00 2001 From: Hengyi Zhang Date: Tue, 7 Jan 2025 17:57:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20[JIRA:HCPSDKFIOR?= =?UTF-8?q?IUIKIT-2882]=20TextInput=20Refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_FioriStyles/TextInputStyle.fiori.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift index ce64b964b..89f72b532 100644 --- a/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift +++ b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift @@ -1,19 +1,7 @@ import FioriThemeManager - -// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery -// DO NOT EDIT import Foundation import SwiftUI -/** - This file provides default fiori style for the component. - - 1. Uncomment the following code. - 2. Implement layout and style in corresponding places. - 3. Delete `.generated` from file name. - 4. Move this file to `_FioriStyles` folder under `FioriSwiftUICore`. - */ - // Base Layout style public struct TextInputBaseStyle: TextInputStyle { @ViewBuilder From a5079d19c1047b864517791267bd3df3102ec0a9 Mon Sep 17 00:00:00 2001 From: Hengyi Zhang Date: Tue, 14 Jan 2025 10:51:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20[JIRA:HCPSDKFIOR?= =?UTF-8?q?IUIKIT-2882]=20TextInput=20Refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseComponentProtocols.swift | 9 --------- .../CompositeComponentProtocols.swift | 8 ++++++++ .../_FioriStyles/TextInputStyle.fiori.swift | 18 +++++++++--------- .../TextInput/TextInput.generated.swift | 4 ++-- .../TextInput/TextInputStyle.generated.swift | 6 ++++++ .../EnvironmentVariables.generated.swift | 2 +- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift b/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift index 2bd8aa05d..0279cba74 100755 --- a/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift +++ b/Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift @@ -496,15 +496,6 @@ protocol _ActivityItemsComponent { var activityItems: [ActivityItemDataType] { get } } -// sourcery: BaseComponent -protocol _TextInputComponent { - // sourcery: @Binding - // sourcery: defaultValue = ".constant("")" - var textInputValue: String { get } - // sourcery: no_view - var onCommit: (() -> Void)? { get } -} - // sourcery: BaseComponent protocol _LowerThumbComponent { // sourcery: @ViewBuilder diff --git a/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift b/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift index 005ef1ed4..76b834f1d 100755 --- a/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift +++ b/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift @@ -761,6 +761,14 @@ protocol _ActivityItemComponent: _IconComponent, _SubtitleComponent { var layout: ActivityItemLayout { get } } +// sourcery: CompositeComponent +protocol _TextInputComponent { + // sourcery: @Binding + var textInputValue: String { get } + // sourcery: no_view + var onCommit: (() -> Void)? { get } +} + // sourcery: CompositeComponent protocol _RangeSliderControlComponent: _LowerThumbComponent, _UpperThumbComponent, _ActiveTrackComponent, _InactiveTrackComponent { // sourcery: @Binding diff --git a/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift index 89f72b532..6bc14b86b 100644 --- a/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift +++ b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift @@ -4,7 +4,6 @@ import SwiftUI // Base Layout style public struct TextInputBaseStyle: TextInputStyle { - @ViewBuilder public func makeBody(_ configuration: TextInputConfiguration) -> some View { // Add default layout here TextField("Default", @@ -14,13 +13,14 @@ public struct TextInputBaseStyle: TextInputStyle { } // Default fiori styles -public struct TextInputFioriStyle: TextInputStyle { - @ViewBuilder - public func makeBody(_ configuration: TextInputConfiguration) -> some View { - TextInput(configuration) - .modifier(TextFieldClearButton(textValue: configuration.$textInputValue)) - .textFieldStyle(BottomTextFieldStyle()) - .font(.fiori(forTextStyle: .body)) - .foregroundColor(.preferredColor(.primaryLabel)) +extension TextInputFioriStyle { + struct ContentFioriStyle: TextInputStyle { + func makeBody(_ configuration: TextInputConfiguration) -> some View { + TextInput(configuration) + .modifier(TextFieldClearButton(textValue: configuration.$textInputValue)) + .textFieldStyle(BottomTextFieldStyle()) + .font(.fiori(forTextStyle: .body)) + .foregroundColor(.preferredColor(.primaryLabel)) + } } } diff --git a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift index ddcabb5ef..ba3fffb28 100644 --- a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift @@ -11,7 +11,7 @@ public struct TextInput { fileprivate var _shouldApplyDefaultStyle = true - public init(textInputValue: Binding = .constant(""), + public init(textInputValue: Binding, onCommit: (() -> Void)? = nil) { self._textInputValue = textInputValue @@ -56,7 +56,7 @@ private extension TextInput { func defaultStyle() -> some View { TextInput(.init(textInputValue: self.$textInputValue, onCommit: self.onCommit)) .shouldApplyDefaultStyle(false) - .textInputStyle(.fiori) + .textInputStyle(TextInputFioriStyle.ContentFioriStyle()) .typeErased } } diff --git a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift index bbb363d20..8e1f3293c 100644 --- a/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift @@ -25,3 +25,9 @@ public struct TextInputConfiguration { @Binding public var textInputValue: String public let onCommit: (() -> Void)? } + +public struct TextInputFioriStyle: TextInputStyle { + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + TextInput(configuration) + } +} diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift index 11c0aee6c..56bba7945 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift @@ -2510,7 +2510,7 @@ struct TextInputStyleStackKey: EnvironmentKey { extension EnvironmentValues { var textInputStyle: any TextInputStyle { - self.textInputStyleStack.last ?? .base + self.textInputStyleStack.last ?? .base.concat(.fiori) } var textInputStyleStack: [any TextInputStyle] {