mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
renamed nthEvent to maxToShow and changed default
This commit is contained in:
parent
292da17aee
commit
efb047e6f0
@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.26.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>405</string>
|
||||
<string>424</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@ -227,7 +227,7 @@ enum ItemType: Decodable {
|
||||
case network(flip: Bool)
|
||||
case darkMode
|
||||
case swipe(direction: String, fingers: Int, minOffset: Float, sourceApple: SourceProtocol?, sourceBash: SourceProtocol?)
|
||||
case upnext(from: Double, to: Double, nthEvent: Int)
|
||||
case upnext(from: Double, to: Double, maxToShow: Int)
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
@ -259,7 +259,7 @@ enum ItemType: Decodable {
|
||||
case direction
|
||||
case fingers
|
||||
case minOffset
|
||||
case nthEvent
|
||||
case maxToShow
|
||||
}
|
||||
|
||||
enum ItemTypeRaw: String, Decodable {
|
||||
@ -385,8 +385,8 @@ enum ItemType: Decodable {
|
||||
case .upnext:
|
||||
let from = try container.decodeIfPresent(Double.self, forKey: .from) ?? 0 // Lower bounds of period of time in hours to search for events
|
||||
let to = try container.decodeIfPresent(Double.self, forKey: .to) ?? 12 // Upper bounds of period of time in hours to search for events
|
||||
let nthEvent = try container.decodeIfPresent(Int.self, forKey: .nthEvent) ?? 1 // 1 indexed array. Get the 1st, 2nd, 3rd event to display multiple notifications
|
||||
self = .upnext(from: from, to: to, nthEvent: nthEvent)
|
||||
let maxToShow = try container.decodeIfPresent(Int.self, forKey: .maxToShow) ?? 1 // 1 indexed array. Get the 1st, 2nd, 3rd event to display multiple notifications
|
||||
self = .upnext(from: from, to: to, maxToShow: maxToShow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,8 +303,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = DarkModeBarItem(identifier: identifier)
|
||||
case let .swipe(direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash):
|
||||
barItem = SwipeItem(identifier: identifier, direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash)
|
||||
case let .upnext(from: from, to: to, nthEvent: nthEvent):
|
||||
barItem = UpNextBarItem(identifier: identifier, interval: 2, from: from, to: to, nthEvent: nthEvent)
|
||||
case let .upnext(from: from, to: to, maxToShow: maxToShow):
|
||||
barItem = UpNextBarItem(identifier: identifier, interval: 2, from: from, to: to, maxToShow: maxToShow)
|
||||
}
|
||||
|
||||
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||
|
||||
@ -20,7 +20,7 @@ class UpNextBarItem: NSCustomTouchBarItem {
|
||||
// Settings
|
||||
private var futureSearchCutoff: Double
|
||||
private var pastSearchCutoff: Double
|
||||
private var nthEvent: Int
|
||||
private var maxToShow: Int
|
||||
private var widthConstraint: NSLayoutConstraint?
|
||||
|
||||
/// <#Description#>
|
||||
@ -29,17 +29,17 @@ class UpNextBarItem: NSCustomTouchBarItem {
|
||||
/// - interval: Update view interval in seconds
|
||||
/// - from: Relative to current time, how far back we search for events in hours
|
||||
/// - to: Relative to current time, how far forward we search for events in hours
|
||||
/// - nthEvent: Which event to show (1 is first, 2 is second, and so on)
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: Double, to: Double, nthEvent: Int) {
|
||||
/// - maxToShow: Which event to show (1 is first, 2 is second, and so on)
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: Double, to: Double, maxToShow: Int) {
|
||||
// Initialise member properties
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updateCheck")
|
||||
pastSearchCutoff = from * 3600
|
||||
futureSearchCutoff = to * 3600
|
||||
self.nthEvent = nthEvent
|
||||
self.maxToShow = maxToShow
|
||||
UpNextItem.df.dateFormat = "HH:mm"
|
||||
// Error handling
|
||||
if (nthEvent <= 0) {
|
||||
fatalError("Error on UpNext bar item. nthEvent property must be greater than 0.")
|
||||
if (maxToShow <= 0) {
|
||||
fatalError("Error on UpNext bar item. maxToShow property must be greater than 0.")
|
||||
}
|
||||
// Init super
|
||||
super.init(identifier: identifier)
|
||||
@ -82,7 +82,7 @@ class UpNextBarItem: NSCustomTouchBarItem {
|
||||
// Add to view
|
||||
self.items.append(item)
|
||||
// Check if should display any more
|
||||
if (index == self.nthEvent) {
|
||||
if (index == self.maxToShow) {
|
||||
break;
|
||||
}
|
||||
index += 1
|
||||
|
||||
@ -347,13 +347,14 @@ To close a group, use the button:
|
||||
#### `upnext`
|
||||
|
||||
> Calender next event plugin
|
||||
Displays upcoming events from MacOS Calendar. Does not display current event
|
||||
|
||||
```js
|
||||
{
|
||||
"type": "upnext",
|
||||
"from": 0, // Lower bound of search range for next event in hours. Default 0 (current time)
|
||||
"from": 0, // Lower bound of search range for next event in hours. Default 0 (current time, can be negative to view events in the past)
|
||||
"to": 12, // Upper bounds of search range for next event in hours. Default 12 (12 hours in the future)
|
||||
"nthEvent": 1 // Sets this touchbar button to show the nthEvent. Default 1 (the first upcoming event)
|
||||
"maxToShow": 3 // Limits the maximum number of events displayed. Default 3 (the first 3 upcoming events)
|
||||
},
|
||||
```
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user