Skip to content

Commit a7b0936

Browse files
committed
Target macOS 13
1 parent c645f80 commit a7b0936

15 files changed

+128
-103
lines changed

.swiftlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ only_rules:
119119
- static_operator
120120
- strong_iboutlet
121121
- superfluous_disable_command
122+
- superfluous_else
122123
- switch_case_alignment
123124
- switch_case_on_newline
124125
- syntactic_sugar
@@ -165,7 +166,6 @@ identifier_name:
165166
min_length:
166167
warning: 2
167168
error: 2
168-
validates_start_with_lowercase: false
169169
allowed_symbols:
170170
- '_'
171171
excluded:
@@ -180,7 +180,7 @@ identifier_name:
180180
- 'y2'
181181
- 'z2'
182182
deployment_target:
183-
macOS_deployment_target: '12'
183+
macOS_deployment_target: '13'
184184
custom_rules:
185185
no_nsrect:
186186
regex: '\bNSRect\b'

Gifski.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@
638638
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
639639
GCC_WARN_UNUSED_FUNCTION = YES;
640640
GCC_WARN_UNUSED_VARIABLE = YES;
641-
MACOSX_DEPLOYMENT_TARGET = 12.4;
641+
MACOSX_DEPLOYMENT_TARGET = 13.3;
642642
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
643643
MTL_FAST_MATH = YES;
644644
ONLY_ACTIVE_ARCH = YES;
@@ -695,7 +695,7 @@
695695
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
696696
GCC_WARN_UNUSED_FUNCTION = YES;
697697
GCC_WARN_UNUSED_VARIABLE = YES;
698-
MACOSX_DEPLOYMENT_TARGET = 12.4;
698+
MACOSX_DEPLOYMENT_TARGET = 13.3;
699699
MTL_ENABLE_DEBUG_INFO = NO;
700700
MTL_FAST_MATH = YES;
701701
SDKROOT = macosx;
@@ -833,7 +833,7 @@
833833
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
834834
requirement = {
835835
kind = upToNextMajorVersion;
836-
minimumVersion = 10.9.0;
836+
minimumVersion = 10.14.0;
837837
};
838838
};
839839
/* End XCRemoteSwiftPackageReference section */

Gifski/App.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import FirebaseCrashlytics
55
import DockProgress
66

77
/**
8-
TODO when targeting macOS 13:
8+
TODO when targeting macOS 14:
99
- Rewrite everything to use async/await, AsyncSequence, and actors.
1010
- Rewrite `CheckerboardView` to use `SwiftUI.Canvas`.
1111
- Make `final class Gifski` an actor.
1212
- Use `@MainActor`
13+
- Add button in the editor to preview the final GIF.
1314
*/
1415

1516
@main
@@ -113,6 +114,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
113114
return .terminateNow
114115
}
115116

117+
func applicationWillTerminate(_ notification: Notification) {
118+
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
119+
}
120+
116121
func application(_ application: NSApplication, willPresentError error: Error) -> Error {
117122
Crashlytics.recordNonFatalError(error: error)
118123
return error

Gifski/Base.lproj/MainMenu.xib

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
4-
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
65
</dependencies>
76
<objects>
87
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">

Gifski/CheckerboardView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class CheckerboardView: NSView {
2020
super.draw(dirtyRect)
2121

2222
NSColor.Checkerboard.first.setFill()
23-
dirtyRect.fill()
23+
bounds.fill()
2424

2525
NSColor.Checkerboard.second.setFill()
2626

Gifski/Constants.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ enum Constants {
88
}
99

1010
extension NSColor {
11-
static let themeColor = NSColor.controlAccentColor
1211
static let progressCircleColor = NSColor(named: "ProgressCircleColor")!
1312

1413
enum Checkerboard {

Gifski/ConversionCompletedViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ final class ConversionCompletedViewController: NSViewController {
6565
)
6666
}
6767

68-
wrapperView.fadeIn(duration: 0.5, delay: 0.15, completion: nil)
68+
wrapperView.fadeIn(duration: .seconds(0.5), delay: .seconds(0.15), completion: nil)
6969
}
7070

71-
delay(seconds: 1) { [weak self] in
71+
delay(.seconds(1)) { [weak self] in
7272
guard let self else {
7373
return
7474
}
@@ -153,7 +153,7 @@ final class ConversionCompletedViewController: NSViewController {
153153
)
154154
}
155155

156-
delay(seconds: 1) { [weak self] in
156+
delay(.seconds(1)) { [weak self] in
157157
guard let self else {
158158
return
159159
}

Gifski/ConversionViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ final class ConversionViewController: NSViewController {
140140
isRunning = false
141141
DockProgress.resetProgress()
142142

143-
circularProgress.fadeOut(delay: 0.5) {
143+
circularProgress.fadeOut(delay: .seconds(0.5)) {
144144
completion?()
145145
}
146146
}

Gifski/EditVideoViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ final class EditVideoViewController: NSViewController {
331331
estimatedFileSizeModel.updateEstimate()
332332
}
333333

334+
Defaults.publisher(.outputSpeed)
335+
.receive(on: DispatchQueue.main)
336+
.sink { [weak self] _ in
337+
self?.estimatedFileSizeModel.updateEstimate()
338+
}
339+
.store(in: &cancellables)
340+
334341
// We round it so that `29.970` becomes `30` for practical reasons.
335342
let frameRate = videoMetadata.frameRate.rounded()
336343

Gifski/EstimatedFileSize.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ final class EstimatedFileSizeModel: ObservableObject {
66
@Published var error: Error?
77

88
// This is outside the scope of "file estimate", but it was easier to add this here than doing a separate SwiftUI view. This should be refactored out into a separate view when all of Gifski is SwiftUI.
9-
@Published var duration: TimeInterval = 0
9+
@Published var duration = Duration.zero
1010

1111
var estimatedFileSizeNaive: String {
1212
Int(getNaiveEstimate()).formatted(.byteCount(style: .file))
@@ -72,7 +72,7 @@ final class EstimatedFileSizeModel: ObservableObject {
7272
}
7373

7474
func updateEstimate() {
75-
Debouncer.debounce(delay: 0.5, action: _estimateFileSize)
75+
Debouncer.debounce(delay: .seconds(0.5), action: _estimateFileSize)
7676
duration = getConversionSettings().gifDuration
7777
}
7878
}
@@ -112,15 +112,8 @@ struct EstimatedFileSizeView: View {
112112
.overlay {
113113
if model.error == nil {
114114
HStack {
115-
// TODO: Use the below instead when targeting macOS 13.
116-
/*
117-
Duration.seconds(duration)
118-
.formatted(
119-
.time(pattern: .minuteSecond(padMinuteToLength: 2, fractionalSecondsLength: 2))
120-
.locale(locale)
121-
)
122-
*/
123-
Text(DateComponentsFormatter.localizedStringPositionalWithFractionalSeconds(model.duration))
115+
let formattedDuration = model.duration.formatted(.time(pattern: .minuteSecond(padMinuteToLength: 2, fractionalSecondsLength: 2)))
116+
Text(formattedDuration)
124117
.monospacedDigit()
125118
.padding(.horizontal, 6)
126119
.padding(.vertical, 3)

0 commit comments

Comments
 (0)