commit 08fe329a7a3f8fd1a7a2e2bf966223890c729319 Author: kejaro Date: Wed Oct 7 14:07:47 2026 +0100 init diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..9fef79a --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,11 @@ +# Workspace Setup Checklist + +- [x] Verify `.github/copilot-instructions.md` exists. +- [x] Clarify requirements: Flutter iOS/Android, Wear OS, watchOS, and Garmin Connect IQ. +- [x] Scaffold four independent app starters. +- [x] Add timer starter screens and platform setup documentation. +- [x] Install required extensions: none were specified or installed. +- [x] Compile the projects: not run; required platform SDKs are unavailable on this Linux host. +- [x] Create and run a task: not applicable; this workspace contains separate native app targets. +- [x] Launch the projects: not launched; platform toolchains are unavailable. +- [x] Ensure `README.md` and this file document the current project setup. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a24f19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Flutter / Dart +.dart_tool/ +.packages +.pub-cache/ +.pub/ +build/ +.flutter-plugins +.flutter-plugins-dependencies + +# Android / Gradle +.gradle/ +local.properties +**/build/ +*.iml + +# Xcode / Swift +.DS_Store +DerivedData/ +*.xcuserstate +xcuserdata/ +.swiftpm/ + +# Garmin Connect IQ +*.prg +*.iq +*.debug.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..158630f --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Hockey Timer + +A four-target workspace for a shared hockey game timer: + +- `projects/mobile_flutter`: Flutter app for iOS and Android. +- `projects/wearos`: standalone Wear OS app in Kotlin and Jetpack Compose. +- `projects/apple_watch`: SwiftUI watchOS app source. Create its Xcode watchOS target on macOS before building or signing. +- `projects/garmin_connectiq`: Garmin Connect IQ Monkey C app source and manifest. + +Each app currently starts with a 20:00 period timer and basic controls. The implementations are independent starters; shared game state, synchronization, scoring, and period rules are not yet defined. + +## Requirements + +- Flutter stable with the iOS/Android toolchains for `mobile_flutter`. +- Android Studio or Android SDK, JDK 17+, and Gradle (or Android Studio's Gradle integration) for `wearos`. +- macOS with Xcode and watchOS SDK for `apple_watch`. This workspace was initialized on Linux, so an Xcode project, signing, simulator run, and device build must be created on macOS. +- Garmin Connect IQ SDK, Monkey C extension/toolchain, and a supported simulator/device for `garmin_connectiq`. + +The current Linux environment does not have Flutter, Dart, Gradle, or Xcode installed. The source/config starters are present, but platform compilation has not been run. + +## Build and run + +From the repository root: + +```sh +cd projects/mobile_flutter +flutter create --platforms=android,ios --project-name hockey_timer_mobile . +flutter pub get +flutter run +``` + +The `flutter create` step generates the platform runner folders omitted from this Linux starter. iOS builds still require macOS and Xcode. + +Open `projects/wearos` in Android Studio, sync Gradle, and run the `app` configuration on a Wear OS emulator or device. Or use `./gradlew :app:installDebug` after adding a Gradle wrapper and Android SDK. + +On macOS, create a new watchOS App target in Xcode named `HockeyTimerWatch`, replace its generated app entry/view with the Swift files in `projects/apple_watch/Sources/HockeyTimerWatch`, then select a watch simulator and run. Xcode owns watchOS app packaging and signing. + +For Garmin, open `projects/garmin_connectiq` in VS Code with the Garmin Connect IQ Monkey C extension and SDK configured; build/run the `HockeyTimer` app against a compatible simulator or device. + +## Workspace layout + +```text +projects/ + mobile_flutter/ + wearos/ + apple_watch/ + garmin_connectiq/ +``` diff --git a/projects/apple_watch/Sources/HockeyTimerWatch/HockeyTimerWatchApp.swift b/projects/apple_watch/Sources/HockeyTimerWatch/HockeyTimerWatchApp.swift new file mode 100644 index 0000000..750dfe2 --- /dev/null +++ b/projects/apple_watch/Sources/HockeyTimerWatch/HockeyTimerWatchApp.swift @@ -0,0 +1,10 @@ +import SwiftUI + +@main +struct HockeyTimerWatchApp: App { + var body: some Scene { + WindowGroup { + TimerView() + } + } +} diff --git a/projects/apple_watch/Sources/HockeyTimerWatch/TimerView.swift b/projects/apple_watch/Sources/HockeyTimerWatch/TimerView.swift new file mode 100644 index 0000000..95befba --- /dev/null +++ b/projects/apple_watch/Sources/HockeyTimerWatch/TimerView.swift @@ -0,0 +1,39 @@ +import SwiftUI + +struct TimerView: View { + @State private var secondsRemaining = 20 * 60 + @State private var isRunning = false + private let ticker = Timer.publish(every: 1, on: .main, in: .common).autoconnect() + + private var timeText: String { + String(format: "%02d:%02d", secondsRemaining / 60, secondsRemaining % 60) + } + + var body: some View { + VStack(spacing: 8) { + Text("PERIOD 1") + .font(.caption2) + .foregroundStyle(.secondary) + Text(timeText) + .font(.system(size: 34, weight: .semibold, design: .rounded)) + .monospacedDigit() + HStack(spacing: 12) { + Button(isRunning ? "Pause" : "Start") { + isRunning.toggle() + } + Button("Reset") { + isRunning = false + secondsRemaining = 20 * 60 + } + } + .font(.caption2) + } + .onReceive(ticker) { _ in + guard isRunning, secondsRemaining > 0 else { return } + secondsRemaining -= 1 + if secondsRemaining == 0 { + isRunning = false + } + } + } +} diff --git a/projects/garmin_connectiq/manifest.xml b/projects/garmin_connectiq/manifest.xml new file mode 100644 index 0000000..bff28be --- /dev/null +++ b/projects/garmin_connectiq/manifest.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/projects/garmin_connectiq/source/HockeyTimerApp.mc b/projects/garmin_connectiq/source/HockeyTimerApp.mc new file mode 100644 index 0000000..84f5fdf --- /dev/null +++ b/projects/garmin_connectiq/source/HockeyTimerApp.mc @@ -0,0 +1,33 @@ +using Toybox.Application as Application; +using Toybox.Graphics as Graphics; +using Toybox.WatchUi as WatchUi; + +class HockeyTimerApp extends Application.AppBase { + function initialize() { + AppBase.initialize(); + } + + function getInitialView() { + return [ new HockeyTimerView() ]; + } +} + +class HockeyTimerView extends WatchUi.View { + function onUpdate(dc) { + dc.clear(); + dc.drawText( + dc.getWidth() / 2, + dc.getHeight() / 2 - 24, + Graphics.FONT_SMALL, + "PERIOD 1", + Graphics.TEXT_JUSTIFY_CENTER + ); + dc.drawText( + dc.getWidth() / 2, + dc.getHeight() / 2, + Graphics.FONT_LARGE, + "20:00", + Graphics.TEXT_JUSTIFY_CENTER + ); + } +} diff --git a/projects/mobile_flutter/lib/main.dart b/projects/mobile_flutter/lib/main.dart new file mode 100644 index 0000000..cd93db9 --- /dev/null +++ b/projects/mobile_flutter/lib/main.dart @@ -0,0 +1,105 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; + +void main() => runApp(const HockeyTimerApp()); + +class HockeyTimerApp extends StatelessWidget { + const HockeyTimerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Hockey Timer', + theme: ThemeData(colorSchemeSeed: const Color(0xff087f8c), useMaterial3: true), + home: const TimerScreen(), + ); + } +} + +class TimerScreen extends StatefulWidget { + const TimerScreen({super.key}); + + @override + State createState() => _TimerScreenState(); +} + +class _TimerScreenState extends State { + static const _periodLength = 20 * 60; + int _secondsRemaining = _periodLength; + Timer? _ticker; + + void _toggleTimer() { + if (_ticker != null) { + _ticker!.cancel(); + setState(() => _ticker = null); + return; + } + + if (_secondsRemaining == 0) return; + setState(() { + _ticker = Timer.periodic(const Duration(seconds: 1), (_) { + if (_secondsRemaining <= 1) { + _ticker?.cancel(); + setState(() { + _secondsRemaining = 0; + _ticker = null; + }); + } else { + setState(() => _secondsRemaining--); + } + }); + }); + } + + void _resetTimer() { + _ticker?.cancel(); + setState(() { + _ticker = null; + _secondsRemaining = _periodLength; + }); + } + + @override + void dispose() { + _ticker?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final minutes = (_secondsRemaining ~/ 60).toString().padLeft(2, '0'); + final seconds = (_secondsRemaining % 60).toString().padLeft(2, '0'); + final running = _ticker != null; + + return Scaffold( + appBar: AppBar(title: const Text('Hockey Timer')), + body: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('PERIOD 1', style: Theme.of(context).textTheme.titleMedium), + const SizedBox(height: 12), + Text('$minutes:$seconds', style: Theme.of(context).textTheme.displayLarge), + const SizedBox(height: 24), + Wrap( + spacing: 12, + children: [ + FilledButton.icon( + onPressed: _toggleTimer, + icon: Icon(running ? Icons.pause : Icons.play_arrow), + label: Text(running ? 'Pause' : 'Start'), + ), + OutlinedButton.icon( + onPressed: _resetTimer, + icon: const Icon(Icons.replay), + label: const Text('Reset'), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/projects/mobile_flutter/pubspec.yaml b/projects/mobile_flutter/pubspec.yaml new file mode 100644 index 0000000..36026e0 --- /dev/null +++ b/projects/mobile_flutter/pubspec.yaml @@ -0,0 +1,13 @@ +name: hockey_timer_mobile +description: Hockey period timer for iOS and Android. +publish_to: "none" +version: 1.0.0+1 + +environment: + sdk: ">=3.4.0 <4.0.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: diff --git a/projects/wearos/app/build.gradle.kts b/projects/wearos/app/build.gradle.kts new file mode 100644 index 0000000..dc9bf09 --- /dev/null +++ b/projects/wearos/app/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("org.jetbrains.kotlin.plugin.compose") +} + +android { + namespace = "com.hockeytimer.wear" + compileSdk = 35 + + defaultConfig { + applicationId = "com.hockeytimer.wear" + minSdk = 30 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + } + + buildFeatures { + compose = true + } +} + +dependencies { + implementation("androidx.activity:activity-compose:1.10.1") + implementation("androidx.compose.material3:material3:1.3.2") + implementation("androidx.compose.ui:ui:1.8.1") + implementation("androidx.wear.compose:compose-material3:1.4.1") +} diff --git a/projects/wearos/app/src/main/AndroidManifest.xml b/projects/wearos/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..74964f8 --- /dev/null +++ b/projects/wearos/app/src/main/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/projects/wearos/app/src/main/java/com/hockeytimer/wear/MainActivity.kt b/projects/wearos/app/src/main/java/com/hockeytimer/wear/MainActivity.kt new file mode 100644 index 0000000..32bf419 --- /dev/null +++ b/projects/wearos/app/src/main/java/com/hockeytimer/wear/MainActivity.kt @@ -0,0 +1,66 @@ +package com.hockeytimer.wear + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import kotlinx.coroutines.delay + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { MaterialTheme { TimerScreen() } } + } +} + +@Composable +private fun TimerScreen() { + var secondsRemaining by remember { mutableIntStateOf(20 * 60) } + var running by remember { mutableStateOf(false) } + + LaunchedEffect(running) { + while (running && secondsRemaining > 0) { + delay(1_000) + secondsRemaining-- + } + if (secondsRemaining == 0) running = false + } + + Column( + modifier = Modifier.fillMaxSize().padding(20.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center, + ) { + Text("PERIOD 1", style = MaterialTheme.typography.labelMedium) + Text( + text = "%02d:%02d".format(secondsRemaining / 60, secondsRemaining % 60), + fontSize = 38.sp, + ) + Button(onClick = { running = !running && secondsRemaining > 0 }) { + Text(if (running) "Pause" else "Start") + } + Button(onClick = { + running = false + secondsRemaining = 20 * 60 + }) { + Text("Reset") + } + } +} diff --git a/projects/wearos/build.gradle.kts b/projects/wearos/build.gradle.kts new file mode 100644 index 0000000..ebdfa7c --- /dev/null +++ b/projects/wearos/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + id("com.android.application") version "8.10.1" apply false + id("org.jetbrains.kotlin.android") version "2.1.20" apply false + id("org.jetbrains.kotlin.plugin.compose") version "2.1.20" apply false +} diff --git a/projects/wearos/gradle.properties b/projects/wearos/gradle.properties new file mode 100644 index 0000000..344ead5 --- /dev/null +++ b/projects/wearos/gradle.properties @@ -0,0 +1,2 @@ +android.useAndroidX=true +org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 diff --git a/projects/wearos/settings.gradle.kts b/projects/wearos/settings.gradle.kts new file mode 100644 index 0000000..c8a3a9c --- /dev/null +++ b/projects/wearos/settings.gradle.kts @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "HockeyTimerWear" +include(":app")