mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Style format
This commit is contained in:
parent
acc248a579
commit
b718b1c9dd
@ -17,9 +17,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>0.19.3</string>
|
<string>0.19.4</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>130</string>
|
<string>140</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@ -6,17 +6,17 @@
|
|||||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import Foundation
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
func trim() -> String {
|
func trim() -> String {
|
||||||
return self.trimmingCharacters(in: NSCharacterSet.whitespaces)
|
return trimmingCharacters(in: NSCharacterSet.whitespaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stripComments() -> String {
|
func stripComments() -> String {
|
||||||
// ((\s|,)\/\*[\s\S]*?\*\/)|(( |, ")\/\/.*)
|
// ((\s|,)\/\*[\s\S]*?\*\/)|(( |, ")\/\/.*)
|
||||||
return self.replacingOccurrences(of: "((\\s|,)\\/\\*[\\s\\S]*?\\*\\/)|(( |, \\\")\\/\\/.*)", with: "", options: .regularExpression)
|
return replacingOccurrences(of: "((\\s|,)\\/\\*[\\s\\S]*?\\*\\/)|(( |, \\\")\\/\\/.*)", with: "", options: .regularExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hexColor: NSColor? {
|
var hexColor: NSColor? {
|
||||||
@ -41,19 +41,18 @@ extension String {
|
|||||||
extension NSImage {
|
extension NSImage {
|
||||||
func resize(maxSize: NSSize) -> NSImage {
|
func resize(maxSize: NSSize) -> NSImage {
|
||||||
var ratio: Float = 0.0
|
var ratio: Float = 0.0
|
||||||
let imageWidth = Float(self.size.width)
|
let imageWidth = Float(size.width)
|
||||||
let imageHeight = Float(self.size.height)
|
let imageHeight = Float(size.height)
|
||||||
let maxWidth = Float(maxSize.width)
|
let maxWidth = Float(maxSize.width)
|
||||||
let maxHeight = Float(maxSize.height)
|
let maxHeight = Float(maxSize.height)
|
||||||
|
|
||||||
// Get ratio (landscape or portrait)
|
// Get ratio (landscape or portrait)
|
||||||
if (imageWidth > imageHeight) {
|
if imageWidth > imageHeight {
|
||||||
// Landscape
|
// Landscape
|
||||||
ratio = maxWidth / imageWidth;
|
ratio = maxWidth / imageWidth
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Portrait
|
// Portrait
|
||||||
ratio = maxHeight / imageHeight;
|
ratio = maxHeight / imageHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate new size based on the ratio
|
// Calculate new size based on the ratio
|
||||||
@ -64,8 +63,8 @@ extension NSImage {
|
|||||||
let newSize: NSSize = NSSize(width: Int(newWidth), height: Int(newHeight))
|
let newSize: NSSize = NSSize(width: Int(newWidth), height: Int(newHeight))
|
||||||
|
|
||||||
// Cast the NSImage to a CGImage
|
// Cast the NSImage to a CGImage
|
||||||
var imageRect:NSRect = NSMakeRect(0, 0, self.size.width, self.size.height)
|
var imageRect: NSRect = NSMakeRect(0, 0, size.width, size.height)
|
||||||
let imageRef = self.cgImage(forProposedRect: &imageRect, context: nil, hints: nil)
|
let imageRef = cgImage(forProposedRect: &imageRect, context: nil, hints: nil)
|
||||||
|
|
||||||
// Create NSImage from the CGImage using the new size
|
// Create NSImage from the CGImage using the new size
|
||||||
let imageWithNewSize = NSImage(cgImage: imageRef!, size: newSize)
|
let imageWithNewSize = NSImage(cgImage: imageRef!, size: newSize)
|
||||||
@ -75,13 +74,12 @@ extension NSImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func rotateByDegreess(degrees: CGFloat) -> NSImage {
|
func rotateByDegreess(degrees: CGFloat) -> NSImage {
|
||||||
|
var imageBounds = NSZeroRect; imageBounds.size = size
|
||||||
var imageBounds = NSZeroRect ; imageBounds.size = self.size
|
|
||||||
let pathBounds = NSBezierPath(rect: imageBounds)
|
let pathBounds = NSBezierPath(rect: imageBounds)
|
||||||
var transform = NSAffineTransform()
|
var transform = NSAffineTransform()
|
||||||
transform.rotate(byDegrees: degrees)
|
transform.rotate(byDegrees: degrees)
|
||||||
pathBounds.transform(using: transform as AffineTransform)
|
pathBounds.transform(using: transform as AffineTransform)
|
||||||
let rotatedBounds:NSRect = NSMakeRect(NSZeroPoint.x, NSZeroPoint.y , self.size.width, self.size.height )
|
let rotatedBounds: NSRect = NSMakeRect(NSZeroPoint.x, NSZeroPoint.y, size.width, size.height)
|
||||||
let rotatedImage = NSImage(size: rotatedBounds.size)
|
let rotatedImage = NSImage(size: rotatedBounds.size)
|
||||||
|
|
||||||
// Center the image within the rotated bounds
|
// Center the image within the rotated bounds
|
||||||
@ -98,10 +96,9 @@ extension NSImage {
|
|||||||
// Draw the original image, rotated, into the new image
|
// Draw the original image, rotated, into the new image
|
||||||
rotatedImage.lockFocus()
|
rotatedImage.lockFocus()
|
||||||
transform.concat()
|
transform.concat()
|
||||||
self.draw(in: imageBounds, from: NSZeroRect, operation: NSCompositingOperation.copy, fraction: 1.0)
|
draw(in: imageBounds, from: NSZeroRect, operation: NSCompositingOperation.copy, fraction: 1.0)
|
||||||
rotatedImage.unlockFocus()
|
rotatedImage.unlockFocus()
|
||||||
|
|
||||||
return rotatedImage
|
return rotatedImage
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ class PomodoroBarItem: CustomButtonTouchBarItem, Widget {
|
|||||||
case rest
|
case rest
|
||||||
case none
|
case none
|
||||||
}
|
}
|
||||||
|
|
||||||
private let defaultTitle = "🍅"
|
private let defaultTitle = "🍅"
|
||||||
private let workTime: TimeInterval
|
private let workTime: TimeInterval
|
||||||
private let restTime: TimeInterval
|
private let restTime: TimeInterval
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class AppleScriptDefinitionTests: XCTestCase {
|
class AppleScriptDefinitionTests: XCTestCase {
|
||||||
|
|
||||||
func testInline() {
|
func testInline() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" } } ]
|
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" } } ]
|
||||||
@ -37,5 +36,4 @@ class AppleScriptDefinitionTests: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class BackgroundColorTests: XCTestCase {
|
class BackgroundColorTests: XCTestCase {
|
||||||
|
|
||||||
func testOpaque() {
|
func testOpaque() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "staticButton", "title": "Pew", "background": "#FF0000" } ]
|
[ { "type": "staticButton", "title": "Pew", "background": "#FF0000" } ]
|
||||||
""".data(using: .utf8)!
|
""".data(using: .utf8)!
|
||||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||||
guard case .background(let color)? = result?.first?.additionalParameters[.background] else {
|
guard case let .background(color)? = result?.first?.additionalParameters[.background] else {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -19,11 +18,10 @@ class BackgroundColorTests: XCTestCase {
|
|||||||
[ { "type": "staticButton", "title": "Pew", "background": "#FF000080" } ]
|
[ { "type": "staticButton", "title": "Pew", "background": "#FF000080" } ]
|
||||||
""".data(using: .utf8)!
|
""".data(using: .utf8)!
|
||||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||||
guard case .background(let color)? = result?.first?.additionalParameters[.background] else {
|
guard case let .background(color)? = result?.first?.additionalParameters[.background] else {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
XCTAssertEqual(color.alphaComponent, 0.5, accuracy: 0.01)
|
XCTAssertEqual(color.alphaComponent, 0.5, accuracy: 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class ParseConfig: XCTestCase {
|
class ParseConfig: XCTestCase {
|
||||||
|
|
||||||
func testButtonNoAction() {
|
func testButtonNoAction() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "staticButton", "title": "Pew" } ]
|
[ { "type": "staticButton", "title": "Pew" } ]
|
||||||
@ -65,5 +64,4 @@ class ParseConfig: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
build.sh
1
build.sh
@ -64,6 +64,7 @@ echo ""
|
|||||||
echo " version '${VERSION}'"
|
echo " version '${VERSION}'"
|
||||||
echo " sha256 '${SHA256}'"
|
echo " sha256 '${SHA256}'"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Update MTMR v${VERSION}"
|
||||||
|
|
||||||
scp MTMR\ ${VERSION}.dmg do:/var/www/mtmr
|
scp MTMR\ ${VERSION}.dmg do:/var/www/mtmr
|
||||||
scp appcast.xml do:/var/www/mtmr
|
scp appcast.xml do:/var/www/mtmr
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user