π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Hide badge share pill in exports
laurenspriemdfab12381e52
diff --git a/mobile/apps/photos/lib/ui/wrapped/cards/badge_card_content.dart b/mobile/apps/photos/lib/ui/wrapped/cards/badge_card_content.dartindex 0a3b17503f..17b9850783 100644--- a/mobile/apps/photos/lib/ui/wrapped/cards/badge_card_content.dart+++ b/mobile/apps/photos/lib/ui/wrapped/cards/badge_card_content.dart@@ -32,6 +32,7 @@ class _BadgeCardContent extends StatelessWidget {final _WrappedViewerPageState? viewerState =context.findAncestorStateOfType<_WrappedViewerPageState>();final GlobalKey? shareKey = viewerState?.shareButtonKey;+ final bool hideSharePill = viewerState?.hideBadgeSharePill ?? false;final _BadgeLayoutConstants layout = _BadgeLayoutConstants(textTheme: textTheme,@@ -154,13 +155,19 @@ class _BadgeCardContent extends StatelessWidget {top: metrics.shareTop,width: metrics.shareWidth,height: metrics.shareHeight,- child: _BadgeSharePill(- labelStyle: shareStyle,- onTap: viewerState == null- ? null- : () => unawaited(viewerState.shareCurrentCard()),- shareButtonKey: shareKey,- size: Size(metrics.shareWidth, metrics.shareHeight),+ child: IgnorePointer(+ ignoring: hideSharePill,+ child: Opacity(+ opacity: hideSharePill ? 0.0 : 1.0,+ child: _BadgeSharePill(+ labelStyle: shareStyle,+ onTap: viewerState == null+ ? null+ : () => unawaited(viewerState.shareCurrentCard()),+ shareButtonKey: shareKey,+ size: Size(metrics.shareWidth, metrics.shareHeight),+ ),+ ),),),],@@ -497,25 +504,27 @@ class _BadgeSharePill extends StatelessWidget {final double shadowScale = size.height / _kDesignShareHeight;return GestureDetector(onTap: onTap,- child: Container(+ child: RepaintBoundary(key: shareButtonKey,- width: size.width,- height: size.height,- alignment: Alignment.center,- decoration: BoxDecoration(- color: Colors.white,- borderRadius: BorderRadius.circular(size.height / 2),- boxShadow: <BoxShadow>[- BoxShadow(- color: Colors.black.withValues(alpha: 0.10),- blurRadius: 16 * shadowScale,- offset: Offset(0, 8 * shadowScale),- ),- ],- ),- child: Text(- "Share",- style: labelStyle,+ child: Container(+ width: size.width,+ height: size.height,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: Colors.white,+ borderRadius: BorderRadius.circular(size.height / 2),+ boxShadow: <BoxShadow>[+ BoxShadow(+ color: Colors.black.withValues(alpha: 0.10),+ blurRadius: 16 * shadowScale,+ offset: Offset(0, 8 * shadowScale),+ ),+ ],+ ),+ child: Text(+ "Share",+ style: labelStyle,+ ),),),);diff --git a/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart b/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dartindex f6aca03bde..9df35332f4 100644--- a/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart+++ b/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart@@ -73,6 +73,9 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>bool _isMusicPlaying = false;bool _musicLoadFailed = false;bool _isFadingOutMusic = false;+ bool _hideBadgeSharePill = false;+ OverlayEntry? _sharePillOverlayEntry;+ ui.Image? _sharePillOverlaySnapshot;StreamSubscription<PlayerState>? _playerStateSubscription;ModalRoute<dynamic>? _registeredRoute;bool _didRegisterWillPop = false;@@ -125,6 +128,7 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>if (_stateListener != null) {wrappedService.stateListenable.removeListener(_stateListener!);}+ _removeSharePillOverlay();if (_didRegisterWillPop && _registeredRoute != null) {// ignore: deprecated_member_use_registeredRoute!.removeScopedWillPopCallback(_handleWillPop);@@ -711,6 +715,7 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>}GlobalKey get shareButtonKey => _shareButtonKey;+ bool get hideBadgeSharePill => _hideBadgeSharePill;Future<void> shareCurrentCard() async {await _handleShare();@@ -726,8 +731,13 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>final bool wasPaused = _isPaused;_pauseAutoplay();try {- final Uint8List? bytes =- await _captureCurrentCard(includeBranding: shouldShowBranding);+ final bool hideShareControls =+ currentCard.type == WrappedCardType.badge ||+ currentCard.type == WrappedCardType.badgeDebug;+ final Uint8List? bytes = await _captureCurrentCard(+ includeBranding: shouldShowBranding,+ hideInteractiveControls: hideShareControls,+ );if (bytes == null) {showShortToast(context, "Unable to prepare share");return;@@ -758,15 +768,41 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>Future<Uint8List?> _captureCurrentCard({required bool includeBranding,+ bool hideInteractiveControls = false,}) async {+ Future<void> showShareControlsIfHidden() async {+ bool awaitedFrame = false;+ if (_hideBadgeSharePill && mounted) {+ setState(() {+ _hideBadgeSharePill = false;+ });+ awaitedFrame = true;+ }+ if (awaitedFrame) {+ await WidgetsBinding.instance.endOfFrame;+ }+ _removeSharePillOverlay();+ }++ if (hideInteractiveControls && !_hideBadgeSharePill && mounted) {+ await _showSharePillOverlay();+ if (!_hideBadgeSharePill && mounted) {+ setState(() {+ _hideBadgeSharePill = true;+ });+ await WidgetsBinding.instance.endOfFrame;+ }+ }await Future<void>.delayed(Duration.zero);final RenderRepaintBoundary? boundary = _cardBoundaryKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;if (boundary == null) {+ await showShareControlsIfHidden();return null;}final double logicalWidth = boundary.size.width;if (logicalWidth <= 0) {+ await showShareControlsIfHidden();return null;}final double pixelRatio = (1080 / logicalWidth).clamp(1.0, 6.0);@@ -777,6 +813,7 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>includeBranding ? await _compositeBranding(image, scale) : image;final ByteData? byteData =await finalImage.toByteData(format: ui.ImageByteFormat.png);+ await showShareControlsIfHidden();return byteData?.buffer.asUint8List();}@@ -785,6 +822,63 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>card.type != WrappedCardType.badgeDebug;}+ Future<void> _showSharePillOverlay() async {+ if (!mounted || _sharePillOverlayEntry != null) {+ return;+ }+ final OverlayState? overlayState = Overlay.of(context, rootOverlay: true);+ if (overlayState == null) {+ return;+ }+ final RenderRepaintBoundary? shareBoundary = _shareButtonKey.currentContext+ ?.findRenderObject() as RenderRepaintBoundary?;+ if (shareBoundary == null) {+ return;+ }+ final Size size = shareBoundary.size;+ final Offset topLeft = shareBoundary.localToGlobal(Offset.zero);+ try {+ final double devicePixelRatio = MediaQuery.of(context).devicePixelRatio;+ final double pixelRatio =+ math.max(1.0, math.min(devicePixelRatio, 4.0));+ final ui.Image snapshot =+ await shareBoundary.toImage(pixelRatio: pixelRatio);+ _sharePillOverlaySnapshot?.dispose();+ _sharePillOverlaySnapshot = snapshot;+ final OverlayEntry entry = OverlayEntry(+ builder: (BuildContext overlayContext) {+ return Positioned(+ left: topLeft.dx,+ top: topLeft.dy,+ width: size.width,+ height: size.height,+ child: IgnorePointer(+ child: RawImage(+ image: snapshot,+ fit: BoxFit.fill,+ ),+ ),+ );+ },+ );+ overlayState.insert(entry);+ _sharePillOverlayEntry = entry;+ } catch (error, stackTrace) {+ _logger.fine(+ "Failed to create share pill overlay",+ error,+ stackTrace,+ );+ }+ }++ void _removeSharePillOverlay() {+ _sharePillOverlayEntry?.remove();+ _sharePillOverlayEntry = null;+ _sharePillOverlaySnapshot?.dispose();+ _sharePillOverlaySnapshot = null;+ }+Future<ui.Image> _compositeBranding(ui.Image baseImage, double scale) async {final ui.Image? logo = await _loadBrandingLogoImage();final ui.PictureRecorder recorder = ui.PictureRecorder();