Skip to content

Commit

Permalink
feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]SwiftUI TimelinePreviewView (#780)
Browse files Browse the repository at this point in the history
* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]SwiftUI TimelinePreviewView

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Address bot checks

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Address the comments

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Address new comments

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Added a new base component

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Updated model to protocol

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Added Docs

* feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-1934]Corrected Docs issue

---------

Co-authored-by: Bill Zhou <bill.zhou01@sap.com>
  • Loading branch information
zzchao-1999 and billzhou0223 authored Sep 4, 2024
1 parent 4889cbd commit 1acd47c
Show file tree
Hide file tree
Showing 26 changed files with 1,454 additions and 16 deletions.
29 changes: 20 additions & 9 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
691DE21925F2A30B00094D4A /* KPIViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 691DE21825F2A30B00094D4A /* KPIViewExample.swift */; };
692F338B26556A6A009B98DA /* SideBarExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 692F338A26556A6A009B98DA /* SideBarExample.swift */; };
69B2B5D9268A333C009AC6B3 /* KPIProgressViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69B2B5D8268A333C009AC6B3 /* KPIProgressViewExample.swift */; };
8732C2C52C350957002110E9 /* TimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C42C350957002110E9 /* TimelineExample.swift */; };
8732C2C72C3524B6002110E9 /* TimelineItemsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C62C3524B6002110E9 /* TimelineItemsExample.swift */; };
8732C2C92C3524C9002110E9 /* SimpleTimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C82C3524C9002110E9 /* SimpleTimelineExample.swift */; };
8732C2CB2C3524D9002110E9 /* CustomTimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2CA2C3524D9002110E9 /* CustomTimelineExample.swift */; };
6D6E86252C50D42000EDB6F4 /* FioriButtonInListExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6E86242C50D42000EDB6F4 /* FioriButtonInListExample.swift */; };
6D6E86292C50E5F900EDB6F4 /* FioriButtonInListMultipleLineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6E86282C50E5F900EDB6F4 /* FioriButtonInListMultipleLineExample.swift */; };
6D6E86672C50FDBE00EDB6F4 /* FioriButtonInCollectionExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6E86662C50FDBE00EDB6F4 /* FioriButtonInCollectionExample.swift */; };
Expand All @@ -49,7 +45,14 @@
6DEC32002C48FB010084DD20 /* LoadingButtonSingleStatusExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC31FF2C48FB010084DD20 /* LoadingButtonSingleStatusExample.swift */; };
6DEC32022C4A4DC70084DD20 /* CardFullWidthSingleButtonExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC32012C4A4DC70084DD20 /* CardFullWidthSingleButtonExample.swift */; };
6DEC32042C4E49C70084DD20 /* CardFixedWidthButtonsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC32032C4E49C70084DD20 /* CardFixedWidthButtonsExample.swift */; };
8732C2C52C350957002110E9 /* TimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C42C350957002110E9 /* TimelineExample.swift */; };
8732C2C72C3524B6002110E9 /* TimelineItemsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C62C3524B6002110E9 /* TimelineItemsExample.swift */; };
8732C2C92C3524C9002110E9 /* SimpleTimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2C82C3524C9002110E9 /* SimpleTimelineExample.swift */; };
8732C2CB2C3524D9002110E9 /* CustomTimelineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8732C2CA2C3524D9002110E9 /* CustomTimelineExample.swift */; };
878219C42BEE128E002FDFBC /* StepperViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 878219C32BEE128E002FDFBC /* StepperViewExample.swift */; };
87F492312C73AD99002B8703 /* CustomTimelinePreviewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87F492302C73AD99002B8703 /* CustomTimelinePreviewExample.swift */; };
87F492332C73ADA1002B8703 /* SimpleTimelinePreviewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87F492322C73ADA1002B8703 /* SimpleTimelinePreviewExample.swift */; };
87F492352C73ADAA002B8703 /* TimelinePreviewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87F492342C73ADAA002B8703 /* TimelinePreviewExample.swift */; };
8A55795724C1286E0098003A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A55795624C1286E0098003A /* AppDelegate.swift */; };
8A55795924C1286E0098003A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A55795824C1286E0098003A /* SceneDelegate.swift */; };
8A55795B24C1286E0098003A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A55795A24C1286E0098003A /* ContentView.swift */; };
Expand Down Expand Up @@ -234,10 +237,6 @@
691DE21825F2A30B00094D4A /* KPIViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIViewExample.swift; sourceTree = "<group>"; };
692F338A26556A6A009B98DA /* SideBarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideBarExample.swift; sourceTree = "<group>"; };
69B2B5D8268A333C009AC6B3 /* KPIProgressViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIProgressViewExample.swift; sourceTree = "<group>"; };
8732C2C42C350957002110E9 /* TimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineExample.swift; sourceTree = "<group>"; };
8732C2C62C3524B6002110E9 /* TimelineItemsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemsExample.swift; sourceTree = "<group>"; };
8732C2C82C3524C9002110E9 /* SimpleTimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleTimelineExample.swift; sourceTree = "<group>"; };
8732C2CA2C3524D9002110E9 /* CustomTimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTimelineExample.swift; sourceTree = "<group>"; };
6D6E86242C50D42000EDB6F4 /* FioriButtonInListExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonInListExample.swift; sourceTree = "<group>"; };
6D6E86282C50E5F900EDB6F4 /* FioriButtonInListMultipleLineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonInListMultipleLineExample.swift; sourceTree = "<group>"; };
6D6E86662C50FDBE00EDB6F4 /* FioriButtonInCollectionExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonInCollectionExample.swift; sourceTree = "<group>"; };
Expand All @@ -252,7 +251,14 @@
6DEC31FF2C48FB010084DD20 /* LoadingButtonSingleStatusExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingButtonSingleStatusExample.swift; sourceTree = "<group>"; };
6DEC32012C4A4DC70084DD20 /* CardFullWidthSingleButtonExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardFullWidthSingleButtonExample.swift; sourceTree = "<group>"; };
6DEC32032C4E49C70084DD20 /* CardFixedWidthButtonsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardFixedWidthButtonsExample.swift; sourceTree = "<group>"; };
8732C2C42C350957002110E9 /* TimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineExample.swift; sourceTree = "<group>"; };
8732C2C62C3524B6002110E9 /* TimelineItemsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemsExample.swift; sourceTree = "<group>"; };
8732C2C82C3524C9002110E9 /* SimpleTimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleTimelineExample.swift; sourceTree = "<group>"; };
8732C2CA2C3524D9002110E9 /* CustomTimelineExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTimelineExample.swift; sourceTree = "<group>"; };
878219C32BEE128E002FDFBC /* StepperViewExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StepperViewExample.swift; sourceTree = "<group>"; };
87F492302C73AD99002B8703 /* CustomTimelinePreviewExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomTimelinePreviewExample.swift; sourceTree = "<group>"; };
87F492322C73ADA1002B8703 /* SimpleTimelinePreviewExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleTimelinePreviewExample.swift; sourceTree = "<group>"; };
87F492342C73ADAA002B8703 /* TimelinePreviewExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimelinePreviewExample.swift; sourceTree = "<group>"; };
8A1E99AD24D59C8000ED8A39 /* cloud-sdk-ios-fiori */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "cloud-sdk-ios-fiori"; path = ../..; sourceTree = "<group>"; };
8A55795324C1286E0098003A /* Examples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Examples.app; sourceTree = BUILT_PRODUCTS_DIR; };
8A55795624C1286E0098003A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -518,6 +524,9 @@
8732C2C32C35092D002110E9 /* Timeline */ = {
isa = PBXGroup;
children = (
87F492342C73ADAA002B8703 /* TimelinePreviewExample.swift */,
87F492322C73ADA1002B8703 /* SimpleTimelinePreviewExample.swift */,
87F492302C73AD99002B8703 /* CustomTimelinePreviewExample.swift */,
8732C2C42C350957002110E9 /* TimelineExample.swift */,
8732C2C62C3524B6002110E9 /* TimelineItemsExample.swift */,
8732C2C82C3524C9002110E9 /* SimpleTimelineExample.swift */,
Expand Down Expand Up @@ -1069,7 +1078,6 @@
C18868D12B32535100F865F7 /* SearchFontAndColor.swift in Sources */,
9D0B26092B9BA5C0004278A5 /* KeyValueFormViewExample.swift in Sources */,
8732C2C52C350957002110E9 /* TimelineExample.swift in Sources */,
9D057DAB2C2F260200F5331C /* RatingControlExample.swift in Sources */,
8A557A1A24C12C820098003A /* ChartsContentView.swift in Sources */,
8A5579CE24C1293C0098003A /* SettingColor.swift in Sources */,
1F55FEF32AC941FF00D7A1BE /* View+Extensions.swift in Sources */,
Expand All @@ -1078,6 +1086,7 @@
8AD9DFB225D49967007448EC /* StylingModifierExample.swift in Sources */,
9D0B260A2B9BA5C0004278A5 /* NoteFormViewExample.swift in Sources */,
9DEC27B72C3F3DE70070B571 /* OtherViewExamples.swift in Sources */,
87F492332C73ADA1002B8703 /* SimpleTimelinePreviewExample.swift in Sources */,
8A5579D124C1293C0098003A /* Settings.swift in Sources */,
8AD9DFB025D49967007448EC /* ContactItemActionItemsExample.swift in Sources */,
8A6D64B125AE658300D2D76C /* ExpHeaderView.swift in Sources */,
Expand Down Expand Up @@ -1139,8 +1148,10 @@
692F338B26556A6A009B98DA /* SideBarExample.swift in Sources */,
8A5579D324C1293C0098003A /* SettingsPoint.swift in Sources */,
B80DA9BA260BBF8600C0B2E9 /* SingleActionProfiles.swift in Sources */,
87F492352C73ADAA002B8703 /* TimelinePreviewExample.swift in Sources */,
B18D593C2B0C52C700ABB1AD /* TabViewExample.swift in Sources */,
8A5579D424C1293C0098003A /* SettingsBaseline.swift in Sources */,
87F492312C73AD99002B8703 /* CustomTimelinePreviewExample.swift in Sources */,
1F90888C261A59820015A84D /* FioriButtonExample.swift in Sources */,
6D6E86252C50D42000EDB6F4 /* FioriButtonInListExample.swift in Sources */,
B8D4377125F983730024EE7D /* ObjectCell_Rules_Alignment.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import FioriSwiftUICore
import SwiftUI

struct CustomTimelinePreviewExample: View {
@State private var items0: [TimelinePreviewItemModelImplementation] = [
TimelinePreviewItemModelImplementation(title: "open", icon: Image(systemName: "a.square"), timelineNode: TimelineNodeType.inProgress, due: ISO8601DateFormatter().date(from: "2024-09-21T12:00:00Z")!, dateFormat: "dd/MM/yyyy"),
TimelinePreviewItemModelImplementation(title: "Before start", icon: Image(systemName: "a.square"), timelineNode: TimelineNodeType.start, due: ISO8601DateFormatter().date(from: "2024-07-23T12:00:00Z")!, dateFormat: "dd/MM/yyyy"),
TimelinePreviewItemModelImplementation(title: "start", timelineNode: TimelineNodeType.open, due: ISO8601DateFormatter().date(from: "2024-08-19T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "open", icon: Image(systemName: "o.square"), timelineNode: TimelineNodeType.inProgress, due: ISO8601DateFormatter().date(from: "2024-08-17T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "open", timelineNode: TimelineNodeType.open, due: ISO8601DateFormatter().date(from: "2024-09-27T12:00:00Z")!)
]

var body: some View {
VStack {
TimelinePreview(
optionalTitle: { Text("Timeline") },
action: {
FioriButton(
label: { _ in
Label("See All (\(self.items0.count))", systemImage: "arrowtriangle.right")
.labelStyle(MyLabelStyle())
}
)
},
items: .constant(self.items0.map { $0 as any TimelinePreviewItemModel })
)
.timelinePreviewItemStyle(content: { config in
TimelinePreviewItem(config)
.titleStyle(content: { titleConfig in
titleConfig.title.foregroundColor(.yellow)
})
.timestampStyle(content: { timestampConfig in
timestampConfig.timestamp.foregroundColor(.red)
})
})
.optionalTitleStyle(content: { config in
config.optionalTitle.foregroundColor(.purple)
})
Spacer()
}
}
}

struct MyLabelStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
HStack(alignment: .center) {
configuration.title
.foregroundColor(.purple)
configuration.icon
.foregroundColor(.green)
}
}
}

#Preview {
CustomTimelinePreviewExample()
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SimpleTimelineExample: View {
}
}
.listStyle(.plain)
.environment(\.defaultMinListRowHeight, 7)
.environment(\.defaultMinListRowHeight, 5)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import FioriSwiftUICore
import SwiftUI

struct SimpleTimelinePreviewExample: View {
@State private var items0: [TimelinePreviewItemModelImplementation] = [
TimelinePreviewItemModelImplementation(title: "POC", timelineNode: TimelineNodeType.beforeStart, due: ISO8601DateFormatter().date(from: "2024-06-03T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project Phase 3", timelineNode: TimelineNodeType.open, due: ISO8601DateFormatter().date(from: "2024-06-25T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project Phase 2", timelineNode: TimelineNodeType.inProgress, due: ISO8601DateFormatter().date(from: "2024-06-20T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project Phase 1", timelineNode: TimelineNodeType.complete, due: ISO8601DateFormatter().date(from: "2024-06-12T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project Start", timelineNode: TimelineNodeType.start, due: ISO8601DateFormatter().date(from: "2024-06-05T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project End", timelineNode: TimelineNodeType.end, due: ISO8601DateFormatter().date(from: "2024-07-25T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Accept Test", timelineNode: TimelineNodeType.beforeEnd, due: ISO8601DateFormatter().date(from: "2024-07-15T12:00:00Z")!),
TimelinePreviewItemModelImplementation(title: "Project Phase 4", timelineNode: TimelineNodeType.open, due: ISO8601DateFormatter().date(from: "2024-07-05T12:00:00Z")!)
]

var body: some View {
VStack {
NavigationLink(destination: TimelineView()) {
TimelinePreview(optionalTitle: { Text("Timeline Preview") }, items: .constant(self.items0.map { $0 as any TimelinePreviewItemModel }))
}
Spacer()
}
}
}

struct TimelineView: View {
var body: some View {
List {
Section(header: Text("Simple Timeline Example")) {
TimelineMarker(timestamp: "06/03/24", secondaryTimestamp: .icon(Image(systemName: "sun.max")), timelineNode: .beforeStart, title: "POC", isPast: true, showUpperVerticalLine: false)
.modifier(CustomListRowModifier())
.secondaryTimestampStyle(content: { config in
config.secondaryTimestamp.foregroundColor(.yellow)
})
TimelineMarker(timestamp: "06/05/24", secondaryTimestamp: .text("Sunny"), timelineNode: .start, title: "Project Start", isPast: true)
.modifier(CustomListRowModifier())
Timeline(timestamp: "06/12/24", secondaryTimestamp: .icon(Image(systemName: "sun.max")), timelineNode: .complete, title: "Project Phase 1", attribute: "xx features implementation done", status: .text("Done"), isPast: true)
.modifier(CustomListRowModifier())
.secondaryTimestampStyle(content: { config in
config.secondaryTimestamp.foregroundColor(.yellow)
})
Timeline(timestamp: "06/20/24", timelineNode: .inProgress, title: "Project Phase 2", subtitle: "Integration test", status: .text("ongoing"), isPresent: true)
.modifier(CustomListRowModifier())
TimelineNowIndicator()
.modifier(CustomListRowModifier())
Timeline(timestamp: "06/25/24", timelineNode: .open, title: "Project Phase 3", attribute: "feature list: xx, xx, xx", status: .text("pending"))
.modifier(CustomListRowModifier())
Timeline(timestamp: "06/28/24", timelineNode: .open, title: "Project Phase 4", attribute: "feature list: xx, xx, xx", status: .text("pending"))
.modifier(CustomListRowModifier())
TimelineMarker(timestamp: "07/05/24", timelineNode: .beforeEnd, title: "Accept Test")
.modifier(CustomListRowModifier())
TimelineMarker(timestamp: "07/09/24", secondaryTimestamp: .icon(Image(systemName: "sun.max")), timelineNode: .end, title: "Project End", showLowerVerticalLine: false)
.modifier(CustomListRowModifier())
.secondaryTimestampStyle(content: { config in
config.secondaryTimestamp.foregroundColor(.yellow)
})
}
}
.listStyle(.plain)
.environment(\.defaultMinListRowHeight, 7)
}
}

#Preview {
SimpleTimelinePreviewExample()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import SwiftUI
struct TimelineExample: View {
var body: some View {
List {
NavigationLink("TimelineItems", destination: TimelineItemsExample())
NavigationLink("SimpleTimelineExample", destination: SimpleTimelineExample())
NavigationLink("CustomTimelineExample", destination: CustomTimelineExample())
Section(header: Text("TimelinePreview")) {
NavigationLink("Simple TimelinePreview Example", destination: TimelinePreviewExample())
NavigationLink("Simple TimelinePreview Use Case", destination: SimpleTimelinePreviewExample())
NavigationLink("Custom TimelinePreview Example", destination: CustomTimelinePreviewExample())
}
Section(header: Text("Timeline")) {
NavigationLink("Timeline Items", destination: TimelineItemsExample())
NavigationLink("Simple Timeline Example", destination: SimpleTimelineExample())
NavigationLink("Custom Timeline Example", destination: CustomTimelineExample())
}
}
}
}
Expand Down
Loading

0 comments on commit 1acd47c

Please sign in to comment.