Listless/Extensions/ItemListView+SyncUI.swift (1244B)
1import SwiftUI
2#if os(iOS)
3import UIKit
4#elseif os(macOS)
5import AppKit
6#endif
7
8extension ItemListViewProtocol {
9 @ViewBuilder
10 var syncErrorBanner: some View {
11 if let message = syncMonitor.transientErrorMessage {
12 HStack(spacing: 8) {
13 Image(systemName: "icloud.slash")
14 .imageScale(.small)
15 Text(message)
16 .font(.caption)
17 .lineLimit(2)
18 Spacer(minLength: 0)
19 }
20 .padding(.horizontal, 12)
21 .padding(.vertical, 8)
22 .background(.thickMaterial)
23 .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
24 .padding(.horizontal, 12)
25 .padding(.top, 8)
26 .transition(.move(edge: .top).combined(with: .opacity))
27 }
28 }
29
30 func openSystemSettings() {
31 #if os(iOS)
32 guard let settingsURL = URL(string: UIApplication.openSettingsURLString) else { return }
33 UIApplication.shared.open(settingsURL)
34 #elseif os(macOS)
35 if let settingsURL = URL(string: "x-apple.systempreferences:") {
36 NSWorkspace.shared.open(settingsURL)
37 }
38 #endif
39 }
40}