fix(store): position categories view below dynamic island using reactive safe area top reader & refactor layout components
This commit is contained in:
@@ -61,3 +61,31 @@ struct AsyncStoreImage: View {
|
||||
.scaledToFill()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user