Skip to content

Commit 74e55cb

Browse files
feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice (SAP#1011)
* feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice * feat: 🎸 [HCPSDKFIORIUIKIT-2847]AI Notice --------- Co-authored-by: I824136 <xiaoqing.he@sap.com>
1 parent 6c49cbd commit 74e55cb

22 files changed

+955
-106
lines changed

Apps/Examples/Examples/FioriSwiftUICore/BannerMessage/BannerMessageCustomInitExample.swift

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,46 @@ struct BannerMessageCustomInitExample: View {
1010
@State var show: Bool = true
1111
@State var isCustomStyle: Bool = false
1212
@State var headerSelection: BannerHeader = .object
13-
13+
@State var showAINotice: Bool = false
14+
1415
let customColor = Color.preferredColor(.blue7)
1516

1617
var bannerView: some View {
17-
BannerMessage {
18-
Image(systemName: "info.circle")
19-
} title: {
20-
Text("This is a banner message")
21-
} closeAction: {
18+
BannerMessage(icon: {
19+
if self.showAINotice {
20+
Image(fioriName: "fiori.ai")
21+
} else {
22+
Image(systemName: "info.circle")
23+
}
24+
}, title: {
25+
if self.showAINotice {
26+
Text("Powered by AI")
27+
} else {
28+
Text("This is a banner message")
29+
}
30+
}, closeAction: {
2231
Button(action: {
2332
withAnimation {
2433
self.show.toggle()
2534
}
2635
}, label: {
2736
Image(systemName: "xmark")
2837
})
29-
}
30-
.ifApply(self.isCustomStyle, content: { v in
31-
v.topDividerStyle { c in
32-
c.topDivider.background(self.customColor)
33-
}
34-
.iconStyle { c in
35-
c.icon.foregroundStyle(self.customColor)
36-
}
37-
.titleStyle { c in
38-
c.title.foregroundStyle(self.customColor)
39-
}
40-
.closeActionStyle { c in
41-
c.closeAction.foregroundStyle(self.customColor)
42-
}
43-
})
38+
}, messageType: self.showAINotice ? .aiNotice : .negative)
39+
.ifApply(self.isCustomStyle, content: { v in
40+
v.topDividerStyle { c in
41+
c.topDivider.background(self.customColor)
42+
}
43+
.iconStyle { c in
44+
c.icon.foregroundStyle(self.customColor)
45+
}
46+
.titleStyle { c in
47+
c.title.foregroundStyle(self.customColor)
48+
}
49+
.closeActionStyle { c in
50+
c.closeAction.foregroundStyle(self.customColor)
51+
}
52+
})
4453
}
4554

4655
var body: some View {
@@ -71,6 +80,8 @@ struct BannerMessageCustomInitExample: View {
7180
Text("Object Header").tag(BannerHeader.object)
7281
Text("KPI Header").tag(BannerHeader.kpi)
7382
}
83+
84+
Toggle("AI Notice", isOn: self.$showAINotice)
7485
} header: {}
7586
}.listStyle(.plain)
7687
.navigationTitle("Custom Creation")

Apps/Examples/Examples/FioriSwiftUICore/BannerMessage/BannerMessageModifierExample.swift

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,40 @@ struct BannerMessageModifierExample: View {
77
@State var withLink: Bool = false
88
@State var withAttachedAction: Bool = false
99
@State var withLongText: Bool = false
10+
@State var showAINotice: Bool = false
11+
@State var showBottomSheet: Bool = false
1012

1113
@ViewBuilder
1214
var titleView: some View {
13-
if self.withAttachedAction {
14-
HStack {
15-
Spacer()
16-
self.messageContent
17-
Button(action: {
18-
print("Custom button tapped in title")
19-
}, label: {
20-
Text("Action")
21-
.foregroundStyle(Color.preferredColor(.tintColor))
22-
})
23-
Spacer()
15+
let text = self.withLongText ? "This is a very very very very very very very very very very very long banner message. " : "This is a banner message. "
16+
let noticeText = self.withLongText ? "Generated by AI. This is a very very very very very very very very very very very long banner message. " : "Generated by AI. "
17+
18+
if self.showAINotice {
19+
if self.withLink {
20+
Text("\(noticeText) with [link](https://www.sap.com)")
21+
} else if self.withAttachedAction {
22+
Text("\(noticeText)") + Text("View more").foregroundStyle(Color.preferredColor(.tintColor)).font(.fiori(forTextStyle: .footnote))
23+
} else {
24+
Text("\(noticeText)")
2425
}
2526
} else {
26-
self.messageContent
27-
}
28-
}
29-
30-
@ViewBuilder
31-
var messageContent: some View {
32-
let text = self.withLongText ? "This is a very very very very very very very very very very very long banner message" : "This is a banner message"
33-
if self.withLink {
34-
Text("\(text) with [link](https://www.sap.com)")
35-
} else {
36-
Text("\(text)")
27+
if self.withLink {
28+
Text("\(text) with [link](https://www.sap.com)")
29+
} else if self.withAttachedAction {
30+
HStack {
31+
Spacer()
32+
Text("\(text)")
33+
Button(action: {
34+
print("Custom button tapped in title")
35+
}, label: {
36+
Text("Action")
37+
.foregroundStyle(Color.preferredColor(.tintColor))
38+
})
39+
Spacer()
40+
}
41+
} else {
42+
Text("\(text)")
43+
}
3744
}
3845
}
3946

@@ -54,17 +61,37 @@ struct BannerMessageModifierExample: View {
5461
Toggle("With Link", isOn: self.$withLink)
5562
Toggle("With Attached Action", isOn: self.$withAttachedAction)
5663
Toggle("Long Text", isOn: self.$withLongText)
64+
Toggle("AI Notice", isOn: self.$showAINotice)
5765
}
5866
.bannerMessageView(isPresented: self.$show,
5967
pushContentDown: self.$pushContentDown,
6068
icon: {
61-
Image(systemName: "info.circle")
69+
if self.showAINotice {
70+
Image(fioriName: "fiori.ai")
71+
} else {
72+
Image(systemName: "info.circle")
73+
}
6274
},
6375
title: {
6476
self.titleView
6577
}, bannerTapped: {
66-
print("banner is tapped")
67-
})
78+
self.withAttachedAction && self.showAINotice ? self.toggleShowSheet() : print("banner is tapped")
79+
},
80+
messageType: self.showAINotice ? .aiNotice : .negative)
6881
.navigationTitle("Banner Message")
82+
.sheet(isPresented: self.$showBottomSheet) {
83+
Text("detail information")
84+
.presentationDetents([.height(250), .medium])
85+
.presentationDragIndicator(.visible)
86+
}
87+
}
88+
89+
func openURL() {
90+
let url = URL(string: "https://sap.com")!
91+
UIApplication.shared.open(url)
92+
}
93+
94+
func toggleShowSheet() {
95+
self.showBottomSheet.toggle()
6996
}
7097
}

0 commit comments

Comments
 (0)