init
This commit is contained in:
commit
08fe329a7a
15 files changed
+434
No files matched your search
@@ -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.
|
||||||
+26
@@ -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
|
||||||
@@ -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/
|
||||||
|
```
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct HockeyTimerWatchApp: App {
|
||||||
|
var body: some Scene {
|
||||||
|
WindowGroup {
|
||||||
|
TimerView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
|
||||||
|
<iq:application
|
||||||
|
id="b89b63dc63124c6e9326e68cd6c4e8bc"
|
||||||
|
type="watch-app"
|
||||||
|
name="Hockey Timer"
|
||||||
|
entry="HockeyTimerApp"
|
||||||
|
minApiLevel="3.2.0">
|
||||||
|
<iq:products>
|
||||||
|
<iq:product id="fenix7" />
|
||||||
|
</iq:products>
|
||||||
|
<iq:permissions />
|
||||||
|
</iq:application>
|
||||||
|
</iq:manifest>
|
||||||
@@ -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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TimerScreen> createState() => _TimerScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TimerScreenState extends State<TimerScreen> {
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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:
|
||||||
@@ -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")
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-feature android:name="android.hardware.type.watch" android:required="true" />
|
||||||
|
|
||||||
|
<application android:label="Hockey Timer" android:theme="@android:style/Theme.DeviceDefault">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<meta-data android:name="com.google.android.wearable.standalone" android:value="true" />
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
android.useAndroidX=true
|
||||||
|
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
||||||
@@ -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")
|
||||||
Reference in new issue
Block a user