Skip to content

Commit

Permalink
Merge branch 'master' into master-web
Browse files Browse the repository at this point in the history
  • Loading branch information
Arenukvern committed Mar 3, 2024
2 parents e412c90 + f0d5896 commit 357b502
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 48 deletions.
41 changes: 34 additions & 7 deletions lib/home/tags/tags_screen_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class TagsScreenNotifier extends ValueNotifier<TagsScreenState> {
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());
Expand Down Expand Up @@ -167,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<void> onSaveTag() async {
Expand Down Expand Up @@ -211,7 +233,10 @@ extension TagsNotifierXFolderEditing on TagsScreenNotifier {
),
),
};
await dto._.projectsNotifier.updateProjects(updatedProjects);
await dto._.projectsNotifier.updateProjects(
updatedProjects,
shouldUpdatePager: _isEditingAppWideTag,
);

/// removed
final projectsToRemove = _removedProjects.difference(projects);
Expand All @@ -222,12 +247,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();
}
Expand Down
73 changes: 34 additions & 39 deletions lib/home/widgets/vertical_projects_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,46 @@ class VerticalProjectsBar extends StatelessWidget {
Widget build(final BuildContext context) {
final themeDefiner = ThemeDefiner.of(context);

return Padding(
padding: const EdgeInsets.only(
left: 6,
right: 6,
return Container(
margin: const EdgeInsets.only(
bottom: 22,
),
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 16,
horizontal: 6,
),
// 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),
),
],
),
),
],
),
);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/core/lib/src/state/opened_project_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ class OpenedProjectNotifier
dto.projectsNotifier.updateEditingProject(item);
}

List<ProjectTagModelId> 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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 357b502

Please sign in to comment.