Search code examples
swiftuiswiftui-list

Disclosure Indicator with .listRowInsets(EdgeInsets())


I want the entire row of my List to have a background color without any white space on the left and right, so I use the .listRowInsets(EdgeInsets()) modifier. Here is the relevant code snippet.

List {
    ForEach(issue.Data, id: \.self) { issueItem in                   
        NavigationLink(destination: IssueView(issueID: issueItem.IssueID)) {
            IssueRow(issue: issueItem)
        }
    }
    .listRowInsets(EdgeInsets())
}

However, this has the effect of pushing the disclosure indicator to the very right, which doesn't look very nice in my opinion:

enter image description here

Without the .listRowInsets(EdgeInsets()) modifier, this is how the screen looks (which is not what I want, I wanted the previous version, but the disclosure indicator looks nicer here):

enter image description here

Is there a way to have the entire row have the background color without the disclosure indicator being pushed all the way to the right?


Solution

  • Try using a nonzero inset only for the trailing:

    .listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 20))