Skip to content

Commit

Permalink
Revert "lightbox: Add "share" button in bottom app bar"
Browse files Browse the repository at this point in the history
This reverts commit 79ad681.
  • Loading branch information
shivanshsharma13 committed Dec 13, 2024
1 parent 79ad681 commit 23e9cb0
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 104 deletions.
8 changes: 0 additions & 8 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,6 @@
"@errorDialogTitle": {
"description": "Generic title for error dialog."
},
"errorShareFailed": "Error Sharing the Image",
"@errorShareFailed": {
"description": "Title for sharing image error dialog."
},
"snackBarDetails": "Details",
"@snackBarDetails": {
"description": "Button label for snack bar button that opens a dialog with more details."
Expand All @@ -350,10 +346,6 @@
"@lightboxCopyLinkTooltip": {
"description": "Tooltip in lightbox for the copy link action."
},
"lightboxShareImageTooltip": "Share Image",
"@lightboxShareImageTooltip": {
"description": "Tooltip in lightbox for the Share Image action."
},
"loginPageTitle": "Log in",
"@loginPageTitle": {
"description": "Page title for login page."
Expand Down
12 changes: 0 additions & 12 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,6 @@ abstract class ZulipLocalizations {
/// **'Error'**
String get errorDialogTitle;

/// Title for sharing image error dialog.
///
/// In en, this message translates to:
/// **'Error Sharing the Image'**
String get errorShareFailed;

/// Button label for snack bar button that opens a dialog with more details.
///
/// In en, this message translates to:
Expand All @@ -559,12 +553,6 @@ abstract class ZulipLocalizations {
/// **'Copy link'**
String get lightboxCopyLinkTooltip;

/// Tooltip in lightbox for the Share Image action.
///
/// In en, this message translates to:
/// **'Share Image'**
String get lightboxShareImageTooltip;

/// Page title for login page.
///
/// In en, this message translates to:
Expand Down
6 changes: 0 additions & 6 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,12 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get errorDialogTitle => 'Error';

@override
String get errorShareFailed => 'Error Sharing the Image';

@override
String get snackBarDetails => 'Details';

@override
String get lightboxCopyLinkTooltip => 'Copy link';

@override
String get lightboxShareImageTooltip => 'Share Image';

@override
String get loginPageTitle => 'Log in';

Expand Down
6 changes: 0 additions & 6 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,12 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get errorDialogTitle => 'Error';

@override
String get errorShareFailed => 'Error Sharing the Image';

@override
String get snackBarDetails => 'Details';

@override
String get lightboxCopyLinkTooltip => 'Copy link';

@override
String get lightboxShareImageTooltip => 'Share Image';

@override
String get loginPageTitle => 'Log in';

Expand Down
6 changes: 0 additions & 6 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,12 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get errorDialogTitle => 'Error';

@override
String get errorShareFailed => 'Error Sharing the Image';

@override
String get snackBarDetails => 'Details';

@override
String get lightboxCopyLinkTooltip => 'Copy link';

@override
String get lightboxShareImageTooltip => 'Share Image';

@override
String get loginPageTitle => 'Log in';

Expand Down
43 changes: 0 additions & 43 deletions lib/widgets/lightbox.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as httpClient;
import 'package:intl/intl.dart';
import 'package:share_plus/share_plus.dart';
import 'package:video_player/video_player.dart';

import '../api/core.dart';
Expand Down Expand Up @@ -91,46 +89,6 @@ class _CopyLinkButton extends StatelessWidget {
}
}

Future<XFile> _downloadImage(Uri url, Map<String, String> headers) async {
final response = await httpClient.get(url, headers: headers);
final bytes = response.bodyBytes;
return XFile.fromData(bytes,
name: url.pathSegments.last,
mimeType: response.headers['content-type']);
}

class _ShareButton extends StatelessWidget {
const _ShareButton({required this.url});

final Uri url;

@override
Widget build(BuildContext context) {
final zulipLocalizations = ZulipLocalizations.of(context);
return IconButton(
tooltip: zulipLocalizations.lightboxShareImageTooltip,
icon: const Icon(Icons.share),
onPressed: () async {
try {
final store = PerAccountStoreWidget.of(context);
final headers = {
if (url.origin == store.account.realmUrl.origin)
...authHeader(email: store.account.email, apiKey: store.account.apiKey),
...userAgentHeader()
};
final xFile = await _downloadImage(url, headers);
await Share.shareXFiles([xFile]);
} catch (error) {
if (!context.mounted) return;
showErrorDialog(
context: context,
title: zulipLocalizations.errorDialogTitle,
message: zulipLocalizations.errorShareFailed);
}
});
}
}

class _LightboxPageLayout extends StatefulWidget {
const _LightboxPageLayout({
required this.routeEntranceAnimation,
Expand Down Expand Up @@ -300,7 +258,6 @@ class _ImageLightboxPageState extends State<_ImageLightboxPage> {
elevation: elevation,
child: Row(children: [
_CopyLinkButton(url: widget.src),
_ShareButton(url: widget.src),
// TODO(#43): Share image
// TODO(#42): Download image
]),
Expand Down
23 changes: 0 additions & 23 deletions test/widgets/lightbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,29 +275,6 @@ void main() {
debugNetworkImageHttpClientProvider = null;
});

testWidgets('share button shows correct icon and downloads image', (tester) async {
prepareBoringImageHttpClient();
final message = eg.streamMessage();
await setupPage(tester, message: message, thumbnailUrl: null);

// Verify share icon exists
final shareIcon = find.descendant(
of: find.byType(BottomAppBar),
matching: find.byIcon(Icons.share),
skipOffstage: false);
check(tester.widget<Icon>(shareIcon).icon).equals(Icons.share);

// Verify tooltip
final button = tester.widget<IconButton>(find.ancestor(
of: shareIcon,
matching: find.byType(IconButton)));
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
check(button.tooltip).equals(zulipLocalizations.lightboxShareImageTooltip);

debugNetworkImageHttpClientProvider = null;
});


// TODO test _CopyLinkButton
// TODO test thumbnail gets shown, then gets replaced when main image loads
// TODO test image is scaled down to fit, but not up
Expand Down

0 comments on commit 23e9cb0

Please sign in to comment.