Skip to content

Commit

Permalink
Require macOS 10.14 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 5, 2019
1 parent 2ead6ab commit 49266ad
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .swiftlint.yml
Expand Up @@ -167,4 +167,4 @@ identifier_name:
- 'y1'
- 'y2'
deployment_target:
macOS_deployment_target: '10.13'
macOS_deployment_target: '10.14'
4 changes: 2 additions & 2 deletions Gifski.xcodeproj/project.pbxproj
Expand Up @@ -633,7 +633,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -687,7 +687,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
14 changes: 3 additions & 11 deletions Gifski/AppDelegate.swift
Expand Up @@ -8,13 +8,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
lazy var mainWindowController = MainWindowController()

// Possible workaround for crashing bug because of Crashlytics swizzling.
var notificationCenter: AnyObject? = {
if #available(macOS 10.14, *) {
return UNUserNotificationCenter.current()
} else {
return nil
}
}()
let notificationCenter = UNUserNotificationCenter.current()

func applicationWillFinishLaunching(_ notification: Notification) {
UserDefaults.standard.register(defaults: [
Expand All @@ -24,14 +18,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ notification: Notification) {
if #available(macOS 10.14, *) {
(notificationCenter as? UNUserNotificationCenter)?.requestAuthorization { _, _ in }
}

#if !DEBUG
Fabric.with([Crashlytics.self])
#endif

notificationCenter.requestAuthorization { _, _ in }

mainWindowController.showWindow(self)

NSApp.isAutomaticCustomizeTouchBarMenuItemEnabled = true
Expand Down
6 changes: 3 additions & 3 deletions Gifski/ConversionCompletedViewController.swift
Expand Up @@ -38,13 +38,13 @@ final class ConversionCompletedViewController: NSViewController {
setUpDropView()
setUp(url: gifUrl)

if #available(macOS 10.14, *), !NSApp.isActive || view.window?.isVisible == false {
if !NSApp.isActive || view.window?.isVisible == false {
let notification = UNMutableNotificationContent()
notification.title = "Conversion Completed"
notification.subtitle = conversion.video.filename
let request = UNNotificationRequest(identifier: "conversionCompleted", content: notification, trigger: nil)
// UNUserNotificationCenter.current().add(request)
(AppDelegate.shared.notificationCenter as? UNUserNotificationCenter)?.add(request)
AppDelegate.shared.notificationCenter.add(request)
}
}

Expand All @@ -70,7 +70,7 @@ final class ConversionCompletedViewController: NSViewController {
self.tooltip.show(from: self.draggableFile, preferredEdge: .maxY)
}

if #available(macOS 10.14, *), Defaults[.successfulConversionsCount] == 5 {
if Defaults[.successfulConversionsCount] == 5 {
SKStoreReviewController.requestReview()
}
}
Expand Down
6 changes: 0 additions & 6 deletions Gifski/ConversionViewController.swift
Expand Up @@ -59,12 +59,6 @@ final class ConversionViewController: NSViewController {
cancelConversion()
}

// TODO: Remove this when we target macOS 10.14.
@objc
func cancel(_ sender: Any?) {
cancelConversion()
}

private func start(conversion: Gifski.Conversion) {
guard !isRunning else {
return
Expand Down
80 changes: 27 additions & 53 deletions Gifski/util.swift
Expand Up @@ -46,26 +46,6 @@ struct Meta {
}


/// macOS 10.14 polyfills
extension NSColor {
static let controlAccentColorPolyfill: NSColor = {
if #available(macOS 10.14, *) {
return NSColor.controlAccentColor
} else {
// swiftlint:disable:next object_literal
return NSColor(red: 0.10, green: 0.47, blue: 0.98, alpha: 1)
}
}()
}


extension NSColor {
func withAlpha(_ alpha: Double) -> NSColor {
withAlphaComponent(CGFloat(alpha))
}
}


extension NSView {
func shake(duration: TimeInterval = 0.3, direction: NSUserInterfaceLayoutOrientation) {
let translation = direction == .horizontal ? "x" : "y"
Expand Down Expand Up @@ -176,16 +156,14 @@ extension NSView {

extension NSWindow {
func makeVibrant() {
if #available(OSX 10.14, *) {
// So there seems to be a visual effect view already created by NSWindow.
// If we can attach ourselves to it and make it a vibrant one - awesome.
// If not, let's just add our view as a first one so it is vibrant anyways.
if let visualEffectView = contentView?.superview?.subviews.compactMap({ $0 as? NSVisualEffectView }).first {
visualEffectView.blendingMode = .behindWindow
visualEffectView.material = .underWindowBackground
} else {
contentView?.superview?.insertVibrancyView(material: .underWindowBackground)
}
// So there seems to be a visual effect view already created by NSWindow.
// If we can attach ourselves to it and make it a vibrant one - awesome.
// If not, let's just add our view as a first one so it is vibrant anyways.
if let visualEffectView = contentView?.superview?.subviews.compactMap({ $0 as? NSVisualEffectView }).first {
visualEffectView.blendingMode = .behindWindow
visualEffectView.material = .underWindowBackground
} else {
contentView?.superview?.insertVibrancyView(material: .underWindowBackground)
}
}
}
Expand Down Expand Up @@ -273,32 +251,28 @@ extension NSAlert {
}

if let detailText = detailText {
if #available(macOS 10.14, *) {
let scrollView = NSTextView.scrollableTextView()

// We're setting the frame manually here as it's impossible to use auto-layout,
// since it has nothing to constrain to. This will eventually be rewritten in SwiftUI anyway.
scrollView.frame = CGRect(width: 300, height: 120)

scrollView.onAddedToSuperview {
if let messageTextField = (scrollView.superview?.superview?.subviews.first { $0 is NSTextField }) {
scrollView.frame.width = messageTextField.frame.width
} else {
assertionFailure("Couldn't detect the message textfield view of the NSAlert panel")
}
}
let scrollView = NSTextView.scrollableTextView()

let textView = scrollView.documentView as! NSTextView
textView.drawsBackground = false
textView.isEditable = false
textView.font = NSFont.systemFont(ofSize: NSFont.systemFontSize(for: .small))
textView.textColor = .secondaryLabelColor
textView.string = detailText
// We're setting the frame manually here as it's impossible to use auto-layout,
// since it has nothing to constrain to. This will eventually be rewritten in SwiftUI anyway.
scrollView.frame = CGRect(width: 300, height: 120)

self.accessoryView = scrollView
} else {
self.informativeText += "\n\(detailText)"
scrollView.onAddedToSuperview {
if let messageTextField = (scrollView.superview?.superview?.subviews.first { $0 is NSTextField }) {
scrollView.frame.width = messageTextField.frame.width
} else {
assertionFailure("Couldn't detect the message textfield view of the NSAlert panel")
}
}

let textView = scrollView.documentView as! NSTextView
textView.drawsBackground = false
textView.isEditable = false
textView.font = NSFont.systemFont(ofSize: NSFont.systemFontSize(for: .small))
textView.textColor = .secondaryLabelColor
textView.string = detailText

self.accessoryView = scrollView
}

self.addButtons(withTitles: buttonTitles)
Expand Down
4 changes: 2 additions & 2 deletions gifski-api/gifski.xcodeproj/project.pbxproj
Expand Up @@ -224,7 +224,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VALID_ARCHS = x86_64;
Expand Down Expand Up @@ -281,7 +281,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VALID_ARCHS = x86_64;
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -15,7 +15,7 @@ Gifski supports all the video formats that macOS supports (`.mp4` or `.mov` with

**[Blog post](https://blog.sindresorhus.com/gifski-972692460aa5)**    **[Product Hunt](https://www.producthunt.com/posts/gifski-2)**

Requires macOS 10.13 or later.
Requires macOS 10.14 or later.


## Download
Expand Down

0 comments on commit 49266ad

Please sign in to comment.