Skip to content

Commit

Permalink
fix: 🐛 [HCPSDKFIORIUIKIT-2720] Style updates in ObjectItem (#793)
Browse files Browse the repository at this point in the history
* chore: 🤖 fix layout issue in Icons and IconBuilder

* fix: 🐛 [HCPSDKFIORIUIKIT-2720] Style updates in ObjectItem
  • Loading branch information
billzhou0223 authored Sep 4, 2024
1 parent c36ba3e commit 4889cbd
Show file tree
Hide file tree
Showing 89 changed files with 441 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct SingleActionCollectionView: View {
}, label: { _ in
Image(systemName: "arrow.down.circle")
.resizable()
.foregroundColor(Color.preferredColor(.tintColor))
.frame(width: 32, height: 32)
}) })
} else {
Expand Down
12 changes: 8 additions & 4 deletions Sources/FioriSwiftUICore/Views/IconStack/IconBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ public protocol ViewList: View, _ViewEmptyChecking {
/// conform View protocol for IconStack
public extension ViewList {
var body: some View {
VStack(alignment: .center, spacing: 6) {
VStack(spacing: 6) {
ForEach(0 ..< min(numberOfIconsToShow(), count), id: \.self) { index in
view(at: index)
.lineLimit(1)
.minimumScaleFactor(0.1)
.frame(width: 16)
.frame(width: 14, height: 14)
}
}
.clipped()
}
}

Expand All @@ -49,8 +48,13 @@ public struct Single<Content: View>: ViewList {
}

/// the View at Index in the ViewList
@ViewBuilder
public func view(at index: Int) -> some View {
self.view
if index == 0 {
self.view
} else {
EmptyView()
}
}

/// is first item a text in the ViewList
Expand Down
2 changes: 1 addition & 1 deletion Sources/FioriSwiftUICore/Views/MHStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public struct MHStack<T: TagViewList>: View {
/// want the stack to choose a default distance for each pair of
/// subviews.
/// - content: A view builder that creates the content of this stack.
public init(spacing: CGFloat? = 10, lineSpacing: CGFloat? = 10, @TagBuilder content: () -> T) {
public init(spacing: CGFloat? = 8, lineSpacing: CGFloat? = 10, @TagBuilder content: () -> T) {
self.tags = content()
self.spacing = spacing!
self.lineSpacing = lineSpacing!
Expand Down
4 changes: 2 additions & 2 deletions Sources/FioriSwiftUICore/Views/TagStack/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct LightTagStyle: TagStyle {
.foregroundColor(.preferredColor(.secondaryLabel))
.lineLimit(1)
.padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3))
.background(RoundedRectangle(cornerRadius: 4).stroke(Color.preferredColor(.quaternaryLabel), lineWidth: 0.5))
.background(RoundedRectangle(cornerRadius: 8).stroke(Color.preferredColor(.quaternaryLabel), lineWidth: 0.5))
}
}

Expand All @@ -57,7 +57,7 @@ public struct DarkTagStyle: TagStyle {
.foregroundColor(.preferredColor(.primaryLabel, background: .darkConstant))
.lineLimit(1)
.padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3))
.background(RoundedRectangle(cornerRadius: 4).fill(Color.preferredColor(.tertiaryLabel)))
.background(RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.tertiaryLabel)))
}
}

Expand Down
50 changes: 45 additions & 5 deletions Sources/FioriSwiftUICore/_FioriStyles/ObjectItemStyle.fiori.swift
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ extension ObjectItemFioriStyle {

func makeBody(_ configuration: TitleConfiguration) -> some View {
Title(configuration)
// Add default style here
.font(.fiori(forTextStyle: .headline, weight: .semibold))
.foregroundStyle(Color.preferredColor(.baseBlack))
}
}

Expand All @@ -529,7 +530,7 @@ extension ObjectItemFioriStyle {

func makeBody(_ configuration: SubtitleConfiguration) -> some View {
Subtitle(configuration)
// Add default style here
.foregroundStyle(Color.preferredColor(.secondaryLabel))
.lineLimit(1)
}
}
Expand Down Expand Up @@ -558,7 +559,7 @@ extension ObjectItemFioriStyle {

func makeBody(_ configuration: StatusConfiguration) -> some View {
Status(configuration)
// Add default style here
.font(.fiori(forTextStyle: .subheadline))
.lineLimit(1)
}
}
Expand All @@ -568,7 +569,7 @@ extension ObjectItemFioriStyle {

func makeBody(_ configuration: SubstatusConfiguration) -> some View {
Substatus(configuration)
// Add default style here
.font(.fiori(forTextStyle: .subheadline))
.lineLimit(1)
}
}
Expand All @@ -589,7 +590,7 @@ extension ObjectItemFioriStyle {

func makeBody(_ configuration: IconsConfiguration) -> some View {
Icons(configuration)
// Add default style here
.foregroundStyle(Color.preferredColor(.tertiaryLabel))
}
}

