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 2258d6f91..be33dc275 100644 --- a/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift +++ b/Sources/FioriSwiftUICore/Models/ModelDefinitions.swift @@ -105,7 +105,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 {} @@ -182,7 +186,7 @@ public protocol ContactItemModel {} // 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 } @@ -200,7 +204,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/CompositeComponentProtocols.swift b/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift index aae356dd8..9b7e62adb 100755 --- a/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift +++ b/Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift @@ -789,6 +789,14 @@ protocol _ActivityItemComponent: _IconComponent, _SubtitleComponent { // sourcery: CompositeComponent protocol _ContactItemComponent: _TitleComponent, _SubtitleComponent, _DescriptionComponent, _DetailImageComponent, _ActivityItemsComponent {} +// 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 new file mode 100644 index 000000000..6bc14b86b --- /dev/null +++ b/Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift @@ -0,0 +1,26 @@ +import FioriThemeManager +import Foundation +import SwiftUI + +// Base Layout style +public struct TextInputBaseStyle: TextInputStyle { + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + // Add default layout here + TextField("Default", + text: configuration.$textInputValue, + onCommit: configuration.onCommit ?? {}) + } +} + +// Default fiori styles +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/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..ba3fffb28 --- /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, + 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(TextInputFioriStyle.ContentFioriStyle()) + .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..8e1f3293c --- /dev/null +++ b/Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift @@ -0,0 +1,33 @@ +// 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)? +} + +public struct TextInputFioriStyle: TextInputStyle { + public func makeBody(_ configuration: TextInputConfiguration) -> some View { + TextInput(configuration) + } +} diff --git a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift index 60cca4170..847468107 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ComponentStyleProtocol+Extension.generated.swift @@ -6471,6 +6471,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 4215364d0..1df59f5ad 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/EnvironmentVariables.generated.swift @@ -2586,6 +2586,27 @@ extension EnvironmentValues { } } +// MARK: TextInputStyle + +struct TextInputStyleStackKey: EnvironmentKey { + static let defaultValue: [any TextInputStyle] = [] +} + +extension EnvironmentValues { + var textInputStyle: any TextInputStyle { + self.textInputStyleStack.last ?? .base.concat(.fiori) + } + + 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 d27198f4e..f3d01adea 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ModifiedStyle.generated.swift @@ -3452,6 +3452,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 d9fc0e697..49764c01a 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ResolvedStyle.generated.swift @@ -1971,6 +1971,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 d6e345fd7..900f10186 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/View+Extension_.generated.swift @@ -2094,6 +2094,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 070c83cc1..ce4f6c471 100755 --- a/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/SupportingFiles/ViewEmptyChecking+Extension.generated.swift @@ -900,6 +900,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/OptionListPickerItem+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/OptionListPickerItem+API.generated.swift index fb5d116d0..2b9d7b204 100644 --- a/Sources/FioriSwiftUICore/_generated/ViewModels/API/OptionListPickerItem+API.generated.swift +++ b/Sources/FioriSwiftUICore/_generated/ViewModels/API/OptionListPickerItem+API.generated.swift @@ -10,9 +10,9 @@ public struct OptionListPickerItem { var _hint: String? = nil var _itemLayout: OptionListPickerItemLayoutType var _onTap: ((_ index: Int) -> 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/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/_ObjectHeader+API.generated.swift b/Sources/FioriSwiftUICore/_generated/ViewModels/API/_ObjectHeader+API.generated.swift index 2ace83e45..6808b32c9 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 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 d3be5cf23..832818fae 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",