From 6c384d8b645c7002d8f84c9894b8b8d837adbff9 Mon Sep 17 00:00:00 2001 From: Ronak99 Date: Sun, 27 Jul 2025 21:36:36 +0530 Subject: [PATCH 1/2] Added a note regarding the "default to Touchbar" issue. --- TrackWeight/ContentView.swift | 4 +- TrackWeight/HomeView.swift | 73 ++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/TrackWeight/ContentView.swift b/TrackWeight/ContentView.swift index 7a4bfa7..870a1f8 100644 --- a/TrackWeight/ContentView.swift +++ b/TrackWeight/ContentView.swift @@ -14,7 +14,7 @@ struct ContentView: View { HomeView { showHomePage = false } - .frame(minWidth: 700, minHeight: 500) + .frame(minWidth: 700, minHeight: 700) } else { TabView(selection: $selectedTab) { TrackWeightView() @@ -38,7 +38,7 @@ struct ContentView: View { } .tag(2) } - .frame(minWidth: 700, minHeight: 500) + .frame(minWidth: 700, minHeight: 700) } } } diff --git a/TrackWeight/HomeView.swift b/TrackWeight/HomeView.swift index 5dadf96..62df4c2 100644 --- a/TrackWeight/HomeView.swift +++ b/TrackWeight/HomeView.swift @@ -4,9 +4,11 @@ // import SwiftUI +import OpenMultitouchSupport struct HomeView: View { let onBegin: () -> Void + @StateObject private var viewModel = ContentViewModel() var body: some View { VStack(spacing: 40) { @@ -71,7 +73,74 @@ struct HomeView: View { .frame(maxWidth: 500) } - Spacer() + // Select a device first + VStack(spacing: 20) { + // Device Card + SettingsCard { + VStack(spacing: 12) { + // Status Row + HStack { + HStack(spacing: 12) { + Text("Verify Device Selection") + .font(.headline) + .fontWeight(.medium) + } + + Spacer() + + if !viewModel.availableDevices.isEmpty { + Text("\(viewModel.availableDevices.count) device\(viewModel.availableDevices.count == 1 ? "" : "s")") + .font(.caption) + .foregroundColor(.secondary) + } + } + + // Device Selector + if !viewModel.availableDevices.isEmpty { + VStack(alignment: .leading, spacing: 12) { + HStack { + Image(systemName: "exclamationmark.triangle") + .font(.system(size: 16, weight: .medium)) + .font(.caption) + .foregroundColor(.orange) + Text("OMS may default to the Touch Bar on Macs equipped with it. You can change the selected device in the settings tab. Please ensure you've selected the correct trackpad.") + .font(.system(size: 12, weight: .medium)) + .foregroundColor(.orange) + } + .padding(.horizontal) + HStack { + Picker("", selection: Binding( + get: { viewModel.selectedDevice }, + set: { device in + if let device = device { + viewModel.selectDevice(device) + } + } + )) { + ForEach(viewModel.availableDevices, id: \.self) { device in + Text(device.deviceName) + .tag(device as OMSDeviceInfo?) + } + } + .pickerStyle(MenuPickerStyle()) + + Spacer() + } + + } + .frame(width: 450) + } else { + HStack { + Text("No devices available") + .foregroundColor(.secondary) + Spacer() + } + } + } + } + } + .frame(maxWidth: 480) + .padding(.horizontal, 40) // Begin button Button(action: onBegin) { @@ -99,7 +168,7 @@ struct HomeView: View { .scaleEffect(1.0) .animation(.spring(response: 0.3, dampingFraction: 0.8), value: true) .padding(.vertical, 10) - + Spacer() } .frame(maxWidth: .infinity, maxHeight: .infinity) From 6ad8125a3f9ab9b143207ed2b1d76500f5a763fe Mon Sep 17 00:00:00 2001 From: Ronak99 Date: Mon, 28 Jul 2025 16:33:20 +0530 Subject: [PATCH 2/2] show device selector only if there are more than 1 devices --- TrackWeight/HomeView.swift | 50 +++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/TrackWeight/HomeView.swift b/TrackWeight/HomeView.swift index 62df4c2..439bc88 100644 --- a/TrackWeight/HomeView.swift +++ b/TrackWeight/HomeView.swift @@ -74,29 +74,30 @@ struct HomeView: View { } // Select a device first - VStack(spacing: 20) { - // Device Card - SettingsCard { - VStack(spacing: 12) { - // Status Row - HStack { - HStack(spacing: 12) { - Text("Verify Device Selection") - .font(.headline) - .fontWeight(.medium) - } - - Spacer() - - if !viewModel.availableDevices.isEmpty { + if viewModel.availableDevices.count > 1 { + VStack(spacing: 20) { + // Device Card + SettingsCard { + VStack(spacing: 12) { + // Status Row + HStack { + HStack(spacing: 12) { + Text("Verify Device Selection") + .font(.headline) + .fontWeight(.medium) + } + + Spacer() + + Text("\(viewModel.availableDevices.count) device\(viewModel.availableDevices.count == 1 ? "" : "s")") .font(.caption) .foregroundColor(.secondary) + } - } - - // Device Selector - if !viewModel.availableDevices.isEmpty { + + // Device Selector + VStack(alignment: .leading, spacing: 12) { HStack { Image(systemName: "exclamationmark.triangle") @@ -129,19 +130,12 @@ struct HomeView: View { } .frame(width: 450) - } else { - HStack { - Text("No devices available") - .foregroundColor(.secondary) - Spacer() - } } } } + .frame(maxWidth: 480) + .padding(.horizontal, 40) } - .frame(maxWidth: 480) - .padding(.horizontal, 40) - // Begin button Button(action: onBegin) { HStack(spacing: 10) {