Zum Inhalt

apple/PhysarumApp/Sources/UI/LockButton.swift

#if !os(tvOS)
import SwiftUI

/// A small 🔒 toggle bound to one ParamID. Locked params are skipped by Randomize/Mutate.
struct LockButton: View {
    @Bindable var state: AppState
    let id: ParamID

    var body: some View {
        Button { state.toggleLock(id) } label: {
            Image(systemName: state.isLocked(id) ? "lock.fill" : "lock.open")
                .font(.system(size: 10))
                .foregroundStyle(state.isLocked(id) ? Theme.Colors.accent : Theme.Colors.fgTertiary)
                #if os(macOS)
                .frame(width: 22, height: 20)   // comfortable click target on macOS
                .contentShape(Rectangle())
                #endif
        }
        .buttonStyle(.plain)
        .help(state.isLocked(id) ? "Unlock (randomize will change it)" : "Lock (randomize will keep it)")
    }
}
#endif