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

refactor: 💡 [JIRA:HCPSDKFIORIUIKIT-2880] ActivityItems Refactor #946

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
6D6E866F2C539CDE00EDB6F4 /* InPlaceLoadingFlexibleButtonExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6E866E2C539CDE00EDB6F4 /* InPlaceLoadingFlexibleButtonExample.swift */; };
6D6E86712C53A0D500EDB6F4 /* CardViewWithTwoButtonsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6E86702C53A0D500EDB6F4 /* CardViewWithTwoButtonsExample.swift */; };
6DE3F6A82D0FB9C600A4DAB6 /* ActionItemsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DE3F6A62D0FB9C600A4DAB6 /* ActionItemsExample.swift */; };
6DE3F6AC2D0FFEF100A4DAB6 /* ActivityItemsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DE3F6AB2D0FFEF100A4DAB6 /* ActivityItemsExample.swift */; };
6DEC31F42C463ED50084DD20 /* FioriButtonTestsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC31F32C463ED50084DD20 /* FioriButtonTestsExample.swift */; };
6DEC31F82C47B7850084DD20 /* FioriButtonStyleToggleExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC31F72C47B7850084DD20 /* FioriButtonStyleToggleExample.swift */; };
6DEC31FA2C48B35D0084DD20 /* FioriButtonCustomButtonExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC31F92C48B35D0084DD20 /* FioriButtonCustomButtonExample.swift */; };
Expand Down Expand Up @@ -273,6 +274,7 @@
6D6E866E2C539CDE00EDB6F4 /* InPlaceLoadingFlexibleButtonExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPlaceLoadingFlexibleButtonExample.swift; sourceTree = "<group>"; };
6D6E86702C53A0D500EDB6F4 /* CardViewWithTwoButtonsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardViewWithTwoButtonsExample.swift; sourceTree = "<group>"; };
6DE3F6A62D0FB9C600A4DAB6 /* ActionItemsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionItemsExample.swift; sourceTree = "<group>"; };
6DE3F6AB2D0FFEF100A4DAB6 /* ActivityItemsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityItemsExample.swift; sourceTree = "<group>"; };
6DEC31F32C463ED50084DD20 /* FioriButtonTestsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonTestsExample.swift; sourceTree = "<group>"; };
6DEC31F72C47B7850084DD20 /* FioriButtonStyleToggleExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonStyleToggleExample.swift; sourceTree = "<group>"; };
6DEC31F92C48B35D0084DD20 /* FioriButtonCustomButtonExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonCustomButtonExample.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -580,6 +582,7 @@
6D66D7F02D02FC7B00F7A97D /* ActivityItem */ = {
isa = PBXGroup;
children = (
6DE3F6AB2D0FFEF100A4DAB6 /* ActivityItemsExample.swift */,
6D66D7EF2D02FC7B00F7A97D /* ActivityItemExample.swift */,
);
path = ActivityItem;
Expand Down Expand Up @@ -1292,6 +1295,7 @@
B84D24EF2652F343007F2373 /* ObjectHeaderTestApp.swift in Sources */,
B84D24EC2652F343007F2373 /* ObjectHeaderSpecCompact.swift in Sources */,
8A5579CD24C1293C0098003A /* SettingsLabel.swift in Sources */,
6DE3F6AC2D0FFEF100A4DAB6 /* ActivityItemsExample.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import FioriSwiftUICore
import SwiftUI

struct ActivityItemsExample: View {
var body: some View {
List {
Section {
ActivityItems(actionItems: [
.init(type: .phone, didSelectActivityItem: {
print("click phone")
})
])
ActivityItems(actionItems: [
.init(type: .phone, didSelectActivityItem: {
print("click phone")
}),
.init(type: .email, didSelectActivityItem: {
print("click email")
})
])
ActivityItems(actionItems: [
.init(type: .phone, didSelectActivityItem: {
print("click phone")
}),
.init(type: .email, didSelectActivityItem: {
print("click email")
}),
.init(type: .message, didSelectActivityItem: {
print("click message")
})
])
ActivityItems(actionItems: [
.init(type: .phone, didSelectActivityItem: {
print("click phone")
}),
.init(type: .email, didSelectActivityItem: {
print("click email")
}),
.init(type: .message, didSelectActivityItem: {
print("click message")
}),
.init(type: .videoCall, didSelectActivityItem: {
print("click videoCall")
})
])
ActivityItems(actionItems: [
.init(type: .phone, didSelectActivityItem: {
print("click phone")
}),
.init(type: .email, didSelectActivityItem: {
print("click email")
}),
.init(type: .message, didSelectActivityItem: {
print("click message")
}),
.init(type: .videoCall, didSelectActivityItem: {
print("click videoCall")
}),
.init(type: .detail, didSelectActivityItem: {
print("click detail")
})
])
.actionItemsStyle { conf in
conf.actionItems
.font(.fiori(forTextStyle: .headline).weight(.bold))
.foregroundColor(.red)
}
} header: {
Text("Usual Type")
.textCase(.none)
}

Section {
ActivityItems(actionItems: [
.init(type: .custom(Image(systemName: "person")), didSelectActivityItem: {
print("custom person")
}),
.init(type: .custom(Image(systemName: "heart")), didSelectActivityItem: {
print("custom heart")
}),
.init(type: .custom(Image(systemName: "clock")), didSelectActivityItem: {
print("custom clock")
})
])
} header: {
Text("Custom Type")
.textCase(.none)
}

Section {
ActivityItems {
Button {
print("click person")
} label: {
Image(systemName: "person")
.font(.fiori(forTextStyle: .headline).weight(.heavy))
.imageScale(.large)
.foregroundColor(.red)
.frame(width: 44, height: 44)
}
.buttonStyle(BorderlessButtonStyle())

Button {
print("click heart")
} label: {
Image(systemName: "heart")
.font(.fiori(forTextStyle: .headline).weight(.heavy))
.imageScale(.large)
.foregroundColor(.yellow)
.frame(width: 44, height: 44)
}
.buttonStyle(BorderlessButtonStyle())

Button {
print("click info.circle")
} label: {
Image(systemName: "info.circle")
.font(.fiori(forTextStyle: .headline).weight(.heavy))
.imageScale(.large)
.foregroundColor(.blue)
.frame(width: 44, height: 44)
}
.buttonStyle(BorderlessButtonStyle())

Button {
print("click book")
} label: {
Image(systemName: "book")
.font(.fiori(forTextStyle: .headline).weight(.heavy))
.imageScale(.large)
.foregroundColor(.green)
.frame(width: 44, height: 44)
}
.buttonStyle(BorderlessButtonStyle())
}
} header: {
Text("Custom items")
.textCase(.none)
}
}
.navigationTitle("ActivityItemsExample")
}
}

#Preview {
ActivityItemsExample()
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,43 @@ struct ContactItemCompactExamples: ListDataProtocol {
func cellForRow(_ indexPath: IndexPath) -> AnyView {
switch (indexPath.section, indexPath.row) {
case (0, 0):
let ci = ContactItem(title: "Seann Longname", actionItems: ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Seann Longname", actionItems: _ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))

return AnyView(ci)

case (0, 1):
let ci = ContactItem(title: "Headline example is allowed to wrap two lines ok", actionItems: ActivityItems(actionItems: [.init(type: .message)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Headline example is allowed to wrap two lines ok", actionItems: _ActivityItems(actionItems: [.init(type: .message)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))

return AnyView(ci)

case (0, 2):
let ci = ContactItem(title: "Sean Long has a name that wraps two lines", detailImage: Image("person_square4").resizable(), actionItems: ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Sean Long has a name that wraps two lines", detailImage: Image("person_square4").resizable(), actionItems: _ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))

return AnyView(ci)

case (0, 3):
let ci = ContactItem(title: "Headline example when it wraps two lines", subtitle: "Team Lead", actionItems: ActivityItems(actionItems: [.init(type: .email), .init(type: .phone)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Headline example when it wraps two lines", subtitle: "Team Lead", actionItems: _ActivityItems(actionItems: [.init(type: .email), .init(type: .phone)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))

return AnyView(ci)

case (0, 4):
let ci = ContactItem(title: "Seann Longname", subtitle: "Team Lead", actionItems: ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Seann Longname", subtitle: "Team Lead", actionItems: _ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))
.splitPercent(0.3)

return AnyView(ci)

case (0, 5):
let ci = ContactItem(title: "Headline when\n wraps 2 lines", subtitle: "Team Lead", detailImage: Image("person_square4").resizable(), actionItems: ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
let ci = ContactItem(title: "Headline when\n wraps 2 lines", subtitle: "Team Lead", detailImage: Image("person_square4").resizable(), actionItems: _ActivityItems(actionItems: [.init(type: .phone), .init(type: .videoCall), .init(type: .message)], didSelectActivityItem: { dataType in
print("\(dataType)")
}))
.splitPercent(0.3)
Expand Down
Loading
Loading