feat(watch): Android Wear Data Layer adapter + foreground service (#91-D)

This commit is contained in:
2026-07-25 19:51:43 +02:00
parent 40a2d5eddc
commit 68a87d1658
13 changed files with 1037 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import '../infrastructure/local/local.dart';
import '../infrastructure/remote/remote.dart';
import '../infrastructure/security/security.dart';
import '../infrastructure/watch_bridge/watch_bridge.dart';
import 'application.dart';
abstract interface class AppDependencies {
@ -33,6 +34,7 @@ final class AppBootstrap implements AppDependencies {
required this.activeExerciseStepUseCases,
required this.watchCompanionProjectionUseCases,
required this.watchCompanionCommandHandler,
required this.watchWearDataLayerAdapter,
required this.closeWorkoutSessionUseCase,
required this.workoutHistoryUseCases,
required this.progressionStatsUseCase,
@ -61,6 +63,7 @@ final class AppBootstrap implements AppDependencies {
final ActiveExerciseStepUseCases activeExerciseStepUseCases;
final WatchCompanionProjectionUseCases watchCompanionProjectionUseCases;
final WatchCompanionCommandHandler watchCompanionCommandHandler;
final WatchWearDataLayerAdapter watchWearDataLayerAdapter;
@override
final CloseWorkoutSessionUseCase closeWorkoutSessionUseCase;
@override
@ -126,6 +129,18 @@ final class AppBootstrap implements AppDependencies {
ids: ids,
originDeviceId: originDeviceId,
);
final watchCompanionCommandHandler = WatchCompanionCommandHandler(
sessionRepository: activeSessionRepository,
activeSessionUseCases: activeWorkoutSessionUseCases,
stepUseCases: activeExerciseStepUseCases,
projectionSource: watchCompanionProjectionUseCases,
);
final watchWearDataLayerAdapter = WatchWearDataLayerAdapter(
nativeChannel: const MethodChannelWatchBridgeNativeChannel(),
commandIngress: watchCompanionCommandHandler,
projectionSource: watchCompanionProjectionUseCases,
);
await watchWearDataLayerAdapter.start();
await SeedStarterContentUseCase(
seedStateRepository: starterSeedRepository,
contentRepository: starterSeedRepository,
@ -184,12 +199,8 @@ final class AppBootstrap implements AppDependencies {
activeWorkoutSessionUseCases: activeWorkoutSessionUseCases,
activeExerciseStepUseCases: activeExerciseStepUseCases,
watchCompanionProjectionUseCases: watchCompanionProjectionUseCases,
watchCompanionCommandHandler: WatchCompanionCommandHandler(
sessionRepository: activeSessionRepository,
activeSessionUseCases: activeWorkoutSessionUseCases,
stepUseCases: activeExerciseStepUseCases,
projectionSource: watchCompanionProjectionUseCases,
),
watchCompanionCommandHandler: watchCompanionCommandHandler,
watchWearDataLayerAdapter: watchWearDataLayerAdapter,
closeWorkoutSessionUseCase: CloseWorkoutSessionUseCase(
sessionRepository: activeSessionRepository,
historyRepository: historyRepository,
@ -243,5 +254,9 @@ final class AppBootstrap implements AppDependencies {
);
}
Future<void> dispose() => database.close();
Future<void> dispose() async {
await watchWearDataLayerAdapter.stop();
await watchCompanionProjectionUseCases.dispose();
await database.close();
}
}