You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi. Thanks for library - very helpful.
Got some issue here and can't solve few days
I'm trying to create CarouselStack Item view with complex layout but getting visual glitches inside of it
I need to split my layout into few subviews because its complex and contains many Stacks for alignment and content, but can't get it working.
I've created sample project for minimal reproducing, see Additional Context
To Reproduce
Minimum amount of code to reproduce:
ContentView.swift
import SwiftUI
import CarouselStack
struct ContentView: View {
var ints = [1,2,3,4,5,6,7,8,9]
var body: some View {
CarouselStack(ints, initialIndex: 0) { int in
CustomView(passedInt: int)
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
CustomView.swift
import SwiftUI
struct CustomView: View {
let passedInt: Int
var body: some View {
VStack { //works if replace VStack with Non-Stack view
if passedInt % 2 == 0 {
viewOne.padding()
}
else {
viewTwo.padding()
}
subscription
.padding()
}
.background(.gray)
}
var viewOne: some View {
Group {
Text("I like this Int: \(passedInt)")
.foregroundColor(.yellow)
.font(.title3)
.background(content: {
ZStack {
Color(.blue)
}
})
}
}
var viewTwo: some View {
Group {
Text("I dont like this Int: \(passedInt)")
.foregroundColor(.white)
.font(.title)
.background(content: {
ZStack {
Color(.blue)
}
})
Text("\(passedInt)")
.foregroundColor(.white)
.font(.title)
.background(content: {
ZStack {
Color(.green)
}
})
}
}
var subscription: some View {
VStack {
Text("Please tell your favorite Int")
.foregroundColor(.red)
}
}
}
struct CustomView_Previews: PreviewProvider {
static var previews: some View {
CustomView(passedInt: 1)
}
}
Steps to reproduce the behavior:
Download attached project and run
Expected behavior
Everything works correctly
Screenshots
Device information (please complete the following information):
@1er4y Thank you for raising this issue with minimum project. 😃
I had a quick look and figured out that SizePreferenceKey is wrongly triggered with CGSize.zero resulting the breakdown of CarouselStack's appearance. So it could be temporarily fixed by skipping CGSize.zero value inside onPreferenceChange(_:_) modifier as follows.
.onPreferenceChange(SizePreferenceKey.self) { size in
if size != .zero {
DispatchQueue.main.async {
self.size = size
}
}
}
I had a quick look and figured out that SizePreferenceKey is wrongly triggered with CGSize.zero resulting the breakdown of CarouselStack's appearance. So it could be temporarily fixed by skipping CGSize.zero value inside onPreferenceChange(_:_) modifier as follows.
.onPreferenceChange(SizePreferenceKey.self) { size in
if size != .zero {
DispatchQueue.main.async {
self.size = size
}
}
}
Thank you for workaround - going to apply this as a temporary fix and will wait for fix versions!
@1er4y Thank you for raising this issue with minimum project. 😃
Describe the bug
Hi. Thanks for library - very helpful.
Got some issue here and can't solve few days
I'm trying to create CarouselStack Item view with complex layout but getting visual glitches inside of it
I need to split my layout into few subviews because its complex and contains many Stacks for alignment and content, but can't get it working.
I've created sample project for minimal reproducing, see Additional Context
To Reproduce
Minimum amount of code to reproduce:
ContentView.swift
CustomView.swift
Steps to reproduce the behavior:
Expected behavior
Everything works correctly
Screenshots
Device information (please complete the following information):
Additional context
MinimalProject.zip
The text was updated successfully, but these errors were encountered: