feat(watch): Android Wear Data Layer adapter + foreground service (#91-D)
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user