Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor: standardize collection title handling and add CollectionChip component

AmanRajSinghMourya8dfabb02d0aa
diff --git a/mobile/apps/locker/lib/ui/components/add_to_collection_sheet.dart b/mobile/apps/locker/lib/ui/components/add_to_collection_sheet.dart
index 6182bb3b93..246be8d4b9 100644
--- a/mobile/apps/locker/lib/ui/components/add_to_collection_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/add_to_collection_sheet.dart
@@ -86,6 +86,7 @@ class _AddToCollectionDialogState extends State<AddToCollectionDialog> {
selectedCollectionIds: _selectedCollectionIds,
onToggleCollection: _toggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
+ title: context.l10n.collections,
),
const SizedBox(height: 28),
SizedBox(
diff --git a/mobile/apps/locker/lib/ui/components/collection_chip.dart b/mobile/apps/locker/lib/ui/components/collection_chip.dart
new file mode 100644
index 0000000000..ee884219c5
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/collection_chip.dart
@@ -0,0 +1,51 @@
+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_selection_widget.dart b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
index b792bf9fb4..975610ef1e 100644
--- a/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_selection_widget.dart
@@ -5,6 +5,7 @@ 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';
@@ -13,7 +14,8 @@ class CollectionSelectionWidget extends StatefulWidget {
final Set<int> selectedCollectionIds;
final Function(int) onToggleCollection;
final Function(List<Collection>)? onCollectionsUpdated;
- final Widget? titleWidget;
+
+ final String title;
final bool singleSelectionMode;
const CollectionSelectionWidget({
@@ -22,7 +24,7 @@ class CollectionSelectionWidget extends StatefulWidget {
required this.selectedCollectionIds,
required this.onToggleCollection,
this.onCollectionsUpdated,
- this.titleWidget,
+ required this.title,
this.singleSelectionMode = false,
});
@@ -34,6 +36,13 @@ class CollectionSelectionWidget extends StatefulWidget {
class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
List<Collection> _availableCollections = [];
Collection? _uncategorizedCollection;
+ final ScrollController _scrollController = ScrollController();
+
+ @override
+ void dispose() {
+ _scrollController.dispose();
+ super.dispose();
+ }
@override
void initState() {
@@ -102,212 +111,99 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
final textTheme = getEnteTextTheme(context);
final containsUncategorized = _uncategorizedCollection != null;
- Widget? headerWidget = widget.titleWidget;
- if (headerWidget == null) {
- headerWidget = Text(
- context.l10n.collections,
- style: textTheme.body,
- );
- }
+ final chips = <Widget>[];
- bool _isHiddenHeader(Widget widget) {
- if (widget is SizedBox) {
- final isZeroWidth = widget.width != null && widget.width == 0;
- final isZeroHeight = widget.height != null && widget.height == 0;
- final noChild = widget.child == null;
- if ((isZeroWidth || isZeroHeight) && noChild) {
- return true;
- }
- }
- return false;
- }
-
- final bool hasVisibleHeader = !_isHiddenHeader(headerWidget);
-
- final chipItems = <_ChipItem>[];
if (containsUncategorized) {
- chipItems.add(
- _ChipItem(
- widget: _buildUncategorizedChip(
- name: context.l10n.uncategorized,
- isSelected: widget.selectedCollectionIds
- .contains(_uncategorizedCollection?.id ?? -1),
- onTap: () {
- if (_uncategorizedCollection != null) {
- _onCollectionTap(_uncategorizedCollection!.id);
- }
- },
- colorScheme: colorScheme,
- textTheme: textTheme,
- ),
- weight: context.l10n.uncategorized.length,
+ chips.add(
+ CollectionChip(
+ label: context.l10n.uncategorized,
+ isSelected: widget.selectedCollectionIds
+ .contains(_uncategorizedCollection?.id ?? -1),
+ onTap: () {
+ if (_uncategorizedCollection != null) {
+ _onCollectionTap(_uncategorizedCollection!.id);
+ }
+ },
+ colorScheme: colorScheme,
+ textTheme: textTheme,
),
);
}
- for (final collection in _availableCollections) {
- final collectionName =
- collection.displayName ?? context.l10n.unnamedCollection;
- chipItems.add(
- _ChipItem(
- widget: _buildCollectionChip(
- collection: collection,
- isSelected: widget.selectedCollectionIds.contains(collection.id),
- onTap: () => _onCollectionTap(collection.id),
- colorScheme: colorScheme,
- textTheme: textTheme,
- ),
- weight: collectionName.length,
- ),
- );
- }
-
- final newCollectionChip = _ChipItem(
- widget: _buildNewCollectionChip(
+ chips.add(
+ _buildNewCollectionChip(
colorScheme: colorScheme,
textTheme: textTheme,
),
- weight: context.l10n.collectionLabel.length,
);
- final topRowChips = <Widget>[];
- final bottomRowChips = <Widget>[];
- var topWeight = 0;
- var bottomWeight = newCollectionChip.weight;
-
- for (final item in chipItems) {
- if (topWeight <= bottomWeight) {
- topRowChips.add(item.widget);
- topWeight += item.weight;
- } else {
- bottomRowChips.add(item.widget);
- bottomWeight += item.weight;
- }
- }
-
- bottomRowChips.add(newCollectionChip.widget);
-
- List<Widget> _buildChipRow(List<Widget> rowChips) {
- final children = <Widget>[];
- for (var i = 0; i < rowChips.length; i++) {
- if (i != 0) {
- children.add(const SizedBox(width: 8));
- }
- children.add(rowChips[i]);
- }
- return children;
+ for (final collection in _availableCollections) {
+ final collectionName =
+ collection.displayName ?? context.l10n.unnamedCollection;
+ chips.add(
+ CollectionChip(
+ label: collectionName,
+ isSelected: widget.selectedCollectionIds.contains(collection.id),
+ onTap: () => _onCollectionTap(collection.id),
+ colorScheme: colorScheme,
+ textTheme: textTheme,
+ ),
+ );
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- if (hasVisibleHeader) ...[
- headerWidget,
+ if (widget.title.isNotEmpty) ...[
+ Text(
+ widget.title,
+ style: textTheme.body,
+ ),
const SizedBox(height: 12),
],
- SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(children: _buildChipRow(topRowChips)),
- if (bottomRowChips.isNotEmpty) ...[
- const SizedBox(height: 12),
- Row(children: _buildChipRow(bottomRowChips)),
- ],
- ],
+ ClipRRect(
+ borderRadius: BorderRadius.circular(16),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxHeight: 168),
+ child: Scrollbar(
+ controller: _scrollController,
+ thumbVisibility: true,
+ radius: const Radius.circular(4),
+ child: SingleChildScrollView(
+ controller: _scrollController,
+ padding: const EdgeInsets.only(right: 12),
+ child: Wrap(
+ spacing: 8,
+ runSpacing: 12,
+ children: chips,
+ ),
+ ),
+ ),
),
),
],
);
}
- Widget _buildCollectionChip({
- required Collection collection,
- required bool isSelected,
- required VoidCallback onTap,
- required colorScheme,
- required textTheme,
- }) {
- final collectionName =
- collection.displayName ?? context.l10n.unnamedCollection;
-
- return GestureDetector(
- onTap: onTap,
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
- decoration: BoxDecoration(
- color: isSelected
- ? colorScheme.primary700.withValues(alpha: 0.2)
- : colorScheme.fillFaint,
- borderRadius: const BorderRadius.all(Radius.circular(24.0)),
- border: Border.all(
- color: isSelected ? colorScheme.primary700 : Colors.transparent,
- width: 1,
- ),
- ),
- child: Text(
- collectionName,
- style: textTheme.small.copyWith(
- color: isSelected ? colorScheme.primary700 : colorScheme.textBase,
- ),
- ),
- ),
- );
- }
-
- Widget _buildUncategorizedChip({
- required String name,
- required bool isSelected,
- required VoidCallback onTap,
+ Widget _buildNewCollectionChip({
required colorScheme,
required textTheme,
}) {
return GestureDetector(
- onTap: onTap,
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
- decoration: BoxDecoration(
- color: isSelected
- ? colorScheme.primary700.withValues(alpha: 0.2)
- : colorScheme.fillFaint,
- borderRadius: const BorderRadius.all(Radius.circular(24.0)),
- border: Border.all(
- color: isSelected ? colorScheme.primary700 : Colors.transparent,
- width: 1,
- ),
- ),
- child: Text(
- name,
- style: textTheme.small.copyWith(
- color: isSelected ? colorScheme.primary700 : colorScheme.textBase,
- ),
+ onTap: () async {
+ await _createNewCollection();
+ },
+ child: DottedBorder(
+ options: const RoundedRectDottedBorderOptions(
+ strokeWidth: 1,
+ padding: EdgeInsets.zero,
+ color: Color(0xFF6B6B6B),
+ dashPattern: [5, 5],
+ radius: Radius.circular(16),
),
- ),
- );
- }
-
- Widget _buildNewCollectionChip({
- required colorScheme,
- required textTheme,
- }) {
- return Material(
- color: Colors.transparent,
- child: InkWell(
- borderRadius: const BorderRadius.all(Radius.circular(24)),
- onTap: () async {
- await _createNewCollection();
- },
- child: DottedBorder(
- options: const RoundedRectDottedBorderOptions(
- padding: EdgeInsets.symmetric(vertical: 14, horizontal: 16),
- strokeWidth: 1,
- color: Color(0xFF6B6B6B),
- dashPattern: [5, 5],
- radius: Radius.circular(24),
- ),
+ child: Container(
+ constraints: const BoxConstraints(minHeight: 42),
+ padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -319,9 +215,8 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
const SizedBox(width: 6),
Text(
context.l10n.collectionLabel,
- style: textTheme.body.copyWith(
+ style: textTheme.small.copyWith(
color: colorScheme.textMuted,
- fontWeight: FontWeight.w500,
),
),
],
@@ -333,10 +228,3 @@ class _CollectionSelectionWidgetState extends State<CollectionSelectionWidget> {
List<Collection> get availableCollections => _availableCollections;
}
-
-class _ChipItem {
- final Widget widget;
- final int weight;
-
- const _ChipItem({required this.widget, required this.weight});
-}
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 06b1c44bdb..e3c2f86b3c 100644
--- a/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/file_edit_sheet.dart
@@ -1,5 +1,4 @@
import 'package:ente_ui/components/base_bottom_sheet.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';
@@ -131,8 +130,6 @@ class _FileEditDialogState extends State<FileEditDialog> {
@override
Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
-
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -150,12 +147,7 @@ class _FileEditDialogState extends State<FileEditDialog> {
selectedCollectionIds: _selectedCollectionIds,
onToggleCollection: _toggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
- titleWidget: Text(
- context.l10n.collections,
- style: textTheme.body.copyWith(
- fontWeight: FontWeight.w600,
- ),
- ),
+ title: context.l10n.collections,
),
const SizedBox(height: 28),
SizedBox(
diff --git a/mobile/apps/locker/lib/ui/components/file_restore_sheet.dart b/mobile/apps/locker/lib/ui/components/file_restore_sheet.dart
index 3a42837495..aa3e0a012c 100644
--- a/mobile/apps/locker/lib/ui/components/file_restore_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/file_restore_sheet.dart
@@ -84,6 +84,7 @@ class _FileRestoreDialogState extends State<FileRestoreDialog> {
selectedCollectionIds: _selectedCollectionIds,
onToggleCollection: _toggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
+ title: context.l10n.collections,
singleSelectionMode: true,
),
const SizedBox(height: 28),
diff --git a/mobile/apps/locker/lib/ui/components/file_upload_sheet.dart b/mobile/apps/locker/lib/ui/components/file_upload_sheet.dart
index 58a30e3ba6..d74a1704e1 100644
--- a/mobile/apps/locker/lib/ui/components/file_upload_sheet.dart
+++ b/mobile/apps/locker/lib/ui/components/file_upload_sheet.dart
@@ -132,6 +132,7 @@ class _FileUploadDialogState extends State<FileUploadDialog> {
selectedCollectionIds: _selectedCollectionIds,
onToggleCollection: _toggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
+ title: context.l10n.collections,
),
const SizedBox(height: 16),
Text(
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 ac7e510c5f..e73c81d166 100644
--- a/mobile/apps/locker/lib/ui/pages/base_info_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/base_info_page.dart
@@ -147,8 +147,7 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>
selectedCollectionIds: _selectedCollectionIds,
onToggleCollection: _onToggleCollection,
onCollectionsUpdated: _onCollectionsUpdated,
- titleWidget:
- showCollectionSelectionTitle ? null : const SizedBox.shrink(),
+ title: showCollectionSelectionTitle ? context.l10n.collections : '',
),
],
),
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 d20daecf8d..db9ab35936 100644
--- a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart
+++ b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart
@@ -1,18 +1,16 @@
import 'dart:io';
-import "package:dotted_border/dotted_border.dart";
import "package:ente_ui/components/title_bar_title_widget.dart";
import "package:ente_ui/theme/colors.dart";
import 'package:ente_ui/theme/ente_theme.dart';
import "package:ente_ui/theme/text_style.dart";
import 'package:flutter/material.dart';
import "package:hugeicons/hugeicons.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_selection_widget.dart';
import 'package:locker/ui/components/file_upload_sheet.dart';
import "package:locker/ui/components/gradient_button.dart";
-import 'package:locker/utils/collection_actions.dart';
import "package:locker/utils/file_icon_utils.dart";
import 'package:path/path.dart' as path;
@@ -33,17 +31,19 @@ class FileUploadScreen extends StatefulWidget {
}
class _FileUploadScreenState extends State<FileUploadScreen> {
- late List<File> _files;
- final Set<Collection> _selectedCollections = {};
+ List<File> _files = [];
+ List<Collection> _availableCollections = [];
+ final Set<int> _selectedCollectionIds = {};
@override
void initState() {
super.initState();
_files = List.from(widget.files);
+ _availableCollections = List.from(widget.collections);
if (widget.selectedCollection != null &&
widget.selectedCollection!.type != CollectionType.uncategorized) {
- _selectedCollections.add(widget.selectedCollection!);
+ _selectedCollectionIds.add(widget.selectedCollection!.id);
}
}
@@ -52,6 +52,22 @@ class _FileUploadScreenState extends State<FileUploadScreen> {
super.dispose();
}
+ void _toggleCollection(int collectionId) {
+ setState(() {
+ if (_selectedCollectionIds.contains(collectionId)) {
+ _selectedCollectionIds.remove(collectionId);
+ } else {
+ _selectedCollectionIds.add(collectionId);
+ }
+ });
+ }
+
+ void _onCollectionsUpdated(List<Collection> updatedCollections) {
+ setState(() {
+ _availableCollections = updatedCollections;
+ });
+ }
+
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
@@ -66,134 +82,129 @@ class _FileUploadScreenState extends State<FileUploadScreen> {
elevation: 0,
),
backgroundColor: colorScheme.backgroundBase,
- body: Padding(
- padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 16),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TitleBarTitleWidget(
- title: context.l10n.uploadFiles,
- ),
- Text(
- context.l10n.filesSelected(_files.length),
- style: textTheme.smallMuted,
- ),
- ],
- ),
- GestureDetector(
- onTap: () {
- Navigator.pop(context);
- },
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(50),
- color: colorScheme.fillFaint,
- ),
- padding: const EdgeInsets.all(8),
- child: Icon(
- Icons.close,
- size: 24,
- color: colorScheme.textBase,
+ body: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 16),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TitleBarTitleWidget(
+ title: context.l10n.uploadFiles,
+ ),
+ Text(
+ context.l10n.filesSelected(_files.length),
+ style: textTheme.smallMuted,
+ ),
+ ],
+ ),
+ GestureDetector(
+ onTap: () {
+ Navigator.pop(context);
+ },
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(50),
+ color: colorScheme.fillFaint,
+ ),
+ padding: const EdgeInsets.all(8),
+ child: Icon(
+ Icons.close,
+ size: 24,
+ color: colorScheme.textBase,
+ ),
),
),
- ),
- ],
- ),
- const SizedBox(height: 24),
- Expanded(
- child: SingleChildScrollView(
- controller: ScrollController(),
- physics: const BouncingScrollPhysics(),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (_files.isNotEmpty) ...[
- Container(
- decoration: BoxDecoration(
- color: colorScheme.strokeFainter,
- borderRadius: BorderRadius.circular(24),
- ),
- padding: const EdgeInsets.all(12),
- child: Container(
- constraints: BoxConstraints(
- maxHeight:
- _files.length > 5 ? 360 : _files.length * 84.0,
+ ],
+ ),
+ const SizedBox(height: 16),
+ Expanded(
+ child: SingleChildScrollView(
+ controller: ScrollController(),
+ physics: const BouncingScrollPhysics(),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ if (_files.isNotEmpty) ...[
+ Container(
+ decoration: BoxDecoration(
+ color: colorScheme.strokeFainter,
+ borderRadius: BorderRadius.circular(24),
),
- child: ListView.separated(
- shrinkWrap: true,
- padding: EdgeInsets.zero,
- physics: _files.length > 5
- ? const BouncingScrollPhysics()
- : const NeverScrollableScrollPhysics(),
- itemCount: _files.length,
- separatorBuilder: (context, index) =>
- const SizedBox(height: 8),
- itemBuilder: (context, index) {
- return _buildFileItem(
- _files[index],
- colorScheme,
- textTheme,
- );
- },
+ padding: const EdgeInsets.all(12),
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight:
+ _files.length > 5 ? 360 : _files.length * 84.0,
+ ),
+ child: ListView.separated(
+ shrinkWrap: true,
+ padding: EdgeInsets.zero,
+ physics: _files.length > 5
+ ? const BouncingScrollPhysics()
+ : const NeverScrollableScrollPhysics(),
+ itemCount: _files.length,
+ separatorBuilder: (context, index) =>
+ const SizedBox(height: 8),
+ itemBuilder: (context, index) {
+ return _buildFileItem(
+ _files[index],
+ colorScheme,
+ textTheme,
+ );
+ },
+ ),
),
),
+ const SizedBox(height: 16),
+ ],
+ TitleBarTitleWidget(
+ title: context.l10n.collectionLabel,
+ ),
+ const SizedBox(height: 16),
+ CollectionSelectionWidget(
+ collections: _availableCollections,
+ selectedCollectionIds: _selectedCollectionIds,
+ onToggleCollection: _toggleCollection,
+ onCollectionsUpdated: _onCollectionsUpdated,
+ title: "",
),
- const SizedBox(height: 24),
],
- TitleBarTitleWidget(
- title: context.l10n.collections,
- ),
- const SizedBox(height: 24),
- Wrap(
- spacing: 8,
- runSpacing: 12,
- children: [
- ...widget.collections.map((collection) {
- final isSelected =
- _selectedCollections.contains(collection);
- return _buildCollectionChip(
- name:
- collection.displayName ?? context.l10n.unnamed,
- isSelected: isSelected,
- onTap: () => _onCollectionSelected(collection),
- colorScheme: colorScheme,
- textTheme: textTheme,
- );
- }),
- _buildNewCollectionChip(colorScheme, textTheme),
- ],
- ),
- ],
+ ),
),
),
- ),
- const SizedBox(height: 24),
- SafeArea(
- child: SizedBox(
- width: double.infinity,
- child: GradientButton(
- onTap: _selectedCollections.isEmpty
- ? null
- : () async {
- final result = FileUploadDialogResult(
- note: '',
- selectedCollections: _selectedCollections.toList(),
- );
- Navigator.of(context).pop(result);
- },
- text: context.l10n.save,
+ const SizedBox(height: 12),
+ SafeArea(
+ child: SizedBox(
+ width: double.infinity,
+ child: GradientButton(
+ onTap: _selectedCollectionIds.isEmpty
+ ? null
+ : () async {
+ final selectedCollections = _availableCollections
+ .where(
+ (c) => _selectedCollectionIds.contains(c.id),
+ )
+ .toList();
+ final result = FileUploadDialogResult(
+ note: '',
+ selectedCollections: selectedCollections,
+ );
+ Navigator.of(context).pop(result);
+ },
+ text: context.l10n.save,
+ ),
),
),
- ),
- ],
+ ],
+ ),
),
),
);
@@ -274,90 +285,4 @@ class _FileUploadScreenState extends State<FileUploadScreen> {
Widget _buildFileIcon(String fileName) {
return FileIconUtils.getFileIcon(fileName, showBackground: true);
}
-
- void _onCollectionSelected(Collection collection) {
- setState(() {
- if (_selectedCollections.contains(collection)) {
- _selectedCollections.remove(collection);
- } else {
- _selectedCollections.add(collection);
- }
- });
- }
-
- Widget _buildCollectionChip({
- required String name,
- required bool isSelected,
- required VoidCallback onTap,
- required EnteColorScheme colorScheme,
- required EnteTextTheme textTheme,
- }) {
- return GestureDetector(
- onTap: onTap,
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
- decoration: BoxDecoration(
- color: isSelected
- ? colorScheme.primary700.withValues(alpha: 0.2)
- : colorScheme.fillFaint,
- borderRadius: const BorderRadius.all(Radius.circular(24.0)),
- border: Border.all(
- color: isSelected ? colorScheme.primary700 : Colors.transparent,
- width: 1,
- ),
- ),
- child: Text(
- name,
- style: textTheme.small.copyWith(
- color: isSelected ? colorScheme.primary700 : colorScheme.textBase,
- ),
- ),
- ),
- );
- }
-
- Widget _buildNewCollectionChip(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return GestureDetector(
- onTap: () async {
- final newCollection = await CollectionActions.createCollection(context);
- if (newCollection != null && mounted) {
- setState(() {
- widget.collections.add(newCollection);
- _selectedCollections.add(newCollection);
- });
- }
- },
- child: DottedBorder(
- options: const RoundedRectDottedBorderOptions(
- padding: EdgeInsets.symmetric(vertical: 14, horizontal: 16),
- strokeWidth: 1,
- color: Color.fromRGBO(82, 82, 82, 0.6),
- dashPattern: [5, 5],
- radius: Radius.circular(24),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.add_rounded,
- size: 18,
- color: colorScheme.textMuted,
- ),
- const SizedBox(width: 6),
- Text(
- context.l10n.collectionButtonLabel,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- ),
- ),
- );
- }
}
diff --git a/mobile/apps/locker/lib/ui/pages/personal_note_page.dart b/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
index 89614162f7..c0c8fa6f1d 100644
--- a/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
@@ -181,8 +181,7 @@ class _PersonalNotePageState
selectedCollectionIds: selectedCollectionIds,
onToggleCollection: toggleCollectionSelection,
onCollectionsUpdated: updateAvailableCollections,
- titleWidget:
- showCollectionSelectionTitle ? null : const SizedBox.shrink(),
+ title: showCollectionSelectionTitle ? context.l10n.collections : '',
),
],
),