mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-27 03:41:19 +01:00
feat: add duplicate and remove button
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// ContextMenuViewModifier.swift
|
||||
// Memola
|
||||
//
|
||||
// Created by Dscyre Scotti on 5/17/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Foundation
|
||||
|
||||
struct ContextMenuViewModifier<MenuContent: View>: ViewModifier {
|
||||
let condition: Bool
|
||||
let menuItems: () -> MenuContent
|
||||
|
||||
@ViewBuilder
|
||||
func body(content: Content) -> some View {
|
||||
if condition {
|
||||
content.contextMenu(menuItems: menuItems)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension View {
|
||||
func contextMenu<MenuContent: View>(if condition: Bool, @ViewBuilder menuItems: @escaping () -> MenuContent) -> some View {
|
||||
modifier(ContextMenuViewModifier(condition: condition, menuItems: menuItems))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user