Skip to content

Commit

Permalink
fix: [JIRA:HCPSDKFIORIUIKIT-2076] Make icons and texts in SideBarList…
Browse files Browse the repository at this point in the history
…Item support dynamic type. (#408)

* chore: 🤖 Add missing semicolon in translation file

* chore: 🤖 Remove duplicated entries in translation file

* chore: 🤖 Update 72 fonts example

* chore: 🤖 Minor update to View+Extension

* docs: ✏️ Update readme to includle new 72 Font

* fix: 🐛 Fix an issue in Sourcery related to binding property

* chore: 🤖 Correct the size talbe for 72 font

* chore: 🤖 Update corner radius for dimension selector and side bar

* chore: 🤖 Remove UserConsentView from 2.0 release

* docs: ✏️ Update changelog.md for 2.0 release

* docs: ✏️ Update readme for 2.0 release and bump up iOS target to 14

* fix: 🐛 use FioriSwiftUI package with version-based requirement

It was not possible to specify dependency for `FioriSwiftUI` package
with `upToNextMajor(from:)` or `upToNextMinor(from:)` due to the use of
commit-based requirement for Zip dependency. Switching to a stable fork
in Package.swift will fix that.

* chore(release): 2.0.1

* Revert "chore: 🤖 Remove UserConsentView from 2.0 release"

This reverts commit f8a6afc.

* chore: 🤖 Support alert configuration for cancel action

Support alert configuration for cancel action in UserConsentForm

* chore: 🤖 Update wagoid/commitlint-github-action in pr_only.yml to v4

* fix: 🐛 Use scaledFont for title and subtitle in SideBarListItem

* fix: 🐛 Make icons of SideBarListItem scalable

* chore: 🤖 fix compilation error on xcode 12.4

* fix: 🐛 Apply two lines layout when in acc content size

Co-authored-by: Marco Eidinger <marco.eidinger@sap.com>
  • Loading branch information
billzhou0223 and MarcoEidinger authored Mar 15, 2022
1 parent 9a3b647 commit f761e77
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Sources/FioriSwiftUICore/Models/ModelDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public protocol ListPickerItemModel: KeyComponent, ValueComponent {}
public protocol ProgressIndicatorModel: ProgressIndicatorComponent {}

// sourcery: add_env_props = "sideBarListItemConfigMode"
// sourcery: add_env_props = "sizeCategory"
// sourcery: virtualPropSidebarIconScaleMetric = "@ScaledMetric var scale: CGFloat = 1"
// sourcery: generated_component
public protocol SideBarListItemModel: IconComponent, TitleComponent, SubtitleComponent, AccessoryIconComponent {}

Expand Down
68 changes: 42 additions & 26 deletions Sources/FioriSwiftUICore/Views/SideBarListItem+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@ extension Fiori {
.truncationMode(.tail)
}
}

struct Icon: ViewModifier {
func body(content: Content) -> some View {
content.padding(.trailing, 11)
}
}

struct AccessoryIcon: ViewModifier {
func body(content: Content) -> some View {
content.padding(.leading, 11)
}
}

typealias Icon = EmptyModifier
typealias AccessoryIcon = EmptyModifier
typealias IconCumulative = EmptyModifier
typealias TitleCumulative = EmptyModifier
typealias SubtitleCumulative = EmptyModifier
Expand All @@ -48,25 +38,51 @@ extension Fiori {

extension SideBarListItem: View {
public var body: some View {
HStack(spacing: 0) {
icon.foregroundColor(.preferredColor(.primaryLabel))
title
.font(.system(size: 17, weight: getFontWeight(), design: .default))
.foregroundColor(getColorStyle())
Spacer()
subtitle
.font(.system(size: 17, weight: getFontWeight(), design: .default))
.foregroundColor(.preferredColor(.tertiaryLabel))
accessoryIcon.foregroundColor(.preferredColor(.tertiaryLabel))
Group {
if sizeCategory.isAccessibilityCategory {
VStack {
HStack(spacing: 11) {
icon
.foregroundColor(.preferredColor(.primaryLabel))
.frame(width: 22 * scale, height: 22 * scale)
title
.font(Font.fiori(forTextStyle: .subheadline).weight(sideBarListItemConfigMode.isSelected ? Font.Weight.bold : Font.Weight.regular))
.foregroundColor(getColorStyle())
Spacer()
}

HStack(spacing: 11) {
Spacer()
subtitle
.font(Font.fiori(forTextStyle: .subheadline).weight(sideBarListItemConfigMode.isSelected ? Font.Weight.bold : Font.Weight.regular))
.foregroundColor(.preferredColor(.tertiaryLabel))
accessoryIcon
.foregroundColor(.preferredColor(.tertiaryLabel))
.frame(width: 22 * scale, height: 22 * scale)
}
}
} else {
HStack(spacing: 11) {
icon
.foregroundColor(.preferredColor(.primaryLabel))
.frame(width: 22 * scale, height: 22 * scale)
title
.font(Font.fiori(forTextStyle: .subheadline).weight(sideBarListItemConfigMode.isSelected ? Font.Weight.bold : Font.Weight.regular))
.foregroundColor(getColorStyle())
Spacer()
subtitle
.font(Font.fiori(forTextStyle: .subheadline).weight(sideBarListItemConfigMode.isSelected ? Font.Weight.bold : Font.Weight.regular))
.foregroundColor(.preferredColor(.tertiaryLabel))
accessoryIcon
.foregroundColor(.preferredColor(.tertiaryLabel))
.frame(width: 22 * scale, height: 22 * scale)
}
}
}
.padding(EdgeInsets(top: 11, leading: 11, bottom: 11, trailing: 11))
.cornerRadius(8, antialiased: true)
}

private func getFontWeight() -> Font.Weight {
sideBarListItemConfigMode.isSelected ? .bold : .regular
}

private func getColorStyle() -> Color {
sideBarListItemConfigMode.isHeaderContent ? .preferredColor(.tertiaryLabel) : .preferredColor(.primaryLabel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public struct KPIProgressItem<Kpi: View, Subtitle: View, Footnote: View> {
let _fraction: Double?
let _subtitle: Subtitle
let _footnote: Footnote
var action: (() -> Void)? = nil
@State var isPressed: Bool = false
var action: (() -> Void)? = nil
private var isModelInit: Bool = false
private var isKpiNil: Bool = false
private var isSubtitleNil: Bool = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ public struct SideBarListItem<Icon: View, Title: View, Subtitle: View, Accessory
@Environment(\.titleModifier) private var titleModifier
@Environment(\.subtitleModifier) private var subtitleModifier
@Environment(\.accessoryIconModifier) private var accessoryIconModifier
@Environment(\.sizeCategory) var sizeCategory
@Environment(\.sideBarListItemConfigMode) var sideBarListItemConfigMode

let _icon: Icon
let _title: Title
let _subtitle: Subtitle
let _accessoryIcon: AccessoryIcon

@ScaledMetric var scale: CGFloat = 1
private var isModelInit: Bool = false
private var isIconNil: Bool = false
private var isSubtitleNil: Bool = false
Expand Down

0 comments on commit f761e77

Please sign in to comment.