Skip to content

armgit / ente

Public Imported from GitHub
0

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

update bottom sheet for add/move action

AmanRajSinghMouryaf0c3a87a8bb2
diff --git a/mobile/apps/photos/lib/ui/collections/album/column_item.dart b/mobile/apps/photos/lib/ui/collections/album/column_item.dart
index 3848414767..05a1ca59d3 100644
--- a/mobile/apps/photos/lib/ui/collections/album/column_item.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/column_item.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
-import "package:intl/intl.dart";
import 'package:logging/logging.dart';
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
@@ -7,13 +6,18 @@ import 'package:photos/models/collection/collection.dart';
import 'package:photos/models/file/file.dart';
import "package:photos/services/collections_service.dart";
import 'package:photos/theme/ente_theme.dart';
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
+import "package:photos/ui/components/collection_share_badge.dart";
import "package:photos/ui/sharing/user_avator_widget.dart";
import 'package:photos/ui/viewer/file/no_thumbnail_widget.dart';
import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
///https://www.figma.com/design/SYtMyLBs5SAOkTbfMMzhqt/Ente-Visual-Design?node-id=39181-172145&t=3qmSZWpXF3ZC4JGN-1
class AlbumColumnItemWidget extends StatelessWidget {
+ static const _thumbSize = 52.0;
+ static const _cornerRadius = 12.0;
+ static const _rowHeight = 68.0;
+ static const _cardRadius = 20.0;
+
final Collection collection;
final List<Collection> selectedCollections;
@@ -27,19 +31,20 @@ class AlbumColumnItemWidget extends StatelessWidget {
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
- const sideOfThumbnail = 60.0;
final isSelected = selectedCollections.contains(collection);
final isOwner = collection.isOwner(Configuration.instance.getUserID()!);
return AnimatedContainer(
curve: Curves.easeOut,
duration: const Duration(milliseconds: 200),
+ height: _rowHeight,
+ padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
+ color: colorScheme.fill,
border: Border.all(
- color:
- isSelected ? colorScheme.strokeMuted : colorScheme.strokeFainter,
+ color: isSelected ? colorScheme.greenStroke : colorScheme.fill,
),
borderRadius: const BorderRadius.all(
- Radius.circular(6),
+ Radius.circular(_cardRadius),
),
),
child: Row(
@@ -50,15 +55,15 @@ class AlbumColumnItemWidget extends StatelessWidget {
child: Row(
children: [
SizedBox(
- height: sideOfThumbnail,
- width: sideOfThumbnail,
+ height: _thumbSize,
+ width: _thumbSize,
child: Stack(
children: [
ClipRRect(
- borderRadius: BorderRadius.circular(4),
+ borderRadius: BorderRadius.circular(_cornerRadius),
child: SizedBox(
- height: sideOfThumbnail,
- width: sideOfThumbnail,
+ height: _thumbSize,
+ width: _thumbSize,
child: FutureBuilder<EnteFile?>(
future: CollectionsService.instance
.getCover(collection),
@@ -95,46 +100,43 @@ class AlbumColumnItemWidget extends StatelessWidget {
),
const SizedBox(width: 12),
Flexible(
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 4),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- collection.displayName,
- overflow: TextOverflow.ellipsis,
- ),
- FutureBuilder<int>(
- future: CollectionsService.instance
- .getFileCount(collection),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text(
- AppLocalizations.of(context).memoryCount(
- count: snapshot.data!,
- formattedCount:
- NumberFormat().format(snapshot.data!),
- ),
- style: textTheme.miniMuted,
- );
- } else {
- if (snapshot.hasError) {
- Logger("AlbumListItemWidget").severe(
- "Failed to fetch file count of collection",
- snapshot.error,
- );
- }
- return Text(
- "",
- style: textTheme.small.copyWith(
- color: colorScheme.textMuted,
- ),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ collection.displayName,
+ overflow: TextOverflow.ellipsis,
+ ),
+ const SizedBox(height: 4),
+ FutureBuilder<int>(
+ future: CollectionsService.instance
+ .getFileCount(collection),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ return Text(
+ AppLocalizations.of(context).itemCount(
+ count: snapshot.data!,
+ ),
+ style: textTheme.smallMuted,
+ );
+ } else {
+ if (snapshot.hasError) {
+ Logger("AlbumListItemWidget").severe(
+ "Failed to fetch file count of collection",
+ snapshot.error,
);
}
- },
- ),
- ],
- ),
+ return Text(
+ "",
+ style: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ );
+ }
+ },
+ ),
+ ],
),
),
],
@@ -143,15 +145,12 @@ class AlbumColumnItemWidget extends StatelessWidget {
Flexible(
flex: 1,
child: AnimatedSwitcher(
- duration: const Duration(milliseconds: 200),
+ duration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeOut,
switchOutCurve: Curves.easeIn,
child: isSelected
- ? IconButtonWidget(
- key: const ValueKey("selected"),
- icon: Icons.check_circle_rounded,
- iconButtonType: IconButtonType.secondary,
- iconColor: colorScheme.blurStrokeBase,
+ ? const CollectionSelectedBadge(
+ key: ValueKey("selected"),
)
: null,
),
diff --git a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
index a226df197b..de8c7fd765 100644
--- a/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
+++ b/mobile/apps/photos/lib/ui/collections/album/vertical_list.dart
@@ -42,6 +42,7 @@ class AlbumVerticalListWidget extends StatefulWidget {
final List<Collection> selectedCollections;
final Function()? onSelectionChanged;
final List<String>? selectedPeople;
+ final ScrollController? scrollController;
const AlbumVerticalListWidget(
this.collections,
@@ -56,6 +57,7 @@ class AlbumVerticalListWidget extends StatefulWidget {
this.sharedCollections = const [],
this.enableSelection = false,
this.onSelectionChanged,
+ this.scrollController,
super.key,
});
@@ -115,6 +117,7 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
sharedItemsCount;
return ListView.separated(
+ controller: widget.scrollController,
itemBuilder: (context, index) {
// Create new album button
if (index == 0 && widget.shouldShowCreateAlbum) {
diff --git a/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart b/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart
index 8d1af7aa39..6f19e2a073 100644
--- a/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart
+++ b/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart
@@ -4,7 +4,6 @@ import 'dart:math';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
-import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import "package:photos/core/configuration.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/create_new_album_event.dart";
@@ -13,18 +12,16 @@ import 'package:photos/models/collection/collection.dart';
import 'package:photos/models/selected_files.dart';
import "package:photos/service_locator.dart";
import 'package:photos/services/collections_service.dart';
-import 'package:photos/theme/colors.dart';
import 'package:photos/theme/ente_theme.dart';
import "package:photos/ui/actions/collection/collection_file_actions.dart";
import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
import 'package:photos/ui/collections/album/vertical_list.dart';
import 'package:photos/ui/common/loading_widget.dart';
import "package:photos/ui/common/progress_dialog.dart";
-import 'package:photos/ui/components/bottom_of_title_bar_widget.dart';
+import "package:photos/ui/components/base_bottom_sheet.dart";
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
import "package:photos/ui/components/text_input_widget.dart";
-import 'package:photos/ui/components/title_bar_title_widget.dart';
import "package:photos/ui/notification/toast.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/separators_util.dart";
@@ -90,27 +87,36 @@ void showCollectionActionSheet(
bool showOptionToCreateNewAlbum = true,
List<String>? selectedPeople,
}) {
- showBarModalBottomSheet(
- context: context,
- builder: (context) {
- return CollectionActionSheet(
+ final topPadding = MediaQuery.paddingOf(context).top;
+ final bottomPadding = MediaQuery.paddingOf(context).bottom;
+ final screenHeight = MediaQuery.sizeOf(context).height;
+ const sheetHeaderHeight = 76.0;
+ final sheetTopGap = screenHeight * 0.20;
+ final height = max(
+ 0.0,
+ screenHeight - topPadding - bottomPadding - sheetTopGap - sheetHeaderHeight,
+ );
+ final filesCount = sharedFiles != null
+ ? sharedFiles.length
+ : selectedPeople != null
+ ? selectedPeople.length
+ : selectedFiles?.files.length ?? 0;
+
+ showBaseBottomSheet<void>(
+ context,
+ title: _actionName(context, actionType, filesCount),
+ isKeyboardAware: false,
+ backgroundColor: getEnteColorScheme(context).backgroundColour,
+ child: SizedBox(
+ height: height,
+ child: CollectionActionSheet(
selectedFiles: selectedFiles,
sharedFiles: sharedFiles,
actionType: actionType,
showOptionToCreateNewAlbum: showOptionToCreateNewAlbum,
selectedPeople: selectedPeople,
- );
- },
- shape: const RoundedRectangleBorder(
- side: BorderSide(width: 0),
- borderRadius: BorderRadius.vertical(
- top: Radius.circular(5),
),
),
- topControl: const SizedBox.shrink(),
- backgroundColor: getEnteColorScheme(context).backgroundElevated,
- barrierColor: backdropFaintDark,
- enableDrag: true,
);
}
@@ -140,6 +146,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
String _searchQuery = "";
final _selectedCollections = <Collection>[];
final _recentlyCreatedCollections = <Collection>[];
+ final _scrollController = ScrollController();
late StreamSubscription<CreateNewAlbumEvent> _createNewAlbumSubscription;
final _logger = Logger("CollectionActionSheet");
@@ -165,16 +172,12 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
@override
void dispose() {
_createNewAlbumSubscription.cancel();
+ _scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
- final filesCount = widget.sharedFiles != null
- ? widget.sharedFiles!.length
- : widget.selectedPeople != null
- ? widget.selectedPeople!.length
- : widget.selectedFiles?.files.length ?? 0;
final bottomInset = MediaQuery.viewInsetsOf(context).bottom;
final isKeyboardUp = bottomInset > 100;
final double bottomPadding =
@@ -183,82 +186,53 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
padding: EdgeInsets.only(
bottom: isKeyboardUp ? bottomPadding : 0,
),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: min(428, MediaQuery.of(context).size.width),
- ),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(0, 32, 0, 8),
- child: Column(
- mainAxisSize: MainAxisSize.max,
- children: [
- Expanded(
- child: Column(
- children: [
- BottomOfTitleBarWidget(
- title: TitleBarTitleWidget(
- title: _actionName(
- context,
- widget.actionType,
- filesCount,
- ),
- ),
- caption: widget.showOptionToCreateNewAlbum
- ? AppLocalizations.of(context).createOrSelectAlbum
- : AppLocalizations.of(context).selectAlbum,
- showCloseButton: true,
- ),
- Padding(
- padding: const EdgeInsets.only(
- top: 16,
- left: 16,
- right: 16,
- ),
- child: TextInputWidget(
- hintText: AppLocalizations.of(context)
- .searchByAlbumNameHint,
- prefixIcon: Icons.search_rounded,
- onChange: (value) {
- setState(() {
- _searchQuery = value.trim();
- });
- },
- isClearable: true,
- shouldUnfocusOnClearOrSubmit: true,
- ),
- ),
- _getCollectionItems(),
- ],
+ child: Center(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 428),
+ child: Column(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Expanded(
+ child: Column(
+ children: [
+ TextInputWidget(
+ hintText:
+ AppLocalizations.of(context).searchByAlbumNameHint,
+ prefixIcon: Icons.search_rounded,
+ onChange: (value) {
+ setState(() {
+ _searchQuery = value.trim();
+ });
+ },
+ isClearable: true,
+ shouldUnfocusOnClearOrSubmit: true,
),
- ),
- SafeArea(
- child: Container(
- //inner stroke of 1pt + 15 pts of top padding = 16 pts
- padding: const EdgeInsets.fromLTRB(16, 15, 16, 8),
- decoration: BoxDecoration(
- border: Border(
- top: BorderSide(
- color: _enableSelection
- ? getEnteColorScheme(context).strokeFaint
- : Colors.transparent,
- ),
- ),
- ),
- child: Column(
- children: [
- ..._actionButtons(),
- ],
+ _getCollectionItems(),
+ ],
+ ),
+ ),
+ SafeArea(
+ child: Container(
+ padding: const EdgeInsets.symmetric(vertical: 8),
+ decoration: BoxDecoration(
+ border: Border(
+ top: BorderSide(
+ color: _enableSelection
+ ? getEnteColorScheme(context).strokeFaint
+ : Colors.transparent,
),
),
),
- ],
+ child: Column(
+ children: [
+ ..._actionButtons(),
+ ],
+ ),
+ ),
),
- ),
+ ],
),
- ],
+ ),
),
);
}
@@ -330,7 +304,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
Flexible _getCollectionItems() {
return Flexible(
child: Padding(
- padding: const EdgeInsets.fromLTRB(16, 24, 4, 0),
+ padding: const EdgeInsets.only(top: 24),
child: FutureBuilder<List<Collection>>(
future: _getCollections(),
builder: (context, snapshot) {
@@ -380,29 +354,40 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
)
.toList()
: collections;
- return Scrollbar(
- thumbVisibility: true,
- interactive: true,
- radius: const Radius.circular(2),
- child: Padding(
- padding: const EdgeInsets.only(right: 12),
- child: AlbumVerticalListWidget(
- searchResults,
- widget.actionType,
- widget.selectedFiles,
- widget.sharedFiles,
- widget.selectedPeople,
- _searchQuery,
- shouldShowCreateAlbum,
- recentCollections: recentCollections,
- sharedCollections: sharedCollections,
- enableSelection: _enableSelection,
- selectedCollections: _selectedCollections,
- onSelectionChanged: () {
- setState(() {});
- },
- ),
- ),
+ return LayoutBuilder(
+ builder: (context, constraints) {
+ return OverflowBox(
+ alignment: Alignment.centerLeft,
+ maxWidth: constraints.maxWidth + 20,
+ child: SizedBox(
+ width: constraints.maxWidth + 20,
+ child: Scrollbar(
+ controller: _scrollController,
+ radius: const Radius.circular(2),
+ child: Padding(
+ padding: const EdgeInsets.only(right: 20),
+ child: AlbumVerticalListWidget(
+ searchResults,
+ widget.actionType,
+ widget.selectedFiles,
+ widget.sharedFiles,
+ widget.selectedPeople,
+ _searchQuery,
+ shouldShowCreateAlbum,
+ recentCollections: recentCollections,
+ sharedCollections: sharedCollections,
+ enableSelection: _enableSelection,
+ selectedCollections: _selectedCollections,
+ scrollController: _scrollController,
+ onSelectionChanged: () {
+ setState(() {});
+ },
+ ),
+ ),
+ ),
+ ),
+ );
+ },
);
} else {
return const EnteLoadingWidget();