diff --git a/Sources/FioriSwiftUICore/Components/CancellableResettableForm.swift b/Sources/FioriSwiftUICore/Components/CancellableResettableForm.swift index d378e9488..6cc6c46dc 100644 --- a/Sources/FioriSwiftUICore/Components/CancellableResettableForm.swift +++ b/Sources/FioriSwiftUICore/Components/CancellableResettableForm.swift @@ -26,7 +26,7 @@ struct CancellableResettableDialogForm 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) @@ -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) @@ -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) } } } diff --git a/Sources/FioriSwiftUICore/Views/OptionListPickerItem+View.swift b/Sources/FioriSwiftUICore/Views/OptionListPickerItem+View.swift index 1dbe861e0..37c777b1d 100644 --- a/Sources/FioriSwiftUICore/Views/OptionListPickerItem+View.swift +++ b/Sources/FioriSwiftUICore/Views/OptionListPickerItem+View.swift @@ -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) } } @@ -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) } } @@ -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) @@ -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)) diff --git a/Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift b/Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift index cab732a47..316f32e6c 100644 --- a/Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift +++ b/Sources/FioriSwiftUICore/Views/SearchListPickerItem+View.swift @@ -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) @@ -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()) diff --git a/Sources/FioriSwiftUICore/Views/SortFilter/FilterFeedbackBarItem+View.swift b/Sources/FioriSwiftUICore/Views/SortFilter/FilterFeedbackBarItem+View.swift index a9a0ed059..33f122b53 100644 --- a/Sources/FioriSwiftUICore/Views/SortFilter/FilterFeedbackBarItem+View.swift +++ b/Sources/FioriSwiftUICore/Views/SortFilter/FilterFeedbackBarItem+View.swift @@ -102,7 +102,7 @@ struct SliderMenuItem: View { } components: { SliderPickerItem(value: Binding(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 @@ -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 @@ -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) @@ -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 @@ -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]) } } } @@ -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, @@ -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 diff --git a/Sources/FioriSwiftUICore/Views/SortFilter/_SortFilterCFGItemContainer.swift b/Sources/FioriSwiftUICore/Views/SortFilter/_SortFilterCFGItemContainer.swift index 76b71a844..313c77aef 100644 --- a/Sources/FioriSwiftUICore/Views/SortFilter/_SortFilterCFGItemContainer.swift +++ b/Sources/FioriSwiftUICore/Views/SortFilter/_SortFilterCFGItemContainer.swift @@ -33,15 +33,13 @@ extension _SortFilterCFGItemContainer: View { ForEach(0 ..< self._items[r].count, id: \.self) { c in 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) } } footer: { Rectangle().fill(Color.preferredColor(.primaryGroupedBackground)) - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth : Screen.bounds.size.width, height: 30) } .listSectionSeparator(.hidden, edges: .all) .listRowInsets(EdgeInsets()) - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 * 2 : Screen.bounds.size.width - 16 * 2) - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth : Screen.bounds.size.width) .background(Color.preferredColor(.secondaryGroupedBackground)) } } @@ -53,10 +51,10 @@ extension _SortFilterCFGItemContainer: View { .modifier(FioriIntrospectModifier { scrollView in DispatchQueue.main.async { 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() - var maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom == .pad ? 150 : 30) + var maxScrollViewHeight = popverHeight - totalSpacing - totalPadding - safeAreaInset.top - safeAreaInset.bottom - (UIDevice.current.userInterfaceIdiom != .phone ? 130 : 30) maxScrollViewHeight -= self._keyboardHeight self.height = min(scrollView.contentSize.height, maxScrollViewHeight) } @@ -131,11 +129,10 @@ extension _SortFilterCFGItemContainer: View { .padding([.top], 12) case .datetime: self.datetimePicker(row: r, column: c) - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth : Screen.bounds.size.width) + .frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : Screen.bounds.size.width) .padding([.top, .bottom], 12) case .stepper: self.stepper(row: r, column: c) - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth : Screen.bounds.size.width) .padding([.top, .bottom], 12) } } @@ -155,10 +152,9 @@ extension _SortFilterCFGItemContainer: View { self._items[r][c].picker.selectAll(isAll) } updateSearchListPickerHeight: { height in if self._keyboardHeight > 0 { - let safeAreaInset = self.getSafeAreaInsets() - self.searchListHeight = height + StatusBar.height + safeAreaInset.top + safeAreaInset.bottom + (UIDevice.current.userInterfaceIdiom == .pad ? 150 : 30) + self.searchListHeight = height + (UIDevice.current.userInterfaceIdiom != .phone ? 230 : 150) } else { - self.searchListHeight = height + 52 + (UIDevice.current.userInterfaceIdiom == .pad ? 150 : 30) + self.searchListHeight = self.height } } .frame(height: self.searchListHeight) @@ -273,7 +269,7 @@ extension _SortFilterCFGItemContainer: View { .foregroundColor(Color.preferredColor(.primaryLabel)) Spacer() } - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 * 2 : Screen.bounds.size.width - 16 * 2) + .frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth - 13 * 2 : Screen.bounds.size.width - 16 * 2) HStack { Text(NSLocalizedString("Time", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")) @@ -287,7 +283,7 @@ extension _SortFilterCFGItemContainer: View { ) .labelsHidden() } - .frame(width: UIDevice.current.userInterfaceIdiom == .pad ? self.popoverWidth - 13 * 2 : Screen.bounds.size.width - 16 * 2) + .frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth - 13 * 2 : Screen.bounds.size.width - 16 * 2) DatePicker( "", @@ -296,7 +292,7 @@ extension _SortFilterCFGItemContainer: 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() } } @@ -343,7 +339,7 @@ extension _SortFilterCFGItemContainer: View { .font(.fiori(forTextStyle: .subheadline, weight: .bold, isItalic: false, isCondensed: false)) .foregroundColor(Color.preferredColor(.primaryLabel)) Spacer() - }.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom == .pad ? 13 : 16) + }.padding([.leading, .trailing], UIDevice.current.userInterfaceIdiom != .phone ? 13 : 16) StepperView( title: { Text(self._items[r][c].stepper.stepperTitle) }, @@ -379,6 +375,7 @@ extension _SortFilterCFGItemContainer: View { v.incrementActionStyle(.deactivate) } .frame(minHeight: self.stepperViewHeight) + .frame(width: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : Screen.bounds.size.width) .padding(0) .sizeReader { s in self.stepperViewHeight = max(self.stepperViewHeight, s.height)