forked from Read-Write/Submariner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// SBToggleNameTransformer.swift | ||
// Submariner | ||
// | ||
// Created by Calvin Buckley on 2024-05-11. | ||
// | ||
// Copyright (c) 2024 Calvin Buckley | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import Cocoa | ||
|
||
@objc(SBToggleNameTransformer) class SBToggleNameTransformer: ValueTransformer { | ||
let name: String | ||
|
||
init(name: String) { | ||
self.name = name | ||
super.init() | ||
} | ||
|
||
override class func allowsReverseTransformation() -> Bool { | ||
return false | ||
} | ||
|
||
override class func transformedValueClass() -> AnyClass { | ||
return NSString.self | ||
} | ||
|
||
override func transformedValue(_ value: Any?) -> Any? { | ||
if let valueNumber = value as? NSNumber?, valueNumber == true { | ||
return "Hide \(name)" | ||
} else { | ||
return "Show \(name)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters