fix(store): replace custom geometry safe area top reader with computed property to fix category tabs placement
This commit is contained in:
@@ -62,30 +62,5 @@ struct AsyncStoreImage: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SafeAreaTopPreferenceKey: PreferenceKey {
|
|
||||||
static let defaultValue: CGFloat = 0
|
|
||||||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
|
||||||
let next = nextValue()
|
|
||||||
if next > 0 {
|
|
||||||
value = next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SafeAreaTopReader: View {
|
|
||||||
@Binding var safeAreaTop: CGFloat
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
GeometryReader { geometry in
|
|
||||||
Color.clear
|
|
||||||
.preference(key: SafeAreaTopPreferenceKey.self, value: geometry.safeAreaInsets.top)
|
|
||||||
}
|
|
||||||
.frame(height: 0)
|
|
||||||
.onPreferenceChange(SafeAreaTopPreferenceKey.self) { value in
|
|
||||||
if value > 0 && safeAreaTop != value {
|
|
||||||
safeAreaTop = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,13 @@ struct StoreDetailView: View {
|
|||||||
@State var categoryHeaderOffsets: [String: CGFloat] = [:]
|
@State var categoryHeaderOffsets: [String: CGFloat] = [:]
|
||||||
@State var isProgrammaticCategoryScroll = false
|
@State var isProgrammaticCategoryScroll = false
|
||||||
@State var scrollOffset: CGFloat = 0
|
@State var scrollOffset: CGFloat = 0
|
||||||
@State var safeAreaTop: CGFloat = 0
|
var safeAreaTop: CGFloat {
|
||||||
|
#if canImport(UIKit)
|
||||||
|
return UIDevice.appSafeAreaTop
|
||||||
|
#else
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@State var isFavoriteRequestInFlight = false
|
@State var isFavoriteRequestInFlight = false
|
||||||
|
|
||||||
let cardTopInset: CGFloat = 180
|
let cardTopInset: CGFloat = 180
|
||||||
@@ -49,8 +55,6 @@ struct StoreDetailView: View {
|
|||||||
let stickyProgress = categoryTabsStickyProgress(safeTop: safeAreaTop)
|
let stickyProgress = categoryTabsStickyProgress(safeTop: safeAreaTop)
|
||||||
|
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
SafeAreaTopReader(safeAreaTop: $safeAreaTop)
|
|
||||||
|
|
||||||
AppColors.backgroundLight.ignoresSafeArea()
|
AppColors.backgroundLight.ignoresSafeArea()
|
||||||
|
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user