Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] feat: update sharing functionality improve UI flow

Aman Raj Singh Mourya95e6a86b10d8
diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
index 9627d5541c..82b3ba1fbe 100644
--- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
+++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
@@ -27,10 +27,8 @@ import 'package:photos/ui/components/dialog_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/ui/payment/subscription.dart';
-import "package:photos/ui/sharing/add_participant_page.dart";
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/email_util.dart';
-import "package:photos/utils/navigation_util.dart";
import 'package:photos/utils/share_util.dart';
import 'package:photos/utils/standalone/date_time.dart';
import "package:styled_text/styled_text.dart";
@@ -335,80 +333,6 @@ class CollectionActions {
}
}
- Future<bool> shareMultipleCollectionSheet(
- BuildContext bContext,
- List<Collection> collection,
- ) async {
- final textTheme = getEnteTextTheme(bContext);
- final actionResult = await showActionSheet(
- context: bContext,
- buttons: [
- ButtonWidget(
- labelText: S.of(bContext).addViewer,
- buttonType: ButtonType.primary,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.first,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- onTap: () async {
- await routeToPage(
- bContext,
- AddParticipantPage(
- collection[0],
- true,
- collections: collection,
- ),
- );
- },
- ),
- ButtonWidget(
- labelText: S.of(bContext).addCollaborator,
- buttonType: ButtonType.neutral,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.second,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- onTap: () async {
- await routeToPage(
- bContext,
- AddParticipantPage(
- collection[0],
- false,
- collections: collection,
- ),
- );
- },
- ),
- ],
- bodyWidget: StyledText(
- text:
- "<bold>Share ${collection.length} ${collection.length == 1 ? 'album' : 'albums'}</bold>",
- style: textTheme.body.copyWith(color: textMutedDark),
- tags: {
- 'bold': StyledTextTag(
- style: textTheme.body.copyWith(color: textBaseDark),
- ),
- },
- ),
- actionSheetType: ActionSheetType.defaultActionSheet,
- );
-
- if (actionResult?.action != null &&
- actionResult!.action == ButtonAction.error) {
- await showGenericErrorDialog(
- context: bContext,
- error: actionResult.exception,
- );
- return false;
- }
- if ((actionResult?.action != null) &&
- (actionResult!.action == ButtonAction.first ||
- actionResult.action == ButtonAction.second)) {
- return true;
- }
- return false;
- }
-
Future<bool> deleteMultipleCollectionSheet(
BuildContext bContext,
List<Collection> collections,
diff --git a/mobile/lib/ui/sharing/add_participant_page.dart b/mobile/lib/ui/sharing/add_participant_page.dart
index c4bdebeff2..9380dd4d4e 100644
--- a/mobile/lib/ui/sharing/add_participant_page.dart
+++ b/mobile/lib/ui/sharing/add_participant_page.dart
@@ -35,7 +35,7 @@ class AddParticipantPage extends StatefulWidget {
);
bool get isMultipleCollections =>
- collections != null && collections!.length > 1;
+ collections != null && collections!.isNotEmpty;
@override
State<StatefulWidget> createState() => _AddParticipantPage();
@@ -84,9 +84,11 @@ class _AddParticipantPage extends State<AddParticipantPage> {
resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
title: Text(
- widget.isAddingViewer
- ? S.of(context).addViewer
- : S.of(context).addCollaborator,
+ widget.isMultipleCollections
+ ? "Add participants"
+ : widget.isAddingViewer
+ ? S.of(context).addViewer
+ : S.of(context).addCollaborator,
),
),
body: Column(
@@ -228,52 +230,9 @@ class _AddParticipantPage extends State<AddParticipantPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 8),
- ButtonWidget(
- buttonType: ButtonType.primary,
- buttonSize: ButtonSize.large,
- labelText: widget.isAddingViewer
- ? S.of(context).addViewers(_selectedEmails.length)
- : S
- .of(context)
- .addCollaborators(_selectedEmails.length),
- isDisabled: _selectedEmails.isEmpty,
- onTap: () async {
- final results = <bool>[];
- final collections = getAllCollections();
-
- for (String email in _selectedEmails) {
- for (Collection collection in collections) {
- results.add(
- await collectionActions.addEmailToCollection(
- context,
- collection,
- email,
- widget.isAddingViewer
- ? CollectionParticipantRole.viewer
- : CollectionParticipantRole.collaborator,
- ),
- );
- }
- }
-
- final noOfSuccessfullAdds =
- results.where((e) => e).length;
- showToast(
- context,
- widget.isAddingViewer
- ? S
- .of(context)
- .viewersSuccessfullyAdded(noOfSuccessfullAdds)
- : S.of(context).collaboratorsSuccessfullyAdded(
- noOfSuccessfullAdds,
- ),
- );
-
- if (!results.any((e) => e == false) && mounted) {
- Navigator.of(context).pop(true);
- }
- },
- ),
+ widget.isMultipleCollections
+ ? _multipleActionButton()
+ : _singleActionButton(),
const SizedBox(height: 12),
],
),
@@ -284,6 +243,124 @@ class _AddParticipantPage extends State<AddParticipantPage> {
);
}
+ Widget _singleActionButton() {
+ return ButtonWidget(
+ buttonType: ButtonType.primary,
+ buttonSize: ButtonSize.large,
+ labelText: widget.isAddingViewer
+ ? S.of(context).addViewers(_selectedEmails.length)
+ : S.of(context).addCollaborators(_selectedEmails.length),
+ isDisabled: _selectedEmails.isEmpty,
+ onTap: () async {
+ final results = <bool>[];
+ final collections = getAllCollections();
+
+ for (String email in _selectedEmails) {
+ for (Collection collection in collections) {
+ results.add(
+ await collectionActions.addEmailToCollection(
+ context,
+ collection,
+ email,
+ widget.isAddingViewer
+ ? CollectionParticipantRole.viewer
+ : CollectionParticipantRole.collaborator,
+ ),
+ );
+ }
+ }
+
+ final noOfSuccessfullAdds = results.where((e) => e).length;
+ showToast(
+ context,
+ widget.isAddingViewer
+ ? S.of(context).viewersSuccessfullyAdded(noOfSuccessfullAdds)
+ : S.of(context).collaboratorsSuccessfullyAdded(
+ noOfSuccessfullAdds,
+ ),
+ );
+
+ if (!results.any((e) => e == false) && mounted) {
+ Navigator.of(context).pop(true);
+ }
+ },
+ );
+ }
+
+ Widget _multipleActionButton() {
+ return Column(
+ children: [
+ ButtonWidget(
+ buttonType: ButtonType.primary,
+ buttonSize: ButtonSize.large,
+ labelText: S.of(context).addViewers(_selectedEmails.length),
+ isDisabled: _selectedEmails.isEmpty,
+ onTap: () async {
+ final results = <bool>[];
+ final collections = getAllCollections();
+
+ for (String email in _selectedEmails) {
+ bool result = false;
+ for (Collection collection in collections) {
+ result = await collectionActions.addEmailToCollection(
+ context,
+ collection,
+ email,
+ CollectionParticipantRole.viewer,
+ );
+ }
+ results.add(result);
+ }
+
+ final noOfSuccessfullAdds = results.where((e) => e).length;
+ showToast(
+ context,
+ S.of(context).viewersSuccessfullyAdded(noOfSuccessfullAdds),
+ );
+
+ if (!results.any((e) => e == false) && mounted) {
+ Navigator.of(context).pop(true);
+ }
+ },
+ ),
+ const SizedBox(height: 8),
+ ButtonWidget(
+ buttonType: ButtonType.primary,
+ buttonSize: ButtonSize.large,
+ labelText: S.of(context).addCollaborators(_selectedEmails.length),
+ isDisabled: _selectedEmails.isEmpty,
+ onTap: () async {
+ final results = <bool>[];
+ final collections = getAllCollections();
+
+ for (String email in _selectedEmails) {
+ bool result = false;
+ for (Collection collection in collections) {
+ result = await collectionActions.addEmailToCollection(
+ context,
+ collection,
+ email,
+ CollectionParticipantRole.collaborator,
+ );
+ }
+ results.add(result);
+ }
+
+ final noOfSuccessfullAdds = results.where((e) => e).length;
+ showToast(
+ context,
+ S.of(context).collaboratorsSuccessfullyAdded(noOfSuccessfullAdds),
+ );
+
+ if (!results.any((e) => e == false) && mounted) {
+ Navigator.of(context).pop(true);
+ }
+ },
+ ),
+ ],
+ );
+ }
+
void clearFocus() {
_textController.clear();
_newEmail = _textController.text;
diff --git a/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart b/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
index 05a47bb33f..e625c31da2 100644
--- a/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
+++ b/mobile/lib/ui/viewer/actions/album_selection_action_widget.dart
@@ -14,8 +14,10 @@ import "package:photos/ui/components/bottom_action_bar/selection_action_button_w
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/sharing/add_participant_page.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/magic_util.dart";
+import "package:photos/utils/navigation_util.dart";
class AlbumSelectionActionWidget extends StatefulWidget {
final SelectedAlbums selectedAlbums;
@@ -156,9 +158,13 @@ class _AlbumSelectionActionWidgetState
}
Future<void> _shareCollection() async {
- await collectionActions.shareMultipleCollectionSheet(
+ await routeToPage(
context,
- widget.selectedAlbums.albums.toList(),
+ AddParticipantPage(
+ widget.selectedAlbums.albums.toList().first,
+ false,
+ collections: widget.selectedAlbums.albums.toList(),
+ ),
);
if (hasFavorites) {
_showFavToast();