From 61e3c34fa2f5d0299239fe5a7ed429de7cb2cd54 Mon Sep 17 00:00:00 2001 From: xiaoyu0722 Date: Mon, 2 Dec 2024 14:44:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20[JIRA:=20HCPSDKFIORIUIKIT?= =?UTF-8?q?-2822]=20warning=20clean-up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Card/MobileCardExample.swift | 2 +- .../DataTable/DataTableExample.swift | 2 +- .../ObjectHeader/ObjectHeaderTestApp.swift | 17 ++++++++++++++--- .../SignatureCaptureViewExample.swift | 9 ++++++++- .../ToolbarExample/ToolbarView.swift | 1 - .../Examples/FioriThemeManager/72-Fonts.swift | 4 ++-- .../Examples/FioriThemeManager/Colors.swift | 2 +- Sources/FioriSwiftUICore/Views/MHStack.swift | 9 ++++----- .../FioriSwiftUICore/Views/_SideBar+View.swift | 10 ---------- .../_FioriStyles/TagStyle.fiori.swift | 4 +--- 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Apps/Examples/Examples/FioriSwiftUICore/Card/MobileCardExample.swift b/Apps/Examples/Examples/FioriSwiftUICore/Card/MobileCardExample.swift index 56ec00575..3f24ef710 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/Card/MobileCardExample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/Card/MobileCardExample.swift @@ -83,7 +83,7 @@ struct MasonryTestView: View { } } -extension VerticalAlignment: Hashable { +extension VerticalAlignment: @retroactive Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(self) } diff --git a/Apps/Examples/Examples/FioriSwiftUICore/DataTable/DataTableExample.swift b/Apps/Examples/Examples/FioriSwiftUICore/DataTable/DataTableExample.swift index 9c4f94b3d..94551e8a3 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/DataTable/DataTableExample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/DataTable/DataTableExample.swift @@ -201,7 +201,7 @@ let threeRowTwoColumnWithAcc = TableModel(headerData: nil, rowData: [row1WithAcc let row1WithAlignment = TableRowItem(data: [DataTextItem("Leading", Font.fiori(forTextStyle: .title1)), DataTextItem("C"), DataImageItem(Image("wheel"))]) let row2WithAlignment = TableRowItem(data: [DataTextItem("Leading", Font.title), DataImageItem(Image("wheel")), DataTextItem("Trailing Trailing")]) -let row3WithAlignment = TableRowItem(data: [DataImageItem(Image("wheel")), DataTextItem("Center Center"), DataTextItem("Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing end", Font.fioriCondensed(forTextStyle: .title1))]) +let row3WithAlignment = TableRowItem(data: [DataImageItem(Image("wheel")), DataTextItem("Center Center"), DataTextItem("Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing Trailing end", Font.fiori(forTextStyle: .title1))]) let row1WithDate = TableRowItem(data: [DataTextItem("Hello", Font.headline, Color.orange), DataImageItem(Image("wheel")), DataDateItem(Date(timeIntervalSince1970: 1), Font.largeTitle, Color.preferredColor(.chart2)), DataTimeItem(Date(timeIntervalSince1970: 1), Font.headline, Color.purple), DataDurationItem(3000, Font.footnote, Color.preferredColor(.secondaryLabel)), DataListItem("San Jose")]) let row2WithDate = TableRowItem(data: [DataImageItem(Image("wheel")), DataTextItem("World"), DataDateItem(Date(timeIntervalSinceReferenceDate: 1), Font.title2), DataTimeItem(Date(timeIntervalSinceReferenceDate: 1000)), DataDurationItem(23000), DataListItem("New York", Font.headline)]) diff --git a/Apps/Examples/Examples/FioriSwiftUICore/ObjectHeader/ObjectHeaderTestApp.swift b/Apps/Examples/Examples/FioriSwiftUICore/ObjectHeader/ObjectHeaderTestApp.swift index b83f4a4c0..f8d795662 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/ObjectHeader/ObjectHeaderTestApp.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/ObjectHeader/ObjectHeaderTestApp.swift @@ -2,6 +2,19 @@ import FioriCharts import FioriSwiftUICore import SwiftUI +struct MyCustomTagStyle: TagStyle { + func makeBody(_ configuration: TagConfiguration) -> some View { + Tag(configuration) + .foregroundStyle(Color.cyan) + .background { + ZStack { + RoundedRectangle(cornerRadius: 4).fill(Color.yellow) + RoundedRectangle(cornerRadius: 4).stroke(Color.red, lineWidth: 0.5) + } + } + } +} + struct ObjectHeaderTestApp: View { var body: some View { let header = ObjectHeader(title: { @@ -10,9 +23,7 @@ struct ObjectHeaderTestApp: View { Text("Job 819701") }, tags: { Tag("I am selected") - .tagStyle(CustomTagStyle(textColor: Color(UIColor.cyan), - fillColor: Color(UIColor.yellow), - borderColor: Color.red)) + .tagStyle(MyCustomTagStyle()) Tag("Tag1") Tag("Tag2") }, bodyText: { diff --git a/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift b/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift index fb1b7d09e..854e40fef 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/SignatureView/SignatureCaptureViewExample.swift @@ -93,7 +93,14 @@ class ImageSaver: NSObject { let hostingController = UIHostingController(rootView: self) hostingController.view.frame = CGRect(x: 0, y: CGFloat(Int.max), width: 1, height: 1) - UIApplication.shared.windows.first!.rootViewController?.view.addSubview(hostingController.view) + let window = UIApplication + .shared + .connectedScenes + .compactMap { ($0 as? UIWindowScene)?.keyWindow } + .last + if let rootView = window?.rootViewController?.view { + rootView.addSubview(hostingController.view) + } let size = hostingController.sizeThatFits(in: UIScreen.main.bounds.size) hostingController.view.bounds = CGRect(origin: .zero, size: size) hostingController.view.sizeToFit() diff --git a/Apps/Examples/Examples/FioriSwiftUICore/ToolbarExample/ToolbarView.swift b/Apps/Examples/Examples/FioriSwiftUICore/ToolbarExample/ToolbarView.swift index fb4a6ee41..3029a14ab 100644 --- a/Apps/Examples/Examples/FioriSwiftUICore/ToolbarExample/ToolbarView.swift +++ b/Apps/Examples/Examples/FioriSwiftUICore/ToolbarExample/ToolbarView.swift @@ -195,7 +195,6 @@ struct ToolbarView: View { #Preview { NavigationStack { - let a = "Extra Extra Extra Long Long Long Long Long Helper Text" ToolbarView(numberOfButtons: .constant(2), useFioriToolbar: .constant(true), helperText: .constant("6768"), customHelperText: .constant(true), moreActionOverflowIcon: .constant(false), primaryButtonText: .constant(""), secondaryButtonText: .constant(""), thirdButtonText: .constant(""), buttonType: .constant(.fiori)) } } diff --git a/Apps/Examples/Examples/FioriThemeManager/72-Fonts.swift b/Apps/Examples/Examples/FioriThemeManager/72-Fonts.swift index c66c599d0..a5a176cdc 100644 --- a/Apps/Examples/Examples/FioriThemeManager/72-Fonts.swift +++ b/Apps/Examples/Examples/FioriThemeManager/72-Fonts.swift @@ -70,13 +70,13 @@ extension FioriFonts { } } -extension Font.FioriWeight: CaseIterable { +extension Font.FioriWeight: @retroactive CaseIterable { public static var allCases: [Font.FioriWeight] { [.black, .heavy, .bold, .semibold, .semiboldDuplex, .medium, .regular, .light, .thin, .ultraLight] } } -extension Font.Weight: CustomStringConvertible { +extension Font.Weight: @retroactive CustomStringConvertible { public var description: String { let name: String diff --git a/Apps/Examples/Examples/FioriThemeManager/Colors.swift b/Apps/Examples/Examples/FioriThemeManager/Colors.swift index 5c093b897..de7682dc5 100644 --- a/Apps/Examples/Examples/FioriThemeManager/Colors.swift +++ b/Apps/Examples/Examples/FioriThemeManager/Colors.swift @@ -111,7 +111,7 @@ struct CustomColors: View { switch self.testData { case .customPalette: Text("Here a custom palette provides random colors for all ColorStyles") - case .programmatic(_), .styleSheet: + case .programmatic(_, _), .styleSheet: Text("ℹ️ primaryLabel color was overridden (other colors come from .latest palette)") } ForEach(self.colorStyles, diff --git a/Sources/FioriSwiftUICore/Views/MHStack.swift b/Sources/FioriSwiftUICore/Views/MHStack.swift index b641682fd..4c97afd9c 100644 --- a/Sources/FioriSwiftUICore/Views/MHStack.swift +++ b/Sources/FioriSwiftUICore/Views/MHStack.swift @@ -46,7 +46,7 @@ public struct MHStack: View { EmptyView() } else { GeometryReader { geometry in - self.makeBody(in: geometry) + self.makeBody(in: geometry.size.width) } .frame(height: self.mainViewSize.height < 0 ? nil : self.mainViewSize.height) } @@ -63,12 +63,11 @@ public struct MHStack: View { return min(limit, self.tags.count) } - - func makeBody(in g: GeometryProxy) -> some View { + + func makeBody(in containerWidth: CGFloat) -> some View { var width = CGFloat.zero var height = CGFloat.zero var tmpMainViewSize: CGSize = .zero - return ZStack(alignment: .topLeading) { ForEach(0 ..< self.tagCount, id: \.self) { index in self.tags.view(at: index) @@ -78,7 +77,7 @@ public struct MHStack: View { tmpMainViewSize = .zero } - if abs(width - d.width) > g.size.width { + if abs(width - d.width) > containerWidth { width = 0 height = -(tmpMainViewSize.height + self.lineSpacing) } diff --git a/Sources/FioriSwiftUICore/Views/_SideBar+View.swift b/Sources/FioriSwiftUICore/Views/_SideBar+View.swift index f6bc1933a..401918b38 100644 --- a/Sources/FioriSwiftUICore/Views/_SideBar+View.swift +++ b/Sources/FioriSwiftUICore/Views/_SideBar+View.swift @@ -141,11 +141,6 @@ public struct ExpandableList: View where Data: RandomAcc rowContent: rowContent(item), selectionBinding: selection) .environment(\.sideBarListItemConfigMode, SideBarListItemConfig(isSelected: true, isHeaderContent: false)) - .overlay(NavigationLink(destination: destination(item), - tag: item, - selection: selection, - label: { EmptyView() }) - .buttonStyle(PlainButtonStyle())) } else { RowContentContainer(item: item, rowContent: rowContent(item), @@ -200,11 +195,6 @@ public extension ExpandableList where Row == _SideBarListItem<_ConditionalConten _SideBarListItem(model: rowModel(item)) .modifier(ListItemBackgroundSelectionStyle()) .environment(\.sideBarListItemConfigMode, SideBarListItemConfig(isSelected: true, isHeaderContent: false)) - .overlay(NavigationLink(destination: destination(item), - tag: item, - selection: selection, - label: { EmptyView() }) - .buttonStyle(PlainButtonStyle())) .contentShape(Rectangle()) .onTapGesture { selection.wrappedValue = item diff --git a/Sources/FioriSwiftUICore/_FioriStyles/TagStyle.fiori.swift b/Sources/FioriSwiftUICore/_FioriStyles/TagStyle.fiori.swift index 799ad9908..19da85bb6 100644 --- a/Sources/FioriSwiftUICore/_FioriStyles/TagStyle.fiori.swift +++ b/Sources/FioriSwiftUICore/_FioriStyles/TagStyle.fiori.swift @@ -7,6 +7,7 @@ public struct TagBaseStyle: TagStyle { @ViewBuilder public func makeBody(_ configuration: TagConfiguration) -> some View { configuration.tag + .padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3)) } } @@ -24,7 +25,6 @@ public struct TagFioriStyle: TagStyle { .font(.fiori(forTextStyle: .footnote)) .foregroundStyle(isLight ? Color.preferredColor(.secondaryLabel) : Color.preferredColor(.primaryLabel, background: .darkConstant)) .lineLimit(self.tagLimit) - .padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3)) .background(background) } } @@ -56,7 +56,6 @@ public struct LightTagStyle: TagStyle { .font(.fiori(forTextStyle: .footnote)) .foregroundColor(.preferredColor(.secondaryLabel)) .lineLimit(1) - .padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3)) .background(RoundedRectangle(cornerRadius: 8).stroke(Color.preferredColor(.quaternaryLabel), lineWidth: 0.5)) } } @@ -72,7 +71,6 @@ public struct DarkTagStyle: TagStyle { .font(.fiori(forTextStyle: .footnote)) .foregroundColor(.preferredColor(.primaryLabel, background: .darkConstant)) .lineLimit(1) - .padding(EdgeInsets(top: 2, leading: 3, bottom: 2, trailing: 3)) .background(RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.tertiaryLabel))) } }