Quantcast
Channel: Active questions tagged onhover - Stack Overflow
Viewing all articles
Browse latest Browse all 50

Add a button in the header of a section next to the collapsing chevron

$
0
0

I'm trying to add a button to the header of a SwiftUI list with :

@State private var isHovered = false@Query(sort: \SoundBoard.createdAt) var soundBoards: [SoundBoard]var body: some View {    List{            Section() {                ForEach(soundBoards) { board in                    Text(board.name)                }            }            header: {                HStack {                    Text("Mes soundboards")                        .font(.subheadline)                        .bold()                    Spacer()                    if isHovered {                        Button("Add", systemImage: "plus.circle", action: { isShowingItemSheet = true })                            .labelStyle(.iconOnly)                            .tint(.accentColor)                            .buttonStyle(.plain)                    }                }                .onHover { hovering in                    isHovered = hovering                }            }        }}

The problem, as you can see from the first attached gif, is that when the mouse hovers over the header the collapsing icon is shown, as is the add button (plus-circle). So far so good.However, when my mouse hovers over the collapsing chevron icon, the hover is no longer detected by the section header.

I'd just like to do what you see on the Apple Plan application (cd gif 2)

I'm a bit new to SwiftUI. Do you have any suggestions?

My app

My app


Apple Plan App

Apple Plan App

Thank you in advance


Viewing all articles
Browse latest Browse all 50

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>