-
Notifications
You must be signed in to change notification settings - Fork 61
[JIRA:HCPSDKFIORIUIKIT-2882] TextInput Deprecated #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
746d28f
refactor: 💡 [JIRA:HCPSDKFIORIUIKIT-2882] TextInput Refactor
hengyi-zhang 0b1dbc7
Merge branch 'main' of https://github.com/SAP/cloud-sdk-ios-fiori int…
hengyi-zhang 87508d7
refactor: 💡 [JIRA:HCPSDKFIORIUIKIT-2882] TextInput Refactor
hengyi-zhang 7b388b4
Merge branch 'main' into feat/textinput-refactor
dyongxu a5079d1
refactor: 💡 [JIRA:HCPSDKFIORIUIKIT-2882] TextInput Refactor
hengyi-zhang eb6c0d8
Merge branch 'main' into feat/textinput-refactor
hengyi-zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Sources/FioriSwiftUICore/_FioriStyles/TextInputStyle.fiori.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Sources/FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInput.generated.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String>, | ||
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 | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../FioriSwiftUICore/_generated/StyleableComponents/TextInput/TextInputStyle.generated.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.