feat: initial project scaffold with Watch companion app

This commit is contained in:
2026-08-04 17:28:06 +02:00
parent adbb4f01c5
commit 43b6467efb
65 changed files with 6361 additions and 166 deletions
@@ -0,0 +1,38 @@
import { useState, useEffect } from "react";
import WatchConnectivity from "../../modules/watch-connectivity";
type WatchConnectionStatus = "connected" | "disconnected" | "pending";
export function useWatchConnection() {
const [status, setStatus] = useState<WatchConnectionStatus>("pending");
const [isPaired, setIsPaired] = useState(false);
const [isInstalled, setIsInstalled] = useState(false);
useEffect(() => {
checkStatus();
const interval = setInterval(checkStatus, 5000);
return () => clearInterval(interval);
}, []);
const checkStatus = async () => {
try {
const supported = await WatchConnectivity.isSupported();
if (!supported) {
setStatus("disconnected");
return;
}
const paired = await WatchConnectivity.isPaired();
const installed = await WatchConnectivity.isWatchAppInstalled();
const reachable = await WatchConnectivity.isReachable();
setIsPaired(paired);
setIsInstalled(installed);
setStatus(reachable ? "connected" : "disconnected");
} catch {
setStatus("disconnected");
}
};
return { status, isPaired, isInstalled };
}