Skip to content

Commit

Permalink
fix: 🐛 [IOSSDKBUG-413] FilterFeedbackBar in visionOS layout (#871)
Browse files Browse the repository at this point in the history
* fix: 🐛 [IOSSDKBUG-413] FilterFeedbackBar in visionOS layout

FilterFeedbackBar list layout in visionOS

* fix: 🐛 [IOSSDKBUG-413] FilterFeedbackBar in visionOS layout

FilterFeedbackBar list layout in visionOS

* fix: 🐛 [IOSSDKBUG-413] FilterFeedbackBar in visionOS layout

---------

Co-authored-by: dyongxu <[email protected]>
  • Loading branch information
2 people authored and Xiayu Liu committed Nov 12, 2024
1 parent 6acb77a commit 3e872a2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ struct CancellableResettableDialogForm<Title: View, CancelAction: View, ResetAct
}

var body: some View {
VStack(spacing: UIDevice.current.userInterfaceIdiom == .pad ? 8 : 16) {
VStack(spacing: UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) {
HStack {
self.cancelAction
Spacer()
self.title
Spacer()
self.resetAction
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)

#if !os(visionOS)
self.components.background(Color.preferredColor(.secondaryGroupedBackground))
Expand All @@ -44,7 +44,7 @@ struct CancellableResettableDialogForm<Title: View, CancelAction: View, ResetAct
self.applyAction
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.padding([.top, .bottom], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.top, .bottom], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
#if !os(visionOS)
.background(Color.preferredColor(.chromeSecondary))
#else
Expand Down Expand Up @@ -79,7 +79,7 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View

var body: some View {
NavigationStack {
VStack(spacing: UIDevice.current.userInterfaceIdiom == .pad ? 8 : 16) {
VStack(spacing: UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) {
#if !os(visionOS)
self.components.background(Color.preferredColor(.secondaryGroupedBackground))
#else
Expand All @@ -101,7 +101,7 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
}
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.padding([.bottom], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.bottom], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
#if !os(visionOS)
.background(Color.preferredColor(.chromeSecondary))
#else
Expand All @@ -117,7 +117,7 @@ struct ApplyButtonStyle: PrimitiveButtonStyle {
func makeBody(configuration: Configuration) -> some View {
if self.isEnabled {
configuration.label
.frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 * 2 :
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth - 13 * 2 :
Screen.bounds.size.width - 16 * 2)
.padding([.top, .bottom], 8)
.font(.body)
Expand All @@ -133,10 +133,10 @@ struct ApplyButtonStyle: PrimitiveButtonStyle {
.onTapGesture {
configuration.trigger()
}
.padding([.top], UIDevice.current.userInterfaceIdiom == .pad ? 16 : 8)
.padding([.top], UIDevice.current.userInterfaceIdiom != .phone ? 16 : 8)
} else {
configuration.label
.frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 * 2 :
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth - 13 * 2 :
Screen.bounds.size.width - 16 * 2)
.padding([.top, .bottom], 8)
.font(.body)
Expand All @@ -147,7 +147,7 @@ struct ApplyButtonStyle: PrimitiveButtonStyle {
.foregroundStyle(Color.preferredColor(.primaryLabel))
#endif
.background(RoundedRectangle(cornerRadius: 8).fill(Color.preferredColor(.grey5)))
.padding([.top], UIDevice.current.userInterfaceIdiom == .pad ? 16 : 8)
.padding([.top], UIDevice.current.userInterfaceIdiom != .phone ? 16 : 8)
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Sources/FioriSwiftUICore/Views/OptionListPickerItem+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ extension OptionListPickerItem: View {
Color.clear
.onAppear {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom == .pad ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16) * 2
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16) * 2
let safeAreaInset = self.getSafeAreaInsets()
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom == .pad ? 210 : 30)
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 210 : 30)
self._height = min(geometry.size.height, maxScrollViewHeight)
}
}
Expand Down Expand Up @@ -95,10 +95,10 @@ extension OptionListPickerItem: View {
Color.clear
.onAppear {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom == .pad ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16) * 2
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16) * 2
let safeAreaInset = self.getSafeAreaInsets()
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom == .pad ? 210 : 30)
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 210 : 30)
self._height = min(geometry.size.height, maxScrollViewHeight)
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ struct OptionListPickerCustomLayout: Layout {
}
var containerHeight = 0.0
var currentRowX = 0.0
let padding = UIDevice.current.userInterfaceIdiom == .pad ? 13.0 : 16.0
let padding = UIDevice.current.userInterfaceIdiom != .phone ? 13.0 : 16.0
for index in 0 ..< subviews.count {
let subview = subviews[index]
let subviewSize = subview.sizeThatFits(.unspecified)
Expand All @@ -174,7 +174,7 @@ struct OptionListPickerCustomLayout: Layout {
guard let containerWidth = proposal.width else { return }
var currentY: CGFloat = bounds.minY
var currentRowX = 0.0
let padding = UIDevice.current.userInterfaceIdiom == .pad ? 13.0 : 16.0
let padding = UIDevice.current.userInterfaceIdiom != .phone ? 13.0 : 16.0
for subview in subviews {
let subviewSize = subview.sizeThatFits(.unspecified)
let subviewWidth = min(subviewSize.width, containerWidth - CGFloat(padding * 2))
Expand Down
16 changes: 5 additions & 11 deletions Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ extension SearchListPickerItem: View {
VStack(spacing: 0) {
List {
if !disableListEntriesSection, _value.count > 0 {
self.selectionHeader()

Section {
self.selectionHeader()
let selectedOptions = _value.wrappedValue.map { _valueOptions[$0] }
ForEach(selectedOptions.filter { _searchText.isEmpty || $0.localizedStandardContains(_searchText) }, id: \.self) { item in
self.rowView(value: item, isSelected: true)
Expand Down Expand Up @@ -87,16 +86,11 @@ extension SearchListPickerItem: View {
let safeAreaInset = self.getSafeAreaInsets()
var maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - (self.isSearchBarHidden ? 0 : 52) - 56 - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 250 : 30)
maxScrollViewHeight -= self._keyboardHeight
self._height = min(scrollView.contentSize.height, maxScrollViewHeight)
var isSelectAllViewShow = false
if allowsMultipleSelection {
if _value.count != _valueOptions.count || allowsEmptySelection {
isSelectAllViewShow = true
}
} else if _value.count == _valueOptions.count {
isSelectAllViewShow = true
if self._keyboardHeight > 0 {
maxScrollViewHeight += 56
}
updateSearchListPickerHeight?(isSelectAllViewShow ? self._height + 44 : self._height)
self._height = min(scrollView.contentSize.height, maxScrollViewHeight)
updateSearchListPickerHeight?(self._height)
}
})
.listStyle(PlainListStyle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct SliderMenuItem: View {

} components: {
SliderPickerItem(value: Binding<Int?>(get: { self.item.workingValue }, set: { self.item.workingValue = $0 }), formatter: self.item.formatter, minimumValue: self.item.minimumValue, maximumValue: self.item.maximumValue)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
}
.readHeight()
.onPreferenceChange(HeightPreferenceKey.self) { height in
Expand All @@ -121,7 +121,7 @@ struct PickerMenuItem: View {

@State var isSheetVisible = false

@State var detentHeight: CGFloat = ((UIDevice.current.userInterfaceIdiom == .phone || UIDevice.current.userInterfaceIdiom == .pad) ? 88 : 0)
@State var detentHeight: CGFloat = ((UIDevice.current.userInterfaceIdiom == .phone || UIDevice.current.userInterfaceIdiom != .phone) ? 88 : 0)
let popoverWidth = 393.0
@State var _keyboardHeight = 0.0

Expand Down Expand Up @@ -181,7 +181,7 @@ struct PickerMenuItem: View {
OptionListPickerItem(value: self.$item.workingValue, valueOptions: self.item.valueOptions, hint: nil, itemLayout: self.item.itemLayout) { index in
self.item.onTap(option: self.item.valueOptions[index])
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
}
.ifApply(UIDevice.current.userInterfaceIdiom != .phone, content: { v in
v.frame(minHeight: 155)
Expand Down Expand Up @@ -259,7 +259,7 @@ struct PickerMenuItem: View {
} updateSearchListPickerHeight: { height in
self.detentHeight = max(height, 88)
}
.frame(maxHeight: UIDevice.current.userInterfaceIdiom != .phone ? (self.detentHeight + (self._keyboardHeight > 0 ? 52 : 0)) : nil)
.frame(maxHeight: UIDevice.current.userInterfaceIdiom != .phone ? self.detentHeight : nil)
.padding(0)
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidShowNotification)) { notif in
let rect = (notif.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect) ?? .zero
Expand All @@ -271,8 +271,8 @@ struct PickerMenuItem: View {
Spacer()
}
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? 393 : nil)
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? self.detentHeight + (self.item.isSearchBarHidden ? 0 : 52) + 56 + 93 : nil)
.presentationDetents([.height(self.detentHeight + (self.item.isSearchBarHidden ? 0 : 52) + 56 + 93), .medium, .large])
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? self.detentHeight + (self.item.isSearchBarHidden ? 0 : 52) + (self._keyboardHeight == 0 ? 56 : 0) + 93 : nil)
.presentationDetents([.height(self.detentHeight + (self.item.isSearchBarHidden ? 0 : 52) + (self._keyboardHeight == 0 ? 56 : 0) + 93), .medium, .large])
}
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ struct DateTimeMenuItem: View {
)
.labelsHidden()
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)

DatePicker(
self.item.label,
Expand All @@ -370,10 +370,10 @@ struct DateTimeMenuItem: View {
)
.datePickerStyle(.graphical)
.labelsHidden()
.frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 : Screen.bounds.size.width - 16)
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth - 13 : Screen.bounds.size.width - 16)
.clipped()
}
.frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth : Screen.bounds.size.width)
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : Screen.bounds.size.width)
}
.readHeight()
.onPreferenceChange(HeightPreferenceKey.self) { height in
Expand Down
Loading

0 comments on commit 3e872a2

Please sign in to comment.