Skip to content
Merged
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
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "AppIcon~ios-marketing copy.png",
"idiom" : "universal",
"platform" : "watchos",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Promptly-WatchOS Watch App/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
24 changes: 24 additions & 0 deletions Promptly-WatchOS Watch App/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ContentView.swift
// Promptly-WatchOS Watch App
//
// Created by Sasha Bagrov on 05/10/2025.
//

import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}

#Preview {
ContentView()
}
138 changes: 138 additions & 0 deletions Promptly-WatchOS Watch App/HomeScreenView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
//
// HomeScreenView.swift
// Promptly-WatchOS Watch App
//
// Created by Sasha Bagrov on 05/10/2025.
//

import SwiftUI
import SwiftData

struct HomeScreenView: View {
@State var navStackMessage: String = ""
@State var showNetworkSettings: Bool = false
@State var availableShows: [String: String] = [:]

@StateObject private var mqttManager = MQTTManager()

var body: some View {
NavigationStack {
Group {
self.content
}
.navigationTitle(Text(
self.navStackMessage
))
.toolbar {
ToolbarItemGroup {
self.toolbarContent
}
}
.onAppear {
self.setupGreeting()

mqttManager.connect(to: Constants.mqttIP, port: Constants.mqttPort)

mqttManager.subscribeToShowChanges { showId, property, message, title in
if UUID(uuidString: showId) != nil && availableShows[showId] == nil {
availableShows[showId] = title ?? "Unknown Show"
}
}
}
.sheet(isPresented: self.$showNetworkSettings) {
NetworkSettingsView()
}
}
}

var content: some View {
Group {
List {
Section(header: Text("Or join a show")) {
if availableShows.isEmpty {
Text("No available shows")
.foregroundStyle(.secondary)
} else {
ForEach(Array(availableShows.keys), id: \.self) { showId in
NavigationLink(destination: MultiPlayerShowDetail(showID: showId, mqttManager: self.mqttManager)) {
Text(availableShows[showId] ?? "Unknown Show")
}
}
}
}
}
}
}

var toolbarContent: some View {
Group {
Button {
self.showNetworkSettings = true
} label: {
Label("Network Settings", systemImage: "network")
}
}
}

private func setupGreeting() {
let hour = Calendar.current.component(.hour, from: Date())
if hour >= 5 && hour < 12 {
self.navStackMessage = "Good Morning"
} else if hour >= 12 && hour < 17 {
self.navStackMessage = "Good Afternoon"
} else if hour >= 17 && hour < 21 {
self.navStackMessage = "Good Evening"
} else {
self.navStackMessage = "Good Night"
}
}
}

struct NetworkSettingsView: View {
@Environment(\.dismiss) var dismiss

@State private var mqttIP: String = Constants.mqttIP
@State private var mqttPort: String = String(Constants.mqttPort)

var body: some View {
NavigationStack {
Form {
Section {
TextField("MQTT IP Address", text: $mqttIP)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()

TextField("MQTT Port", text: $mqttPort)
} header: {
Text("Connection Settings")
} footer: {
Text("To apply changes, restart the app")
.foregroundStyle(.secondary)
}
}
.navigationTitle("Network Settings")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
dismiss()
}
}

ToolbarItem(placement: .confirmationAction) {
Button("Save") {
if let port = Int(mqttPort) {
Constants.mqttIP = mqttIP
Constants.mqttPort = port
}
dismiss()
}
}
}
}
}
}

#Preview {
HomeScreenView()
}
17 changes: 17 additions & 0 deletions Promptly-WatchOS Watch App/Promptly_WatchOSApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Promptly_WatchOSApp.swift
// Promptly-WatchOS Watch App
//
// Created by Sasha Bagrov on 05/10/2025.
//

import SwiftUI

@main
struct Promptly_WatchOS_Watch_AppApp: App {
var body: some Scene {
WindowGroup {
HomeScreenView()
}
}
}
Loading
Loading