I don't understand why the green button in the yellow view is NOT clickable, because it is in a "safe area" of the detail section and the blue button at the top is clickable, even tough it is in the "safe area" too?
I have NO idea:
I don't understand why the green button in the yellow view is NOT clickable, because it is in a "safe area" of the detail section and the blue button at the top is clickable, even tough it is in the "safe area" too?
I have NO idea:
You should show code. Is it this one ?
let plusButton = IconButton(imageName: "plus.circle.fill", color: Color(uiColor: ThemeColor.SeaFoam.color),
imageWidth: p.size.width * 5 / 100, buttonWidth: p.size.width * 5 / 100)
let regularAddButton = Button(action: { log.info("| Regular Add Button pressed") } ) {
plusButton
}
How is IconButton defined ?
It seems the plusButton intercepts the tap, and regularAddButton is not fired.
To test, tryto add a print statement in plusButton action.
If that solves the issue, don't forget to close the thread by marking the correct answer.
Here is the code which produces the screen shown above. I've replaced the "fancy" button with a regular text button, but the problem still persists.
struct NavTestView: View {
@State private var selection: TestView?
var body: some View {
GeometryReader { p in
let plusButton = IconButton(imageName: "plus.circle.fill", color: Color.blue,
imageWidth: p.size.width * 5 / 100, buttonWidth: p.size.width * 5 / 100)
let regularAddButton = Button(action: { log.info("| Regular Add Button pressed") } ) {
plusButton
}
VStack(spacing: 0) {
VStack {
regularAddButton
}.frame(width: p.size.width , height: (p.size.height * 10 / 100) + p.safeAreaInsets.top , alignment: .top)
.background(Color.brown)
.ignoresSafeArea()
NavigationSplitView {
List(names) { n in
NavigationLink {
GeometryReader { inner in
TestView(label: n.name).ignoresSafeArea()
}
} label: {
Button(action: {} ) {
Label(n.name, systemImage: "lasso")
}
}
}.listRowSpacing(p.size.height * 0.15 / 100 )
.toolbar(.hidden, for: .automatic)
} detail: {
TestView(label: "No selection").ignoresSafeArea()//.frame(maxWidth: .infinity , maxHeight: .infinity)
}.frame(width: p.size.width, height: p.size.height * 90 / 100 , alignment: .topLeading)
.background(Color.yellow)
}
}
}
}
struct TestView: View {
var label: String
var body: some View {
GeometryReader { p in
let plusButton = IconButton(imageName: "plus.circle.fill", color: Color(uiColor: ThemeColor.SeaFoam.color),
imageWidth: p.size.width * 5 / 100, buttonWidth: p.size.width * 5 / 100)
let regularAddButton = Button(action: { log.info("| Regular Add Button pressed") } ) {
plusButton
}
VStack {
Button(action: { } ) {
Text("Click me!")
}
// regularAddButton
Text(label)
}.frame(width: p.size.width , height: p.size.height, alignment: .top)
.background(Color.yellow)
}
}
}