Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][locker] Fix linter warnings

Neeraj Gupta99a0dd600017
diff --git a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
index ce58eb34e7..799346bf2b 100644
--- a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
+++ b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
@@ -240,7 +240,7 @@ class FileUploader {
await _tryToUpload(file, collection, forcedUpload).timeout(
kFileUploadTimeout,
onTimeout: () {
- final message = "Upload timed out for file";
+ const message = "Upload timed out for file";
_logger.warning(message);
throw TimeoutException(message);
},
@@ -408,10 +408,10 @@ class FileUploader {
final encryptedMetadataResult = await CryptoUtil.encryptData(
utf8.encode(jsonEncode(enteFile.metadata)),
- fileAttributes.key!,
+ fileAttributes.key,
);
final fileDecryptionHeader =
- CryptoUtil.bin2base64(fileAttributes.header!);
+ CryptoUtil.bin2base64(fileAttributes.header);
final thumbnailDecryptionHeader =
CryptoUtil.bin2base64(encryptedThumbnailData.header!);
final encryptedMetadata = CryptoUtil.bin2base64(
@@ -420,7 +420,7 @@ class FileUploader {
final metadataDecryptionHeader =
CryptoUtil.bin2base64(encryptedMetadataResult.header!);
final encryptedFileKeyData = CryptoUtil.encryptSync(
- fileAttributes.key!,
+ fileAttributes.key,
CryptoHelper.instance.getCollectionKey(collection),
);
final encryptedKey =
@@ -434,7 +434,7 @@ class FileUploader {
pubMetadataRequest = await getPubMetadataRequest(
enteFile,
pubMetadata,
- fileAttributes.key!,
+ fileAttributes.key,
);
}
final remoteFile = await _uploadFile(
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index 6e70c3723f..c209c2b814 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -219,7 +219,6 @@ class _HomePageState extends UploaderPageState<HomePage>
final _selectedFiles = SelectedFiles();
final _scrollController = ScrollController();
bool _isLoading = true;
- bool _hasCompletedInitialLoad = false;
bool _isSettingsOpen = false;
List<Collection> _collections = [];
@@ -505,18 +504,12 @@ class _HomePageState extends UploaderPageState<HomePage>
final sortedCollections =
CollectionSortUtil.getSortedCollections(collections);
- // Only mark initial load complete when first sync has finished
- // This prevents empty state while sync is in progress
- final hasCompletedFirstSync =
- CollectionService.instance.hasCompletedFirstSync();
-
if (mounted) {
setState(() {
_collections = sortedCollections;
_filteredCollections = _filterOutUncategorized(sortedCollections);
_filteredFiles = _recentFiles;
_isLoading = false;
- _hasCompletedInitialLoad = hasCompletedFirstSync;
});
}
} catch (error) {
@@ -524,8 +517,6 @@ class _HomePageState extends UploaderPageState<HomePage>
setState(() {
_error = 'Error fetching collections: $error';
_isLoading = false;
- _hasCompletedInitialLoad =
- CollectionService.instance.hasCompletedFirstSync();
});
}
}
diff --git a/mobile/apps/locker/lib/ui/pages/trash_page.dart b/mobile/apps/locker/lib/ui/pages/trash_page.dart
index 222e8ada83..291af4829b 100644
--- a/mobile/apps/locker/lib/ui/pages/trash_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/trash_page.dart
@@ -7,16 +7,12 @@ import 'package:ente_ui/utils/dialog_util.dart';
import 'package:ente_ui/utils/toast_util.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/services/trash/models/trash_file.dart';
import 'package:locker/services/trash/trash_service.dart';
import "package:locker/ui/components/delete_confirmation_sheet.dart";
import "package:locker/ui/components/empty_state_widget.dart";
-import 'package:locker/ui/components/file_restore_dialog.dart';
import 'package:locker/ui/components/item_list_view.dart';
-import 'package:locker/utils/collection_list_util.dart';
class TrashPage extends StatefulWidget {
final List<TrashFile> trashFiles;
@@ -41,92 +37,6 @@ class _TrashPageState extends State<TrashPage> {
_sortedTrashFiles = List.from(widget.trashFiles);
}
- void _restoreFile(BuildContext context, EnteFile file) async {
- final collections = await CollectionService.instance.getCollectionsForUI();
-
- final availableCollections = uniqueCollectionsById(collections);
-
- if (availableCollections.isEmpty) {
- showToast(
- context,
- context.l10n.noCollectionsAvailableForRestore,
- );
- return;
- }
-
- final dialogResult = await showFileRestoreDialog(
- context,
- file: file,
- collections: availableCollections,
- );
-
- if (dialogResult != null && dialogResult.selectedCollections.isNotEmpty) {
- await _performRestore(
- context,
- file,
- dialogResult.selectedCollections.first,
- );
- }
- }
-
- void _deleteFilePermanently(BuildContext context, EnteFile file) {
- TrashService.instance.deleteFromTrash([file]).then((_) {
- setState(() {
- _sortedTrashFiles.remove(file);
- _allTrashFiles.remove(file);
- });
- showToast(
- context,
- context.l10n.deletedPermanently(file.displayName),
- );
- }).catchError((error) {
- showToast(
- context,
- context.l10n.failedToDeleteFile(error.toString()),
- );
- });
- }
-
- Future<void> _performRestore(
- BuildContext context,
- EnteFile file,
- Collection targetCollection,
- ) async {
- final dialog = createProgressDialog(
- context,
- context.l10n.restoring,
- isDismissible: false,
- );
-
- try {
- await dialog.show();
-
- await TrashService.instance.restore([file], targetCollection);
-
- setState(() {
- _sortedTrashFiles.remove(file);
- _allTrashFiles.remove(file);
- });
-
- await dialog.hide();
-
- showToast(
- context,
- context.l10n.restoredFileToCollection(
- file.displayName,
- targetCollection.name ?? 'Unnamed Collection',
- ),
- );
- } catch (error) {
- await dialog.hide();
-
- showToast(
- context,
- context.l10n.failedToRestoreFile(file.displayName, error.toString()),
- );
- }
- }
-
Future<void> _emptyTrash() async {
final result = await showDeleteConfirmationSheet(
context,
diff --git a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
index 970b4871f0..194eba968d 100644
--- a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
+++ b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
@@ -9,14 +9,12 @@ import "package:ente_ui/components/divider_widget.dart";
import "package:ente_ui/components/menu_item_widget_v2.dart";
import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
import "package:intl/intl.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/configuration.dart";
import "package:locker/ui/components/gradient_button.dart";
-import "package:locker/ui/components/popup_menu_item_widget.dart";
import "package:locker/ui/viewer/date/date_time_picker.dart";
import "package:locker/utils/collection_actions.dart";
@@ -52,12 +50,12 @@ class AddEmailSheet extends StatefulWidget {
}
class _AddEmailSheetState extends State<AddEmailSheet> {
- bool _shareLater = false;
+ final bool _shareLater = false;
String _email = "";
bool _emailIsValid = false;
DateTime? _scheduledDate;
TimeOfDay? _scheduledTime;
- CollectionParticipantRole _selectedRole = CollectionParticipantRole.viewer;
+ final CollectionParticipantRole _selectedRole = CollectionParticipantRole.viewer;
final _textController = TextEditingController();
final _textFieldFocusNode = FocusNode();
@@ -154,71 +152,6 @@ class _AddEmailSheetState extends State<AddEmailSheet> {
);
}
- Widget _buildRoleDropdown(colorScheme, textTheme) {
- return PopupMenuButton<CollectionParticipantRole>(
- onSelected: (role) {
- setState(() {
- _selectedRole = role;
- });
- },
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
- side: BorderSide(color: colorScheme.strokeFaint),
- ),
- padding: EdgeInsets.zero,
- menuPadding: EdgeInsets.zero,
- color: colorScheme.backdropBase,
- surfaceTintColor: Colors.transparent,
- elevation: 15,
- shadowColor: Colors.black.withValues(alpha: 0.08),
- constraints: const BoxConstraints(minWidth: 120),
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.backdropBase,
- borderRadius: BorderRadius.circular(10),
- ),
- padding: const EdgeInsets.all(8),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- HugeIcon(
- icon: _selectedRole == CollectionParticipantRole.viewer
- ? HugeIcons.strokeRoundedView
- : HugeIcons.strokeRoundedUserMultiple,
- color: colorScheme.textBase,
- size: 20,
- ),
- const SizedBox(width: 4),
- HugeIcon(
- icon: HugeIcons.strokeRoundedArrowDown01,
- color: colorScheme.textBase,
- size: 24,
- ),
- ],
- ),
- ),
- // TODO: Re-enable collaborator option when ready
- // For now, only viewer role is available in Locker
- itemBuilder: (context) => [
- PopupMenuItem<CollectionParticipantRole>(
- value: CollectionParticipantRole.viewer,
- height: 0,
- padding: EdgeInsets.zero,
- child: PopupMenuItemWidget(
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedView,
- color: colorScheme.textBase,
- size: 20,
- ),
- label: context.l10n.viewer,
- isFirst: true,
- isLast: true,
- ),
- ),
- ],
- );
- }
-
Widget _buildExistingContactsSection(colorScheme, textTheme) {
final filteredUsers = _suggestedUsers
.where(
@@ -374,57 +307,6 @@ class _AddEmailSheetState extends State<AddEmailSheet> {
);
}
- Widget _buildShareLaterCheckbox(colorScheme, textTheme) {
- return GestureDetector(
- onTap: () {
- setState(() {
- _shareLater = !_shareLater;
- if (!_shareLater) {
- _scheduledDate = null;
- _scheduledTime = null;
- }
- });
- },
- child: SizedBox(
- width: double.infinity,
- child: Wrap(
- crossAxisAlignment: WrapCrossAlignment.center,
- spacing: 12,
- runSpacing: 8,
- children: [
- Container(
- width: 18,
- height: 18,
- decoration: BoxDecoration(
- border: Border.all(
- color: _shareLater
- ? colorScheme.primary700
- : colorScheme.strokeMuted,
- width: 2,
- ),
- borderRadius: BorderRadius.circular(6),
- color:
- _shareLater ? colorScheme.primary700 : Colors.transparent,
- ),
- alignment: Alignment.center,
- child: _shareLater
- ? const Icon(
- Icons.check,
- size: 12,
- color: Colors.white,
- )
- : null,
- ),
- Text(
- context.l10n.shareLater,
- style: textTheme.small,
- ),
- ],
- ),
- ),
- );
- }
-
Widget _buildScheduleDateTimeRow(colorScheme, textTheme) {
final dateText = _scheduledDate != null
? DateFormat("dd/MM/yy").format(_scheduledDate!)
diff --git a/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart
index b585835ae0..1006bec4d3 100644
--- a/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart
+++ b/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart
@@ -282,30 +282,6 @@ class _AdvancedSharingBottomSheetState
);
}
- Future<void> _updateUrlSettings(
- BuildContext context,
- Map<String, dynamic> prop, {
- bool showProgressDialog = true,
- }) async {
- final dialog = showProgressDialog
- ? createProgressDialog(context, context.l10n.pleaseWait)
- : null;
- await dialog?.show();
- try {
- await CollectionApiClient.instance
- .updateShareUrl(widget.collection!, prop);
- await dialog?.hide();
- showShortToast(context, "Collection updated");
- if (mounted) {
- setState(() {});
- }
- } catch (e) {
- await dialog?.hide();
- await showGenericErrorDialog(context: context, error: e);
- rethrow;
- }
- }
-
Future<void> _createPublicLink() async {
final success = await CollectionActions.enableUrl(
context,