Skip to content

Commit adce8a8

Browse files
authored
Merge pull request #192 from getditto/fix/logging-macOS
Fix/logging mac os
2 parents 70a51ed + 846bcff commit adce8a8

File tree

6 files changed

+170
-277
lines changed

6 files changed

+170
-277
lines changed

DittoToolsApp/DittoToolsApp/DittoToolsApp.entitlements

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<true/>
77
<key>com.apple.security.device.bluetooth</key>
88
<true/>
9+
<key>com.apple.security.files.downloads.read-write</key>
10+
<true/>
11+
<key>com.apple.security.files.user-selected.read-write</key>
12+
<true/>
913
<key>com.apple.security.network.client</key>
1014
<true/>
1115
</dict>

Sources/DittoAllToolsMenu/Views/Tool Container Views/LoggingDetailsViewer.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ struct LoggingDetailsViewer: View {
1414
var ditto: Ditto
1515

1616
var body: some View {
17-
#if !os(macOS)
1817
LoggingDetailsView(ditto: ditto)
19-
#endif
2018
}
2119
}

Sources/DittoDataBrowser/DataBrowser.swift

Lines changed: 28 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,44 @@ public struct DataBrowser: View {
1313
@StateObject var viewModel: DataBrowserViewModel
1414
@State var startSubscriptions: Bool = false
1515
@State var isStandAlone: Bool = false
16-
@State var isShowingModal: Bool = false
17-
#if os(tvOS)
18-
@FocusState private var focusedButton: ButtonFocus?
19-
20-
enum ButtonFocus: Hashable {
21-
case cancel, start
22-
}
23-
#endif
16+
@State var isShowingAlert: Bool = false
2417
@State private var isHovered = false
2518

2619
public init(ditto: Ditto) {
2720
self._viewModel = StateObject(wrappedValue: DataBrowserViewModel(ditto: ditto))
2821
}
2922

3023
public var body: some View {
31-
ZStack {
32-
VStack(alignment: .leading) {
33-
// macOS requires a NavigationView for Lists to work
34-
#if os(macOS)
35-
NavigationView {
36-
listView
37-
}
38-
#else
39-
listView
40-
#endif
41-
}
42-
.navigationTitle("Collections")
43-
#if os(iOS)
44-
.navigationBarTitleDisplayMode(.inline)
45-
#endif
46-
.toolbar {
47-
ToolbarItem(placement: .confirmationAction) {
48-
// Hides startPauseButton so it doesn't interfere with modal on tvOS
49-
#if os(tvOS)
50-
if !isShowingModal {
51-
startPauseButton
52-
}
53-
#else
54-
startPauseButton
55-
#endif
56-
}
57-
}
58-
.disabled(self.isShowingModal)
59-
// Sheet works best on macOS for popup (for current versions). ZStack works best on iOS and tvOS for popups (for current versions).
24+
VStack(alignment: .leading) {
6025
#if os(macOS)
61-
.sheet(isPresented: $isShowingModal) {
62-
modalView
26+
NavigationView {
27+
listView
6328
}
29+
#else
30+
listView
6431
#endif
65-
#if os(iOS) || os(tvOS)
66-
if self.isShowingModal {
67-
Color.black.opacity(0.4)
68-
.ignoresSafeArea()
69-
.transition(.opacity)
70-
71-
modalView
72-
.transition(.scale)
73-
.zIndex(1)
32+
}
33+
.navigationTitle("Collections")
34+
#if os(iOS)
35+
.navigationBarTitleDisplayMode(.inline)
36+
#endif
37+
.toolbar {
38+
ToolbarItem(placement: .confirmationAction) {
39+
startPauseButton
7440
}
75-
#endif
7641
}
77-
.animation(.easeInOut, value: self.isShowingModal)
42+
.disabled(isShowingAlert)
43+
.alert(isPresented: $isShowingAlert) {
44+
Alert(
45+
title: Text("Standalone App?"),
46+
message: Text("Only start subscriptions if using the Data Browser in a standalone app."),
47+
primaryButton: .default(
48+
Text("Start"),
49+
action: start
50+
),
51+
secondaryButton: .cancel(Text("Cancel"))
52+
)
53+
}
7854
}
7955

8056
private var listView: some View {
@@ -94,66 +70,13 @@ public struct DataBrowser: View {
9470
#endif
9571
}
9672

97-
private var spacingInteger: CGFloat {
98-
#if os(iOS) || os(macOS)
99-
return 20
100-
#else
101-
return 40
102-
#endif
103-
}
104-
105-
private var modalView: some View {
106-
VStack(spacing: spacingInteger / 2) {
107-
Text("Standalone App?")
108-
.font(.title2)
109-
.fontWeight(.semibold)
110-
.multilineTextAlignment(.center)
111-
.padding(.top, 8)
112-
113-
Text("Only start subscriptions if using the Data Browser in a standalone app.")
114-
.font(.body)
115-
.multilineTextAlignment(.center)
116-
.foregroundColor(.secondary)
117-
118-
HStack(spacing: spacingInteger) {
119-
cancelButton
120-
startButton
121-
}
122-
.padding(.top, 8)
123-
}
124-
.padding()
125-
#if os(iOS)
126-
.frame(maxWidth: 400)
127-
.background(Color(UIColor.systemGray6))
128-
#elseif os(macOS)
129-
.frame(maxWidth: 300)
130-
.background(Color.clear)
131-
#else
132-
.padding()
133-
.frame(maxWidth: 800)
134-
.background(Color.gray.opacity(0.3))
135-
.onAppear {
136-
DispatchQueue.main.async {
137-
focusedButton = .cancel
138-
}
139-
}
140-
#endif
141-
#if !os(macOS)
142-
.cornerRadius(24)
143-
.shadow(radius: 20)
144-
#endif
145-
#if os(iOS)
146-
.padding()
147-
#endif
148-
}
149-
15073
private var startPauseButton: some View {
15174
Button {
15275
if self.startSubscriptions {
15376
self.startSubscriptions = false
15477
viewModel.closeLiveQuery()
15578
} else {
156-
self.isShowingModal = true
79+
self.isShowingAlert = true
15780
}
15881
} label: {
15982
#if os(iOS)
@@ -178,46 +101,10 @@ public struct DataBrowser: View {
178101
#endif
179102
}
180103

181-
182-
private var startButton: some View {
183-
Button(action: start) {
184-
Text("Start")
185-
.frame(maxWidth: .infinity)
186-
#if os(iOS)
187-
.padding()
188-
.background(Color.blue)
189-
.foregroundColor(.white)
190-
.cornerRadius(10)
191-
#elseif os(tvOS)
192-
.focusable(true)
193-
.focused($focusedButton, equals: .start)
194-
#endif
195-
}
196-
}
197-
198-
private var cancelButton: some View {
199-
Button {
200-
self.isShowingModal = false
201-
} label: {
202-
Text("Cancel")
203-
.frame(maxWidth: .infinity)
204-
#if os(iOS)
205-
.padding()
206-
.background(Color(UIColor.systemGray5))
207-
.foregroundColor(.blue)
208-
.cornerRadius(10)
209-
#elseif os(tvOS)
210-
.focusable(true)
211-
.focused($focusedButton, equals: .cancel)
212-
#endif
213-
}
214-
}
215-
216104
private func start() {
217105
self.startSubscriptions = true
218106
viewModel.startSubscription()
219107
self.isStandAlone = true
220-
self.isShowingModal = false
108+
self.isShowingAlert = false
221109
}
222110
}
223-

Sources/DittoExportLogs/DittoLogManager.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
//
22
// Copyright © 2021 DittoLive Incorporated. All rights reserved.
33
//
4-
#if !os(macOS)
5-
import Foundation
6-
#if canImport(MessageUI)
7-
import MessageUI
8-
#endif
9-
import UIKit
104
import DittoSwift
115

126
private struct Config {
@@ -54,4 +48,3 @@ struct LogManager {
5448
return Config.zippedLogsURL
5549
}
5650
}
57-
#endif

Sources/DittoExportLogs/ExportLogs.swift

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)