π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add New Album Card Widget for Collecting Photos
Aman Raj Singh Mourya5792c2bae640
diff --git a/mobile/assets/2.0x/create_new_album.png b/mobile/assets/2.0x/create_new_album.pngnew file mode 100644index 0000000000..79ed8833bbBinary files /dev/null and b/mobile/assets/2.0x/create_new_album.png differdiff --git a/mobile/assets/2.0x/new_empty_album.png b/mobile/assets/2.0x/new_empty_album.pngnew file mode 100644index 0000000000..cbd3834a06Binary files /dev/null and b/mobile/assets/2.0x/new_empty_album.png differdiff --git a/mobile/assets/3.0x/create_new_album.png b/mobile/assets/3.0x/create_new_album.pngnew file mode 100644index 0000000000..94fe5819c7Binary files /dev/null and b/mobile/assets/3.0x/create_new_album.png differdiff --git a/mobile/assets/3.0x/new_empty_album.png b/mobile/assets/3.0x/new_empty_album.pngnew file mode 100644index 0000000000..a1be6b14a7Binary files /dev/null and b/mobile/assets/3.0x/new_empty_album.png differdiff --git a/mobile/assets/create_new_album.png b/mobile/assets/create_new_album.pngnew file mode 100644index 0000000000..c75de0bfb3Binary files /dev/null and b/mobile/assets/create_new_album.png differdiff --git a/mobile/assets/new_empty_album.png b/mobile/assets/new_empty_album.pngnew file mode 100644index 0000000000..495c2bb553Binary files /dev/null and b/mobile/assets/new_empty_album.png differdiff --git a/mobile/lib/ui/settings/new_album_card_widget.dart b/mobile/lib/ui/settings/new_album_card_widget.dartnew file mode 100644index 0000000000..d398290c35--- /dev/null+++ b/mobile/lib/ui/settings/new_album_card_widget.dart@@ -0,0 +1,182 @@+import "package:figma_squircle/figma_squircle.dart";+import 'package:flutter/material.dart';+import "package:intl/intl.dart";+import "package:logging/logging.dart";+import "package:photos/generated/l10n.dart";+import "package:photos/models/collection/collection.dart";+import "package:photos/models/collection/collection_items.dart";+import "package:photos/services/collections_service.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";+import "package:photos/ui/viewer/gallery/collection_page.dart";+import "package:photos/utils/dialog_util.dart";+import "package:photos/utils/navigation_util.dart";++class NewAlbumCardWidget extends StatefulWidget {+ const NewAlbumCardWidget({super.key});++ @override+ State<NewAlbumCardWidget> createState() => _NewAlbumCardWidgetState();+}++class _NewAlbumCardWidgetState extends State<NewAlbumCardWidget> {+ Future<void> _onTapCreateAlbum() async {+ final String currentDate =+ DateFormat('MMMM d, yyyy').format(DateTime.now());+ final result = await showTextInputDialog(+ context,+ title: "Name the album",+ submitButtonLabel: S.of(context).create,+ hintText: S.of(context).enterAlbumName,+ alwaysShowSuccessState: false,+ initialValue: currentDate,+ textCapitalization: TextCapitalization.words,+ onSubmit: (String text) async {+ // indicates user cancelled the rename request+ if (text.trim() == "") {+ return;+ }++ try {+ final Collection c =+ await CollectionsService.instance.createAlbum(text);+ // ignore: unawaited_futures+ routeToPage(+ context,+ CollectionPage(+ isNewCollection: true,+ CollectionWithThumbnail(c, null),+ ),+ );+ } catch (e, s) {+ Logger("CreateNewAlbumIcon").severe("Failed to rename album", e, s);+ rethrow;+ }+ },+ );+ if (result is Exception) {+ await showGenericErrorDialog(context: context, error: result);+ }+ }++ @override+ Widget build(BuildContext context) {+ final textTheme = getEnteTextTheme(context);+ final colorTheme = getEnteColorScheme(context);+ return Stack(+ children: [+ Positioned(+ bottom: 22,+ left: 14,+ child: Container(+ height: 125,+ width: 125,+ decoration: BoxDecoration(+ borderRadius:+ const BorderRadius.only(bottomLeft: Radius.circular(12)),+ gradient: LinearGradient(+ colors: [+ colorTheme.primary700.withOpacity(0.9),+ colorTheme.backdropBase.withOpacity(0.6),+ colorTheme.backdropBase,+ ],+ begin: Alignment.bottomLeft,+ end: Alignment.topRight,+ ),+ ),+ ),+ ),+ GestureDetector(+ onTap: () => _onTapCreateAlbum(),+ child: Padding(+ padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),+ child: Container(+ decoration: ShapeDecoration(+ color: colorTheme.backgroundElevated,+ shadows: [+ BoxShadow(+ color: colorTheme.textBase.withOpacity(0.1),+ blurRadius: 4.0,+ offset: const Offset(0, 1),+ ),+ ],+ shape: SmoothRectangleBorder(+ borderRadius: SmoothBorderRadius(+ cornerRadius: 10.0,+ cornerSmoothing: 1.0,+ ),+ ),+ ),+ child: Padding(+ padding:+ const EdgeInsets.symmetric(horizontal: 12, vertical: 16),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ "Collect photos",+ style: textTheme.bodyBold,+ ),+ const SizedBox(+ height: 16,+ ),+ Text(+ "Create a link where your friends can upload photos in original quality.",+ style: textTheme.smallMuted,+ ),+ const SizedBox(+ height: 34,+ ),+ Row(+ mainAxisAlignment: MainAxisAlignment.end,+ children: [+ ButtonWidget(+ buttonType: ButtonType.primary,+ buttonSize: ButtonSize.small,+ labelText: "Collect",+ icon: Icons.add_photo_alternate_outlined,+ shouldShowSuccessConfirmation: false,+ shouldSurfaceExecutionStates: false,+ onTap: () => _onTapCreateAlbum(),+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ Positioned(+ bottom: 24,+ left: 16,+ child: Container(+ height: 90,+ width: 90,+ decoration: BoxDecoration(+ borderRadius:+ const BorderRadius.only(bottomLeft: Radius.circular(10)),+ gradient: LinearGradient(+ colors: [+ colorTheme.primary700.withOpacity(0.4),+ colorTheme.backgroundElevated.withOpacity(0.6),+ colorTheme.backgroundElevated,+ ],+ begin: Alignment.bottomLeft,+ end: Alignment.topRight,+ ),+ ),+ ),+ ),+ Positioned(+ bottom: 25,+ left: 20,+ child: SizedBox(+ child: Image.asset('assets/create_new_album.png'),+ ),+ ),+ ],+ );+ }+}diff --git a/mobile/lib/ui/tabs/shared_collections_tab.dart b/mobile/lib/ui/tabs/shared_collections_tab.dartindex 2994a293c2..577884394f 100644--- a/mobile/lib/ui/tabs/shared_collections_tab.dart+++ b/mobile/lib/ui/tabs/shared_collections_tab.dart@@ -17,6 +17,7 @@ import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/buttons/icon_button_widget.dart";import "package:photos/ui/components/divider_widget.dart";import "package:photos/ui/components/models/button_type.dart";+import "package:photos/ui/settings/new_album_card_widget.dart";import 'package:photos/ui/tabs/section_title.dart';import "package:photos/ui/tabs/shared/all_quick_links_page.dart";import "package:photos/ui/tabs/shared/empty_state.dart";@@ -318,6 +319,7 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>],): const SizedBox.shrink(),+ const NewAlbumCardWidget(),const SizedBox(height: 32),],),diff --git a/mobile/lib/ui/viewer/gallery/collection_page.dart b/mobile/lib/ui/viewer/gallery/collection_page.dartindex e0288f238b..b2efa7eeca 100644--- a/mobile/lib/ui/viewer/gallery/collection_page.dart+++ b/mobile/lib/ui/viewer/gallery/collection_page.dart@@ -13,6 +13,7 @@ import 'package:photos/models/selected_files.dart';import 'package:photos/services/ignored_files_service.dart';import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';import "package:photos/ui/viewer/gallery/empty_album_state.dart";+import "package:photos/ui/viewer/gallery/empty_album_state_new.dart";import 'package:photos/ui/viewer/gallery/empty_state.dart';import 'package:photos/ui/viewer/gallery/gallery.dart';import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';@@ -22,11 +23,13 @@ class CollectionPage extends StatelessWidget {final CollectionWithThumbnail c;final String tagPrefix;final bool? hasVerifiedLock;+ final bool isNewCollection;CollectionPage(this.c, {this.tagPrefix = "collection",this.hasVerifiedLock = false,+ this.isNewCollection = false,Key? key,}) : super(key: key);@@ -86,8 +89,14 @@ class CollectionPage extends StatelessWidget {sortAsyncFn: () => c.collection.pubMagicMetadata.asc ?? false,showSelectAllByDefault: galleryType != GalleryType.sharedCollection,emptyState: galleryType == GalleryType.ownedCollection- ? EmptyAlbumState(c.collection)+ ? EmptyAlbumState(+ c.collection,+ isNewCollection: isNewCollection,+ ): const EmptyState(),+ footer: isNewCollection+ ? const SizedBox(height: 20)+ : const SizedBox(height: 212),);return Scaffold(appBar: PreferredSize(@@ -99,6 +108,13 @@ class CollectionPage extends StatelessWidget {collection: c.collection,),),+ floatingActionButton: isNewCollection+ ? EmptyAlbumStateNew(+ c.collection,+ selectedFiles: _selectedFiles,+ )+ : const SizedBox.shrink(),+ floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,body: SelectionState(selectedFiles: _selectedFiles,child: Stack(diff --git a/mobile/lib/ui/viewer/gallery/empty_album_state.dart b/mobile/lib/ui/viewer/gallery/empty_album_state.dartindex c90721a687..fdaffb2447 100644--- a/mobile/lib/ui/viewer/gallery/empty_album_state.dart+++ b/mobile/lib/ui/viewer/gallery/empty_album_state.dart@@ -8,35 +8,51 @@ import "package:photos/utils/dialog_util.dart";class EmptyAlbumState extends StatelessWidget {final Collection c;- const EmptyAlbumState(this.c, {super.key});+ final bool isNewCollection;+ const EmptyAlbumState(+ this.c, {+ super.key,+ this.isNewCollection = false,+ });@overrideWidget build(BuildContext context) {- return Stack(- children: [- Center(- child: Opacity(- opacity: 0.5,- child: Image.asset('assets/loading_photos_background.png'),- ),- ),- Center(- child: ButtonWidget(- buttonType: ButtonType.primary,- buttonSize: ButtonSize.small,- labelText: S.of(context).addPhotos,- icon: Icons.add_photo_alternate_outlined,- shouldSurfaceExecutionStates: false,- onTap: () async {- try {- await showAddPhotosSheet(context, c);- } catch (e) {- await showGenericErrorDialog(context: context, error: e);- }- },- ),- ),- ],- );+ return isNewCollection+ ? Stack(+ children: [+ Center(+ child: Opacity(+ opacity: 0.5,+ child: Image.asset('assets/new_empty_album.png'),+ ),+ ),+ ],+ )+ : Stack(+ children: [+ Center(+ child: Opacity(+ opacity: 0.5,+ child: Image.asset('assets/loading_photos_background.png'),+ ),+ ),+ Center(+ child: ButtonWidget(+ buttonType: ButtonType.primary,+ buttonSize: ButtonSize.small,+ labelText: S.of(context).addPhotos,+ icon: Icons.add_photo_alternate_outlined,+ shouldSurfaceExecutionStates: false,+ onTap: () async {+ try {+ await showAddPhotosSheet(context, c);+ } catch (e) {+ await showGenericErrorDialog(context: context, error: e);+ }+ },+ ),+ ),+ ],+ );}}diff --git a/mobile/lib/ui/viewer/gallery/empty_album_state_new.dart b/mobile/lib/ui/viewer/gallery/empty_album_state_new.dartnew file mode 100644index 0000000000..d9944f9c99--- /dev/null+++ b/mobile/lib/ui/viewer/gallery/empty_album_state_new.dart@@ -0,0 +1,134 @@+import "package:fast_base58/fast_base58.dart";+import "package:flutter/material.dart";+import "package:photos/generated/l10n.dart";+import "package:photos/models/api/collection/public_url.dart";+import "package:photos/models/collection/collection.dart";+import "package:photos/models/selected_files.dart";+import "package:photos/services/collections_service.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";+import "package:photos/ui/viewer/gallery/hooks/add_photos_sheet.dart";+import "package:photos/utils/dialog_util.dart";+import "package:photos/utils/share_util.dart";++class EmptyAlbumStateNew extends StatefulWidget {+ final Collection c;+ final SelectedFiles? selectedFiles;+ const EmptyAlbumStateNew(+ this.c, {+ super.key,+ this.selectedFiles,+ });++ @override+ State<EmptyAlbumStateNew> createState() => _EmptyAlbumStateNewState();+}++class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {+ final ValueNotifier<bool> _hasSelectedFilesNotifier = ValueNotifier(false);++ @override+ void initState() {+ super.initState();+ widget.selectedFiles?.addListener(_selectedFilesListener);+ }++ @override+ void dispose() {+ _hasSelectedFilesNotifier.dispose();+ widget.selectedFiles!.removeListener(_selectedFilesListener);+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final GlobalKey shareLinkAlbumButtonKey = GlobalKey();++ Future<String> getAlbumShareUrl() async {+ final PublicURL url = widget.c.publicURLs!.firstOrNull!;+ final String collectionKey = Base58Encode(+ CollectionsService.instance.getCollectionKey(widget.c.id),+ );+ return "${url.url}#$collectionKey";+ }++ return ValueListenableBuilder(+ valueListenable: _hasSelectedFilesNotifier,+ builder: (context, value, child) {+ return AnimatedCrossFade(+ firstCurve: Curves.easeInOutExpo,+ secondCurve: Curves.easeInOutExpo,+ sizeCurve: Curves.easeInOutExpo,+ duration: const Duration(milliseconds: 300),+ crossFadeState: !_hasSelectedFilesNotifier.value+ ? CrossFadeState.showFirst+ : CrossFadeState.showSecond,+ firstChild: Stack(+ children: [+ Align(+ alignment: Alignment.bottomCenter,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(24, 0, 24, 12),+ child: Column(+ mainAxisAlignment: MainAxisAlignment.end,+ crossAxisAlignment: CrossAxisAlignment.center,+ mainAxisSize: MainAxisSize.min,+ children: [+ Container(+ decoration: BoxDecoration(+ color: getEnteColorScheme(context).backdropBase,+ borderRadius:+ const BorderRadius.all(Radius.circular(4)),+ ),+ child: ButtonWidget(+ buttonType: ButtonType.secondary,+ buttonSize: ButtonSize.large,+ labelText: S.of(context).addPhotos,+ icon: Icons.add_photo_alternate_outlined,+ shouldSurfaceExecutionStates: false,+ onTap: () async {+ try {+ await showAddPhotosSheet(context, widget.c);+ } catch (e) {+ await showGenericErrorDialog(+ context: context,+ error: e,+ );+ }+ },+ ),+ ),+ const SizedBox(height: 10),+ ButtonWidget(+ buttonType: ButtonType.primary,+ buttonSize: ButtonSize.large,+ labelText: S.of(context).share,+ icon: Icons.adaptive.share,+ shouldSurfaceExecutionStates: false,+ onTap: () async {+ final String shareUrl = await getAlbumShareUrl();+ await shareAlbumLinkWithPlaceholder(+ context,+ widget.c,+ shareUrl,+ shareLinkAlbumButtonKey,+ );+ },+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ secondChild: const SizedBox.shrink(),+ );+ },+ );+ }++ _selectedFilesListener() {+ _hasSelectedFilesNotifier.value = widget.selectedFiles!.files.isNotEmpty;+ }+}