I am working on a task list app that displays tasks as items in a SwiftUI List. The user can perform a swipe action to mark an item as finished or unfinished. The code for that looks like this:
.swipeActions(edge: .leading, allowsFullSwipe: true) {
Button(task.status.isDone ? "Uncheck" : "Check") {
task.status.isDone.toggle()
}
.tint(.blue)
Button("Schedule") { /* ... */ }
}
When I test it on macOS, the width of the check/uncheck button changes with its content.
I’ve done a few tests and the swipe button’s width seems to depend on its text. Whenever I put in something like “Uncheck” or “Unfinished”, it occupies the full width when swiped. I get the same effect when I set the button’s role to destructive, however setting a different role to prevent it doesn’t work.
Is this the intended behaviour? If so, why? I would very much like for the button to stay the same, regardless of its text, but that doesn’t seem to be possible.