Skip to content
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

feat: 🎸 [JIRA:0] TextInputInfoView for TextInput #645

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

struct InformationViewExample: View {
var body: some View {
VStack(alignment: .leading) {
List {
Text("Default Fiori style, no icon")
.informationView(description: AttributedString("test message"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ struct TextInputInfoViewExample: View {
Text("Default Fiori style, no icon")
.textInputInfoView(description: AttributedString("test message"), counter: AttributedString("10/100"))

Text("Default Fiori style, no message")
.textInputInfoView(counter: AttributedString("10/100"))

Text("Default Fiori style, no counter")
.textInputInfoView(description: AttributedString("test message"))

Text("Error style")
.textInputInfoView(description: AttributedString("test message, long messag long message long message long message long message long message long message long message"), counter: AttributedString("12/10"))
.textInputInfoViewStyle(.error)
Expand Down Expand Up @@ -45,5 +51,6 @@ struct TextInputInfoViewExample: View {

Spacer()
}
.padding()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ extension InformationViewFioriStyle {
func makeBody(_ configuration: InformationViewConfiguration) -> some View {
InformationView(configuration)
.foregroundColor(.preferredColor(.primaryLabel))
.padding(.leading, 16)
.padding(.trailing, 16)
.padding(.top, 4)
.padding(.bottom, 11)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SwiftUI
// Base Layout style
public struct TextInputInfoViewBaseStyle: TextInputInfoViewStyle {
public func makeBody(_ configuration: TextInputInfoViewConfiguration) -> some View {
GeometryReader { geometry in
GeometryReader { _ in
VStack {
xiaoqinggrace marked this conversation as resolved.
Show resolved Hide resolved
configuration.content
HStack(alignment: .top, spacing: 8) {
Expand All @@ -14,9 +14,6 @@ public struct TextInputInfoViewBaseStyle: TextInputInfoViewStyle {
Spacer()
xiaoqinggrace marked this conversation as resolved.
Show resolved Hide resolved
configuration.counter
}
.frame(width: geometry.size.width - 32)
.padding(.leading, 16)
.padding(.trailing, 16)
.padding(.top, 4)
.padding(.bottom, 11)
}
Expand Down Expand Up @@ -52,7 +49,6 @@ extension TextInputInfoViewFioriStyle {
struct CounterFioriStyle: CounterStyle {
func makeBody(_ configuration: CounterConfiguration) -> some View {
Counter(configuration)
// .foregroundStyle(Color.preferredColor(.primaryLabel))
.font(.fiori(forTextStyle: .footnote))
}
}
Expand All @@ -66,7 +62,7 @@ extension TextInputInfoViewFioriStyle {

public extension View {
/// To show the TextInputInfoView at the bottom of the view. It includes an icon and text. It is used in error handling to show error / warning / informational / success confirmation message.
func textInputInfoView(icon: Image? = nil, description: AttributedString, counter: AttributedString) -> some View {
func textInputInfoView(icon: Image? = nil, description: AttributedString? = nil, counter: AttributedString? = nil) -> some View {
TextInputInfoView(icon: icon, description: description, content: { self }, counter: counter)
}
}
Expand All @@ -89,9 +85,11 @@ public struct TextInputInfoViewErrorStyle: TextInputInfoViewStyle {
.foregroundStyle(Color.preferredColor(.negativeLabel))
})
.counterStyle(content: { counterConfiguration in
counterConfiguration.counter
.foregroundStyle(Color.preferredColor(.negativeLabel))
.font(.fiori(forTextStyle: .footnote))
if !counterConfiguration.counter.isEmpty {
counterConfiguration.counter
.foregroundStyle(Color.preferredColor(.negativeLabel))
.font(.fiori(forTextStyle: .footnote))
}
})
}
}
Expand Down
Loading