Expand Down Expand Up @@ -710,6 +711,45 @@ public struct ObjectItemBorderedAction: ActionStyle {
config.title
.foregroundStyle(.blue) // take effect
}
.padding([.leading, .trailing], 8)
}
}

#Preview("With Action") {
List {
ObjectItem(title: {
Text("Title")
}, subtitle: {
Text("Subtitle")
}, footnote: {
Text("Footnote")
}, description: {
Text("Description")
}, status: {
Text("Status")
}, substatus: {
Text("Substatus")
}, detailImage: {
Image(systemName: "person.circle").resizable().frame(width: 45, height: 45)
}, icons: {
Text("1")
Circle().fill(Color.preferredColor(.tintColor)).frame(width: 14, height: 14)
Image(systemName: "paperclip").font(.system(size: 14))
}, footnoteIcons: {
Color.red
Color.green
Color.blue
Color.red
Color.green
Color.blue
Color.red
Color.green
Color.blue
}, footnoteIconsText: {
Text("Footnote icons text.")
}, action: {
FioriButton(title: "Action")
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension AccessoryIcon {
}

func defaultStyle() -> some View {
AccessoryIcon(accessoryIcon: { self.accessoryIcon })
AccessoryIcon(.init(accessoryIcon: .init(self.accessoryIcon)))
.shouldApplyDefaultStyle(false)
.accessoryIconStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension Action {
}

func defaultStyle() -> some View {
Action(action: { self.action })
Action(.init(action: .init(self.action)))
.shouldApplyDefaultStyle(false)
.actionStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension Attribute {
}

func defaultStyle() -> some View {
Attribute(attribute: { self.attribute })
Attribute(.init(attribute: .init(self.attribute)))
.shouldApplyDefaultStyle(false)
.attributeStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension Avatars {
}

func defaultStyle() -> some View {
Avatars(avatars: { self.avatars })
Avatars(.init(avatars: .init(self.avatars)))
.shouldApplyDefaultStyle(false)
.avatarsStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public struct BannerMessage {
@ViewBuilder topDivider: () -> any View = { Rectangle().fill(Color.clear) },
bannerTapAction: (() -> Void)? = nil)
{
self.icon = Icon { icon() }
self.title = Title { title() }
self.closeAction = CloseAction { closeAction() }
self.topDivider = TopDivider { topDivider() }
self.icon = Icon(icon: icon)
self.title = Title(title: title)
self.closeAction = CloseAction(closeAction: closeAction)
self.topDivider = TopDivider(topDivider: topDivider)
self.bannerTapAction = bannerTapAction
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ public struct Card {
@ViewBuilder tertiaryAction: () -> any View = { EmptyView() },
@ViewBuilder overflowAction: () -> any View = { FioriButton { _ in Image(systemName: "ellipsis") } })
{
self.mediaImage = MediaImage { mediaImage() }
self.description = Description { description() }
self.title = Title { title() }
self.subtitle = Subtitle { subtitle() }
self.icons = Icons { icons() }
self.detailImage = DetailImage { detailImage() }
self.headerAction = HeaderAction { headerAction() }
self.counter = Counter { counter() }
self.row1 = Row1 { row1() }
self.row2 = Row2 { row2() }
self.row3 = Row3 { row3() }
self.kpi = Kpi { kpi() }
self.kpiCaption = KpiCaption { kpiCaption() }
self.cardBody = CardBody { cardBody() }
self.action = Action { action() }
self.secondaryAction = SecondaryAction { secondaryAction() }
self.tertiaryAction = TertiaryAction { tertiaryAction() }
self.overflowAction = OverflowAction { overflowAction() }
self.mediaImage = MediaImage(mediaImage: mediaImage)
self.description = Description(description: description)
self.title = Title(title: title)
self.subtitle = Subtitle(subtitle: subtitle)
self.icons = Icons(icons: icons)
self.detailImage = DetailImage(detailImage: detailImage)
self.headerAction = HeaderAction(headerAction: headerAction)
self.counter = Counter(counter: counter)
self.row1 = Row1(row1: row1)
self.row2 = Row2(row2: row2)
self.row3 = Row3(row3: row3)
self.kpi = Kpi(kpi: kpi)
self.kpiCaption = KpiCaption(kpiCaption: kpiCaption)
self.cardBody = CardBody(cardBody: cardBody)
self.action = Action(action: action)
self.secondaryAction = SecondaryAction(secondaryAction: secondaryAction)
self.tertiaryAction = TertiaryAction(tertiaryAction: tertiaryAction)
self.overflowAction = OverflowAction(overflowAction: overflowAction)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private extension CardBody {
}

func defaultStyle() -> some View {
CardBody(cardBody: { self.cardBody })
CardBody(.init(cardBody: .init(self.cardBody)))
.shouldApplyDefaultStyle(false)
.cardBodyStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public struct CardExtHeader {
@ViewBuilder kpi: () -> any View = { EmptyView() },
@ViewBuilder kpiCaption: () -> any View = { EmptyView() })
{
self.row1 = Row1 { row1() }
self.row2 = Row2 { row2() }
self.row3 = Row3 { row3() }
self.kpi = Kpi { kpi() }
self.kpiCaption = KpiCaption { kpiCaption() }
self.row1 = Row1(row1: row1)
self.row2 = Row2(row2: row2)
self.row3 = Row3(row3: row3)
self.kpi = Kpi(kpi: kpi)
self.kpiCaption = KpiCaption(kpiCaption: kpiCaption)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public struct CardFooter {
@ViewBuilder tertiaryAction: () -> any View = { EmptyView() },
@ViewBuilder overflowAction: () -> any View = { FioriButton { _ in Image(systemName: "ellipsis") } })
{
self.action = Action { action() }
self.secondaryAction = SecondaryAction { secondaryAction() }
self.tertiaryAction = TertiaryAction { tertiaryAction() }
self.overflowAction = OverflowAction { overflowAction() }
self.action = Action(action: action)
self.secondaryAction = SecondaryAction(secondaryAction: secondaryAction)
self.tertiaryAction = TertiaryAction(tertiaryAction: tertiaryAction)
self.overflowAction = OverflowAction(overflowAction: overflowAction)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ public struct CardHeader {
@ViewBuilder kpi: () -> any View = { EmptyView() },
@ViewBuilder kpiCaption: () -> any View = { EmptyView() })
{
self.mediaImage = MediaImage { mediaImage() }
self.description = Description { description() }
self.title = Title { title() }
self.subtitle = Subtitle { subtitle() }
self.icons = Icons { icons() }
self.detailImage = DetailImage { detailImage() }
self.headerAction = HeaderAction { headerAction() }
self.counter = Counter { counter() }
self.row1 = Row1 { row1() }
self.row2 = Row2 { row2() }
self.row3 = Row3 { row3() }
self.kpi = Kpi { kpi() }
self.kpiCaption = KpiCaption { kpiCaption() }
self.mediaImage = MediaImage(mediaImage: mediaImage)
self.description = Description(description: description)
self.title = Title(title: title)
self.subtitle = Subtitle(subtitle: subtitle)
self.icons = Icons(icons: icons)
self.detailImage = DetailImage(detailImage: detailImage)
self.headerAction = HeaderAction(headerAction: headerAction)
self.counter = Counter(counter: counter)
self.row1 = Row1(row1: row1)
self.row2 = Row2(row2: row2)
self.row3 = Row3(row3: row3)
self.kpi = Kpi(kpi: kpi)
self.kpiCaption = KpiCaption(kpiCaption: kpiCaption)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public struct CardMainHeader {
@ViewBuilder headerAction: () -> any View = { EmptyView() },
@ViewBuilder counter: () -> any View = { EmptyView() })
{
self.title = Title { title() }
self.subtitle = Subtitle { subtitle() }
self.icons = Icons { icons() }
self.detailImage = DetailImage { detailImage() }
self.headerAction = HeaderAction { headerAction() }
self.counter = Counter { counter() }
self.title = Title(title: title)
self.subtitle = Subtitle(subtitle: subtitle)
self.icons = Icons(icons: icons)
self.detailImage = DetailImage(detailImage: detailImage)
self.headerAction = HeaderAction(headerAction: headerAction)
self.counter = Counter(counter: counter)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public struct CardMedia {
public init(@ViewBuilder mediaImage: () -> any View = { EmptyView() },
@ViewBuilder description: () -> any View = { EmptyView() })
{
self.mediaImage = MediaImage { mediaImage() }
self.description = Description { description() }
self.mediaImage = MediaImage(mediaImage: mediaImage)
self.description = Description(description: description)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension CloseAction {
}

func defaultStyle() -> some View {
CloseAction(closeAction: { self.closeAction })
CloseAction(.init(closeAction: .init(self.closeAction)))
.shouldApplyDefaultStyle(false)
.closeActionStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private extension Counter {
}

func defaultStyle() -> some View {
Counter(counter: { self.counter })
Counter(.init(counter: .init(self.counter)))
.shouldApplyDefaultStyle(false)
.counterStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private extension DecrementAction {
}

func defaultStyle() -> some View {
DecrementAction(decrementAction: { self.decrementAction })
DecrementAction(.init(decrementAction: .init(self.decrementAction)))
.shouldApplyDefaultStyle(false)
.decrementActionStyle(.fiori)
.typeErased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ struct DemoView {
@ViewBuilder action: () -> any View = { EmptyView() },
isOn: Binding<Bool>)
{
self.title = Title { title() }
self.subtitle = Subtitle { subtitle() }
self.status = Status { status() }
self.action = Action { action() }
self.title = Title(title: title)
self.subtitle = Subtitle(subtitle: subtitle)
self.status = Status(status: status)
self.action = Action(action: action)
self._isOn = isOn
}
}
Expand Down
Loading

0 comments on commit 4889cbd

Please sign in to comment.