Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 [IOSSDKBUG-416]FilterFeedBackBar layout #883

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
var resetAction: ResetAction
var applyAction: ApplyAction

let popoverWidth = 393.0

public init(@ViewBuilder title: () -> Title,
@ViewBuilder cancelAction: () -> CancelAction,
@ViewBuilder resetAction: () -> ResetAction,
Expand Down Expand Up @@ -100,7 +98,6 @@ struct CancellableResettableDialogNavigationForm<Title: View, CancelAction: View
}
}
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.padding([.bottom], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
#if !os(visionOS)
.background(Color.preferredColor(.chromeSecondary))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ extension OptionListPickerItem: View {
GeometryReader { geometry in
Color.clear
.onAppear {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let popverHeight = Screen.bounds.size.height
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 != .phone ? 210 : 30)
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 210 : 60)
self._height = min(geometry.size.height, maxScrollViewHeight)
}
}
Expand Down Expand Up @@ -94,11 +94,11 @@ extension OptionListPickerItem: View {
GeometryReader { geometry in
Color.clear
.onAppear {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let popverHeight = Screen.bounds.size.height
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 != .phone ? 210 : 30)
let maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 210 : 60)
self._height = min(geometry.size.height, maxScrollViewHeight)
}
}
Expand Down
132 changes: 64 additions & 68 deletions Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,13 @@ public extension SearchListPickerItem {

extension SearchListPickerItem: View {
public var body: some View {
VStack(spacing: 0) {
List {
if !disableListEntriesSection, _value.count > 0 {
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)
.padding(0)
.contentShape(Rectangle())
.onTapGesture {
guard let index = findIndex(of: item) else {
return
}
_onTap?(index)
}
}

Rectangle().fill(Color.preferredColor(.primaryGroupedBackground))
.frame(height: 30)
.listRowInsets(EdgeInsets())
}
}

List {
if !disableListEntriesSection, !_value.isEmpty {
Section {
if allowsMultipleSelection {
if _value.count != _valueOptions.count || allowsEmptySelection {
self.selectAllView()
}
} else if _value.count == _valueOptions.count {
self.selectAllView()
} else {
EmptyView()
}
ForEach(_valueOptions.filter { _searchText.isEmpty || $0.localizedStandardContains(_searchText) }, id: \.self) { item in
let isSelected = self.isItemSelected(item)
self.rowView(value: item, isSelected: isSelected)
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)
.padding(0)
.contentShape(Rectangle())
.onTapGesture {
Expand All @@ -73,43 +43,69 @@ extension SearchListPickerItem: View {
_onTap?(index)
}
}

Rectangle().fill(Color.preferredColor(.primaryGroupedBackground))
.frame(height: 30)
.listRowInsets(EdgeInsets())
}
}
.modifier(FioriIntrospectModifier<UIScrollView> { scrollView in
if !_searchText.isEmpty {
return
}
DispatchQueue.main.async {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16) * 2
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
if self._keyboardHeight > 0 {
maxScrollViewHeight += 56

Section {
if allowsMultipleSelection {
if _value.count != _valueOptions.count || allowsEmptySelection {
self.selectAllView()
}
self._height = min(scrollView.contentSize.height, maxScrollViewHeight)
updateSearchListPickerHeight?(self._height)
} else if _value.count == _valueOptions.count {
self.selectAllView()
} else {
EmptyView()
}
})
.listStyle(PlainListStyle())
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? popoverWidth : nil)
.scrollContentBackground(.hidden)
.padding(0)
.environment(\.defaultMinListRowHeight, 0)
.environment(\.defaultMinListHeaderHeight, 0)
.ifApply(!isSearchBarHidden, content: { v in
v.searchable(text: $_searchText, placement: .navigationBarDrawer(displayMode: .always))
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidShowNotification)) { notif in
let rect = (notif.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect) ?? .zero
self._keyboardHeight = rect.height
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidHideNotification)) { _ in
self._keyboardHeight = 0
}
})
ForEach(_valueOptions.filter { _searchText.isEmpty || $0.localizedStandardContains(_searchText) }, id: \.self) { item in
let isSelected = self.isItemSelected(item)
self.rowView(value: item, isSelected: isSelected)
.padding(0)
.contentShape(Rectangle())
.onTapGesture {
guard let index = findIndex(of: item) else {
return
}
_onTap?(index)
}
}
}
}
.modifier(FioriIntrospectModifier<UIScrollView> { scrollView in
if !_searchText.isEmpty {
return
}
DispatchQueue.main.async {
let popverHeight = Screen.bounds.size.height
let safeAreaInset = self.getSafeAreaInsets()
var maxScrollViewHeight = popverHeight - (self.isSearchBarHidden ? 0 : 52) - 56 - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 250 : 30)
maxScrollViewHeight -= self._keyboardHeight
if self._keyboardHeight > 0 {
maxScrollViewHeight += 56
}
self._height = min(scrollView.contentSize.height, maxScrollViewHeight)
updateSearchListPickerHeight?(self._height)
}
})
.listStyle(PlainListStyle())
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.scrollContentBackground(.hidden)
.padding(0)
.environment(\.defaultMinListRowHeight, 0)
.environment(\.defaultMinListHeaderHeight, 0)
.ifApply(!isSearchBarHidden, content: { v in
v.searchable(text: $_searchText, placement: .navigationBarDrawer(displayMode: .always))
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidShowNotification)) { notif in
let rect = (notif.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect) ?? .zero
self._keyboardHeight = rect.height
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidHideNotification)) { _ in
self._keyboardHeight = 0
}
})
}

private func rowView(value: String, isSelected: Bool) -> some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ struct PickerMenuItem: View {
}
Spacer()
}
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? 393 : nil)
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.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 @@ -313,7 +313,11 @@ struct DateTimeMenuItem: View {

var onUpdate: () -> Void

let popoverWidth = 393.0
#if !os(visionOS)
let popoverWidth = 393.0
#else
let popoverWidth = 480.0
#endif

public init(item: Binding<SortFilterItem.DateTimeItem>, onUpdate: @escaping () -> Void) {
self._item = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@ extension SortFilterView: View {
})
.environmentObject(context)
}
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? popoverWidth : nil)
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? size.height + 130 : nil)
.presentationDetents([.large])
#if !os(visionOS)
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? 393.0 : nil)
.background(Color.preferredColor(.chromeSecondary))
#else
.frame(minWidth: 480.0)
.background(Color.clear)
#endif
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? size.height + 150 : nil)
.presentationDetents([.large])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public struct _SortFilterCFGItemContainer {
@Binding var _items: [[SortFilterItem]]
@State var height = 88.0

let popoverWidth = 393.0
#if !os(visionOS)
let popoverWidth = 393.0
#else
let popoverWidth = 480.0
#endif
@State var stepperViewHeight: CGFloat = 110
@State var searchListHeight: CGFloat = 88.0
@State var _keyboardHeight: CGFloat = 0.0
Expand All @@ -34,6 +38,7 @@ extension _SortFilterCFGItemContainer: View {
self.rowView(row: r, column: c)
.listRowSeparator(c == self._items[r].count - 1 ? .hidden : .visible, edges: .all)
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
}
} footer: {
Rectangle().fill(Color.preferredColor(.primaryGroupedBackground))
Expand All @@ -50,12 +55,12 @@ extension _SortFilterCFGItemContainer: View {
.background(Color.preferredColor(.secondaryGroupedBackground))
.modifier(FioriIntrospectModifier<UIScrollView> { scrollView in
DispatchQueue.main.async {
let popverHeight = Screen.bounds.size.height - StatusBar.height
let totalSpacing: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 8 : 16) * 2
let totalPadding: CGFloat = (UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16) * 2
let popverHeight = Screen.bounds.size.height
let safeAreaInset = self.getSafeAreaInsets()
var maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 130 : 30)
maxScrollViewHeight -= self._keyboardHeight
var maxScrollViewHeight = popverHeight - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 190 : 150)
if UIDevice.current.userInterfaceIdiom == .pad {
maxScrollViewHeight -= self._keyboardHeight
}
self.height = min(scrollView.contentSize.height, maxScrollViewHeight)
}
})
Expand Down Expand Up @@ -129,7 +134,6 @@ extension _SortFilterCFGItemContainer: View {
.padding([.top], 12)
case .datetime:
self.datetimePicker(row: r, column: c)
.frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : Screen.bounds.size.width)
.padding([.top, .bottom], 12)
case .stepper:
self.stepper(row: r, column: c)
Expand All @@ -151,13 +155,17 @@ extension _SortFilterCFGItemContainer: View {
} selectAll: { isAll in
self._items[r][c].picker.selectAll(isAll)
} updateSearchListPickerHeight: { height in
if self._keyboardHeight > 0 {
self.searchListHeight = height + (UIDevice.current.userInterfaceIdiom != .phone ? 230 : 150)
} else {
self.searchListHeight = self.height
if UIDevice.current.userInterfaceIdiom == .pad {
if self._keyboardHeight > 0 {
self.searchListHeight = height + (UIDevice.current.userInterfaceIdiom != .phone ? 190 : 150)
} else {
self.searchListHeight = self.height
}
}
}
.frame(height: self.searchListHeight)
.ifApply(UIDevice.current.userInterfaceIdiom == .pad, content: { v in
v.frame(height: self.searchListHeight)
})
.onReceive(NotificationCenter.default.publisher(for: UIApplication.keyboardDidShowNotification)) { notif in
let rect = (notif.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect) ?? .zero
self._keyboardHeight = rect.height
Expand Down Expand Up @@ -339,7 +347,8 @@ extension _SortFilterCFGItemContainer: View {
.font(.fiori(forTextStyle: .subheadline, weight: .bold, isItalic: false, isCondensed: false))
.foregroundColor(Color.preferredColor(.primaryLabel))
Spacer()
}.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16)
}
.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 0 : 16)

StepperView(
title: { Text(self._items[r][c].stepper.stepperTitle) },
Expand Down
Loading