Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Use a Share sheet in the file viewer

ashilkn7746663c0a25
diff --git a/mobile/apps/photos/changes/viewer-share-sheet.md b/mobile/apps/photos/changes/viewer-share-sheet.md
new file mode 100644
index 0000000000..905d84462e
--- /dev/null
+++ b/mobile/apps/photos/changes/viewer-share-sheet.md
@@ -0,0 +1 @@
+- Choose between sending a copy and sending a link from the Share sheet in the file viewer.
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
index ff47077451..c3ed5046d0 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
@@ -158,7 +158,6 @@ class FileBottomBarState extends State<FileBottomBar> {
child: FileShareButton(
key: shareButtonKey,
canSendLink: file.isUploaded && file.isOwner && !isFileHidden,
- isVideo: file.isVideo,
onSendFile: () =>
share(context, [file], shareButtonKey: shareButtonKey),
onSendLink: () => _sendLink(file),
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_share_button.dart b/mobile/apps/photos/lib/ui/viewer/file/file_share_button.dart
index e34aaac5b4..9dea1ab0ca 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_share_button.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_share_button.dart
@@ -1,26 +1,24 @@
import "dart:async";
import "dart:io";
-import "dart:math" as math;
import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
+import "package:photos/ui/sharing/share_components.dart";
enum _FileShareAction { file, link }
class FileShareButton extends StatefulWidget {
const FileShareButton({
required this.canSendLink,
- required this.isVideo,
required this.onSendFile,
required this.onSendLink,
super.key,
});
final bool canSendLink;
- final bool isVideo;
final FutureOr<void> Function() onSendFile;
final FutureOr<void> Function() onSendLink;
@@ -29,7 +27,8 @@ class FileShareButton extends StatefulWidget {
}
class _FileShareButtonState extends State<FileShareButton> {
- _FileShareRoute? _route;
+ ModalRoute<_FileShareAction>? _route;
+ bool _sharing = false;
@override
void dispose() {
@@ -57,383 +56,90 @@ class _FileShareButtonState extends State<FileShareButton> {
}
Future<void> _share() async {
- if (_route != null) return;
+ if (_sharing) return;
+ _sharing = true;
final sendFile = widget.onSendFile;
final sendLink = widget.onSendLink;
- if (!widget.canSendLink) {
- await sendFile();
- return;
- }
-
- final navigator = Navigator.of(context);
- Rect anchorRect() {
- final button = context.findRenderObject()! as RenderBox;
- final overlay =
- navigator.overlay!.context.findRenderObject()! as RenderBox;
- return button.localToGlobal(Offset.zero, ancestor: overlay) & button.size;
- }
-
- final initialAnchor = anchorRect();
- final route = _FileShareRoute(
- anchorRect: () => mounted ? anchorRect() : initialAnchor,
- fileLabel: widget.isVideo
- ? context.strings.sendVideo
- : context.strings.sendPhoto,
- linkLabel: context.strings.sendLink,
- shareLabel: context.strings.share,
- closeLabel: context.strings.close,
- isVideo: widget.isVideo,
- reduceMotion: MediaQuery.disableAnimationsOf(context),
- themes: InheritedTheme.capture(from: context, to: navigator.context),
- );
- _route = route;
- final action = await navigator.push(route);
- // Native sharing must wait until the popup's overlay has been removed.
- await route.completed;
- _route = null;
- if (!mounted) return;
- switch (action) {
- case _FileShareAction.file:
+ try {
+ if (!widget.canSendLink) {
await sendFile();
- case _FileShareAction.link:
- await sendLink();
- case null:
- break;
- }
- }
-}
-
-class _FileShareRoute extends PopupRoute<_FileShareAction> {
- _FileShareRoute({
- required this.anchorRect,
- required this.fileLabel,
- required this.linkLabel,
- required this.shareLabel,
- required this.closeLabel,
- required this.isVideo,
- required this.reduceMotion,
- required this.themes,
- });
-
- final Rect Function() anchorRect;
- final String fileLabel;
- final String linkLabel;
- final String shareLabel;
- final String closeLabel;
- final bool isVideo;
- final bool reduceMotion;
- final CapturedThemes themes;
-
- @override
- Color? get barrierColor => null;
- @override
- bool get barrierDismissible => true;
- @override
- String get barrierLabel => closeLabel;
- @override
- Duration get transitionDuration =>
- Duration(milliseconds: reduceMotion ? 120 : 260);
- @override
- Duration get reverseTransitionDuration =>
- Duration(milliseconds: reduceMotion ? 120 : 140);
-
- void _select([_FileShareAction? action]) {
- if (isCurrent) navigator!.pop(action);
- }
-
- @override
- Widget buildPage(
- BuildContext context,
- Animation<double> animation,
- Animation<double> secondaryAnimation,
- ) {
- return themes.wrap(
- LayoutBuilder(
- builder: (context, constraints) {
- final mediaQuery = MediaQuery.of(context);
- final anchor = anchorRect();
- return Semantics(
- scopesRoute: true,
- namesRoute: true,
- label: shareLabel,
- explicitChildNodes: true,
- child: Stack(
- children: [
- CustomSingleChildLayout(
- delegate: _ShareDockLayout(anchor, mediaQuery.padding),
- child: _ShareDockTransition(
- animation: animation,
- reduceMotion: reduceMotion,
- child: _ShareDock(
- fileLabel: fileLabel,
- linkLabel: linkLabel,
- isVideo: isVideo,
- maxHalfWidth:
- (constraints.maxWidth -
- mediaQuery.padding.horizontal) *
- 0.35,
- onSelected: _select,
- ),
- ),
- ),
- Positioned.fromRect(
- rect: anchor,
- child: Semantics(
- button: true,
- label: closeLabel,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: _select,
- child: const SizedBox.expand(),
- ),
- ),
- ),
- ],
- ),
- );
+ return;
+ }
+
+ final action = await showBottomSheetComponent<_FileShareAction>(
+ context: context,
+ builder: (sheetContext) {
+ _route = ModalRoute.of<_FileShareAction>(sheetContext);
+ return const _FileShareSheet();
},
- ),
- );
+ );
+ // UIKit sharing must wait until the sheet's overlay has been removed.
+ await _route?.completed;
+ _route = null;
+ if (!mounted) return;
+ switch (action) {
+ case _FileShareAction.file:
+ await sendFile();
+ case _FileShareAction.link:
+ await sendLink();
+ case null:
+ break;
+ }
+ } finally {
+ _sharing = false;
+ }
}
}
-class _ShareDockTransition extends StatelessWidget {
- const _ShareDockTransition({
- required this.animation,
- required this.reduceMotion,
- required this.child,
- });
-
- final Animation<double> animation;
- final bool reduceMotion;
- final Widget child;
-
- static const _riseCurve = Cubic(0.2, 0.7, 0.3, 1);
- static final _scale = Tween<double>(
- begin: 0.96,
- end: 1,
- ).chain(CurveTween(curve: _riseCurve));
- static final _offset = Tween<double>(
- begin: 14,
- end: 0,
- ).chain(CurveTween(curve: _riseCurve));
+class _FileShareSheet extends StatelessWidget {
+ const _FileShareSheet();
@override
Widget build(BuildContext context) {
- if (reduceMotion) {
- return FadeTransition(opacity: animation, child: child);
+ void select(_FileShareAction action) {
+ if (ModalRoute.of(context)?.isCurrent ?? false) {
+ Navigator.of(context).pop(action);
+ }
}
- return DualTransitionBuilder(
- animation: animation,
- forwardBuilder: (context, entrance, child) => FadeTransition(
- opacity: entrance.drive(
- CurveTween(curve: const Interval(0, 0.68, curve: _riseCurve)),
- ),
- child: AnimatedBuilder(
- animation: entrance,
- builder: (context, child) => Transform.translate(
- offset: Offset(0, _offset.transform(entrance.value)),
- child: Transform.scale(
- scale: _scale.transform(entrance.value),
- alignment: Alignment.bottomCenter,
- child: child,
- ),
- ),
- child: child,
- ),
- ),
- reverseBuilder: (context, exit, child) {
- final closing = exit.drive(CurveTween(curve: Curves.easeIn));
- return FadeTransition(
- opacity: ReverseAnimation(closing),
- child: AnimatedBuilder(
- animation: closing,
- builder: (context, child) => Transform.translate(
- offset: Offset(0, 6 * closing.value),
- child: Transform.scale(
- scale: 1 - 0.02 * closing.value,
- alignment: Alignment.bottomCenter,
- child: child,
- ),
- ),
- child: child,
- ),
- );
- },
- child: child,
- );
- }
-}
-
-class _ShareDockLayout extends SingleChildLayoutDelegate {
- const _ShareDockLayout(this.anchor, this.padding);
-
- final Rect anchor;
- final EdgeInsets padding;
-
- @override
- BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
- return BoxConstraints(
- maxWidth: math.max(0, constraints.maxWidth - padding.horizontal - 32),
- maxHeight: math.max(0, anchor.top - padding.top - 24),
- );
- }
- @override
- Offset getPositionForChild(Size size, Size childSize) {
- return Offset(
- (anchor.center.dx - childSize.width / 2).clamp(
- padding.left + 16,
- size.width - padding.right - childSize.width - 16,
+ return ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.sizeOf(context).height * 0.95,
),
- anchor.top - childSize.height - 12,
- );
- }
-
- @override
- bool shouldRelayout(_ShareDockLayout oldDelegate) =>
- anchor != oldDelegate.anchor || padding != oldDelegate.padding;
-}
-
-class _ShareDock extends StatelessWidget {
- const _ShareDock({
- required this.fileLabel,
- required this.linkLabel,
- required this.isVideo,
- required this.maxHalfWidth,
- required this.onSelected,
- });
-
- final String fileLabel;
- final String linkLabel;
- final bool isVideo;
- final double maxHalfWidth;
- final ValueChanged<_FileShareAction> onSelected;
-
- static final _labelStyle = TextStyles.body.copyWith(color: Colors.white);
-
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(
- builder: (context, constraints) {
- final textScaler = MediaQuery.textScalerOf(context);
- final painter = TextPainter(
- textDirection: Directionality.of(context),
- textScaler: textScaler,
- );
- var contentWidth = 26.0;
- for (final label in [fileLabel, linkLabel]) {
- painter.text = TextSpan(text: label, style: _labelStyle);
- painter.layout();
- contentWidth = math.max(contentWidth, painter.width);
- }
- final halfWidth = math.min(
- maxHalfWidth,
- math.max(kMinInteractiveDimension, contentWidth + 24),
- );
- final dockWidth = math.min(constraints.maxWidth, halfWidth * 2 + 17);
- var stacked = false;
- if (textScaler.scale(_labelStyle.fontSize!) >=
- _labelStyle.fontSize! * 2) {
- painter.maxLines = 2;
- for (final label in [fileLabel, linkLabel]) {
- painter.text = TextSpan(text: label, style: _labelStyle);
- painter.layout(maxWidth: math.max(0, (dockWidth - 17) / 2 - 24));
- stacked |= painter.didExceedMaxLines;
- }
- }
- painter.dispose();
-
- final file = _action(
- label: fileLabel,
- icon: isVideo
- ? HugeIcons.strokeRoundedVideo01
- : HugeIcons.strokeRoundedImage01,
- action: _FileShareAction.file,
- stacked: stacked,
- );
- final link = _action(
- label: linkLabel,
- icon: HugeIcons.strokeRoundedLink02,
- action: _FileShareAction.link,
- stacked: stacked,
- );
- final dividerColor = Colors.white.withValues(alpha: 0.16);
- return SizedBox(
- width: stacked ? math.min(360, constraints.maxWidth) : dockWidth,
- child: Material(
- key: const ValueKey("file-share-dock"),
- color: ColorTokens.dark.fillLight.withValues(alpha: 0.96),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(24),
- side: BorderSide(color: Colors.white.withValues(alpha: 0.22)),
- ),
- clipBehavior: Clip.antiAlias,
- child: SingleChildScrollView(
- padding: const EdgeInsets.all(8),
- child: stacked
- ? Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- file,
- Divider(height: 1, thickness: 1, color: dividerColor),
- link,
- ],
- )
- : IntrinsicHeight(
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Expanded(child: file),
- VerticalDivider(
- width: 1,
- thickness: 1,
- color: dividerColor,
- ),
- Expanded(child: link),
- ],
- ),
- ),
+ child: BottomSheetComponent(
+ key: const ValueKey("file-share-sheet"),
+ title: context.strings.share,
+ closeTooltip: context.strings.close,
+ content: Flexible(
+ child: SingleChildScrollView(
+ child: ShareMenuGroup(
+ items: [
+ ShareMenuItem(
+ key: const ValueKey("file-share-file"),
+ title: context.strings.sendACopy,
+ subtitle: context.strings.sendFileToAnotherApp,
+ icon: Platform.isAndroid
+ ? HugeIcons.strokeRoundedShare08
+ : null,
+ leading: Platform.isAndroid
+ ? null
+ : Icon(
+ CupertinoIcons.share,
+ size: IconSizes.small,
+ color: context.componentColors.textLight,
+ ),
+ onTap: () => select(_FileShareAction.file),
+ ),
+ ShareMenuItem(
+ key: const ValueKey("file-share-link"),
+ title: context.strings.sendLink,
+ subtitle: context.strings.shareLinkToThisItem,
+ icon: HugeIcons.strokeRoundedLink02,
+ onTap: () => select(_FileShareAction.link),
+ ),
+ ],
),
),
- );
- },
- );
- }
-
- Widget _action({
- required String label,
- required List<List<dynamic>> icon,
- required _FileShareAction action,
- required bool stacked,
- }) {
- final iconWidget = HugeIcon(icon: icon, color: Colors.white, size: 26);
- final text = Text(
- label,
- style: _labelStyle,
- textAlign: stacked ? TextAlign.start : TextAlign.center,
- );
- return InkWell(
- key: ValueKey("file-share-${action.name}"),
- borderRadius: BorderRadius.circular(16),
- onTap: () => onSelected(action),
- child: ConstrainedBox(
- constraints: BoxConstraints(minHeight: stacked ? 64 : 88),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
- child: stacked
- ? Row(
- children: [
- iconWidget,
- const SizedBox(width: 16),
- Expanded(child: text),
- ],
- )
- : Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [iconWidget, const SizedBox(height: 10), text],
- ),
),
),
);
diff --git a/mobile/apps/photos/test/ui/viewer/file/file_share_button_test.dart b/mobile/apps/photos/test/ui/viewer/file/file_share_button_test.dart
index 7ba986e625..a619a0a658 100644
--- a/mobile/apps/photos/test/ui/viewer/file/file_share_button_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/file/file_share_button_test.dart
@@ -3,18 +3,14 @@ import "package:ente_strings/ente_strings.dart";
import "package:ente_strings/l10n/strings_localizations_en.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
-import "package:flutter/semantics.dart";
import "package:flutter/services.dart";
import "package:flutter_test/flutter_test.dart";
import "package:photos/ui/viewer/file/file_share_button.dart";
-const _dockKey = ValueKey("file-share-dock");
-const _fileKey = ValueKey("file-share-file");
+const _sheetKey = ValueKey("file-share-sheet");
const _linkKey = ValueKey("file-share-link");
class _LongStrings extends StringsLocalizationsEn {
- @override
- String get sendVideo => "Eine Kopie dieses Videos an eine andere App senden";
@override
String get sendLink =>
"Einen Link zu diesem Video mit anderen Personen teilen";
@@ -37,10 +33,8 @@ Future<void> _pumpShareButton(
required VoidCallback onSendLink,
VoidCallback? onBackgroundTap,
bool canSendLink = true,
- bool isVideo = false,
double textScale = 1,
bool longLabels = false,
- bool reduceMotion = false,
TextDirection direction = TextDirection.ltr,
Size size = const Size(390, 844),
}) async {
@@ -48,17 +42,16 @@ Future<void> _pumpShareButton(
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
MaterialApp(
- theme: ComponentTheme.darkTheme(),
+ theme: ComponentTheme.darkTheme().copyWith(platform: TargetPlatform.iOS),
localizationsDelegates: [
if (longLabels) const _LongStringsDelegate(),
...StringsLocalizations.localizationsDelegates,
],
supportedLocales: const [Locale("en")],
builder: (context, child) => MediaQuery(
- data: MediaQuery.of(context).copyWith(
- textScaler: TextScaler.linear(textScale),
- disableAnimations: reduceMotion,
- ),
+ data: MediaQuery.of(
+ context,
+ ).copyWith(textScaler: TextScaler.linear(textScale)),
child: Directionality(textDirection: direction, child: child!),
),
home: Scaffold(
@@ -70,7 +63,6 @@ Future<void> _pumpShareButton(
child: SafeArea(
child: FileShareButton(
canSendLink: canSendLink,
- isVideo: isVideo,
onSendFile: onSendFile,
onSendLink: onSendLink,
),
@@ -93,7 +85,7 @@ void main() {
await font.load();
});
- testWidgets("dock opens without overshoot and shares only after closing", (
+ testWidgets("shares the selected action only after the sheet is removed", (
tester,
) async {
var filesSent = 0;
@@ -101,51 +93,22 @@ void main() {
await _pumpShareButton(
tester,
onSendFile: () {
- expect(find.byKey(_dockKey), findsNothing);
+ expect(find.byKey(_sheetKey), findsNothing);
filesSent++;
},
onSendLink: () {
- expect(find.byKey(_dockKey), findsNothing);
+ expect(find.byKey(_sheetKey), findsNothing);
linksSent++;
},
);
-
final button = find.byType(FileShareButton);
- final buttonRect = tester.getRect(button);
await tester.tap(button);
- await tester.pump();
- final openingRect = tester.getRect(find.byKey(_dockKey));
- await tester.pump(const Duration(milliseconds: 40));
- final risingRect = tester.getRect(find.byKey(_dockKey));
- expect(risingRect.width, greaterThan(openingRect.width));
- expect(risingRect.bottom, lessThan(openingRect.bottom));
- expect(tester.getRect(button), buttonRect);
- await tester.pump(const Duration(milliseconds: 69));
- final approachingRect = tester.getRect(find.byKey(_dockKey));
await tester.pumpAndSettle();
- final settledRect = tester.getRect(find.byKey(_dockKey));
- expect(approachingRect.width, greaterThanOrEqualTo(risingRect.width));
- expect(approachingRect.width, lessThanOrEqualTo(settledRect.width));
- expect(approachingRect.bottom, lessThanOrEqualTo(risingRect.bottom));
- expect(approachingRect.bottom, greaterThanOrEqualTo(settledRect.bottom));
- final fileRect = tester.getRect(find.byKey(_fileKey));
- final linkRect = tester.getRect(find.byKey(_linkKey));
- expect(linkRect.bottom, lessThan(buttonRect.top));
- expect(fileRect.center.dy, linkRect.center.dy);
- expect(fileRect.size, linkRect.size);
- expect(fileRect.width, lessThan(390 * 0.35));
- expect(tester.getRect(find.byKey(_dockKey)).width, lessThan(390 * 0.7));
- expect(fileRect.height, greaterThanOrEqualTo(kMinInteractiveDimension));
-
- await tester.binding.setSurfaceSize(const Size(844, 390));
- await tester.pumpAndSettle();
- final rotatedButton = tester.getRect(button);
- final rotatedDock = tester.getRect(find.byKey(_dockKey));
- expect(rotatedDock.bottom, lessThan(rotatedButton.top));
- expect(rotatedDock.center.dx, closeTo(rotatedButton.center.dx, 1));
- expect(rotatedDock.width, closeTo(settledRect.width, 1));
-
- await tester.tap(find.text("Send photo"));
+ expect(find.byType(BottomSheetComponent), findsOneWidget);
+ expect(find.text("Send a copy"), findsOneWidget);
+ expect(find.text("Send the file to another app"), findsOneWidget);
+ expect(find.text("Share a link to this item"), findsOneWidget);
+ await tester.tap(find.text("Send a copy"));
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
expect(filesSent, 0);
@@ -161,10 +124,9 @@ void main() {
expect(linksSent, 1);
});
- testWidgets("dismissal cancels without sharing or activating the viewer", (
+ testWidgets("closing cancels without sharing or activating the viewer", (
tester,
) async {
- final semantics = tester.ensureSemantics();
var actions = 0;
var backgroundTaps = 0;
await _pumpShareButton(
@@ -173,74 +135,18 @@ void main() {
onSendLink: () => actions++,
onBackgroundTap: () => backgroundTaps++,
);
- final button = find.byType(FileShareButton);
- final anchor = tester.getCenter(button);
for (final cancel in <Future<void> Function()>[
+ () => tester.tap(find.byTooltip("Close")),
() => tester.tapAt(const Offset(20, 20)),
- () => tester.tapAt(anchor),
- () async {
- await tester.binding.handlePopRoute();
- },
- () => tester.sendKeyEvent(LogicalKeyboardKey.escape),
- () async {
- tester.semantics.dismiss(
- find.semantics.byAction(SemanticsAction.dismiss),
- );
- },
]) {
- await tester.tap(button);
+ await tester.tap(find.byType(FileShareButton));
await tester.pumpAndSettle();
await cancel();
await tester.pumpAndSettle();
- expect(find.byKey(_dockKey), findsNothing);
+ expect(find.byKey(_sheetKey), findsNothing);
expect(actions, 0);
expect(backgroundTaps, 0);
}
-
- await tester.tap(button);
- await tester.pump();
- await tester.pump(const Duration(milliseconds: 70));
- final openingRect = tester.getRect(find.byKey(_dockKey));
- await tester.tapAt(anchor);
- await tester.pump();
- expect(tester.getRect(find.byKey(_dockKey)), openingRect);
- await tester.pumpAndSettle();
- expect(find.byKey(_dockKey), findsNothing);
- expect(actions, 0);
- expect(backgroundTaps, 0);
- semantics.dispose();
- });
-
- testWidgets("Reduce Motion fades without shifting or scaling the dock", (
- tester,
- ) async {
- await _pumpShareButton(
- tester,
- reduceMotion: true,
- onSendFile: () {},
- onSendLink: () {},
- );
- await tester.tap(find.byType(FileShareButton));
- await tester.pump();
- final openingRect = tester.getRect(find.byKey(_dockKey));
- await tester.pump(const Duration(milliseconds: 60));
- final fade = find.ancestor(
- of: find.byKey(_dockKey),
- matching: find.byType(FadeTransition),
- );
- expect(
- tester.widget<FadeTransition>(fade).opacity.value,
- allOf(greaterThan(0), lessThan(1)),
- );
- expect(tester.getRect(find.byKey(_dockKey)), openingRect);
- await tester.pumpAndSettle();
- expect(tester.getRect(find.byKey(_dockKey)), openingRect);
- await tester.tapAt(const Offset(20, 20));
- await tester.pump();
- await tester.pump(const Duration(milliseconds: 60));
- expect(tester.getRect(find.byKey(_dockKey)), openingRect);
- await tester.pumpAndSettle();
- expect(find.byKey(_dockKey), findsNothing);
});
testWidgets("shares directly when a link is unavailable", (tester) async {
@@ -256,70 +162,36 @@ void main() {
await tester.pumpAndSettle();
expect(filesSent, 1);
expect(linksSent, 0);
- expect(find.byKey(_dockKey), findsNothing);
+ expect(find.byKey(_sheetKey), findsNothing);
});
- testWidgets("long labels stack, wrap, and stay usable at large text in RTL", (
- tester,
- ) async {
- var filesSent = 0;
- var linksSent = 0;
- await _pumpShareButton(
- tester,
- isVideo: true,
- longLabels: true,
- size: const Size(320, 568),
- onSendFile: () => filesSent++,
- onSendLink: () => linksSent++,
- );
- await tester.tap(find.byType(FileShareButton));
- await tester.pumpAndSettle();
- final wrappedFile = tester.getRect(find.byKey(_fileKey));
- final wrappedLink = tester.getRect(find.byKey(_linkKey));
- expect(wrappedFile.size, wrappedLink.size);
- expect(wrappedFile.center.dy, wrappedLink.center.dy);
- expect(wrappedFile.width, closeTo(320 * 0.35, 0.01));
- expect(
- tester.getSize(find.text(_LongStrings().sendVideo)).height,
- greaterThan(20),
- );
- expect(tester.takeException(), isNull);
- await tester.tapAt(const Offset(20, 20));
- await tester.pumpAndSettle();
- await _pumpShareButton(
- tester,
- isVideo: true,
- longLabels: true,
- textScale: 3,
- direction: TextDirection.rtl,
- size: const Size(320, 568),
- onSendFile: () => filesSent++,
- onSendLink: () => linksSent++,
- );
- final button = find.byType(FileShareButton);
- await tester.tap(button);
- await tester.pumpAndSettle();
- final fileRect = tester.getRect(find.byKey(_fileKey));
- final linkRect = tester.getRect(find.byKey(_linkKey));
- expect(find.text(_LongStrings().sendVideo), findsOneWidget);
- expect(linkRect.top, greaterThanOrEqualTo(fileRect.bottom));
- final dockRect = tester.getRect(find.byKey(_dockKey));
- expect(dockRect.left, greaterThanOrEqualTo(16));
- expect(dockRect.right, lessThanOrEqualTo(304));
- expect(dockRect.top, greaterThanOrEqualTo(12));
- expect(dockRect.bottom, lessThan(tester.getRect(button).top));
- expect(tester.takeException(), isNull);
- await tester.scrollUntilVisible(
- find.byKey(_linkKey),
- 100,
- scrollable: find.descendant(
- of: find.byKey(_dockKey),
- matching: find.byType(Scrollable),
- ),
- );
- await tester.tap(find.text(_LongStrings().sendLink));
- await tester.pumpAndSettle();
- expect(linksSent, 1);
- expect(filesSent, 0);
- });
+ testWidgets(
+ "choices remain reachable with large text in a narrow RTL sheet",
+ (tester) async {
+ var linksSent = 0;
+ await _pumpShareButton(
+ tester,
+ longLabels: true,
+ textScale: 3,
+ direction: TextDirection.rtl,
+ size: const Size(320, 568),
+ onSendFile: () {},
+ onSendLink: () => linksSent++,
+ );
+ await tester.tap(find.byType(FileShareButton));
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
+ await tester.scrollUntilVisible(
+ find.byKey(_linkKey),
+ 100,
+ scrollable: find.descendant(
+ of: find.byKey(_sheetKey),
+ matching: find.byType(Scrollable),
+ ),
+ );
+ await tester.tap(find.text(_LongStrings().sendLink));
+ await tester.pumpAndSettle();
+ expect(linksSent, 1);
+ },
+ );
}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 6310e36428..14a0c9f49e 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -3995,6 +3995,10 @@
"@send": {
"description": "Label for send button"
},
+ "sendACopy": "Send a copy",
+ "@sendACopy": {
+ "description": "Share a copy of the current photo or video using the system share sheet, as opposed to sending a viewing link"
+ },
"sendCountInvites": "{count, plural, =0{Send invites} one{Send {count} invite} other{Send {count} invites}}",
"@sendCountInvites": {
"placeholders": {
@@ -4004,6 +4008,10 @@
}
}
},
+ "sendFileToAnotherApp": "Send the file to another app",
+ "@sendFileToAnotherApp": {
+ "description": "Subtitle for sending a copy of the current photo or video from the file viewer"
+ },
"sendInvite": "Send invite",
"sendLink": "Send link",
"sendLogsDescription": "This will send across logs to help us debug your issue. While we take precautions to ensure that sensitive information is not logged, we encourage you to view these logs before sharing them.",
@@ -4114,6 +4122,10 @@
"shareKey": "Share key",
"shareLegacyDescription": "Send each card to the person it's for. No single card works alone.",
"shareLink": "Share link",
+ "shareLinkToThisItem": "Share a link to this item",
+ "@shareLinkToThisItem": {
+ "description": "Subtitle for sending a viewing link to the current photo or video from the file viewer"
+ },
"shareMemory": "Share memory",
"shareMyVerificationID": "Here's my verification ID: {verificationID} for ente.com.",
"@shareMyVerificationID": {