Given:
SectionView
as a row representation in aList
- Swipe actions associated with this view
- Tappable
Image
as a part of the same view
Required:
Display swipe actions on Image
tap, not only using a swipe gesture.
Will be thankful for any clues regarding implementation.
struct SectionView: View {
@ObservedObject var viewModel: SectionVM
var body: some View {
HStack {
...
Image("iconVerticalDots")
.renderingMode(.template)
.foregroundColor(AppColors.accent.asColor)
.padding([.vertical, .leading], 4.0)
.onTapGesture {
//Show swipe actions
}
}
.swipeActions {
actions
}
}
var actions: some View {
ForEach(viewModel.menuTypes, id: \.name) { item in
Button {
print(item)
} label: {
VStack(spacing: 4.0) {
item.icon
.map(Image.init)?
.resizable()
.frame(width: 16.0, height: 16.0)
.aspectRatio(contentMode: .fit)
Text(item.name)
}
}
.tint(item.background.asColor)
}
}