From 5ad0210e3ecdc4e913b95ec067a5de7f0a6572c7 Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Sun, 3 Mar 2024 10:52:04 +0200 Subject: [PATCH 1/5] fix: create open note in folder fix: insert or remove only if folder is open --- lib/home/tags/tags_screen_state.dart | 23 +++++++++++++------ .../src/state/opened_project_notifier.dart | 3 +++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/home/tags/tags_screen_state.dart b/lib/home/tags/tags_screen_state.dart index 6139d545..111e94e4 100644 --- a/lib/home/tags/tags_screen_state.dart +++ b/lib/home/tags/tags_screen_state.dart @@ -59,6 +59,10 @@ class TagsScreenNotifier extends ValueNotifier { void onSearchAddProjects(final String? search) => _addProjectsSearchUpdatesController.add(search); ProjectTagModel get selectedTag => value.selectedTag.value; + ProjectTagModelId get _appWideSelectedTagId => + dto._.projectsNotifier.selectedTagId; + bool get _isEditingAppWideTag => _appWideSelectedTagId == selectedTag.id; + @override void dispose() { unawaited(_addProjectsSearchUpdatesController.close()); @@ -211,7 +215,10 @@ extension TagsNotifierXFolderEditing on TagsScreenNotifier { ), ), }; - await dto._.projectsNotifier.updateProjects(updatedProjects); + await dto._.projectsNotifier.updateProjects( + updatedProjects, + shouldUpdatePager: _isEditingAppWideTag, + ); /// removed final projectsToRemove = _removedProjects.difference(projects); @@ -222,12 +229,14 @@ extension TagsNotifierXFolderEditing on TagsScreenNotifier { ); await dto._.projectsNotifier .updateProjects(updatedRemovedProjects, shouldUpdatePager: false); - final map = updatedRemovedProjects.toMap( - toKey: (final i) => i.id, - toValue: (final i) => i, - ); - dto._.projectsNotifier.projectsPagedController - .deleteItemsWhere((final e) => map.containsKey(e.id)); + if (_isEditingAppWideTag) { + final map = updatedRemovedProjects.toMap( + toKey: (final i) => i.id, + toValue: (final i) => i, + ); + dto._.projectsNotifier.projectsPagedController + .deleteItemsWhere((final e) => map.containsKey(e.id)); + } _removedProjects.clear(); } diff --git a/packages/core/lib/src/state/opened_project_notifier.dart b/packages/core/lib/src/state/opened_project_notifier.dart index d353448a..9702cdfd 100644 --- a/packages/core/lib/src/state/opened_project_notifier.dart +++ b/packages/core/lib/src/state/opened_project_notifier.dart @@ -51,11 +51,13 @@ class OpenedProjectNotifier dto.projectsNotifier.updateEditingProject(item); } + List get _tagsIds => [dto.projectsNotifier.selectedTagId]; void createNoteProject(final BuildContext context) { final note = ProjectModelNote( id: ProjectModelId.generate(), createdAt: DateTime.now(), updatedAt: DateTime.now(), + tagsIds: _tagsIds, charactersLimit: dto.userNotifier.settings.charactersLimitForNewNotes, ); loadProject(context: context, project: note); @@ -69,6 +71,7 @@ class OpenedProjectNotifier id: ProjectModelId.generate(), createdAt: DateTime.now(), updatedAt: DateTime.now(), + tagsIds: _tagsIds, title: title, ); if (title.isNotEmpty) dto.projectsNotifier.updateEditingProject(idea); From d5ea4b0cd9aef60485ade8526289482666e6c138 Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Sun, 3 Mar 2024 12:23:22 +0200 Subject: [PATCH 2/5] fix: switch folders if opened deleted --- lib/home/tags/tags_screen_state.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/home/tags/tags_screen_state.dart b/lib/home/tags/tags_screen_state.dart index 111e94e4..d52334c8 100644 --- a/lib/home/tags/tags_screen_state.dart +++ b/lib/home/tags/tags_screen_state.dart @@ -171,11 +171,29 @@ extension TagsNotifierXFolderEditing on TagsScreenNotifier { if (!shouldBeDeleted) return; + final isDeletingAppWideTag = tag.id == dto._.projectsNotifier.selectedTagId; + final tagId = tag.id; _removedProjects.addAll(value.projects.value); _updateProjects([]); await _assignTagToProjects(tagId); dto._.tagsNotifier.remove(key: tagId); + if (isDeletingAppWideTag) { + final tags = dto._.tagsNotifier.values; + if (tags.isNotEmpty) { + dto._.projectsNotifier.updateDto( + (final dto) => dto.copyWith( + tagId: tags.first.id, + ), + ); + } else { + dto._.projectsNotifier.updateDto( + (final dto) => dto.copyWith( + tagId: ProjectTagModelId.empty, + ), + ); + } + } } Future onSaveTag() async { From bdb43e96bc2c73868b29f323e486ad25c368ccf0 Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Sun, 3 Mar 2024 12:25:04 +0200 Subject: [PATCH 3/5] fix: vertical projects --- lib/home/widgets/vertical_projects_bar.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/home/widgets/vertical_projects_bar.dart b/lib/home/widgets/vertical_projects_bar.dart index 3b4c0b17..0e0b1dcc 100644 --- a/lib/home/widgets/vertical_projects_bar.dart +++ b/lib/home/widgets/vertical_projects_bar.dart @@ -16,14 +16,11 @@ class VerticalProjectsBar extends StatelessWidget { return Padding( padding: const EdgeInsets.only( - left: 6, - right: 6, bottom: 22, ), child: Container( padding: const EdgeInsets.symmetric( vertical: 16, - horizontal: 6, ), // TODO(arenukvern): add gradient decoration: BoxDecoration( From b736a07f9ff9ce85528f86711899363d65ab83e9 Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Sun, 3 Mar 2024 12:25:26 +0200 Subject: [PATCH 4/5] fix: vertical projects --- lib/home/widgets/vertical_projects_bar.dart | 70 ++++++++++----------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/lib/home/widgets/vertical_projects_bar.dart b/lib/home/widgets/vertical_projects_bar.dart index 0e0b1dcc..42cca396 100644 --- a/lib/home/widgets/vertical_projects_bar.dart +++ b/lib/home/widgets/vertical_projects_bar.dart @@ -14,48 +14,46 @@ class VerticalProjectsBar extends StatelessWidget { Widget build(final BuildContext context) { final themeDefiner = ThemeDefiner.of(context); - return Padding( - padding: const EdgeInsets.only( + return Container( + margin: const EdgeInsets.only( bottom: 22, ), - child: Container( - padding: const EdgeInsets.symmetric( - vertical: 16, - ), - // TODO(arenukvern): add gradient - decoration: BoxDecoration( - borderRadius: defaultBorderRadius, - color: themeDefiner.themeToUse == ThemeToUse.fromContext - ? Theme.of(context).splashColor.withOpacity(0.05) - : null, - ), - child: Wrap( - direction: Axis.vertical, - spacing: 16, - children: [ - if (Envs.isFeedbackAvailable) - BarItem( - onTap: () => FeedbackProvider.show(context), - label: 'Bugs', - child: const FeedbackButton(), - ), + padding: const EdgeInsets.symmetric( + vertical: 16, + ), + // TODO(arenukvern): add gradient + decoration: BoxDecoration( + borderRadius: defaultBorderRadius, + color: themeDefiner.themeToUse == ThemeToUse.fromContext + ? Theme.of(context).splashColor.withOpacity(0.05) + : null, + ), + child: Wrap( + direction: Axis.vertical, + spacing: 16, + children: [ + if (Envs.isFeedbackAvailable) BarItem( + onTap: () => FeedbackProvider.show(context), + label: 'Bugs', + child: const FeedbackButton(), + ), + BarItem( + onTap: onIdeaTap, + label: context.l10n.idea, + child: IconIdeaButton( onTap: onIdeaTap, - label: context.l10n.idea, - child: IconIdeaButton( - onTap: onIdeaTap, - ), ), - BarItem( - onTap: onNoteTap, - label: context.l10n.note, - child: IconButton( - onPressed: onNoteTap, - icon: const Icon(Icons.book), - ), + ), + BarItem( + onTap: onNoteTap, + label: context.l10n.note, + child: IconButton( + onPressed: onNoteTap, + icon: const Icon(Icons.book), ), - ], - ), + ), + ], ), ); } From f0d58966bfe44c5d3958b8d2988238770409aeb9 Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Sun, 3 Mar 2024 13:02:22 +0200 Subject: [PATCH 5/5] chore: 3.19.2+44 --- pubspec.yaml | 2 +- snap/snapcraft.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 01cbb67b..89864511 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 3.19.1+43 +version: 3.19.2+44 environment: sdk: ">=3.3.0 <4.0.0" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 31529d95..488e212a 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: last-answer -version: 3.19.1+43 +version: 3.19.2+44 summary: Fast ideas brainstorming tool with quick notes description: | You have a cool idea or you need to write a post/article for your blog.