Skip to content

Commit

Permalink
fix: 🐛 [JIRA:IOSSDKBUG-413] FilterFeedbackBar in visionOS
Browse files Browse the repository at this point in the history
Adapt FilterFeedbackBar popover background color in visionOS
  • Loading branch information
hengyi-zhang committed Oct 31, 2024
1 parent 7a9a1b7 commit 182eee2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
58 changes: 48 additions & 10 deletions Sources/FioriSwiftUICore/Components/CancellableResettableForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ struct CancellableResettableDialogForm<Title: View, CancelAction: View, ResetAct
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)

self.components.background(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.secondaryGroupedBackground) : Color.clear)
#if !os(visionOS)
self.components.background(Color.preferredColor(.secondaryGroupedBackground))
#else
self.components.background(Color.clear)
#endif
self.applyAction
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? 393 : nil)
.padding([.top, .bottom], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.background(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.chromeSecondary) : Color.clear)
#if !os(visionOS)
.background(Color.preferredColor(.chromeSecondary))
#else
.background(Color.clear)
#endif
}
}

Expand Down Expand Up @@ -68,7 +76,11 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
var body: some View {
NavigationStack {
VStack(spacing: UIDevice.current.userInterfaceIdiom == .pad ? 8 : 16) {
self.components.background(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.secondaryGroupedBackground) : Color.clear)
#if !os(visionOS)
self.components.background(Color.preferredColor(.secondaryGroupedBackground))
#else
self.components.background(Color.clear)
#endif
self.applyAction
}
.navigationBarTitleDisplayMode(.inline)
Expand All @@ -86,7 +98,11 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? 393 : nil)
.padding([.bottom], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.background(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.chromeSecondary) : Color.clear)
#if !os(visionOS)
.background(Color.preferredColor(.chromeSecondary))
#else
.background(Color.clear)
#endif
}
}

Expand All @@ -101,8 +117,14 @@ struct ApplyButtonStyle: PrimitiveButtonStyle {
.padding([.top, .bottom], 8)
.font(.body)
.fontWeight(.bold)
.foregroundStyle(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.base2) : Color.preferredColor(.primaryLabel))
.background(RoundedRectangle(cornerRadius: 8).fill(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.tintColor) : Color.clear))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.base2))
.background(RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.tintColor)))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
.background(RoundedRectangle(cornerRadius: 8).fill(Color.clear))
#endif

.onTapGesture {
configuration.trigger()
}
Expand All @@ -114,7 +136,11 @@ struct ApplyButtonStyle: PrimitiveButtonStyle {
.padding([.top, .bottom], 8)
.font(.body)
.fontWeight(.bold)
.foregroundStyle(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.grey1) : Color.preferredColor(.primaryLabel))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.grey1))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
.background(RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.grey5)))
.padding([.top], UIDevice.current.userInterfaceIdiom == .pad ? 16 : 8)
}
Expand All @@ -126,7 +152,11 @@ struct CancelButtonStyle: PrimitiveButtonStyle {
configuration.label
.font(.body)
.fontWeight(.bold)
.foregroundStyle(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.tintColor) : Color.preferredColor(.primaryLabel))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.tintColor))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
.onTapGesture {
configuration.trigger()
}
Expand All @@ -141,15 +171,23 @@ struct ResetButtonStyle: PrimitiveButtonStyle {
configuration.label
.font(.body)
.fontWeight(.bold)
.foregroundStyle(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.tintColor) : Color.preferredColor(.primaryLabel))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.tintColor))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
.onTapGesture {
configuration.trigger()
}
} else {
configuration.label
.font(.body)
.fontWeight(.bold)
.foregroundStyle(UIDevice.current.userInterfaceIdiom != .vision ? Color.preferredColor(.separator) : Color.preferredColor(.primaryLabel))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.separator))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public protocol OptionListPickerStyle {
func makeBody(configuration: OptionListPickerButtonConfiguration) -> AnyView
}

#if !os(visionOS)
public let DefaultOptionListPickerForegroundColor = Color.preferredColor(.tintColor)
#else
public let DefaultOptionListPickerForegroundColor = Color.preferredColor(.primaryLabel)
#endif

/// Default option list picker style
public struct DefaultOptionListPickerStyle: OptionListPickerStyle {
let font: Font
Expand All @@ -68,7 +74,7 @@ public struct DefaultOptionListPickerStyle: OptionListPickerStyle {
let minTouchHeight: CGFloat

/// :nodoc:
public init(font: Font = .system(.body), foregroundColorSelected: Color = .preferredColor(.tintColor), foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = .preferredColor(.secondaryGroupedBackground), fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = .preferredColor(.tintColor), strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 16, spacing: CGFloat = 4, borderWidth: CGFloat = 1, minHeight: CGFloat = 44, minTouchHeight: CGFloat = 50) {
public init(font: Font = .system(.body), foregroundColorSelected: Color = DefaultOptionListPickerForegroundColor, foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = .preferredColor(.secondaryGroupedBackground), fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = DefaultOptionListPickerForegroundColor, strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 16, spacing: CGFloat = 4, borderWidth: CGFloat = 1, minHeight: CGFloat = 44, minTouchHeight: CGFloat = 50) {
self.font = font
self.foregroundColorSelected = foregroundColorSelected
self.foregroundColorUnselected = foregroundColorUnselected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ extension SearchListPickerItem: View {
Spacer()
if isSelected {
Image(systemName: "checkmark")
.foregroundColor(.preferredColor(UIDevice.current.userInterfaceIdiom != .vision ? .tintColor : .primaryLabel))
#if !os(visionOS)
.foregroundStyle(Color.preferredColor(.tintColor))
#else
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
}
}
.padding(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public protocol FilterFeedbackBarStyle {
func makeBody(configuration: Self.Configuration) -> AnyView
}

#if !os(visionOS)
public let DefaultFilterFeedbackBarForegroundColor = Color.preferredColor(.tintColor)
#else
public let DefaultFilterFeedbackBarForegroundColor = Color.preferredColor(.primaryLabel)
#endif

/// Default style for sort and filer menu item
public struct DefaultFilterFeedbackBarStyle: FilterFeedbackBarStyle {
let font: Font
Expand All @@ -40,7 +46,7 @@ public struct DefaultFilterFeedbackBarStyle: FilterFeedbackBarStyle {
let minHeight: CGFloat

/// :nodoc:
public init(font: Font = .system(.body), foregroundColorSelected: Color = (UIDevice.current.userInterfaceIdiom != .vision ? .preferredColor(.tintColor) : .preferredColor(.primaryLabel)), foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = Color.clear, fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = (UIDevice.current.userInterfaceIdiom != .vision ? .preferredColor(.tintColor) : .preferredColor(.primaryLabel)), strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 10, spacing: CGFloat = 6, padding: CGFloat = 8, borderWidth: CGFloat = 1, minHeight: CGFloat = 38) {
public init(font: Font = .system(.body), foregroundColorSelected: Color = DefaultFilterFeedbackBarForegroundColor, foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = Color.clear, fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = DefaultFilterFeedbackBarForegroundColor, strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 10, spacing: CGFloat = 6, padding: CGFloat = 8, borderWidth: CGFloat = 1, minHeight: CGFloat = 38) {
self.font = font
self.foregroundColorSelected = foregroundColorSelected
self.foregroundColorUnselected = foregroundColorUnselected
Expand Down

0 comments on commit 182eee2

Please sign in to comment.