Ferrite-backup/Ferrite/Views/CommonViews/Modifiers/DisabledAppearance.swift
kingbri 4a87d86e76 Ferrite: Add fixes for Introspect v0.2.2
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>
2023-02-18 11:39:03 -05:00

23 lines
543 B
Swift

//
// DisabledAppearance.swift
// Ferrite
//
// Created by Brian Dashore on 9/10/22.
//
// Adds opacity transitions to the disabled modifier
//
import SwiftUI
struct DisabledAppearanceModifier: ViewModifier {
let disabled: Bool
let dimmedOpacity: Double?
let animation: Animation?
func body(content: Content) -> some View {
content
.disabled(disabled)
.opacity(disabled ? dimmedOpacity.map { $0 } ?? 0.5 : 1)
.animation(animation.map { $0 } ?? .none, value: disabled)
}
}