Skip to content

Commit f05dae5

Browse files
committed
More dynamic content for +
1 parent 3f0c9f8 commit f05dae5

2 files changed

Lines changed: 135 additions & 112 deletions

File tree

airsync-mac/Core/AppState.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class AppState: ObservableObject {
2929
let adbPortValue = UserDefaults.standard.integer(forKey: "adbPort")
3030
self.adbPort = adbPortValue == 0 ? 5555 : UInt16(adbPortValue)
3131
self.mirroringPlus = UserDefaults.standard.bool(forKey: "mirroringPlus")
32+
self.adbEnabled = UserDefaults.standard.bool(forKey: "adbEnabled")
3233

3334
self.isClipboardSyncEnabled = UserDefaults.standard.bool(forKey: "isClipboardSyncEnabled")
3435
if isClipboardSyncEnabled {
@@ -87,6 +88,12 @@ class AppState: ObservableObject {
8788
}
8889
}
8990

91+
@Published var adbEnabled: Bool {
92+
didSet {
93+
UserDefaults.standard.set(adbEnabled, forKey: "adbEnabled")
94+
}
95+
}
96+
9097
// Toggle licensing
9198
let licenseCheck: Bool = true
9299

airsync-mac/Screens/Settings/SettingsView.swift

Lines changed: 128 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -41,143 +41,151 @@ struct SettingsView: View {
4141

4242
VStack{
4343
HStack {
44-
Label("Connect ADB", systemImage: "iphone")
44+
Label("Connect ADB", systemImage: "bolt.horizontal.circle")
4545
Spacer()
46-
Toggle("", isOn: .constant(true)) // Change to real binding if implemented
47-
.toggleStyle(.switch)
48-
}
4946

50-
// Show port field if ADB toggle is on
51-
HStack {
52-
Label("ADB Port", systemImage: "arrow.left.arrow.right")
53-
Spacer()
54-
TextField("ADB Port", text: $adbPortString)
55-
.textFieldStyle(.roundedBorder)
56-
.frame(width: 100)
57-
.onChange(of: adbPortString) { _, newValue in
58-
adbPortString = newValue.filter { "0123456789".contains($0) }
59-
}
60-
61-
if #available(macOS 26.0, *) {
62-
GlassButtonView(
63-
label: "Set",
64-
systemImage: "checkmark.circle",
65-
action: {
66-
if let port = UInt16(adbPortString), port > 0 && port < 65535 {
67-
appState.adbPort = port
68-
UserDefaults.standard.set(port, forKey: "adbPort")
69-
}
70-
}
47+
ZStack {
48+
Toggle(
49+
"",
50+
isOn: $appState.adbEnabled
7151
)
72-
.buttonStyle(.glass)
73-
.disabled(adbPortString.isEmpty)
74-
} else {
75-
GlassButtonView(
76-
label: "Set",
77-
systemImage: "checkmark.circle",
78-
action: {
79-
if let port = UInt16(adbPortString), port > 0 && port < 65535 {
80-
appState.adbPort = port
81-
UserDefaults.standard.set(port, forKey: "adbPort")
52+
.labelsHidden()
53+
.toggleStyle(.switch)
54+
.disabled(!AppState.shared.isPlus && AppState.shared.licenseCheck)
55+
56+
// Transparent tap area on top to show popover even if disabled
57+
if !AppState.shared.isPlus && AppState.shared.licenseCheck {
58+
Rectangle()
59+
.fill(Color.clear)
60+
.contentShape(Rectangle())
61+
.onTapGesture {
62+
showingPlusPopover = true
8263
}
83-
}
84-
)
85-
.disabled(adbPortString.isEmpty)
64+
}
8665
}
66+
.frame(width: 55)
67+
}
68+
.popover(isPresented: $showingPlusPopover, arrowEdge: .bottom) {
69+
PlusFeaturePopover(message: "Wireless ADB features are available in AirSync+")
70+
.onTapGesture {
71+
showingPlusPopover = false
72+
}
73+
}
74+
75+
// Show port field if ADB toggle is on
76+
if appState.isPlus, appState.adbEnabled{
77+
HStack {
78+
Label("ADB Port", systemImage: "arrow.left.arrow.right")
79+
Spacer()
80+
TextField("ADB Port", text: $adbPortString)
81+
.textFieldStyle(.roundedBorder)
82+
.frame(width: 100)
83+
.onChange(of: adbPortString) { _, newValue in
84+
adbPortString = newValue.filter { "0123456789".contains($0) }
85+
}
8786

88-
if appState.adbConnected {
8987
if #available(macOS 26.0, *) {
9088
GlassButtonView(
91-
label: "Disconnect ADB",
92-
systemImage: "stop.circle",
89+
label: "Set",
90+
systemImage: "checkmark.circle",
9391
action: {
94-
ADBConnector.disconnectADB()
95-
appState.adbConnected = false
92+
if let port = UInt16(adbPortString), port > 0 && port < 65535 {
93+
appState.adbPort = port
94+
UserDefaults.standard.set(port, forKey: "adbPort")
95+
}
9696
}
9797
)
9898
.buttonStyle(.glass)
99+
.disabled(adbPortString.isEmpty)
99100
} else {
100101
GlassButtonView(
101-
label: "Disconnect ADB",
102-
systemImage: "stop.circle",
102+
label: "Set",
103+
systemImage: "checkmark.circle",
103104
action: {
104-
ADBConnector.disconnectADB()
105-
appState.adbConnected = false
105+
if let port = UInt16(adbPortString), port > 0 && port < 65535 {
106+
appState.adbPort = port
107+
UserDefaults.standard.set(port, forKey: "adbPort")
108+
}
106109
}
107110
)
111+
.disabled(adbPortString.isEmpty)
108112
}
109-
} else {
110-
if #available(macOS 26.0, *) {
111-
GlassButtonView(
112-
label: "Connect ADB",
113-
systemImage: "play.circle",
114-
action: {
115-
let ip = appState.device?.ipAddress ?? ""
116-
let port = appState.adbPort
117-
ADBConnector.connectToADB(ip: ip, port: port)
118-
}
119-
)
120-
.buttonStyle(.glass)
121-
.disabled(
122-
adbPortString.isEmpty || appState.device == nil
123-
)
113+
114+
if appState.adbConnected {
115+
if #available(macOS 26.0, *) {
116+
GlassButtonView(
117+
label: "Disconnect ADB",
118+
systemImage: "stop.circle",
119+
action: {
120+
ADBConnector.disconnectADB()
121+
appState.adbConnected = false
122+
}
123+
)
124+
.buttonStyle(.glass)
125+
} else {
126+
GlassButtonView(
127+
label: "Disconnect ADB",
128+
systemImage: "stop.circle",
129+
action: {
130+
ADBConnector.disconnectADB()
131+
appState.adbConnected = false
132+
}
133+
)
134+
}
124135
} else {
125-
GlassButtonView(
126-
label: "Connect ADB",
127-
systemImage: "play.circle",
128-
action: {
129-
let ip = appState.device?.ipAddress ?? ""
130-
let port = appState.adbPort
131-
ADBConnector.connectToADB(ip: ip, port: port)
132-
}
133-
)
134-
.disabled(
135-
adbPortString.isEmpty || appState.device == nil
136-
)
137-
}
136+
if #available(macOS 26.0, *) {
137+
GlassButtonView(
138+
label: "Connect ADB",
139+
systemImage: "play.circle",
140+
action: {
141+
let ip = appState.device?.ipAddress ?? ""
142+
let port = appState.adbPort
143+
ADBConnector.connectToADB(ip: ip, port: port)
144+
}
145+
)
146+
.buttonStyle(.glass)
147+
.disabled(
148+
adbPortString.isEmpty || appState.device == nil
149+
)
150+
} else {
151+
GlassButtonView(
152+
label: "Connect ADB",
153+
systemImage: "play.circle",
154+
action: {
155+
let ip = appState.device?.ipAddress ?? ""
156+
let port = appState.adbPort
157+
ADBConnector.connectToADB(ip: ip, port: port)
158+
}
159+
)
160+
.disabled(
161+
adbPortString.isEmpty || appState.device == nil
162+
)
163+
}
138164

139-
}
165+
}
140166

141167

142168

143-
}
144-
.padding()
169+
}
145170

146171

147-
HStack {
148-
Label("Mirroring+", systemImage: "apps.iphone.badge.plus")
149-
Spacer()
150172

151-
ZStack {
152-
Toggle("Mirror apps from notifications", isOn: $appState.mirroringPlus)
173+
HStack{
174+
Label("App Mirroring", systemImage: "apps.iphone.badge.plus")
175+
Spacer()
176+
Toggle("", isOn: $appState.mirroringPlus)
153177
.toggleStyle(.switch)
154-
.disabled(!AppState.shared.isPlus && AppState.shared.licenseCheck)
155-
.labelsHidden()
156-
157-
// Transparent overlay to catch taps even when disabled
158-
Rectangle()
159-
.fill(Color.clear)
160-
.contentShape(Rectangle())
161-
.onTapGesture {
162-
if !AppState.shared.isPlus && AppState.shared.licenseCheck {
163-
showingPlusPopover = true
164-
}
165-
}
166-
}
167-
.frame(width: 50)
168-
.popover(isPresented: $showingPlusPopover, arrowEdge: .bottom) {
169-
PlusFeaturePopover(message: "Mirror Apps with AirSync+")
170178
}
171-
}
172179

173-
if let result = appState.adbConnectionResult {
174-
VStack(alignment: .leading, spacing: 4) {
175-
ExpandableLicenseSection(title: "ADB Console", content: result)
180+
if let result = appState.adbConnectionResult {
181+
VStack(alignment: .leading, spacing: 4) {
182+
ExpandableLicenseSection(title: "ADB Console", content: result)
183+
}
184+
.padding()
185+
.transition(.opacity)
176186
}
177-
.padding()
178-
.transition(.opacity)
179-
}
180187

188+
}
181189

182190

183191
HStack{
@@ -336,14 +344,14 @@ struct SettingsView: View {
336344

337345
if isCheckingLicense {
338346
ProgressView()
339-
.scaleEffect(0.8)
347+
.scaleEffect(0.6)
340348
} else if let valid = licenseValid {
341349
Image(systemName: valid ? "checkmark.circle.fill" : "xmark.octagon.fill")
342350
.foregroundColor(valid ? .green : .red)
343351
.transition(.scale)
344352
}
345353

346-
if #available(macOS 26.0, *) {
354+
if #available(macOS 26.0, *), !appState.isPlus {
347355
GlassButtonView(
348356
label: "Get AirSync+",
349357
systemImage: "link",
@@ -354,7 +362,7 @@ struct SettingsView: View {
354362
}
355363
)
356364
.buttonStyle(.glass)
357-
} else {
365+
} else if !appState.isPlus {
358366
GlassButtonView(
359367
label: "Get AirSync+",
360368
systemImage: "link",
@@ -371,9 +379,17 @@ struct SettingsView: View {
371379

372380
if let details = appState.licenseDetails {
373381
VStack(alignment: .leading, spacing: 8) {
374-
Text("License Info")
375-
.font(.headline)
376-
.padding(.bottom, 4)
382+
HStack{
383+
Text("License Info")
384+
.font(.headline)
385+
.padding(.bottom, 4)
386+
387+
Spacer()
388+
389+
Text("Thank you <3")
390+
.font(.subheadline)
391+
.padding(.bottom, 4)
392+
}
377393

378394
Divider()
379395

0 commit comments

Comments
 (0)