iOS 16 is now the minimum version for the project. Signed-off-by: kingbri <bdashore3@proton.me>
28 lines
731 B
Swift
28 lines
731 B
Swift
//
|
|
// ConditionalContextMenu.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 9/3/22.
|
|
//
|
|
// Used as a workaround for iOS 15 not updating context views with conditional variables
|
|
// A stateful ID is required for the contextMenu to update itself.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ConditionalContextMenuModifier<InternalContent: View, ID: Hashable>: ViewModifier {
|
|
let internalContent: () -> InternalContent
|
|
let id: ID
|
|
|
|
init(@ViewBuilder _ internalContent: @escaping () -> InternalContent, id: ID) {
|
|
self.internalContent = internalContent
|
|
self.id = id
|
|
}
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.contextMenu {
|
|
internalContent()
|
|
}
|
|
}
|
|
}
|