Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][locker] Upload to uncategorized (#11160)

Aman Rajfeca39e30696
diff --git a/mobile/apps/locker/changes/allow-uploading-to-uncategorized-collection.md b/mobile/apps/locker/changes/allow-uploading-to-uncategorized-collection.md
new file mode 100644
index 0000000000..bd5d18cc90
--- /dev/null
+++ b/mobile/apps/locker/changes/allow-uploading-to-uncategorized-collection.md
@@ -0,0 +1 @@
+- Allow uploading to uncategorized collection
diff --git a/mobile/apps/locker/changes/drag-to-open-drawer.md b/mobile/apps/locker/changes/drag-to-open-drawer.md
new file mode 100644
index 0000000000..49ba89d56e
--- /dev/null
+++ b/mobile/apps/locker/changes/drag-to-open-drawer.md
@@ -0,0 +1 @@
+- Drag to open drawer
diff --git a/mobile/apps/locker/lib/ui/components/collection_chip.dart b/mobile/apps/locker/lib/ui/components/collection_chip.dart
deleted file mode 100644
index ee884219c5..0000000000
--- a/mobile/apps/locker/lib/ui/components/collection_chip.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-import "package:ente_ui/theme/colors.dart";
-import "package:ente_ui/theme/text_style.dart";
-import "package:flutter/material.dart";
-
-class CollectionChip extends StatelessWidget {
- const CollectionChip({
- super.key,
- required this.label,
- required this.isSelected,
- required this.onTap,
- required this.colorScheme,
- required this.textTheme,
- this.backgroundColor,
- });
-
- final String label;
- final bool isSelected;
- final VoidCallback onTap;
- final EnteColorScheme colorScheme;
- final EnteTextTheme textTheme;
- final Color? backgroundColor;
-
- @override
- Widget build(BuildContext context) {
- final bgColor = backgroundColor ?? colorScheme.fillFaint;
-
- return GestureDetector(
- onTap: onTap,
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- constraints: const BoxConstraints(minHeight: 44),
- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
- decoration: BoxDecoration(
- color: isSelected ? colorScheme.primary700 : bgColor,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- label,
- style: textTheme.small.copyWith(
- color: isSelected ? Colors.white : colorScheme.textMuted,
- ),
- ),
- ],
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/locker/lib/ui/components/collection_list_widget.dart b/mobile/apps/locker/lib/ui/components/collection_list_widget.dart
index d0082689a9..3cb4e50cfa 100644
--- a/mobile/apps/locker/lib/ui/components/collection_list_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_list_widget.dart
@@ -14,7 +14,6 @@ import "package:locker/ui/sharing/album_share_info_widget.dart";
class CollectionListWidget extends StatelessWidget {
final Collection collection;
- final bool isLastItem;
final SelectedCollections? selectedCollections;
final void Function(Collection)? onTapCallback;
final void Function(Collection)? onLongPressCallback;
@@ -22,7 +21,6 @@ class CollectionListWidget extends StatelessWidget {
const CollectionListWidget({
super.key,
required this.collection,
- this.isLastItem = false,
this.selectedCollections,
this.onTapCallback,
this.onLongPressCallback,
diff --git a/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
index 4279c677bb..437c9514fd 100644
--- a/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
@@ -1,13 +1,11 @@
import 'package:collection/collection.dart' show IterableExtension;
import 'package:dotted_border/dotted_border.dart';
-import "package:ente_ui/theme/colors.dart";
+import "package:ente_components/ente_components.dart";
import 'package:ente_ui/theme/ente_theme.dart';
-import "package:ente_ui/theme/text_style.dart";
import 'package:flutter/material.dart';
import 'package:locker/extensions/collection_extension.dart';
import 'package:locker/l10n/l10n.dart';
import 'package:locker/services/collections/models/collection.dart';
-import 'package:locker/ui/components/collection_chip.dart';
import 'package:locker/utils/collection_actions.dart';
import 'package:locker/utils/collection_list_util.dart';
@@ -18,7 +16,6 @@ class CollectionSelectionWidget extends StatefulWidget {
final Function(List<Collection>)? onCollectionsUpdated;
final String title;
- final bool singleSelectionMode;
const CollectionSelectionWidget({
super.key,
@@ -27,7 +24,6 @@ class CollectionSelectionWidget extends StatefulWidget {
required this.onToggleCollection,
this.onCollectionsUpdated,
required this.title,
- this.singleSelectionMode = false,
});
@override
@@ -80,73 +76,57 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
_availableCollections.add(newCollection);
});
- // In single selection mode, clear other selections before selecting the new one
- if (widget.singleSelectionMode) {
- final collectionIdsCopy = Set<int>.from(widget.selectedCollectionIds);
- for (final id in collectionIdsCopy) {
- widget.onToggleCollection(id);
- }
- }
-
widget.onToggleCollection(newCollection.id);
- widget.onCollectionsUpdated?.call(_availableCollections);
+ widget.onCollectionsUpdated?.call([
+ ?_uncategorizedCollection,
+ ..._availableCollections,
+ ]);
}
}
void _onCollectionTap(int collectionId) {
- if (widget.singleSelectionMode) {
- // In single selection mode, clear other selections first
- final collectionIdsCopy = Set<int>.from(widget.selectedCollectionIds);
- for (final id in collectionIdsCopy) {
- if (id != collectionId) {
- widget.onToggleCollection(id);
- }
- }
- }
widget.onToggleCollection(collectionId);
}
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
final containsUncategorized = _uncategorizedCollection != null;
final chips = <Widget>[];
+ chips.add(_buildNewCollectionChip());
+
if (containsUncategorized) {
chips.add(
- CollectionChip(
+ TagChipComponent(
label: context.l10n.uncategorized,
- isSelected: widget.selectedCollectionIds.contains(
- _uncategorizedCollection?.id ?? -1,
- ),
+ state:
+ widget.selectedCollectionIds.contains(
+ _uncategorizedCollection?.id ?? -1,
+ )
+ ? TagChipComponentState.selected
+ : TagChipComponentState.unselected,
onTap: () {
if (_uncategorizedCollection != null) {
_onCollectionTap(_uncategorizedCollection!.id);
}
},
- colorScheme: colorScheme,
- textTheme: textTheme,
),
);
}
- chips.add(
- _buildNewCollectionChip(colorScheme: colorScheme, textTheme: textTheme),
- );
-
for (final collection in _availableCollections) {
final collectionName =
collection.displayName ?? context.l10n.unnamedCollection;
chips.add(
- CollectionChip(
+ TagChipComponent(
label: collectionName,
- isSelected: widget.selectedCollectionIds.contains(collection.id),
+ state: widget.selectedCollectionIds.contains(collection.id)
+ ? TagChipComponentState.selected
+ : TagChipComponentState.unselected,
onTap: () => _onCollectionTap(collection.id),
- colorScheme: colorScheme,
- textTheme: textTheme,
),
);
}
@@ -178,10 +158,10 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
);
}
- Widget _buildNewCollectionChip({
- required EnteColorScheme colorScheme,
- required EnteTextTheme textTheme,
- }) {
+ Widget _buildNewCollectionChip() {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
return GestureDetector(
onTap: () async {
await _createNewCollection();
diff --git a/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart b/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart
index 970760f540..c69c870cef 100644
--- a/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart
@@ -42,6 +42,10 @@ class _FileEditSheetState extends State<FileEditSheet> {
final TextEditingController _captionController = TextEditingController();
final Set<int> _selectedCollectionIds = <int>{};
List<Collection> _availableCollections = [];
+ bool _hasLoadedCollectionSelection = false;
+
+ bool get _canSave =>
+ _hasLoadedCollectionSelection && _selectedCollectionIds.isNotEmpty;
@override
void initState() {
@@ -68,17 +72,16 @@ class _FileEditSheetState extends State<FileEditSheet> {
setState(() {
_selectedCollectionIds
..clear()
- ..addAll(
- existingCollections
- .where(
- (collection) =>
- collection.type != CollectionType.uncategorized,
- )
- .map((collection) => collection.id),
- );
+ ..addAll(existingCollections.map((collection) => collection.id));
+ _hasLoadedCollectionSelection = true;
});
} catch (_) {
// Ignore failures; selections will remain empty.
+ if (mounted) {
+ setState(() {
+ _hasLoadedCollectionSelection = true;
+ });
+ }
}
}
@@ -109,11 +112,7 @@ class _FileEditSheetState extends State<FileEditSheet> {
}
List<Collection> _filterCollections(List<Collection> source) {
- final filtered = uniqueCollectionsById(source)
- ..removeWhere(
- (collection) => collection.type == CollectionType.uncategorized,
- );
- return filtered;
+ return uniqueCollectionsById(source);
}
Future<void> _onSave() async {
@@ -155,9 +154,7 @@ class _FileEditSheetState extends State<FileEditSheet> {
SizedBox(
width: double.infinity,
child: GradientButton(
- onTap: () async {
- await _onSave();
- },
+ onTap: _canSave ? _onSave : null,
text: context.l10n.save,
),
),
diff --git a/mobile/apps/locker/lib/ui/components/file_list_widget.dart b/mobile/apps/locker/lib/ui/components/file_list_widget.dart
index 77c6d80ab2..91bbb54ff9 100644
--- a/mobile/apps/locker/lib/ui/components/file_list_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/file_list_widget.dart
@@ -17,7 +17,6 @@ import "package:locker/utils/info_item_utils.dart";
class FileListWidget extends StatelessWidget {
final EnteFile file;
- final bool isLastItem;
final SelectedFiles? selectedFiles;
final void Function(EnteFile)? onTapCallback;
final void Function(EnteFile)? onLongPressCallback;
@@ -25,7 +24,6 @@ class FileListWidget extends StatelessWidget {
const FileListWidget({
super.key,
required this.file,
- this.isLastItem = false,
this.selectedFiles,
this.onTapCallback,
this.onLongPressCallback,
diff --git a/mobile/apps/locker/lib/ui/components/item_list_view.dart b/mobile/apps/locker/lib/ui/components/item_list_view.dart
index ceb3cf049c..1b1cd3f2bb 100644
--- a/mobile/apps/locker/lib/ui/components/item_list_view.dart
+++ b/mobile/apps/locker/lib/ui/components/item_list_view.dart
@@ -126,16 +126,15 @@ class _ItemListViewState extends State<ItemListView> {
Widget _buildItem(int index) {
final item = _sortedItems[index];
- final isLastItem = index == _sortedItems.length - 1;
if (item.isCollection) {
- return _buildCollectionItem(item.collection!, isLastItem);
+ return _buildCollectionItem(item.collection!);
} else {
- return _buildFileItem(item.file!, isLastItem);
+ return _buildFileItem(item.file!);
}
}
- Widget _buildCollectionItem(Collection collection, bool isLastItem) {
+ Widget _buildCollectionItem(Collection collection) {
final hasSelection = widget.selectedCollections != null;
if (hasSelection) {
@@ -145,7 +144,6 @@ class _ItemListViewState extends State<ItemListView> {
final isAnySelected = widget.selectedCollections!.hasSelections;
return _createCollectionWidget(
collection: collection,
- isLastItem: isLastItem,
onTap: (c) => isAnySelected
? _toggleCollectionSelection(c)
: _navigateToCollectionPage(c),
@@ -157,13 +155,10 @@ class _ItemListViewState extends State<ItemListView> {
);
}
- return _createCollectionWidget(
- collection: collection,
- isLastItem: isLastItem,
- );
+ return _createCollectionWidget(collection: collection);
}
- Widget _buildFileItem(EnteFile file, bool isLastItem) {
+ Widget _buildFileItem(EnteFile file) {
final hasSelection = widget.selectedFiles != null;
if (hasSelection) {
@@ -173,7 +168,6 @@ class _ItemListViewState extends State<ItemListView> {
final isAnySelected = widget.selectedFiles!.hasSelections;
return _createFileWidget(
file: file,
- isLastItem: isLastItem,
onTap: isAnySelected ? (f) => _toggleFileSelection(f) : null,
onLongPress: isAnySelected ? null : (f) => _toggleFileSelection(f),
);
@@ -181,18 +175,16 @@ class _ItemListViewState extends State<ItemListView> {
);
}
- return _createFileWidget(file: file, isLastItem: isLastItem);
+ return _createFileWidget(file: file);
}
Widget _createCollectionWidget({
required Collection collection,
- required bool isLastItem,
Function(Collection)? onTap,
Function(Collection)? onLongPress,
}) {
return CollectionListWidget(
collection: collection,
- isLastItem: isLastItem,
selectedCollections: widget.selectedCollections,
onTapCallback: onTap,
onLongPressCallback: onLongPress,
@@ -201,13 +193,11 @@ class _ItemListViewState extends State<ItemListView> {
Widget _createFileWidget({
required EnteFile file,
- required bool isLastItem,
Function(EnteFile)? onTap,
Function(EnteFile)? onLongPress,
}) {
return FileListWidget(
file: file,
- isLastItem: isLastItem,
selectedFiles: widget.selectedFiles,
onTapCallback: onTap,
onLongPressCallback: onLongPress,
diff --git a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
index 8bef16e7f4..b7f721bc6c 100644
--- a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
@@ -1,4 +1,4 @@
-import "package:ente_ui/components/close_icon_button.dart";
+import "package:ente_components/ente_components.dart";
import "package:ente_ui/theme/colors.dart";
import 'package:ente_ui/theme/ente_theme.dart';
import "package:ente_ui/theme/text_style.dart";
@@ -11,7 +11,6 @@ import "package:locker/models/selected_files.dart";
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/files/sync/models/file.dart';
-import 'package:locker/ui/components/collection_chip.dart';
import "package:locker/ui/components/empty_state_widget.dart";
import 'package:locker/ui/components/item_list_view.dart';
import 'package:locker/ui/pages/all_collections_page.dart';
@@ -112,58 +111,31 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
return null;
}
- final chipModels = orderedFilters
- .map(
- (collection) => _FilterChipViewModel(
- key: 'c_${collection.id}',
- label: _collectionLabel(collection),
- isSelected: _selectedCollections.contains(collection),
- onTap: () => _onCollectionSelected(collection),
- ),
- )
- .toList();
-
return _FilterChipsRow(
- chips: chipModels,
- showClearButton: false,
- onClearTapped: _clearAllFilters,
+ chips: _buildFilterChipModels(context, orderedFilters),
onFilterIconTapped: () => _showFilterBottomSheet(context),
);
}
void _showFilterBottomSheet(BuildContext context) {
- showModalBottomSheet(
+ final navigator = Navigator.of(context);
+
+ showBottomSheetComponent<void>(
context: context,
- isScrollControlled: true,
- backgroundColor: Colors.transparent,
- builder: (bottomSheetContext) {
+ builder: (sheetContext) {
return StatefulBuilder(
builder: (context, setBottomSheetState) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
final orderedFilters = _getOrderedCollections();
- final chipModels = orderedFilters
- .map(
- (collection) => _FilterChipViewModel(
- key: 'c_${collection.id}',
- label: _collectionLabel(collection),
- isSelected: _selectedCollections.contains(collection),
- onTap: () async {
- await _onCollectionSelected(collection);
- setBottomSheetState(() {});
- },
- ),
- )
- .toList();
return _FilterBottomSheet(
- chips: chipModels,
- colorScheme: colorScheme,
- textTheme: textTheme,
- hasActiveFilters: _hasActiveFilters,
+ chips: _buildFilterChipModels(
+ context,
+ orderedFilters,
+ afterTap: () => setBottomSheetState(() {}),
+ ),
onSeeAllCollections: () {
- Navigator.push(
- context,
+ navigator.pop();
+ navigator.push(
MaterialPageRoute(
builder: (context) => const AllCollectionsPage(),
),
@@ -173,7 +145,6 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
await _clearAllFilters();
setBottomSheetState(() {});
},
- onClose: () => Navigator.pop(context),
);
},
);
@@ -181,6 +152,26 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
);
}
+ List<_FilterChipViewModel> _buildFilterChipModels(
+ BuildContext context,
+ List<Collection> collections, {
+ VoidCallback? afterTap,
+ }) {
+ return collections
+ .map(
+ (collection) => _FilterChipViewModel(
+ key: 'c_${collection.id}',
+ label: _collectionLabel(context, collection),
+ isSelected: _selectedCollections.contains(collection),
+ onTap: () async {
+ await _onCollectionSelected(collection);
+ afterTap?.call();
+ },
+ ),
+ )
+ .toList();
+ }
+
Widget _buildRecentsTable(BuildContext context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
@@ -254,9 +245,8 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
Future<void> _updateFilteredFiles() async {
final int computationId = ++_filtersComputationId;
final hasCollectionFilters = _selectedCollections.isNotEmpty;
- final hasAnyFilters = hasCollectionFilters;
- if (!hasAnyFilters) {
+ if (!hasCollectionFilters) {
if (!mounted || computationId != _filtersComputationId) {
return;
}
@@ -275,7 +265,7 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
final fileCollections = await _ensureCollectionsForFiles(
widget.recentFiles,
- refresh: hasCollectionFilters,
+ refresh: true,
);
if (!mounted || computationId != _filtersComputationId) {
@@ -294,14 +284,12 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
? (fileCollections[fileId] ?? const <Collection>[])
: const <Collection>[];
- if (hasCollectionFilters) {
- final collectionIdsForFile = collectionsForFile
- .map((collection) => collection.id)
- .toSet();
+ final collectionIdsForFile = collectionsForFile
+ .map((collection) => collection.id)
+ .toSet();
- if (!selectedCollectionIds.every(collectionIdsForFile.contains)) {
- continue;
- }
+ if (!selectedCollectionIds.every(collectionIdsForFile.contains)) {
+ continue;
}
filteredFiles.add(file);
@@ -311,7 +299,6 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
}
final availableCollections = _computeAvailableCollections(
- hasActiveFilters: hasAnyFilters,
filteredFiles: filteredFiles,
fileCollections: filteredFileCollections,
);
@@ -401,14 +388,9 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
}
List<Collection> _computeAvailableCollections({
- required bool hasActiveFilters,
required List<EnteFile> filteredFiles,
required Map<int, List<Collection>> fileCollections,
}) {
- if (!hasActiveFilters) {
- return List.from(widget.collections);
- }
-
final availableIds = <int>{};
for (final file in filteredFiles) {
@@ -464,10 +446,10 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
return orderedCollections;
}
- String _collectionLabel(Collection collection) {
+ String _collectionLabel(BuildContext context, Collection collection) {
final name = collection.displayName?.trim();
if (name == null || name.isEmpty) {
- return 'Untitled';
+ return context.l10n.untitled;
}
return name;
}
@@ -490,166 +472,62 @@ class _FilterChipViewModel {
class _FilterChipsRow extends StatelessWidget {
const _FilterChipsRow({
required this.chips,
- required this.showClearButton,
- required this.onClearTapped,
required this.onFilterIconTapped,
});
final List<_FilterChipViewModel> chips;
- final bool showClearButton;
- final VoidCallback onClearTapped;
final VoidCallback onFilterIconTapped;
@override
Widget build(BuildContext context) {
final listKey = chips.map((chip) => chip.key).join('-');
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return SizedBox(
- height: 44,
- child: Row(
- children: [
- _FilterIconButton(
- onTap: onFilterIconTapped,
- colorScheme: colorScheme,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: ClipRRect(
- borderRadius: BorderRadius.circular(16),
- child: AnimatedSwitcher(
- duration: const Duration(milliseconds: 300),
- child: ListView.builder(
- key: ValueKey(listKey),
- scrollDirection: Axis.horizontal,
- itemCount: chips.length,
- itemBuilder: (context, index) {
- final chip = chips[index];
- return AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- margin: const EdgeInsets.only(right: 8),
- child: CollectionChip(
- label: chip.label,
- isSelected: chip.isSelected,
- onTap: chip.onTap,
- colorScheme: colorScheme,
- textTheme: textTheme,
- backgroundColor: colorScheme.backdropBase,
+ return Row(
+ children: [
+ IconButtonComponent(
+ icon: const HugeIcon(icon: HugeIcons.strokeRoundedFilterHorizontal),
+ variant: IconButtonComponentVariant.primary,
+ shouldSurfaceExecutionStates: false,
+ tooltip: context.l10n.filters,
+ onTap: onFilterIconTapped,
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(16),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ return AnimatedSwitcher(
+ duration: const Duration(milliseconds: 300),
+ child: SizedBox(
+ key: ValueKey(listKey),
+ width: constraints.maxWidth,
+ child: SingleChildScrollView(
+ scrollDirection: Axis.horizontal,
+ padding: const EdgeInsets.only(right: 24),
+ child: Row(
+ children: chips.map((chip) {
+ return AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ margin: const EdgeInsets.only(right: 8),
+ child: TagChipComponent(
+ label: chip.label,
+ state: chip.isSelected
+ ? TagChipComponentState.selected
+ : TagChipComponentState.unselected,
+ onTap: chip.onTap,
+ ),
+ );
+ }).toList(),
),
- );
- },
- ),
- ),
- ),
- ),
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 300),
- switchInCurve: Curves.easeOut,
- switchOutCurve: Curves.easeIn,
- transitionBuilder: (Widget child, Animation<double> animation) {
- return SlideTransition(
- position:
- Tween<Offset>(
- begin: const Offset(1.0, 0.0),
- end: Offset.zero,
- ).animate(
- CurvedAnimation(parent: animation, curve: Curves.easeOut),
),
- child: FadeTransition(opacity: animation, child: child),
- );
- },
- child: showClearButton
- ? Padding(
- key: const ValueKey('clear_button'),
- padding: const EdgeInsets.only(left: 8),
- child: _FilterClearButton(
- onTap: onClearTapped,
- colorScheme: colorScheme,
- textTheme: textTheme,
- ),
- )
- : const SizedBox.shrink(key: ValueKey('no_clear_button')),
- ),
- ],
- ),
- );
- }
-}
-
-class _FilterIconButton extends StatelessWidget {
- const _FilterIconButton({required this.onTap, required this.colorScheme});
-
- final VoidCallback onTap;
- final EnteColorScheme colorScheme;
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- width: 44,
- height: 44,
- decoration: BoxDecoration(
- color: colorScheme.backdropBase,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Center(
- child: Icon(
- Icons.filter_list,
- color: colorScheme.textMuted,
- size: 24,
- ),
- ),
- ),
- );
- }
-}
-
-class _FilterClearButton extends StatelessWidget {
- const _FilterClearButton({
- required this.onTap,
- required this.colorScheme,
- required this.textTheme,
- });
-
- final VoidCallback onTap;
- final EnteColorScheme colorScheme;
- final EnteTextTheme textTheme;
-
- @override
- Widget build(BuildContext context) {
- final accentColor = colorScheme.warning500;
- final backgroundColor = accentColor.withValues(alpha: 0.12);
-
- return GestureDetector(
- onTap: onTap,
- child: Container(
- constraints: const BoxConstraints(minHeight: 44),
- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
- decoration: BoxDecoration(
- color: backgroundColor,
- borderRadius: const BorderRadius.all(Radius.circular(24.0)),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- HugeIcon(
- icon: HugeIcons.strokeRoundedDelete02,
- size: 16,
- color: accentColor,
- ),
- const SizedBox(width: 4),
- Text(
- context.l10n.clear,
- style: textTheme.small.copyWith(
- color: accentColor,
- fontWeight: FontWeight.w600,
- ),
+ ),
+ );
+ },
),
- ],
+ ),
),
- ),
+ ],
);
}
}
@@ -657,29 +535,24 @@ class _FilterClearButton extends StatelessWidget {
class _FilterBottomSheet extends StatelessWidget {
const _FilterBottomSheet({
required this.chips,
- required this.colorScheme,
- required this.textTheme,
- required this.hasActiveFilters,
required this.onSeeAllCollections,
required this.onClearAllFilters,
- required this.onClose,
});
final List<_FilterChipViewModel> chips;
- final EnteColorScheme colorScheme;
- final EnteTextTheme textTheme;
- final bool hasActiveFilters;
final VoidCallback onSeeAllCollections;
final VoidCallback onClearAllFilters;
- final VoidCallback onClose;
@override
Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
- padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
child: Row(
children: [
_ActionPillButton(
@@ -698,55 +571,27 @@ class _FilterBottomSheet extends StatelessWidget {
],
),
),
- Container(
- decoration: BoxDecoration(
- color: colorScheme.backdropBase.withValues(alpha: 1.0),
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(20),
- topRight: Radius.circular(20),
- ),
- border: Border(top: BorderSide(color: colorScheme.strokeFaint)),
- ),
- child: SafeArea(
- top: false,
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(context.l10n.filters, style: textTheme.largeBold),
- const CloseIconButton(),
- ],
- ),
- const SizedBox(height: 16),
- ClipRRect(
- borderRadius: BorderRadius.circular(16),
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxHeight: 200),
- child: SingleChildScrollView(
- padding: const EdgeInsets.only(bottom: 12),
- child: Wrap(
- spacing: 8,
- runSpacing: 8,
- children: chips.map((chip) {
- return CollectionChip(
- label: chip.label,
- isSelected: chip.isSelected,
- onTap: chip.onTap,
- colorScheme: colorScheme,
- textTheme: textTheme,
- backgroundColor: colorScheme.backgroundElevated2,
- );
- }).toList(),
- ),
- ),
- ),
- ),
- ],
+ BottomSheetComponent(
+ title: context.l10n.filters,
+ content: ClipRRect(
+ borderRadius: BorderRadius.circular(16),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxHeight: 200),
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.only(bottom: 12),
+ child: Wrap(
+ spacing: 8,
+ runSpacing: 8,
+ children: chips.map((chip) {
+ return TagChipComponent(
+ label: chip.label,
+ state: chip.isSelected
+ ? TagChipComponentState.selected
+ : TagChipComponentState.unselected,
+ onTap: chip.onTap,
+ );
+ }).toList(),
+ ),
),
),
),
diff --git a/mobile/apps/locker/lib/ui/pages/base_info_page.dart b/mobile/apps/locker/lib/ui/pages/base_info_page.dart
index 0c7c082690..9b2c81701c 100644
--- a/mobile/apps/locker/lib/ui/pages/base_info_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/base_info_page.dart
@@ -61,6 +61,7 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
// Collection selection state
List<Collection> _availableCollections = [];
Set<int> _selectedCollectionIds = {};
+ bool _hasLoadedCollectionSelection = false;
// Getter for current data - prioritizes updated data over existing file data
T? get currentData {
@@ -98,7 +99,10 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
double get collectionSpacing => 24;
@protected
- bool get isSaveEnabled => !_isLoading && _selectedCollectionIds.isNotEmpty;
+ bool get isSaveEnabled =>
+ !_isLoading &&
+ _hasLoadedCollectionSelection &&
+ (widget.existingFile == null || _selectedCollectionIds.isNotEmpty);
bool get _canEditExistingFile => widget.existingFile is! TrashFile;
@@ -191,18 +195,16 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
Future<void> _loadCollections() async {
try {
+ final isEditingExistingFile = widget.existingFile != null;
final filteredCollections = await CollectionService.instance
- .getCollectionsForUI();
+ .getCollectionsForUI(includeUncategorized: isEditingExistingFile);
Set<int> initialSelection = _selectedCollectionIds;
- if (widget.existingFile != null) {
+ if (isEditingExistingFile) {
final fileCollections = await CollectionService.instance
.getCollectionsForFile(widget.existingFile!);
- initialSelection = fileCollections
- .where((c) => c.type != CollectionType.uncategorized)
- .map((c) => c.id)
- .toSet();
+ initialSelection = fileCollections.map((c) => c.id).toSet();
}
if (!mounted) {
@@ -212,6 +214,7 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
setState(() {
_availableCollections = filteredCollections;
_selectedCollectionIds = initialSelection;
+ _hasLoadedCollectionSelection = true;
});
} catch (e) {
// Handle error silently or show a message
@@ -223,7 +226,6 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
if (_selectedCollectionIds.contains(collectionId)) {
_selectedCollectionIds.remove(collectionId);
} else {
- // Allow multiple selections
_selectedCollectionIds.add(collectionId);
}
});
@@ -333,6 +335,7 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
Future<void> _updateCollectionMembership() async {
if (widget.existingFile == null) return;
+ if (!_hasLoadedCollectionSelection) return;
// Get current collections for the file
final currentCollections = await CollectionService.instance
@@ -365,7 +368,10 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
);
}
- // Get regular (non-favorites, non-uncategorized) collection IDs
+ // Only favorites is special-cased; Uncategorized is treated as a normal
+ // collection. A file can belong to multiple collections (incl.
+ // Uncategorized), so it is only removed from Uncategorized when the user
+ // explicitly deselects it.
final regularCurrentIds = currentCollectionIds
.where((id) => id != favoriteCollection.id)
.toSet();
@@ -436,16 +442,16 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
}
Future<void> _createNewFile(InfoItem infoItem) async {
- if (_selectedCollectionIds.isEmpty) {
- showToast(context, context.l10n.pleaseSelectAtLeastOneCollection);
- return;
- }
-
- // Upload to all selected collections
final selectedCollections = _availableCollections
.where((c) => _selectedCollectionIds.contains(c.id))
.toList();
+ if (selectedCollections.isEmpty) {
+ final uncategorizedCollection = await CollectionService.instance
+ .getOrCreateUncategorizedCollection();
+ selectedCollections.add(uncategorizedCollection);
+ }
+
// Upload to the first collection
final uploadedFile = await InfoFileService.instance.createAndUploadInfoFile(
infoItem: infoItem,
diff --git a/mobile/apps/locker/lib/ui/pages/emergency_contact_page.dart b/mobile/apps/locker/lib/ui/pages/emergency_contact_page.dart
index a1ccac4fd7..f5d562e469 100644
--- a/mobile/apps/locker/lib/ui/pages/emergency_contact_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/emergency_contact_page.dart
@@ -26,6 +26,8 @@ class _EmergencyContactPageState
@override
void initState() {
super.initState();
+ _nameController.addListener(_onFieldChanged);
+ _contactDetailsController.addListener(_onFieldChanged);
_loadExistingData();
}
@@ -46,6 +48,8 @@ class _EmergencyContactPageState
@override
void dispose() {
+ _nameController.removeListener(_onFieldChanged);
+ _contactDetailsController.removeListener(_onFieldChanged);
_nameController.dispose();
_contactDetailsController.dispose();
_notesController.dispose();
@@ -67,6 +71,9 @@ class _EmergencyContactPageState
_contactDetailsController.text.trim().isNotEmpty;
}
+ @override
+ bool get isSaveEnabled => super.isSaveEnabled && validateForm();
+
@override
EmergencyContactData createInfoData() {
return EmergencyContactData(
@@ -118,6 +125,12 @@ class _EmergencyContactPageState
];
}
+ void _onFieldChanged() {
+ if (mounted) {
+ setState(() {});
+ }
+ }
+
@override
List<Widget> buildViewFields() {
return [
diff --git a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart
index 116ea09495..0f28e50fff 100644
--- a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart
+++ b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart
@@ -194,20 +194,16 @@ class _FileUploadScreenState extends State<FileUploadScreen> {
child: SizedBox(
width: double.infinity,
child: GradientButton(
- onTap: _selectedCollectionIds.isEmpty
- ? null
- : () async {
- final selectedCollections = _availableCollections
- .where(
- (c) => _selectedCollectionIds.contains(c.id),
- )
- .toList();
- final result = FileUploadScreenResult(
- note: '',
- selectedCollections: selectedCollections,
- );
- Navigator.of(context).pop(result);
- },
+ onTap: () async {
+ final selectedCollections = _availableCollections
+ .where((c) => _selectedCollectionIds.contains(c.id))
+ .toList();
+ final result = FileUploadScreenResult(
+ note: '',
+ selectedCollections: selectedCollections,
+ );
+ Navigator.of(context).pop(result);
+ },
text: context.l10n.save,
),
),
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index f018f16a6b..3e188d567e 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -230,6 +230,8 @@ class _HomePageState extends UploaderPageState<HomePage>
);
String? _error;
+ // Accumulated rightward drag distance for the open-drawer swipe.
+ double _drawerDragDx = 0;
final _logger = Logger('HomePage');
StreamSubscription? _mediaStreamSubscription;
StreamSubscription<Uri>? _deepLinkSubscription;
@@ -269,11 +271,6 @@ class _HomePageState extends UploaderPageState<HomePage>
}
}
- List<Collection> get _displayedCollections {
- final collections = isSearchActive ? _filteredCollections : _collections;
- return _filterOutUncategorized(collections);
- }
-
List<Collection> _filterOutUncategorized(List<Collection> collections) {
return CollectionSortUtil.filterAndSortCollections(collections);
}
@@ -652,7 +649,7 @@ class _HomePageState extends UploaderPageState<HomePage>
backgroundColor: componentColors.backgroundBase,
child: _settingsPage,
),
- drawerEnableOpenDragGesture: true,
+ drawerEnableOpenDragGesture: false,
onDrawerChanged: (isOpened) {
_isSettingsOpen = isOpened;
if (isOpened) {
@@ -671,7 +668,19 @@ class _HomePageState extends UploaderPageState<HomePage>
),
body: Stack(
children: [
- _buildBody(),
+ GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onHorizontalDragStart: (_) => _drawerDragDx = 0,
+ onHorizontalDragUpdate: (details) =>
+ _drawerDragDx += details.delta.dx,
+ onHorizontalDragEnd: (details) {
+ final velocity = details.primaryVelocity ?? 0;
+ if (_drawerDragDx > 60 || velocity > 150) {
+ scaffoldKey.currentState?.openDrawer();
+ }
+ },
+ child: _buildBody(),
+ ),
ValueListenableBuilder<List<EnteFile>>(
valueListenable: _displayedFilesNotifier,
builder: (context, displayedFiles, _) {
@@ -749,15 +758,6 @@ class _HomePageState extends UploaderPageState<HomePage>
),
);
}
- if (_displayedCollections.isEmpty) {
- return Center(
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: HomeEmptyStateWidget(isLoading: _isSyncing),
- ),
- );
- }
-
return LayoutBuilder(
builder: (context, constraints) {
final scrollBottomPadding = MediaQuery.of(context).padding.bottom + 120;
@@ -782,7 +782,7 @@ class _HomePageState extends UploaderPageState<HomePage>
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RecentsSectionWidget(
- collections: _filterOutUncategorized(_collections),
+ collections: _collections,
recentFiles: _recentFiles,
selectedFiles: _selectedFiles,
displayedFilesNotifier: _displayedFilesNotifier,
diff --git a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index 0608be493a..025d6529d3 100644
--- a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -620,8 +620,9 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
'Opening add-to dialog for ${ownedFiles.length} file(s); fetching collections.',
);
- final allCollections = await CollectionService.instance
- .getCollectionsForUI();
+ final allCollections = await CollectionService.instance.getCollectionsForUI(
+ includeUncategorized: true,
+ );
final dedupedCollections = uniqueCollectionsById(allCollections);
_logger.info(
'Presenting ${dedupedCollections.length} unique collection option(s) '
@@ -827,8 +828,9 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
Future<void> _restoreFiles(BuildContext context, List<EnteFile> files) async {
_logger.info('Opening restore dialog for ${files.length} file(s)');
- final allCollections = await CollectionService.instance
- .getCollectionsForUI();
+ final allCollections = await CollectionService.instance.getCollectionsForUI(
+ includeUncategorized: true,
+ );
final dedupedCollections = uniqueCollectionsById(allCollections);
final result = await showAddToCollectionSheet(
diff --git a/mobile/apps/locker/lib/utils/file_actions.dart b/mobile/apps/locker/lib/utils/file_actions.dart
index 2d0350241d..1ab1a4d9fa 100644
--- a/mobile/apps/locker/lib/utils/file_actions.dart
+++ b/mobile/apps/locker/lib/utils/file_actions.dart
@@ -49,7 +49,7 @@ class FileActions {
_logger.info('Opening edit dialog for file ${file.uploadedFileID}');
final editableCollections = await CollectionService.instance
- .getCollectionsForUI();
+ .getCollectionsForUI(includeUncategorized: true);
final currentCollections = await CollectionService.instance
.getCollectionsForFile(file);