Introspect now properly updates on every view lifecycle change, so add a check to a reference on the UIHostingController and see if it has been instantiated already. Also clean up view struct names to reflect what is a modifier. Signed-off-by: kingbri <bdashore3@proton.me>
24 lines
451 B
Swift
24 lines
451 B
Swift
//
|
|
// ConditionalId.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 9/4/22.
|
|
//
|
|
// Applies an ID below iOS 16
|
|
// This is due to ID workarounds making iOS 16 apps crash
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ConditionalIdModifier<ID: Hashable>: ViewModifier {
|
|
let id: ID
|
|
|
|
func body(content: Content) -> some View {
|
|
if #available(iOS 16, *) {
|
|
content
|
|
} else {
|
|
content
|
|
.id(id)
|
|
}
|
|
}
|
|
}
|