I am trying to make Menu using swiftUI in MacOS application.
Based on this:
I am using this specific code
struct SelectionRow: View {
var title: String
var isSelected: Bool
var action: () -> Void
var body: some View {
Button(action: self.action) {
HStack {
if self.isSelected {
Image("checkmark")
.resizable()
.renderingMode(.template)
.scaledToFit()
} else {
//FIXME: What to add here ???!!! <-- Need to add solution here I believe
}
Text(self.title)
//.frame(alignment: .trailing). <-- Not effective
}
}.foregroundColor(Color.black)
}
}
Menu-item entries:
Menu("Example Menu"){
SelectionRow(title: "One", isSelected: true, action: { print("hello world")})
SelectionRow(title: "Two", isSelected: false, action: { print("hello world")})
SelectionRow(title: "Three", isSelected: true, action: { print("hello world")})
}
If you look at the image "Two" menu item is not aligned with "One" and "Three" menu options, as there is an image of checkmark is there for options "One" & "Thrree". I tried Spacer with Minimum width (and some other options) but doesn't seem to work and align "Two" with "One" & "Three"
Can you recommend anything which can resolve this issue and make alignment of "Two" inline with "One" & "Three" ?