Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] changes: add new album icon to flex grid view

Aman Raj Singh Mouryaa5644f292e46
diff --git a/mobile/lib/ui/collections/collection_list_page.dart b/mobile/lib/ui/collections/collection_list_page.dart
index 7b73e06e8d..8d9d89d56b 100644
--- a/mobile/lib/ui/collections/collection_list_page.dart
+++ b/mobile/lib/ui/collections/collection_list_page.dart
@@ -10,7 +10,6 @@ import 'package:photos/models/collection/collection_items.dart';
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/ui/collections/flex_grid_view.dart";
-import "package:photos/ui/collections/new_album_icon.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/utils/local_settings.dart";
@@ -88,7 +87,7 @@ class _CollectionListPageState extends State<CollectionListPage> {
),
CollectionsFlexiGridViewWidget(
collections,
- displayLimitCount: collections?.length ?? 0,
+ displayLimitCount: (collections?.length ?? 0) + 1,
tag: widget.tag,
),
],
@@ -126,10 +125,6 @@ class _CollectionListPageState extends State<CollectionListPage> {
),
child: Row(
children: [
- const NewAlbumIcon(
- icon: Icons.add_rounded,
- iconButtonType: IconButtonType.secondary,
- ),
GestureDetector(
onTapDown: (TapDownDetails details) async {
final int? selectedValue = await showMenu<int>(
diff --git a/mobile/lib/ui/collections/flex_grid_view.dart b/mobile/lib/ui/collections/flex_grid_view.dart
index c96d2e1c4e..c78f5882cd 100644
--- a/mobile/lib/ui/collections/flex_grid_view.dart
+++ b/mobile/lib/ui/collections/flex_grid_view.dart
@@ -3,6 +3,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:photos/models/collection/collection.dart';
import "package:photos/ui/collections/album/row_item.dart";
+import "package:photos/ui/collections/new_album_icon.dart";
class CollectionsFlexiGridViewWidget extends StatelessWidget {
/*
@@ -45,19 +46,35 @@ class CollectionsFlexiGridViewWidget extends StatelessWidget {
final double sideOfThumbnail =
(screenWidth - gapOnSizeOfAlbums - gapBetweenAlbums) /
albumsCountInOneRow;
+ final List<Widget> displayItems = [];
+
+ displayItems.add(
+ NewAlbumIcon(
+ height: sideOfThumbnail,
+ width: sideOfThumbnail,
+ ),
+ );
+
+ if (collections != null && collections!.isNotEmpty) {
+ for (int i = 0; i < collections!.length; i++) {
+ displayItems.add(
+ AlbumRowItemWidget(
+ collections![i],
+ sideOfThumbnail,
+ tag: tag,
+ ),
+ );
+ }
+ }
return SliverPadding(
padding: const EdgeInsets.all(8),
sliver: SliverGrid(
delegate: SliverChildBuilderDelegate(
(context, index) {
- return AlbumRowItemWidget(
- collections![index],
- sideOfThumbnail,
- tag: tag,
- );
+ return displayItems[index];
},
- childCount: min(collections!.length, displayLimitCount),
+ childCount: min(displayItems.length, displayLimitCount),
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: albumsCountInOneRow,
diff --git a/mobile/lib/ui/collections/new_album_icon.dart b/mobile/lib/ui/collections/new_album_icon.dart
index 4e18123b66..8a58afc6cb 100644
--- a/mobile/lib/ui/collections/new_album_icon.dart
+++ b/mobile/lib/ui/collections/new_album_icon.dart
@@ -1,66 +1,96 @@
+import "package:dotted_border/dotted_border.dart";
import 'package:flutter/material.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/ui/components/buttons/icon_button_widget.dart";
+import "package:photos/theme/ente_theme.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 NewAlbumIcon extends StatelessWidget {
- final IconData icon;
final Color? color;
- final IconButtonType iconButtonType;
+ final double height;
+ final double width;
const NewAlbumIcon({
- required this.icon,
- required this.iconButtonType,
this.color,
super.key,
+ required this.height,
+ required this.width,
});
@override
Widget build(BuildContext context) {
- return IconButtonWidget(
- icon: icon,
- iconButtonType: iconButtonType,
- onTap: () async {
- final result = await showTextInputDialog(
- context,
- title: S.of(context).newAlbum,
- submitButtonLabel: S.of(context).create,
- hintText: S.of(context).enterAlbumName,
- alwaysShowSuccessState: false,
- initialValue: "",
- textCapitalization: TextCapitalization.words,
- popnavAfterSubmission: false,
- onSubmit: (String text) async {
- if (text.trim() == "") {
- return;
- }
+ final enteColorScheme = getEnteColorScheme(context);
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 2.5),
+ child: GestureDetector(
+ onTap: () async {
+ final result = await showTextInputDialog(
+ context,
+ title: S.of(context).newAlbum,
+ submitButtonLabel: S.of(context).create,
+ hintText: S.of(context).enterAlbumName,
+ alwaysShowSuccessState: false,
+ initialValue: "",
+ textCapitalization: TextCapitalization.words,
+ popnavAfterSubmission: false,
+ onSubmit: (String text) async {
+ if (text.trim() == "") {
+ return;
+ }
- try {
- final Collection c =
- await CollectionsService.instance.createAlbum(text);
- // ignore: unawaited_futures
- await routeToPage(
- context,
- CollectionPage(CollectionWithThumbnail(c, null)),
- );
- Navigator.of(context).pop();
- } catch (e, s) {
- Logger("CreateNewAlbumIcon")
- .severe("Failed to rename album", e, s);
- rethrow;
- }
- },
- );
+ try {
+ final Collection c =
+ await CollectionsService.instance.createAlbum(text);
+ // ignore: unawaited_futures
+ await routeToPage(
+ context,
+ CollectionPage(CollectionWithThumbnail(c, null)),
+ );
+ Navigator.of(context).pop();
+ } catch (e, s) {
+ Logger("CreateNewAlbumIcon")
+ .severe("Failed to rename album", e, s);
+ rethrow;
+ }
+ },
+ );
- if (result is Exception) {
- await showGenericErrorDialog(context: context, error: result);
- }
- },
+ if (result is Exception) {
+ await showGenericErrorDialog(context: context, error: result);
+ }
+ },
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ DottedBorder(
+ borderType: BorderType.RRect,
+ strokeWidth: 1.5,
+ borderPadding: const EdgeInsets.all(0.75),
+ dashPattern: const [3.75, 3.75],
+ radius: const Radius.circular(2.35),
+ padding: EdgeInsets.zero,
+ color: enteColorScheme.strokeFaint,
+ child: SizedBox(
+ height: height,
+ width: width,
+ child: Icon(
+ Icons.add,
+ color: enteColorScheme.strokeFaint,
+ ),
+ ),
+ ),
+ const SizedBox(height: 2),
+ Text(
+ S.of(context).addNew,
+ style: getEnteTextTheme(context).smallFaint,
+ ),
+ ],
+ ),
+ ),
);
}
}