Skip to content

armgit / ente

Public Imported from GitHub
0

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

More UI changes

AmanRajSinghMourya9aaf3a2e235c
diff --git a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
index 0b7fcee322..227b139f39 100644
--- a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
@@ -8,6 +8,7 @@ import "package:locker/services/collections/models/collection.dart";
import "package:locker/services/collections/models/collection_view_type.dart";
import "package:locker/services/configuration.dart";
import "package:locker/ui/components/item_list_view.dart";
+import "package:locker/ui/components/menu_item_widget.dart";
import "package:locker/utils/collection_actions.dart";
class CollectionPopupMenuWidget extends StatelessWidget {
@@ -24,12 +25,21 @@ class CollectionPopupMenuWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+
return PopupMenuButton<String>(
onSelected: (value) => _handleMenuAction(context, value),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(16),
+ side: BorderSide(color: colorScheme.strokeFaint),
+ ),
+ color: colorScheme.backgroundElevated,
+ elevation: 15,
+ shadowColor: Colors.black.withValues(alpha: 0.08),
child: child ??
HugeIcon(
icon: HugeIcons.strokeRoundedMoreVertical,
- color: getEnteColorScheme(context).iconColor,
+ color: colorScheme.iconColor,
),
itemBuilder: (BuildContext context) {
return _buildPopupMenuItems(context);
@@ -38,24 +48,30 @@ class CollectionPopupMenuWidget extends StatelessWidget {
}
List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+
if (overflowActions != null && overflowActions!.isNotEmpty) {
- return overflowActions!
- .map(
- (action) => PopupMenuItem<String>(
- value: action.id,
- child: Row(
- children: [
- Icon(
- action.icon,
- size: 16,
- ),
- const SizedBox(width: 8),
- Text(action.label),
- ],
+ final items = <PopupMenuItem<String>>[];
+ for (int i = 0; i < overflowActions!.length; i++) {
+ final action = overflowActions![i];
+ items.add(
+ PopupMenuItem<String>(
+ value: action.id,
+ padding: EdgeInsets.zero,
+ child: MenuItemWidget(
+ icon: Icon(
+ action.icon,
+ color: colorScheme.iconColor,
+ size: 20,
),
+ label: action.label,
+ isFirst: i == 0,
+ isLast: i == overflowActions!.length - 1,
),
- )
- .toList();
+ ),
+ );
+ }
+ return items;
}
final collectionViewType = getCollectionViewType(
@@ -63,54 +79,68 @@ class CollectionPopupMenuWidget extends StatelessWidget {
Configuration.instance.getUserID()!,
);
- return [
- if (collectionViewType == CollectionViewType.ownedCollection ||
- collectionViewType == CollectionViewType.hiddenOwnedCollection ||
- collectionViewType == CollectionViewType.quickLink)
+ final items = <PopupMenuItem<String>>[];
+
+ if (collectionViewType == CollectionViewType.ownedCollection ||
+ collectionViewType == CollectionViewType.hiddenOwnedCollection ||
+ collectionViewType == CollectionViewType.quickLink) {
+ items.add(
PopupMenuItem<String>(
value: 'edit',
- child: Row(
- children: [
- const HugeIcon(
- icon: HugeIcons.strokeRoundedEdit02,
- size: 16,
- ),
- const SizedBox(width: 8),
- Text(context.l10n.edit),
- ],
+ padding: EdgeInsets.zero,
+ child: MenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedEdit02,
+ color: colorScheme.iconColor,
+ size: 20,
+ ),
+ label: context.l10n.edit,
+ isFirst: true,
+ isLast: false,
),
),
- if (collectionViewType == CollectionViewType.ownedCollection ||
- collectionViewType == CollectionViewType.hiddenOwnedCollection ||
- collectionViewType == CollectionViewType.quickLink)
+ );
+
+ items.add(
PopupMenuItem<String>(
value: 'delete',
- child: Row(
- children: [
- const HugeIcon(
- icon: HugeIcons.strokeRoundedDelete01,
- size: 16,
- ),
- const SizedBox(width: 8),
- Text(context.l10n.delete),
- ],
+ padding: EdgeInsets.zero,
+ child: MenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedDelete01,
+ color: colorScheme.warning500,
+ size: 20,
+ ),
+ label: context.l10n.delete,
+ isFirst: false,
+ isLast: true,
+ isDelete: true,
),
),
- if (collectionViewType == CollectionViewType.sharedCollection)
+ );
+ }
+
+ if (collectionViewType == CollectionViewType.sharedCollection) {
+ items.add(
PopupMenuItem<String>(
value: 'leave_collection',
- child: Row(
- children: [
- const HugeIcon(
- icon: HugeIcons.strokeRoundedLogout02,
- size: 16,
- ),
- const SizedBox(width: 8),
- Text(context.l10n.leaveCollection),
- ],
+ padding: EdgeInsets.zero,
+ child: MenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedLogout02,
+ color: colorScheme.warning500,
+ size: 20,
+ ),
+ label: context.l10n.leaveCollection,
+ isFirst: true,
+ isLast: true,
+ isDelete: true,
),
),
- ];
+ );
+ }
+
+ return items;
}
void _handleMenuAction(BuildContext context, String action) {
diff --git a/mobile/apps/locker/lib/ui/components/input_dialog_sheet.dart b/mobile/apps/locker/lib/ui/components/input_dialog_sheet.dart
new file mode 100644
index 0000000000..c9becc42fe
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/input_dialog_sheet.dart
@@ -0,0 +1,188 @@
+import "package:ente_base/typedefs.dart";
+import "package:ente_ui/components/buttons/gradient_button.dart";
+import "package:ente_ui/theme/ente_theme.dart";
+import "package:flutter/material.dart";
+
+class InputDialogSheet extends StatefulWidget {
+ final String title;
+ final String hintText;
+ final String submitButtonLabel;
+ final FutureVoidCallbackParamStr onSubmit;
+ final String? initialValue;
+ final TextCapitalization textCapitalization;
+ final int? maxLength;
+
+ const InputDialogSheet({
+ super.key,
+ required this.title,
+ required this.hintText,
+ required this.submitButtonLabel,
+ required this.onSubmit,
+ this.initialValue,
+ this.textCapitalization = TextCapitalization.words,
+ this.maxLength = 200,
+ });
+
+ @override
+ State<InputDialogSheet> createState() => _InputDialogSheetState();
+}
+
+class _InputDialogSheetState extends State<InputDialogSheet> {
+ late final TextEditingController _textController;
+ bool _isSubmitting = false;
+
+ @override
+ void initState() {
+ super.initState();
+ _textController = TextEditingController(text: widget.initialValue ?? '');
+ }
+
+ @override
+ void dispose() {
+ _textController.dispose();
+ super.dispose();
+ }
+
+ Future<void> _onSubmit() async {
+ final text = _textController.text.trim();
+
+ if (text.isEmpty) {
+ Navigator.of(context).pop();
+ return;
+ }
+
+ setState(() {
+ _isSubmitting = true;
+ });
+
+ try {
+ await widget.onSubmit(text);
+
+ if (mounted) {
+ Navigator.of(context).pop();
+ }
+ } catch (e) {
+ if (mounted) {
+ setState(() {
+ _isSubmitting = false;
+ });
+
+ Navigator.of(context).pop(e);
+ }
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ return Container(
+ width: 400,
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated,
+ borderRadius: BorderRadius.circular(24),
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 24),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 24),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ widget.title,
+ style: textTheme.largeBold,
+ ),
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ padding: const EdgeInsets.all(4),
+ child: Icon(
+ Icons.close,
+ color: colorScheme.iconColor,
+ size: 24,
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 24),
+ TextField(
+ controller: _textController,
+ autofocus: true,
+ textCapitalization: widget.textCapitalization,
+ maxLength: widget.maxLength,
+ decoration: InputDecoration(
+ hintText: widget.hintText,
+ 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: "",
+ ),
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
+ onSubmitted: (_) => _onSubmit(),
+ ),
+ const SizedBox(height: 36),
+ SizedBox(
+ width: double.infinity,
+ child: GradientButton(
+ onTap: _isSubmitting ? null : _onSubmit,
+ text: widget.submitButtonLabel,
+ ),
+ ),
+ const SizedBox(height: 24),
+ ],
+ ),
+ );
+ }
+}
+
+Future<dynamic> showInputDialogSheet(
+ BuildContext context, {
+ required String title,
+ required String hintText,
+ required String submitButtonLabel,
+ required FutureVoidCallbackParamStr onSubmit,
+ String? initialValue,
+ TextCapitalization textCapitalization = TextCapitalization.words,
+ int? maxLength = 200,
+}) async {
+ final result = await showDialog<dynamic>(
+ context: context,
+ builder: (context) => Dialog(
+ backgroundColor: Colors.transparent,
+ child: InputDialogSheet(
+ title: title,
+ hintText: hintText,
+ submitButtonLabel: submitButtonLabel,
+ onSubmit: onSubmit,
+ initialValue: initialValue,
+ textCapitalization: textCapitalization,
+ maxLength: maxLength,
+ ),
+ ),
+ );
+
+ return result;
+}
diff --git a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
index fab4fca494..905f865ed3 100644
--- a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
@@ -241,6 +241,7 @@ class _AllCollectionsPageState extends State<AllCollectionsPage> {
_allCollections.length.toString() + " items",
style: getEnteTextTheme(context).smallMuted,
),
+ const SizedBox(height: 20),
Flexible(
child: ItemListView(
collections: _sortedCollections,
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index ed9a4a87d7..5a41f5da8c 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -1,6 +1,8 @@
import 'dart:async';
import 'dart:io';
+// import "package:dotted_border/dotted_border.dart";
+import "package:dotted_border/dotted_border.dart";
import "package:ente_accounts/services/user_service.dart";
import 'package:ente_events/event_bus.dart';
import 'package:ente_ui/components/buttons/gradient_button.dart';
@@ -24,11 +26,9 @@ import 'package:locker/ui/components/recents_section_widget.dart';
import 'package:locker/ui/components/search_result_view.dart';
import 'package:locker/ui/mixins/search_mixin.dart';
import 'package:locker/ui/pages/all_collections_page.dart';
-import 'package:locker/ui/pages/collection_page.dart';
import 'package:locker/ui/pages/information_page.dart';
import "package:locker/ui/pages/settings_page.dart";
import 'package:locker/ui/pages/uploader_page.dart';
-import 'package:locker/utils/collection_actions.dart';
import 'package:locker/utils/collection_sort_util.dart';
import 'package:logging/logging.dart';
@@ -512,14 +512,6 @@ class _HomePageState extends UploaderPageState<HomePage>
_recentFiles = uniqueFiles;
}
- void _navigateToCollection(Collection collection) {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => CollectionPage(collection: collection),
- ),
- );
- }
-
void _handleSearchChange(String query) {
// Trigger search by activating search with the current query
activateSearchWithQuery(query);
@@ -641,46 +633,49 @@ class _HomePageState extends UploaderPageState<HomePage>
}
if (_displayedCollections.isEmpty) {
- return SingleChildScrollView(
- physics: const AlwaysScrollableScrollPhysics(),
- child: SizedBox(
- height: MediaQuery.of(context).size.height - 200,
- child: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Icon(
- Icons.folder_outlined,
- size: 64,
- color: Colors.grey,
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ return Center(
+ child: SingleChildScrollView(
+ physics: const AlwaysScrollableScrollPhysics(),
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: SizedBox(
+ width: double.infinity,
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(24),
+ ),
+ child: DottedBorder(
+ options: RoundedRectDottedBorderOptions(
+ strokeWidth: 2,
+ color: colorScheme.fillMuted,
+ dashPattern: const [6, 6],
+ radius: const Radius.circular(24),
+ padding: const EdgeInsets.all(48),
),
- const SizedBox(height: 16),
- Text(
- context.l10n.noCollectionsFound,
- style: getEnteTextTheme(context).large.copyWith(
- color: Colors.grey,
+ child: Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Image.asset(
+ 'assets/empty_state.png',
),
- ),
- const SizedBox(height: 8),
- Text(
- context.l10n.createYourFirstCollection,
- style: getEnteTextTheme(context).body.copyWith(
- color: Colors.grey,
+ const SizedBox(height: 16),
+ Text(
+ 'Upload a File',
+ style: textTheme.h3Bold,
),
- ),
- const SizedBox(height: 24),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 40),
- child: GradientButton(
- onTap: _createCollection,
- text: context.l10n.createCollection,
- hugeIcon: const HugeIcon(
- icon: HugeIcons.strokeRoundedPlusSign,
- ),
- paddingValue: 8.0,
+ const SizedBox(height: 4),
+ Text(
+ 'Click here to upload',
+ style: textTheme.small,
+ ),
+ ],
),
),
- ],
+ ),
),
),
),
@@ -773,15 +768,6 @@ class _HomePageState extends UploaderPageState<HomePage>
);
}
- Future<void> _createCollection() async {
- final createdCollection = await CollectionActions.createCollection(context);
-
- if (createdCollection != null) {
- await _loadCollections();
- _navigateToCollection(createdCollection);
- }
- }
-
Widget _buildMultiOptionFab() {
return ValueListenableBuilder<bool>(
valueListenable: _isFabOpen,
diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dart
index e2b9434d22..e185b837fa 100644
--- a/mobile/apps/locker/lib/utils/collection_actions.dart
+++ b/mobile/apps/locker/lib/utils/collection_actions.dart
@@ -20,6 +20,7 @@ import "package:locker/services/collections/collections_api_client.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/input_dialog_sheet.dart";
import 'package:locker/utils/snack_bar_utils.dart';
import 'package:logging/logging.dart';
@@ -27,25 +28,19 @@ import 'package:logging/logging.dart';
class CollectionActions {
static final _logger = Logger('CollectionActions');
- /// Shows a dialog to create a new collection
+ /// Shows a dialog sheet to create a new collection
static Future<Collection?> createCollection(
BuildContext context, {
bool autoSelectInParent = false,
}) async {
Collection? createdCollection;
- final nameSuggestion =
- await CollectionService.instance.getRandomUnusedCollectionName();
-
- final result = await showTextInputDialog(
+ final result = await showInputDialogSheet(
context,
title: context.l10n.createNewCollection,
+ hintText: context.l10n.documentsHint,
submitButtonLabel: context.l10n.create,
- hintText: nameSuggestion,
- alwaysShowSuccessState: true,
- textCapitalization: TextCapitalization.words,
onSubmit: (String text) async {
- // indicates user cancelled the creation request
if (text.trim().isEmpty) {
return;
}