Skip to content

Commit 3aa1509

Browse files
fix: 🐛 [IOSSDKBUG-811] Tag component adjustment (SAP#1169)
* fix: 🐛 [IOSSDKBUG-811] Tag component adjustment Adjust the tag's fiori style with a filled background color in gray as default. Add a new outlined style with a border and clear background color. * fix: 🐛 [IOSSDKBUG-811] Tag component adjustment Adjust the example code --------- Co-authored-by: dyongxu <[email protected]>
1 parent d57f01b commit 3aa1509

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

Apps/Examples/Examples/FioriSwiftUICore/ObjectHeader/ObjectHeaderTestApp.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ struct ObjectHeaderTestApp: View {
2222
}, subtitle: {
2323
Text("Job 819701")
2424
}, tags: {
25-
Tag("I am selected")
25+
Tag("Tag custom style")
2626
.tagStyle(MyCustomTagStyle())
27-
Tag("Tag1")
28-
Tag("Tag2")
27+
Tag("Tag default style .filled")
28+
Tag("Tag .outlined style")
29+
.tagStyle(.outlined)
2930
}, bodyText: {
3031
Text("1000-Hamburg, MECHANIK")
3132
}, footnote: {

Sources/FioriSwiftUICore/_FioriStyles/TagStyle.fiori.swift

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,26 @@ public struct TagBaseStyle: TagStyle {
77
@ViewBuilder
88
public func makeBody(_ configuration: TagConfiguration) -> some View {
99
configuration.tag
10-
.padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3))
10+
.padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4))
1111
}
1212
}
1313

1414
// Default fiori styles
1515
public struct TagFioriStyle: TagStyle {
1616
@Environment(\.tagLimit) var tagLimit
17-
@Environment(\.colorScheme) var colorScheme
18-
@Environment(\.isLoading) var isLoading
17+
@Environment(\.tagStyle) var tagStyle
1918
@ViewBuilder
2019
public func makeBody(_ configuration: TagConfiguration) -> some View {
21-
let isLight = self.colorScheme == .light
22-
let background = isLight ? RoundedRectangle(cornerRadius: 8).stroke(Color.preferredColor(.quaternaryLabel), lineWidth: 0.5).typeErased : RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.tertiaryLabel)).typeErased
23-
2420
Tag(configuration)
2521
.font(.fiori(forTextStyle: .footnote))
26-
.foregroundStyle(self.getTextColor(configuration: configuration))
22+
.foregroundStyle(Color.preferredColor(.accentLabel10))
2723
.lineLimit(self.tagLimit)
28-
.background(background)
29-
.ifApply(self.isLoading) {
30-
$0.foregroundStyle(Color.preferredColor(.separator))
31-
}
32-
}
33-
34-
func getTextColor(configuration: TagConfiguration) -> Color {
35-
let isLight = self.colorScheme == .light
36-
if self.isLoading {
37-
return Color.preferredColor(.separator)
38-
} else {
39-
return isLight ? Color.preferredColor(.secondaryLabel) : Color.preferredColor(.primaryLabel, background: .darkConstant)
40-
}
24+
.ifApply(!(self.tagStyle is OutlinedTagStyle), content: {
25+
$0.background(
26+
RoundedRectangle(cornerRadius: 8)
27+
.fill(Color.preferredColor(.accentBackground10))
28+
)
29+
})
4130
}
4231
}
4332

@@ -87,6 +76,27 @@ public struct DarkTagStyle: TagStyle {
8776
}
8877
}
8978

79+
public struct OutlinedTagStyle: TagStyle {
80+
/// :nodoc:
81+
public init() {}
82+
public func makeBody(_ configuration: TagConfiguration) -> some View {
83+
Tag(configuration)
84+
.foregroundStyle(Color.preferredColor(.secondaryLabel))
85+
.background(
86+
RoundedRectangle(cornerRadius: 8)
87+
.stroke(Color.preferredColor(.tertiaryLabel), lineWidth: 0.5)
88+
)
89+
}
90+
}
91+
92+
/// :nodoc:
93+
public extension TagStyle where Self == OutlinedTagStyle {
94+
/// Outlined tag style
95+
static var outlined: OutlinedTagStyle {
96+
OutlinedTagStyle()
97+
}
98+
}
99+
90100
@available(*, deprecated, message: "Use `tagStyle(_ style: some TagStyle)` or `tagStyle(@ViewBuilder content: @escaping (TagConfiguration) -> some View)` to customize the style. We will remove this in the future.")
91101
/// :nodoc:
92102
public struct CustomTagStyle: TagStyle {

0 commit comments

Comments
 (0)