[mob][photos] Update cast selection dialog
This commit is contained in:
parent
729e2adfd1
commit
aced4bb5cf
3 changed files with 94 additions and 38 deletions
|
@ -1,6 +1,6 @@
|
|||
import "package:dio/dio.dart";
|
||||
import "package:ente_cast/ente_cast.dart";
|
||||
import "package:ente_cast_none/ente_cast_none.dart";
|
||||
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";
|
||||
|
||||
|
|
83
mobile/lib/ui/cast/choose.dart
Normal file
83
mobile/lib/ui/cast/choose.dart
Normal file
|
@ -0,0 +1,83 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
import "package:photos/ui/components/buttons/button_widget.dart";
|
||||
import "package:photos/ui/components/models/button_type.dart";
|
||||
|
||||
class CastChooseDialog extends StatefulWidget {
|
||||
CastChooseDialog({
|
||||
Key? key,
|
||||
}) : super(key: key) {}
|
||||
|
||||
@override
|
||||
State<CastChooseDialog> createState() => _AutoCastDialogState();
|
||||
}
|
||||
|
||||
class _AutoCastDialogState extends State<CastChooseDialog> {
|
||||
final bool doesUserExist = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textStyle = getEnteTextTheme(context);
|
||||
final AlertDialog alert = AlertDialog(
|
||||
title: Text(
|
||||
"Play album on TV",
|
||||
style: textStyle.largeBold,
|
||||
),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"Auto Pair requires connecting to Google servers and only works with Chromecast supported devices. Google will not receive sensitive data, such as your photos.",
|
||||
style: textStyle.bodyMuted,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ButtonWidget(
|
||||
labelText: S.of(context).autoPair,
|
||||
icon: Icons.cast_outlined,
|
||||
buttonType: ButtonType.primary,
|
||||
buttonSize: ButtonSize.large,
|
||||
shouldStickToDarkTheme: true,
|
||||
buttonAction: ButtonAction.first,
|
||||
shouldSurfaceExecutionStates: false,
|
||||
isInAlert: true,
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop(ButtonAction.first);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 36),
|
||||
Text(
|
||||
"Pair with PIN works for any large screen device you want to play your album on.",
|
||||
style: textStyle.bodyMuted,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ButtonWidget(
|
||||
labelText: S.of(context).pairWithPin,
|
||||
buttonType: ButtonType.primary,
|
||||
// icon for pairing with TV manually
|
||||
icon: Icons.tv_outlined,
|
||||
buttonSize: ButtonSize.large,
|
||||
isInAlert: true,
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop(ButtonAction.second);
|
||||
},
|
||||
shouldStickToDarkTheme: true,
|
||||
buttonAction: ButtonAction.second,
|
||||
shouldSurfaceExecutionStates: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return alert;
|
||||
}
|
||||
|
||||
Future<void> _connectToYourApp(
|
||||
BuildContext context,
|
||||
Object castDevice,
|
||||
) async {
|
||||
await castService.connectDevice(context, castDevice);
|
||||
}
|
||||
}
|
|
@ -25,9 +25,9 @@ import 'package:photos/services/sync_service.dart';
|
|||
import 'package:photos/services/update_service.dart';
|
||||
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
|
||||
import "package:photos/ui/cast/auto.dart";
|
||||
import "package:photos/ui/cast/choose.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";
|
||||
|
@ -857,47 +857,20 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
|||
final gw = CastGateway(NetworkClient.instance.enteDio);
|
||||
// stop any existing cast session
|
||||
gw.revokeAllTokens().ignore();
|
||||
final result = await showDialogWidget(
|
||||
final result = await showDialog<ButtonAction?>(
|
||||
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,
|
||||
),
|
||||
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
|
||||
],
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return CastChooseDialog();
|
||||
},
|
||||
);
|
||||
_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) {
|
||||
// wait to allow the dialog to close
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (result == ButtonAction.first) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
|
@ -906,7 +879,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
|||
},
|
||||
);
|
||||
}
|
||||
if (result.action == ButtonAction.second) {
|
||||
if (result == ButtonAction.second) {
|
||||
await _pairWithPin(gw);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue