Skip to content

Commit 6240f91

Browse files
authored
refactor: 💡 object header (#948)
* refactor: 💡 object header * feat: 🎸 add doc and usage * feat: 🎸 add doc
1 parent 46de7ae commit 6240f91

26 files changed

+2231
-557
lines changed

Sources/FioriSwiftUICore/Models/ModelDefinitions.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public protocol TagStackModel: TagsComponent {}
4040
// sourcery: virtualPropStatusViewSize = "@State var statusViewSize: CGSize = .zero"
4141
// sourcery: virtualPropCurrentTabIndex = "@State var currentTabIndex: Int = 0"
4242
// sourcery: generated_component_composite
43-
public protocol ObjectHeaderModel: TitleComponent, SubtitleComponent, TagsComponent, BodyTextComponent, FootnoteComponent, DescriptionTextComponent, StatusComponent, SubstatusComponent, DetailImageComponent {}
43+
public protocol _ObjectHeaderModel: TitleComponent, SubtitleComponent, TagsComponent, BodyTextComponent, FootnoteComponent, DescriptionTextComponent, StatusComponent, SubstatusComponent, DetailImageComponent {}
44+
45+
@available(*, unavailable, renamed: "_ObjectHeaderModel", message: "Will be removed in the future release. Please create ObjectHeader with other initializers instead.")
46+
public protocol ObjectHeaderModel {}
4447

4548
// sourcery: add_view_builder_params = "chart"
4649
// sourcery: virtualPropIntStateChanged = "@State var mainViewSize: CGSize = CGSize(width: 312, height: 0)"

Sources/FioriSwiftUICore/Views/ObjectHeader+View.swift renamed to Sources/FioriSwiftUICore/Views/_ObjectHeader+View.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import FioriCharts
22
import SwiftUI
33

4-
public extension ObjectHeader where Title == Text,
4+
public extension _ObjectHeader where Title == Text,
55
Subtitle == _ConditionalContent<Text, EmptyView>,
66
Tags == _ConditionalContent<TagStack, EmptyView>,
77
BodyText == _ConditionalContent<Text, EmptyView>,
@@ -37,7 +37,7 @@ public extension ObjectHeader where Title == Text,
3737
}
3838

3939
extension Fiori {
40-
enum ObjectHeader {
40+
enum _ObjectHeader {
4141
struct Title: ViewModifier {
4242
func body(content: Content) -> some View {
4343
if #available(iOS 14.0, *) {
@@ -156,7 +156,7 @@ extension Fiori {
156156
else descriptionView will get its own page
157157
*/
158158

159-
extension ObjectHeader: View {
159+
extension _ObjectHeader: View {
160160
public var body: some View {
161161
Group {
162162
if horizontalSizeClass == .some(.compact) {
@@ -609,17 +609,17 @@ struct ObjectHeader_Preview: PreviewProvider {
609609
})
610610

611611
return Group {
612-
ObjectHeader(title: "Transformer Overheating",
613-
subtitle: "Three Phase Pad Mounted Transformer (533423)", footnote: "1000 - Hamburg, MECHANIK",
614-
descriptionText: "Customer noticed that the transformer started to over heat within 45 minutes each time he turned it on at 7:30am. The first technician who looked at this did not have the correct additional tools to complete the job.",
615-
status: TextOrIcon.text("High"), substatus: TextOrIcon.text("Scheduled"),
616-
detailImage: Image(systemName: "person"),
617-
detailContent: { hc })
612+
_ObjectHeader(title: "Transformer Overheating",
613+
subtitle: "Three Phase Pad Mounted Transformer (533423)", footnote: "1000 - Hamburg, MECHANIK",
614+
descriptionText: "Customer noticed that the transformer started to over heat within 45 minutes each time he turned it on at 7:30am. The first technician who looked at this did not have the correct additional tools to complete the job.",
615+
status: TextOrIcon.text("High"), substatus: TextOrIcon.text("Scheduled"),
616+
detailImage: Image(systemName: "person"),
617+
detailContent: { hc })
618618
.previewLayout(.fixed(width: 390, height: 150))
619619
.environment(\.horizontalSizeClass, .compact)
620620

621621
// page 6
622-
ObjectHeader(title: {
622+
_ObjectHeader(title: {
623623
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines")
624624
}, subtitle: {
625625
Text("Job 819701")
@@ -644,7 +644,7 @@ struct ObjectHeader_Preview: PreviewProvider {
644644
.environment(\.horizontalSizeClass, .regular)
645645
.environment(\.colorScheme, .dark)
646646

647-
ObjectHeader(title: {
647+
_ObjectHeader(title: {
648648
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines")
649649
}, subtitle: {
650650
Text("Job 819701")
@@ -657,7 +657,7 @@ struct ObjectHeader_Preview: PreviewProvider {
657657
.environment(\.horizontalSizeClass, .regular)
658658
.environment(\.colorScheme, .dark)
659659

660-
ObjectHeader(title: {
660+
_ObjectHeader(title: {
661661
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines")
662662
}, subtitle: {
663663
Text("Job 819701")
@@ -680,7 +680,7 @@ struct ObjectHeader_Preview: PreviewProvider {
680680
.environment(\.horizontalSizeClass, .regular)
681681
.environment(\.colorScheme, .dark)
682682

683-
ObjectHeader(title: {
683+
_ObjectHeader(title: {
684684
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines")
685685
}, subtitle: {
686686
Text("Job 819701")
@@ -697,7 +697,7 @@ struct ObjectHeader_Preview: PreviewProvider {
697697
.environment(\.horizontalSizeClass, .regular)
698698
.environment(\.colorScheme, .dark)
699699

700-
ObjectHeader(title: {
700+
_ObjectHeader(title: {
701701
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines Accessibility Settings Testing")
702702
}, subtitle: {
703703
Text("Job 819701 Accessibility Settings Testing")
@@ -713,7 +713,7 @@ struct ObjectHeader_Preview: PreviewProvider {
713713
.environment(\.colorScheme, .dark)
714714
.environment(\.sizeCategory, .extraExtraLarge)
715715

716-
ObjectHeader(title: {
716+
_ObjectHeader(title: {
717717
Text("Inspect Electric Pump Motor Long Job Title Example Wrapping Two Lines Accessibility Settings Testing")
718718
}, subtitle: {
719719
Text("Job 819701 Accessibility Settings Testing")

Sources/FioriSwiftUICore/_ComponentProtocols/BaseComponentProtocols.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ protocol _DescriptionComponent {
5454
var description: AttributedString? { get }
5555
}
5656

57+
// sourcery: BaseComponent
58+
protocol _DescriptionTextComponent {
59+
// sourcery: @ViewBuilder
60+
var descriptionText: AttributedString? { get }
61+
}
62+
5763
// sourcery: BaseComponent
5864
protocol _StatusComponent {
5965
// sourcery: resultBuilder.name = @ViewBuilder, resultBuilder.backingComponent = TextOrIconView
@@ -543,6 +549,18 @@ protocol _LineComponent {
543549
var line: (() -> any View)? { get }
544550
}
545551

552+
// sourcery: BaseComponent
553+
protocol _BodyTextComponent {
554+
// sourcery: @ViewBuilder
555+
var bodyText: AttributedString? { get }
556+
}
557+
558+
// sourcery: BaseComponent
559+
protocol _DetailContentComponent {
560+
@ViewBuilder
561+
var detailContent: (() -> any View)? { get }
562+
}
563+
546564
// sourcery: BaseComponent
547565
protocol _InnerCircleComponent {
548566
// sourcery: @ViewBuilder

Sources/FioriSwiftUICore/_ComponentProtocols/CompositeComponentProtocols.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,3 +1021,31 @@ protocol _StepProgressIndicatorComponent: _TitleComponent, _ActionComponent, _Ca
10211021
// sourcery: resultBuilder.returnType = any IndexedViewContainer
10221022
var steps: [StepItem] { get }
10231023
}
1024+
1025+
/// `ObjectHeader` is a view that displays an object's title, subtitle, tags, body text, footnote, description, status, substatus, detail image and detail content.
1026+
/// ## Usage
1027+
/// ```swift
1028+
/// ObjectHeader {
1029+
/// Text("title")
1030+
/// } subtitle: {
1031+
/// Text("subtitle")
1032+
/// } tags: {
1033+
/// Text("tag01")
1034+
/// } bodyText: {
1035+
/// Text("body")
1036+
/// } footnote: {
1037+
/// Text("footnote")
1038+
/// } descriptionText: {
1039+
/// Text("description")
1040+
/// } status: {
1041+
/// Text("status")
1042+
/// } substatus: {
1043+
/// Text("substatus")
1044+
/// } detailImage: {
1045+
/// Image(systemName: "person")
1046+
/// } detailContent: {
1047+
/// Text("detail content")
1048+
/// }
1049+
/// ```
1050+
// sourcery: CompositeComponent
1051+
protocol _ObjectHeaderComponent: _TitleComponent, _SubtitleComponent, _TagsComponent, _BodyTextComponent, _FootnoteComponent, _DescriptionTextComponent, _StatusComponent, _SubstatusComponent, _DetailImageComponent, _DetailContentComponent {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import FioriThemeManager
2+
import Foundation
3+
import SwiftUI
4+
5+
// Base Layout style
6+
public struct BodyTextBaseStyle: BodyTextStyle {
7+
@ViewBuilder
8+
public func makeBody(_ configuration: BodyTextConfiguration) -> some View {
9+
configuration.bodyText
10+
}
11+
}
12+
13+
// Default fiori styles
14+
public struct BodyTextFioriStyle: BodyTextStyle {
15+
@ViewBuilder
16+
public func makeBody(_ configuration: BodyTextConfiguration) -> some View {
17+
BodyText(configuration)
18+
}
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import FioriThemeManager
2+
import Foundation
3+
import SwiftUI
4+
5+
// Base Layout style
6+
public struct DescriptionTextBaseStyle: DescriptionTextStyle {
7+
@ViewBuilder
8+
public func makeBody(_ configuration: DescriptionTextConfiguration) -> some View {
9+
// Add default layout here
10+
configuration.descriptionText
11+
}
12+
}
13+
14+
// Default fiori styles
15+
public struct DescriptionTextFioriStyle: DescriptionTextStyle {
16+
@ViewBuilder
17+
public func makeBody(_ configuration: DescriptionTextConfiguration) -> some View {
18+
DescriptionText(configuration)
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import FioriThemeManager
2+
import Foundation
3+
import SwiftUI
4+
5+
// Base Layout style
6+
public struct DetailContentBaseStyle: DetailContentStyle {
7+
@ViewBuilder
8+
public func makeBody(_ configuration: DetailContentConfiguration) -> some View {
9+
configuration.detailContent
10+
}
11+
}
12+
13+
// Default fiori styles
14+
public struct DetailContentFioriStyle: DetailContentStyle {
15+
@ViewBuilder
16+
public func makeBody(_ configuration: DetailContentConfiguration) -> some View {
17+
DetailContent(configuration)
18+
}
19+
}

0 commit comments

Comments
 (0)