1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 17:38:38 +00:00
MTMR/MTMR/Widgets/BrightnessUpBarItem.swift
Fedor Zaitsev 101a81bf3b Refactored parsing
Rewrote presets parsing. Instead of parsing presets in a separate file using bunch of huge enums it is now parsed inside each object.

To implement a new class:
1. Derive your class from CustomTouchBarItem (for static) or CustomButtonTouchBarItem (for buttons)
2. Override class var typeIdentifier with your object identificator
3. Override init(from decoder: Decoder) and read all custom json params you need
4. Don't forget to call super.init(identifier: CustomTouchBarItem.createIdentifier(type)) in the init() function
5. Add your new class to BarItemDefinition.types in ItemParsing.swift

Good example is PomodoroBarItem

If you want to inherid from some other NS class (NSSlider or NSPopoverTouchBarItem or other) then look into GroupBarItem and BrightnessViewController
2020-04-30 22:16:24 -07:00

28 lines
664 B
Swift

//
// BrightnessUpBarItem.swift
// MTMR
//
// Created by Fedor Zaitsev on 4/27/20.
// Copyright © 2020 Anton Palgunov. All rights reserved.
//
import Foundation
class BrightnessUpBarItem: CustomButtonTouchBarItem {
override class var typeIdentifier: String {
return "brightnessUp"
}
required init(from decoder: Decoder) throws {
try super.init(from: decoder)
self.setImage(#imageLiteral(resourceName: "brightnessUp"))
self.setTapAction(EventAction().setKeyPressClosure(keycode: 144))
}
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}