Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update edit dialog

vishnukvmde9812a90c122
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arb
index a2a5dccec6..64cfad380d 100644
--- a/mobile/apps/locker/lib/l10n/app_en.arb
+++ b/mobile/apps/locker/lib/l10n/app_en.arb
@@ -13,8 +13,8 @@
"untitled": "Untitled",
"edit": "Edit",
"delete": "Delete",
- "noFilesFound": "No files here",
- "addFiles": "Add files",
+ "noFilesFound": "No items here",
+ "addFiles": "Add items",
"name": "Name",
"date": "Date",
"pleaseWait": "Please wait...",
@@ -132,10 +132,10 @@
},
"pleaseSelectAtLeastOneCollection": "Please select at least one collection",
"unknownItemType": "Unknown item type",
- "fileDeletedSuccessfully": "File deleted successfully",
- "failedToDeleteFile": "Failed to delete file: {error}",
+ "fileDeletedSuccessfully": "Item deleted successfully",
+ "failedToDeleteFile": "Failed to delete item: {error}",
"@failedToDeleteFile": {
- "description": "Error message when file deletion fails",
+ "description": "Error message when item deletion fails",
"placeholders": {
"error": {
"type": "String",
@@ -143,10 +143,10 @@
}
}
},
- "fileUpdatedSuccessfully": "File updated successfully!",
- "failedToUpdateFile": "Failed to update file: {error}",
+ "fileUpdatedSuccessfully": "Item updated successfully!",
+ "failedToUpdateFile": "Failed to update item: {error}",
"@failedToUpdateFile": {
- "description": "Error message when file update fails",
+ "description": "Error message when item update fails",
"placeholders": {
"error": {
"type": "String",
@@ -654,6 +654,8 @@
"addToCollection": "Add to collection",
"newCollection": "New collection",
"title": "Title",
+ "editItem": "Edit item",
+ "enterNewTitle": "Enter a new title",
"backToView": "Back to view",
"back": "Back",
"failedToLoadCollections": "Failed to load collections: {error}",
diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dart
index 9ebba71116..de4fde51e2 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart
@@ -181,13 +181,13 @@ abstract class AppLocalizations {
/// No description provided for @noFilesFound.
///
/// In en, this message translates to:
- /// **'No files here'**
+ /// **'No items here'**
String get noFilesFound;
/// No description provided for @addFiles.
///
/// In en, this message translates to:
- /// **'Add files'**
+ /// **'Add items'**
String get addFiles;
/// No description provided for @name.
@@ -355,25 +355,25 @@ abstract class AppLocalizations {
/// No description provided for @fileDeletedSuccessfully.
///
/// In en, this message translates to:
- /// **'File deleted successfully'**
+ /// **'Item deleted successfully'**
String get fileDeletedSuccessfully;
- /// Error message when file deletion fails
+ /// Error message when item deletion fails
///
/// In en, this message translates to:
- /// **'Failed to delete file: {error}'**
+ /// **'Failed to delete item: {error}'**
String failedToDeleteFile(String error);
/// No description provided for @fileUpdatedSuccessfully.
///
/// In en, this message translates to:
- /// **'File updated successfully!'**
+ /// **'Item updated successfully!'**
String get fileUpdatedSuccessfully;
- /// Error message when file update fails
+ /// Error message when item update fails
///
/// In en, this message translates to:
- /// **'Failed to update file: {error}'**
+ /// **'Failed to update item: {error}'**
String failedToUpdateFile(String error);
/// No description provided for @noChangesWereMade.
@@ -2140,6 +2140,18 @@ abstract class AppLocalizations {
/// **'Title'**
String get title;
+ /// No description provided for @editItem.
+ ///
+ /// In en, this message translates to:
+ /// **'Edit item'**
+ String get editItem;
+
+ /// No description provided for @enterNewTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter a new title'**
+ String get enterNewTitle;
+
/// No description provided for @backToView.
///
/// In en, this message translates to:
diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
index d747a013d3..7297c92977 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
@@ -53,10 +53,10 @@ class AppLocalizationsEn extends AppLocalizations {
String get delete => 'Delete';
@override
- String get noFilesFound => 'No files here';
+ String get noFilesFound => 'No items here';
@override
- String get addFiles => 'Add files';
+ String get addFiles => 'Add items';
@override
String get name => 'Name';
@@ -161,19 +161,19 @@ class AppLocalizationsEn extends AppLocalizations {
String get unknownItemType => 'Unknown item type';
@override
- String get fileDeletedSuccessfully => 'File deleted successfully';
+ String get fileDeletedSuccessfully => 'Item deleted successfully';
@override
String failedToDeleteFile(String error) {
- return 'Failed to delete file: $error';
+ return 'Failed to delete item: $error';
}
@override
- String get fileUpdatedSuccessfully => 'File updated successfully!';
+ String get fileUpdatedSuccessfully => 'Item updated successfully!';
@override
String failedToUpdateFile(String error) {
- return 'Failed to update file: $error';
+ return 'Failed to update item: $error';
}
@override
@@ -1208,6 +1208,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get title => 'Title';
+ @override
+ String get editItem => 'Edit item';
+
+ @override
+ String get enterNewTitle => 'Enter a new title';
+
@override
String get backToView => 'Back to view';
diff --git a/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart b/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart
index 3e1f54329d..cd102594a1 100644
--- a/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart
+++ b/mobile/apps/locker/lib/ui/components/file_edit_dialog.dart
@@ -2,9 +2,11 @@ import "package:ente_ui/components/buttons/gradient_button.dart";
import 'package:ente_ui/theme/ente_theme.dart';
import 'package:flutter/material.dart';
import 'package:locker/l10n/l10n.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_selection_widget.dart';
+import 'package:locker/ui/components/form_text_input_widget.dart';
import 'package:locker/utils/collection_list_util.dart';
import 'package:locker/utils/snack_bar_utils.dart';
@@ -46,11 +48,39 @@ class _FileEditDialogState extends State<FileEditDialog> {
void initState() {
super.initState();
- _availableCollections = uniqueCollectionsById(widget.collections);
+ _availableCollections = _filterCollections(widget.collections);
_titleController.text = widget.file.displayName;
_captionController.text = widget.file.caption ?? '';
+
+ _initializeSelections();
+ }
+
+ Future<void> _initializeSelections() async {
+ try {
+ final existingCollections =
+ await CollectionService.instance.getCollectionsForFile(widget.file);
+
+ if (!mounted) {
+ return;
+ }
+
+ setState(() {
+ _selectedCollectionIds
+ ..clear()
+ ..addAll(
+ existingCollections
+ .where(
+ (collection) =>
+ collection.type != CollectionType.uncategorized,
+ )
+ .map((collection) => collection.id),
+ );
+ });
+ } catch (_) {
+ // Ignore failures; selections will remain empty.
+ }
}
@override
@@ -71,10 +101,20 @@ class _FileEditDialogState extends State<FileEditDialog> {
void _onCollectionsUpdated(List<Collection> updatedCollections) {
setState(() {
- _availableCollections = uniqueCollectionsById(updatedCollections);
+ _availableCollections = _filterCollections(updatedCollections);
+ _selectedCollectionIds
+ .removeWhere((id) => !_availableCollections.any((c) => c.id == id));
});
}
+ List<Collection> _filterCollections(List<Collection> source) {
+ final filtered = uniqueCollectionsById(source)
+ ..removeWhere(
+ (collection) => collection.type == CollectionType.uncategorized,
+ );
+ return filtered;
+ }
+
Future<void> _onCancel() async {
Navigator.of(context).pop();
}
@@ -101,10 +141,6 @@ class _FileEditDialogState extends State<FileEditDialog> {
Navigator.of(context).pop(result);
}
- String get _fileName {
- return widget.file.displayName;
- }
-
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
@@ -137,18 +173,9 @@ class _FileEditDialogState extends State<FileEditDialog> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Rename your document",
+ context.l10n.editItem,
style: textTheme.largeBold,
),
- const SizedBox(height: 4),
- Text(
- _fileName,
- style: textTheme.small.copyWith(
- color: colorScheme.textMuted,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
],
),
),
@@ -169,36 +196,13 @@ class _FileEditDialogState extends State<FileEditDialog> {
),
],
),
- const SizedBox(height: 20),
- TextField(
+ const SizedBox(height: 24),
+ FormTextInputWidget(
controller: _titleController,
- decoration: InputDecoration(
- hintText: "Enter a new name for your document",
- hintStyle: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- filled: true,
- fillColor: colorScheme.fillFaint,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 16,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(8),
- borderSide: BorderSide.none,
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(8),
- borderSide: BorderSide(
- color: colorScheme.strokeFaint,
- ),
- ),
- counterText: "",
- ),
+ labelText: context.l10n.title,
+ hintText: context.l10n.enterNewTitle,
maxLength: 200,
- style: textTheme.body.copyWith(
- color: colorScheme.textBase,
- ),
+ shouldUseTextInputWidget: false,
),
const SizedBox(height: 24),
CollectionSelectionWidget(
@@ -207,8 +211,10 @@ class _FileEditDialogState extends State<FileEditDialog> {
onToggleCollection: _toggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
titleWidget: Text(
- "Add to collection",
- style: textTheme.largeBold,
+ context.l10n.collections,
+ style: textTheme.body.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
),
const SizedBox(height: 28),