Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions TrackWeight.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
93A095122E33359600E1E1D1 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A095112E33359600E1E1D1 /* SettingsView.swift */; };
93A095162E33624200E1E1D1 /* OpenMultitouchSupport in Frameworks */ = {isa = PBXBuildFile; productRef = 93A095152E33624200E1E1D1 /* OpenMultitouchSupport */; };
93ABD0212E2E01E200668D4F /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93ABD0202E2E01E200668D4F /* HomeView.swift */; };
94B0A0112E40010000E1E1D1 /* GlassTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B0A0102E40010000E1E1D1 /* GlassTheme.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -39,6 +40,7 @@
77292AA72B931E06001CA3F6 /* ScaleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScaleViewModel.swift; sourceTree = "<group>"; };
93A095112E33359600E1E1D1 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
93ABD0202E2E01E200668D4F /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
94B0A0102E40010000E1E1D1 /* GlassTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlassTheme.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -80,6 +82,7 @@
77292A972B931D60001CA3F6 /* ContentViewModel.swift */,
77292A9D2B931E01001CA3F6 /* WeighingState.swift */,
93ABD0202E2E01E200668D4F /* HomeView.swift */,
94B0A0102E40010000E1E1D1 /* GlassTheme.swift */,
77292A9F2B931E02001CA3F6 /* WeighingViewModel.swift */,
93A095112E33359600E1E1D1 /* SettingsView.swift */,
77292AA12B931E03001CA3F6 /* TrackWeightView.swift */,
Expand Down Expand Up @@ -137,7 +140,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1520;
LastUpgradeCheck = 1620;
LastUpgradeCheck = 2650;
TargetAttributes = {
77292A832B931953001CA3F6 = {
CreatedOnToolsVersion = 15.2;
Expand Down Expand Up @@ -186,6 +189,7 @@
77292A982B931D60001CA3F6 /* ContentViewModel.swift in Sources */,
77292A882B931953001CA3F6 /* TrackWeightApp.swift in Sources */,
93ABD0212E2E01E200668D4F /* HomeView.swift in Sources */,
94B0A0112E40010000E1E1D1 /* GlassTheme.swift in Sources */,
77292A9C2B931E01001CA3F6 /* WeighingState.swift in Sources */,
77292A9E2B931E02001CA3F6 /* WeighingViewModel.swift in Sources */,
77292AA02B931E03001CA3F6 /* TrackWeightView.swift in Sources */,
Expand Down Expand Up @@ -259,6 +263,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand Down Expand Up @@ -318,6 +323,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
Expand All @@ -333,7 +339,7 @@
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 9ZRLG6277G;
DEVELOPMENT_TEAM = M7X27V439V;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -345,7 +351,7 @@
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.krishkrosh.trackweight;
PRODUCT_BUNDLE_IDENTIFIER = com.liladhar.trackweight;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -365,6 +371,7 @@
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 9ZRLG6277G;
"DEVELOPMENT_TEAM[sdk=macosx*]" = M7X27V439V;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
41 changes: 29 additions & 12 deletions TrackWeight/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,60 @@ import SwiftUI

struct ContentView: View {
@State private var showHomePage = true
@State private var selectedTab = 1 // Start with Scale tab (index 1)
@State private var selectedTab = 1

var body: some View {
if showHomePage {
HomeView {
showHomePage = false
Group {
if showHomePage {
HomeView {
withAnimation(.easeInOut(duration: 0.45)) {
showHomePage = false
}
}
} else {
mainTabs
}
.frame(minWidth: 700, minHeight: 500)
} else {
}
.frame(
minWidth: AppLayout.windowMinWidth,
minHeight: AppLayout.windowMinHeight
)
.preferredColorScheme(.dark)
}

private var mainTabs: some View {
ZStack {
GlassBackground()

TabView(selection: $selectedTab) {
TrackWeightView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.tabItem {
Image(systemName: "arrow.3.trianglepath")
Text("Guided (Experimental)")
Text("Guided")
}
.tag(0)

ScaleView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.tabItem {
Image(systemName: "scalemass")
Text("Scale")
}
.tag(1)

SettingsView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
.tag(2)
}
.frame(minWidth: 700, minHeight: 500)
}
}
}


#Preview {
ContentView()
}
126 changes: 59 additions & 67 deletions TrackWeight/DebugView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// DebugView.swift
// TrackWeight
//
// Created by Takuto Nakamura on 2024/03/02.
//

import OpenMultitouchSupport
import SwiftUI
Expand All @@ -13,80 +11,73 @@ struct DebugView: View {
@Environment(\.dismiss) private var dismiss

var body: some View {
VStack {
// Header with close button
HStack {
Text("Debug Console")
.font(.title2)
.fontWeight(.semibold)

Spacer()

Button(action: {
dismiss()
}) {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.foregroundColor(.secondary)
ZStack {
GlassBackground()

VStack(spacing: 20) {
HStack {
Text("Debug Console")
.font(.title2.weight(.bold))
.accentGradientForeground()

Spacer()

Button(action: { dismiss() }) {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.foregroundStyle(.white.opacity(0.5))
}
.buttonStyle(.plain)
.help("Close Debug Console")
}
.buttonStyle(PlainButtonStyle())
.help("Close Debug Console")
}
.padding(.bottom)

// Device Selector
if !viewModel.availableDevices.isEmpty {
VStack(alignment: .leading) {
Text("Trackpad Device:")
.font(.headline)
Picker("Select Device", selection: Binding(
get: { viewModel.selectedDevice },
set: { device in
if let device = device {
viewModel.selectDevice(device)
if !viewModel.availableDevices.isEmpty {
VStack(alignment: .leading, spacing: 10) {
Text("Trackpad Device")
.font(.headline)
.foregroundStyle(.white.opacity(0.85))

Picker("Select Device", 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) (ID: \(device.deviceID))")
.tag(device as OMSDeviceInfo?)
}
}
)) {
ForEach(viewModel.availableDevices, id: \.self) { device in
Text("\(device.deviceName) (ID: \(device.deviceID))")
.tag(device as OMSDeviceInfo?)
}
.pickerStyle(.menu)
.tint(.white)
}
.pickerStyle(MenuPickerStyle())
.padding(20)
.glassCard(cornerRadius: 16)
}
.padding(.bottom)
}

if viewModel.isListening {
Button {
viewModel.stop()
} label: {
Text("Stop")
}
} else {
Button {
viewModel.start()
} label: {
Text("Start")

if viewModel.isListening {
Button { viewModel.stop() } label: { Text("Stop") }
.buttonStyle(GlassPrimaryButtonStyle())
} else {
Button { viewModel.start() } label: { Text("Start") }
.buttonStyle(GlassPrimaryButtonStyle())
}
}
Canvas { context, size in
viewModel.touchData.forEach { touch in
let path = makeEllipse(touch: touch, size: size)
context.fill(path, with: .color(.primary.opacity(Double(touch.total))))

Canvas { context, size in
viewModel.touchData.forEach { touch in
let path = makeEllipse(touch: touch, size: size)
context.fill(path, with: .color(.cyan.opacity(Double(touch.total))))
}
}
.frame(width: 600, height: 400)
.glassCard(cornerRadius: 16)
}
.frame(width: 600, height: 400)
.border(Color.primary)
}
.fixedSize()
.padding()
.onAppear {
viewModel.onAppear()
}
.onDisappear {
viewModel.onDisappear()
.padding(28)
}
.onAppear { viewModel.onAppear() }
.onDisappear { viewModel.onDisappear() }
}

private func makeEllipse(touch: OMSTouchData, size: CGSize) -> Path {
Expand All @@ -104,4 +95,5 @@ struct DebugView: View {

#Preview {
DebugView()
}
.frame(width: 700, height: 500)
}
Loading