fix(store): position categories view below dynamic island using reactive safe area top reader & refactor layout components

This commit is contained in:
Daniel Arantes Loverde
2026-06-03 11:29:27 -03:00
parent 9fb8dae45a
commit 235b6d44cc
43 changed files with 435 additions and 413 deletions

View File

@@ -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
}
}
}
}