[mob][cast] Show choice to auto and manual pair

This commit is contained in:
Neeraj Gupta 2024-04-24 10:57:28 +05:30
parent bd225ced04
commit 1251a014b0
4 changed files with 78 additions and 0 deletions

View file

@ -357,6 +357,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Authentication failed, please try again"),
"authenticationSuccessful":
MessageLookupByLibrary.simpleMessage("Authentication successful!"),
"autoPair": MessageLookupByLibrary.simpleMessage("Auto pair"),
"available": MessageLookupByLibrary.simpleMessage("Available"),
"backedUpFolders":
MessageLookupByLibrary.simpleMessage("Backed up folders"),
@ -982,6 +983,7 @@ class MessageLookup extends MessageLookupByLibrary {
"orPickAnExistingOne":
MessageLookupByLibrary.simpleMessage("Or pick an existing one"),
"pair": MessageLookupByLibrary.simpleMessage("Pair"),
"pairWithPin": MessageLookupByLibrary.simpleMessage("Pair with PIN"),
"passkey": MessageLookupByLibrary.simpleMessage("Passkey"),
"passkeyAuthTitle":
MessageLookupByLibrary.simpleMessage("Passkey verification"),

View file

@ -8378,6 +8378,26 @@ class S {
);
}
/// `Auto pair`
String get autoPair {
return Intl.message(
'Auto pair',
name: 'autoPair',
desc: '',
args: [],
);
}
/// `Pair with PIN`
String get pairWithPin {
return Intl.message(
'Pair with PIN',
name: 'pairWithPin',
desc: '',
args: [],
);
}
/// `Device not found`
String get deviceNotFound {
return Intl.message(

View file

@ -1195,6 +1195,8 @@
"verifyPasskey": "Verify passkey",
"playOnTv": "Play album on TV",
"pair": "Pair",
"autoPair": "Auto pair",
"pairWithPin": "Pair with PIN",
"deviceNotFound": "Device not found",
"castInstruction": "Visit cast.ente.io on the device you want to pair.\n\nEnter the code below to play the album on your TV.",
"deviceCodeHint": "Enter the code",

View file

@ -26,6 +26,7 @@ import 'package:photos/services/update_service.dart';
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import 'package:photos/ui/components/action_sheet_widget.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import "package:photos/ui/components/dialog_widget.dart";
import 'package:photos/ui/components/models/button_type.dart';
import "package:photos/ui/map/enable_map.dart";
import "package:photos/ui/map/map_screen.dart";
@ -892,6 +893,59 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
final gw = CastGateway(NetworkClient.instance.enteDio);
// stop any existing cast session
gw.revokeAllTokens().ignore();
final result = await showDialogWidget(
context: context,
title: S.of(context).playOnTv,
body:
"Auto Pair requires connecting to Google servers and only works with Chromecast supported devices. Google will not receive sensitive data, such as your photos.\n\nPair with PIN works for any large screen device you want to play your album on.",
buttons: [
ButtonWidget(
labelText: S.of(context).autoPair,
icon: Icons.cast_outlined,
buttonType: ButtonType.trailingIconPrimary,
buttonSize: ButtonSize.large,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.first,
shouldSurfaceExecutionStates: true,
isInAlert: true,
onTap: () async {
showToast(context, "Coming soon");
// await _castAlbum(gw);
},
),
ButtonWidget(
labelText: S.of(context).pairWithPin,
buttonType: ButtonType.trailingIconPrimary,
// icon for pairing with TV manually
icon: Icons.tv_outlined,
buttonSize: ButtonSize.large,
isInAlert: true,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.second,
shouldSurfaceExecutionStates: false,
),
// cancel button
],
);
_logger.info("Cast result: $result");
if (result == null) {
return;
}
if (result.action == ButtonAction.error) {
await showGenericErrorDialog(
context: context,
error: result.exception,
);
}
if (result.action == ButtonAction.first) {
showToast(context, "Coming soon");
}
if (result.action == ButtonAction.second) {
await _pairWithPin(gw);
}
}
Future<void> _pairWithPin(CastGateway gw) async {
await showTextInputDialog(
context,
title: context.l10n.playOnTv,