-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'no-need-for-full-disk-permission'
- Loading branch information
Showing
22 changed files
with
731 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
TimeMachineStatus/Components/HideWindowControlsViewModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// HideWindowControlsViewModifier.swift | ||
// TimeMachineStatus | ||
// | ||
// Created by Lukas Pistrol on 02.10.24. | ||
// | ||
// Copyright © 2024 Lukas Pistrol. All rights reserved. | ||
// | ||
// See LICENSE.md for license information. | ||
// | ||
|
||
import SwiftUI | ||
|
||
private struct HideWindowControllsViewModifier: ViewModifier { | ||
|
||
let types: [NSWindow.ButtonType] | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.onReceive(NotificationCenter.default.publisher(for: NSWindow.didBecomeKeyNotification)) { notification in | ||
guard let window = NSApplication.shared.windows.first(where: { $0.isKeyWindow }) else { return } | ||
hideWindowControls(for: window) | ||
} | ||
} | ||
|
||
private func hideWindowControls(for window: NSWindow) { | ||
types.forEach { | ||
window.standardWindowButton($0)?.isHidden = true | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func hideWindowControls( | ||
_ types: [NSWindow.ButtonType] = [ | ||
.closeButton, | ||
.miniaturizeButton, | ||
.zoomButton | ||
] | ||
) -> some View { | ||
modifier(HideWindowControllsViewModifier(types: types)) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
TimeMachineStatus/Components/PreferencesFileImporterViewModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// PreferencesFileImporterViewModifier.swift | ||
// TimeMachineStatus | ||
// | ||
// Created by Lukas Pistrol on 01.10.24. | ||
// | ||
// Copyright © 2024 Lukas Pistrol. All rights reserved. | ||
// | ||
// See LICENSE.md for license information. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct PreferencesFileImporterViewModifier: ViewModifier { | ||
@Binding var showPicker: Bool | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.fileImporter(isPresented: $showPicker, allowedContentTypes: [.propertyList]) { _ in } | ||
.fileDialogDefaultDirectory(Constants.URLs.timeMachinePreferencesPlist) | ||
.fileDialogMessage(Text("dialog_label_select_file_\(lastPathComponent)")) | ||
.fileDialogConfirmationLabel(Text("button_select")) | ||
.fileDialogURLEnabled(#Predicate<URL> { url in | ||
url.lastPathComponent == lastPathComponent | ||
}) | ||
} | ||
|
||
private var lastPathComponent: String { Constants.URLs.timeMachinePreferencesPlist.lastPathComponent } | ||
} | ||
|
||
extension View { | ||
func preferencesFileImporter(_ showPicker: Binding<Bool>) -> some View { | ||
modifier(PreferencesFileImporterViewModifier(showPicker: showPicker)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
TimeMachineStatus/Components/VisualEffectBackgroundViewModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// VisualEffectBackgroundViewModifier.swift | ||
// TimeMachineStatus | ||
// | ||
// Created by Lukas Pistrol on 02.10.24. | ||
// | ||
// Copyright © 2024 Lukas Pistrol. All rights reserved. | ||
// | ||
// See LICENSE.md for license information. | ||
// | ||
|
||
import SwiftUI | ||
|
||
private struct VisualEffectBackgroundViewModifier: ViewModifier { | ||
|
||
let material: NSVisualEffectView.Material | ||
let state: NSVisualEffectView.State | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.background { | ||
_VisualEffectView(material: material, state: state) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.ignoresSafeArea() | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
@ViewBuilder | ||
func backgroundVisualEffect( | ||
_ material: NSVisualEffectView.Material, | ||
state: NSVisualEffectView.State = .active | ||
) -> some View { | ||
if isPreview { | ||
self | ||
} else { | ||
modifier(VisualEffectBackgroundViewModifier(material: material, state: state)) | ||
} | ||
} | ||
} | ||
|
||
private struct _VisualEffectView: NSViewRepresentable { | ||
|
||
let material: NSVisualEffectView.Material | ||
let state: NSVisualEffectView.State | ||
|
||
func makeNSView(context: Context) -> NSVisualEffectView { | ||
let effectView = NSVisualEffectView() | ||
effectView.material = material | ||
effectView.state = state | ||
return effectView | ||
} | ||
|
||
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Timer+Sendable.swift | ||
// TimeMachineStatus | ||
// | ||
// Created by Lukas Pistrol on 03.10.24. | ||
// | ||
// Copyright © 2024 Lukas Pistrol. All rights reserved. | ||
// | ||
// See LICENSE.md for license information. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Timer: @unchecked @retroactive Sendable {} |
Oops, something went wrong.