diff --git a/mobile/lib/service_locator.dart b/mobile/lib/service_locator.dart index eb79aab0fbb15894868d7d8f5525386047ff06fd..397703761efb7c2aba28639e33c6f860b19769e6 100644 --- a/mobile/lib/service_locator.dart +++ b/mobile/lib/service_locator.dart @@ -4,22 +4,6 @@ import "package:ente_cast_normal/ente_cast_normal.dart"; import "package:ente_feature_flag/ente_feature_flag.dart"; import "package:shared_preferences/shared_preferences.dart"; -CastService? _castService; -CastService get castService { - _castService ??= CastServiceImpl(); - return _castService!; -} - -FlagService? _flagService; - -FlagService get flagService { - _flagService ??= FlagService( - ServiceLocator.instance.prefs, - ServiceLocator.instance.enteDio, - ); - return _flagService!; -} - class ServiceLocator { late final SharedPreferences prefs; late final Dio enteDio; @@ -34,3 +18,19 @@ class ServiceLocator { this.enteDio = enteDio; } } + +FlagService? _flagService; + +FlagService get flagService { + _flagService ??= FlagService( + ServiceLocator.instance.prefs, + ServiceLocator.instance.enteDio, + ); + return _flagService!; +} + +CastService? _castService; +CastService get castService { + _castService ??= CastServiceImpl(); + return _castService!; +} diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index f433b336cbbfe32f5a0dc76462eddb7551cceef6..a33fc9628b21e7008f3b0c5873964104c282bede 100644 --- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -646,7 +646,7 @@ class _GalleryAppBarWidgetState extends State { } Widget castWidget(BuildContext context) { - return FutureBuilder>( + return FutureBuilder>( future: castService.searchDevices(), builder: (context, snapshot) { if (snapshot.hasError) { @@ -666,7 +666,9 @@ class _GalleryAppBarWidgetState extends State { } return Column( - children: snapshot.data!.map((device) { + children: snapshot.data!.map((result) { + final device = result.$2; + final name = result.$1; return GestureDetector( onTap: () async { try { @@ -675,7 +677,7 @@ class _GalleryAppBarWidgetState extends State { showGenericErrorDialog(context: context, error: e).ignore(); } }, - child: Text(device.toString()), + child: Text(name), ); }).toList(), ); diff --git a/mobile/plugins/ente_cast/analysis_options.yaml b/mobile/plugins/ente_cast/analysis_options.yaml index fac60e247cb14f3de359aa9f45453db57bb0faae..f04c6cf0f30d4f8306eabe5dfd00f2a4c902b838 100644 --- a/mobile/plugins/ente_cast/analysis_options.yaml +++ b/mobile/plugins/ente_cast/analysis_options.yaml @@ -1 +1 @@ -include: ../../analysis_options.yaml \ No newline at end of file +include: ../../analysis_options.yaml diff --git a/mobile/plugins/ente_cast/lib/src/service.dart b/mobile/plugins/ente_cast/lib/src/service.dart index 74834f79d0a57ccd75f79e815a73f691dcfab09a..230269bb390f9eb4d533f28c64994e5a9d127bdc 100644 --- a/mobile/plugins/ente_cast/lib/src/service.dart +++ b/mobile/plugins/ente_cast/lib/src/service.dart @@ -2,6 +2,6 @@ import "package:flutter/widgets.dart"; abstract class CastService { bool get isSupported; - Future> searchDevices(); + Future> searchDevices(); Future connectDevice(BuildContext context, Object device); } diff --git a/mobile/plugins/ente_cast/pubspec.yaml b/mobile/plugins/ente_cast/pubspec.yaml index 8ed1e74121ae3ccbc0bfb1d846572e5bb02bb5ec..967e147e91a438f8a9f793420613a903bbe6e9d7 100644 --- a/mobile/plugins/ente_cast/pubspec.yaml +++ b/mobile/plugins/ente_cast/pubspec.yaml @@ -16,4 +16,4 @@ dependencies: dev_dependencies: flutter_lints: -flutter: \ No newline at end of file +flutter: diff --git a/mobile/plugins/ente_cast_none/analysis_options.yaml b/mobile/plugins/ente_cast_none/analysis_options.yaml index fac60e247cb14f3de359aa9f45453db57bb0faae..f04c6cf0f30d4f8306eabe5dfd00f2a4c902b838 100644 --- a/mobile/plugins/ente_cast_none/analysis_options.yaml +++ b/mobile/plugins/ente_cast_none/analysis_options.yaml @@ -1 +1 @@ -include: ../../analysis_options.yaml \ No newline at end of file +include: ../../analysis_options.yaml diff --git a/mobile/plugins/ente_cast_none/lib/src/service.dart b/mobile/plugins/ente_cast_none/lib/src/service.dart index 964f4e472aa3dce08656da0a4d1874f47b7a1c56..166108c52833b7b4b82cf71333309a5be102585e 100644 --- a/mobile/plugins/ente_cast_none/lib/src/service.dart +++ b/mobile/plugins/ente_cast_none/lib/src/service.dart @@ -8,10 +8,11 @@ class CastServiceImpl extends CastService { } @override - Future> searchDevices() { - throw UnimplementedError(); - } + bool get isSupported => false; @override - bool get isSupported => false; + Future> searchDevices() { + // TODO: implement searchDevices + throw UnimplementedError(); + } } diff --git a/mobile/plugins/ente_cast_none/pubspec.yaml b/mobile/plugins/ente_cast_none/pubspec.yaml index 0484f000f0c4733cfa42615d3fa5e2b00e824246..a4559fac5363ed3c7c29227be7627ca252fd3377 100644 --- a/mobile/plugins/ente_cast_none/pubspec.yaml +++ b/mobile/plugins/ente_cast_none/pubspec.yaml @@ -15,4 +15,4 @@ dependencies: dev_dependencies: flutter_lints: -flutter: \ No newline at end of file +flutter: diff --git a/mobile/plugins/ente_cast_normal/analysis_options.yaml b/mobile/plugins/ente_cast_normal/analysis_options.yaml index fac60e247cb14f3de359aa9f45453db57bb0faae..f04c6cf0f30d4f8306eabe5dfd00f2a4c902b838 100644 --- a/mobile/plugins/ente_cast_normal/analysis_options.yaml +++ b/mobile/plugins/ente_cast_normal/analysis_options.yaml @@ -1 +1 @@ -include: ../../analysis_options.yaml \ No newline at end of file +include: ../../analysis_options.yaml diff --git a/mobile/plugins/ente_cast_normal/lib/src/service.dart b/mobile/plugins/ente_cast_normal/lib/src/service.dart index 1664511b6c1a6673c16afd8fe2be3d0ef93cadb5..eac98ae51b0a33ee6af4032036b59e39b2fa5a2f 100644 --- a/mobile/plugins/ente_cast_normal/lib/src/service.dart +++ b/mobile/plugins/ente_cast_normal/lib/src/service.dart @@ -27,9 +27,10 @@ class CastServiceImpl extends CastService { } @override - Future> searchDevices() { - // TODO: implement searchDevices - throw UnimplementedError(); + Future> searchDevices() { + return CastDiscoveryService().search().then((devices) { + return devices.map((device) => (device.name, device)).toList(); + }); } @override diff --git a/mobile/plugins/ente_cast_normal/pubspec.yaml b/mobile/plugins/ente_cast_normal/pubspec.yaml index 17d172121841f555043401c7c33102379555f4de..c97d70a84bed4dc462b92be6657130386a04bd41 100644 --- a/mobile/plugins/ente_cast_normal/pubspec.yaml +++ b/mobile/plugins/ente_cast_normal/pubspec.yaml @@ -19,4 +19,4 @@ dependencies: dev_dependencies: flutter_lints: -flutter: \ No newline at end of file +flutter: