diff --git a/mobile/lib/service_locator.dart b/mobile/lib/service_locator.dart index eb79aab0f..397703761 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 f433b336c..a33fc9628 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 fac60e247..f04c6cf0f 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 74834f79d..230269bb3 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 8ed1e7412..967e147e9 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 fac60e247..f04c6cf0f 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 964f4e472..166108c52 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 0484f000f..a4559fac5 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 fac60e247..f04c6cf0f 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 1664511b6..eac98ae51 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 17d172121..c97d70a84 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: