Skip to content

Commit

Permalink
Require macOS 14
Browse files Browse the repository at this point in the history
Fixes #149
  • Loading branch information
sindresorhus committed Jan 16, 2024
1 parent d6a1418 commit 75f399f
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 374 deletions.
2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

12 changes: 2 additions & 10 deletions Plash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,13 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
E31C8C5F2A9FCC7E00C01756 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
E32421272384E9D700D28A91 = {
isa = PBXGroup;
children = (
E32AD6BB26D271C00008D900 /* Config.xcconfig */,
E32421322384E9D700D28A91 /* Plash */,
E32AD6AA26D2718B0008D900 /* ShareExtension */,
E32421312384E9D700D28A91 /* Products */,
E31C8C5F2A9FCC7E00C01756 /* Frameworks */,
);
sourceTree = "<group>";
tabWidth = 4;
Expand Down Expand Up @@ -432,7 +424,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MACOSX_DEPLOYMENT_TARGET = 14.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -492,7 +484,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MACOSX_DEPLOYMENT_TARGET = 14.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down
16 changes: 8 additions & 8 deletions Plash/AddWebsiteScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,27 @@ struct AddWebsiteScreen: View {

private var topView: some View {
Section {
// TODO: Use `.textContentType(.URL)` when targeting macOS 14.
TextField("URL", text: $urlString)
.textContentType(.URL)
.lineLimit(1)
// This change listener is used to respond to URL changes from the outside, like the "Revert" button or the Shortcuts actions.
.onChange(of: website.wrappedValue.url) {
.onChange(of: website.wrappedValue.url) { _, url in
guard
$0.absoluteString != "-",
$0.absoluteString != urlString
url.absoluteString != "-",
url.absoluteString != urlString
else {
return
}

urlString = $0.absoluteString
urlString = url.absoluteString
}
.onChange(of: urlString) {
guard let url = URL(humanString: $0) else {
guard let url = URL(humanString: urlString) else {
// Makes the “Revert” button work if the user clears the URL field.
if urlString.trimmed.isEmpty {
website.wrappedValue.url = "-"
} else if
let url = URL(string: $0),
let url = URL(string: urlString, encodingInvalidCharacters: false),
url.isValid
{
website.wrappedValue.url = url
Expand Down Expand Up @@ -315,7 +315,7 @@ struct AddWebsiteScreen: View {
panel.directoryURL = url
}

// TODO: Make it a sheet instead when targeting the macOS bug is fixed. (macOS 13.1)
// TODO: Make it a sheet instead when targeting the macOS bug is fixed. (macOS 14.2)
// let result = await panel.beginSheet(hostingWindow)
let result = await panel.begin()

Expand Down
10 changes: 3 additions & 7 deletions Plash/App.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import SwiftUI

/**
TODO macOS 14:
- Focus filter support.
- Set `!` as menu bar item text when there is an error.
- handle loose `URL(string: $0)`

TODO macOS 15:
- Use SwiftUI for the desktop window and the web view.
- Use `MenuBarExtra`.
- Use `MenuBarExtra` and afterwards switch to `@Observable`.
- Remove `Combine` and `Defaults.publisher` usage.
- Use `EnvironmentValues#requestReview`.
- Remove `ensureRunning()` from some intents that don't require Plash to stay open.
- Focus filter support.
- Use SwiftUI for the desktop window and the web view.
*/

@main
Expand Down
19 changes: 5 additions & 14 deletions Plash/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ final class AppState: ObservableObject {

var isBrowsingMode = false {
didSet {
guard isEnabled else {
return
}

desktopWindow.isInteractive = isBrowsingMode
desktopWindow.alphaValue = isBrowsingMode ? 1 : Defaults[.opacity]
resetTimer()
Expand Down Expand Up @@ -94,25 +98,12 @@ final class AppState: ObservableObject {
_ = desktopWindow
setUpEvents()
showWelcomeScreenIfNeeded()
SSApp.requestReviewAfterBeingCalledThisManyTimes([8, 50, 500])
SSApp.requestReviewAfterBeingCalledThisManyTimes([6, 50, 500])

#if DEBUG
// SSApp.showSettingsWindow()
// Constants.openWebsitesWindow()
#endif

SSApp.runOnce(identifier: "warnAboutSettingDisplaySetting") {
guard
!SSApp.isFirstLaunch,
UserDefaults.standard.string(forKey: "display") != #"{"id":1}"#
else {
return
}

SSApp.activateIfAccessory()
NSAlert.showModal(title: "Because of a bug, you need to select the display to show Plash on again in the settings.")
SSApp.showSettingsWindow()
}
}

func handleMenuBarIcon() {
Expand Down
8 changes: 4 additions & 4 deletions Plash/Events.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ extension AppState {
}
.store(in: &cancellables)

SSPublishers.deviceDidWake
SSEvents.deviceDidWake
.sink { [self] in
loadUserURL()
}
.store(in: &cancellables)

SSPublishers.isScreenLocked
SSEvents.isScreenLocked
.sink { [self] in
isScreenLocked = $0
setEnabledStatus()
Expand Down Expand Up @@ -122,8 +122,8 @@ extension AppState {
Defaults[.isBrowsingMode].toggle()
}

KeyboardShortcuts.onKeyUp(for: .toggleEnabled) {
self.isManuallyDisabled.toggle()
KeyboardShortcuts.onKeyUp(for: .toggleEnabled) { [self] in
isManuallyDisabled.toggle()
}

KeyboardShortcuts.onKeyUp(for: .reload) { [self] in
Expand Down
Loading

0 comments on commit 75f399f

Please sign in to comment.