-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [68] feat: add support for labels * [68] fix: initialize notes service * [68] fix: disable labels list onTap in the bin * [68] fix: sort labels * [68] feat: allow to disable labels * [68] feat: allow to hide labels on note tiles and in the editor * [68] fix: notes and bin providers update * [68] feat: add l10n * [68] doc: add dart doc * [68] feat: hide hidden labels on tile and editor labels lists * [68] fix: rebase * [68] fix: wrong current note in the editor
- Loading branch information
1 parent
675cdb2
commit 0248401
Showing
84 changed files
with
2,857 additions
and
672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:localmaterialnotes/common/constants/constants.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/pages/labels/dialogs/label_dialog.dart'; | ||
import 'package:localmaterialnotes/providers/labels/labels/labels_provider.dart'; | ||
|
||
/// Adds a label. | ||
Future<void> addLabel(BuildContext context, WidgetRef ref) async { | ||
final label = await showAdaptiveDialog<Label>( | ||
context: context, | ||
builder: (context) { | ||
return LabelDialog(title: l.dialog_label_add); | ||
}, | ||
); | ||
|
||
if (label == null) { | ||
return; | ||
} | ||
|
||
ref.read(labelsProvider.notifier).edit(label); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ignore_for_file: unused_import | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:localmaterialnotes/common/actions/labels/select.dart'; | ||
import 'package:localmaterialnotes/common/actions/notes/select.dart'; | ||
import 'package:localmaterialnotes/common/constants/constants.dart'; | ||
import 'package:localmaterialnotes/common/dialogs/confirmation_dialog.dart'; | ||
import 'package:localmaterialnotes/common/extensions/build_context_extension.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/models/note/note.dart'; | ||
import 'package:localmaterialnotes/providers/bin/bin_provider.dart'; | ||
import 'package:localmaterialnotes/providers/labels/labels/labels_provider.dart'; | ||
import 'package:localmaterialnotes/providers/notes/notes/notes_provider.dart'; | ||
import 'package:localmaterialnotes/providers/notifiers.dart'; | ||
import 'package:localmaterialnotes/routing/routes/notes/notes_editor_route.dart'; | ||
import 'package:localmaterialnotes/routing/routes/shell/shell_route.dart'; | ||
|
||
/// Deletes the [label]. | ||
/// | ||
/// Returns `true` if the [label] was deleted, `false` otherwise. | ||
/// | ||
/// First, asks for a confirmation if needed. | ||
Future<bool> deleteLabel(BuildContext context, WidgetRef ref, Label? label) async { | ||
if (label == null) { | ||
return false; | ||
} | ||
|
||
if (!await askForConfirmation( | ||
context, | ||
l.dialog_delete, | ||
l.dialog_delete_body(1), | ||
l.dialog_delete, | ||
)) { | ||
return false; | ||
} | ||
|
||
return await ref.read(labelsProvider.notifier).delete(label); | ||
} | ||
|
||
/// Deletes the [labels]. | ||
/// | ||
/// Returns `true` if the [labels] were deleted, `false` otherwise. | ||
/// | ||
/// First, asks for a confirmation if needed. | ||
Future<bool> deleteLabels(BuildContext context, WidgetRef ref, List<Label> labels) async { | ||
if (!await askForConfirmation( | ||
context, | ||
l.dialog_delete, | ||
l.dialog_delete_body(labels.length), | ||
l.dialog_delete, | ||
)) { | ||
return false; | ||
} | ||
|
||
final succeeded = await ref.read(labelsProvider.notifier).deleteAll(labels); | ||
|
||
if (context.mounted) { | ||
exitLabelsSelectionMode(ref); | ||
} | ||
|
||
return succeeded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:localmaterialnotes/common/actions/labels/select.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/providers/labels/labels/labels_provider.dart'; | ||
|
||
/// Toggles the pined status of the [label]. | ||
/// | ||
/// Returns `true` if the pined status of the [label] was toggled, `false` otherwise. | ||
Future<bool> togglePinLabel(BuildContext context, WidgetRef ref, Label? label) async { | ||
if (label == null) { | ||
return false; | ||
} | ||
|
||
await ref.read(labelsProvider.notifier).togglePin(label); | ||
|
||
return false; | ||
} | ||
|
||
/// Toggles the pined status of the [labels]. | ||
Future<void> togglePinLabels(WidgetRef ref, List<Label> labels) async { | ||
await ref.read(labelsProvider.notifier).togglePinAll(labels); | ||
|
||
exitLabelsSelectionMode(ref); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/providers/labels/labels/labels_provider.dart'; | ||
import 'package:localmaterialnotes/providers/notifiers.dart'; | ||
|
||
/// Toggles the select status of the [label]. | ||
void toggleSelectLabel(WidgetRef ref, Label label) { | ||
label.selected ? ref.read(labelsProvider.notifier).unselect(label) : ref.read(labelsProvider.notifier).select(label); | ||
} | ||
|
||
/// Selects all the labels. | ||
void selectAllLabels(WidgetRef ref) { | ||
ref.read(labelsProvider.notifier).selectAll(); | ||
} | ||
|
||
/// Unselects all the labels. | ||
void unselectAllLabels(WidgetRef ref) { | ||
ref.read(labelsProvider.notifier).unselectAll(); | ||
} | ||
|
||
/// Exits the labels selection mode. | ||
/// | ||
/// First unselects all the labels. | ||
void exitLabelsSelectionMode(WidgetRef ref) { | ||
unselectAllLabels(ref); | ||
|
||
isLabelsSelectionModeNotifier.value = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:localmaterialnotes/common/actions/labels/select.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/providers/labels/labels/labels_provider.dart'; | ||
|
||
/// Toggles the visible status of the [label]. | ||
/// | ||
/// Returns `true` if the visible status of the [label] was toggled, `false` otherwise. | ||
Future<bool> toggleVisibleLabel(WidgetRef ref, Label? label) async { | ||
if (label == null) { | ||
return false; | ||
} | ||
|
||
await ref.read(labelsProvider.notifier).toggleVisible(label); | ||
|
||
return false; | ||
} | ||
|
||
/// Toggles the visible status of the [labels]. | ||
Future<void> toggleVisibleLabels(WidgetRef ref, List<Label> labels) async { | ||
await ref.read(labelsProvider.notifier).toggleVisibleAll(labels); | ||
|
||
exitLabelsSelectionMode(ref); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:localmaterialnotes/models/label/label.dart'; | ||
import 'package:localmaterialnotes/models/note/note.dart'; | ||
import 'package:localmaterialnotes/pages/editor/dialogs/labels_selection_dialog.dart'; | ||
import 'package:localmaterialnotes/providers/notes/notes/notes_provider.dart'; | ||
import 'package:localmaterialnotes/providers/notifiers.dart'; | ||
|
||
/// Asks the user to select the labels for the [note]. | ||
Future<List<Label>?> selectLabels(BuildContext context, WidgetRef ref, Note note) async { | ||
final selectedLabels = await showAdaptiveDialog<List<Label>>( | ||
context: context, | ||
builder: (context) { | ||
return LabelsSelectionDialog( | ||
note: note, | ||
); | ||
}, | ||
); | ||
|
||
if (selectedLabels == null) { | ||
return null; | ||
} | ||
|
||
await ref.read(notesProvider.notifier).editLabels(note, selectedLabels); | ||
|
||
// Forcefully notify the listeners because only the labels of the note have changed | ||
currentNoteNotifier.value = note; | ||
currentNoteNotifier.forceNotify(); | ||
|
||
return selectedLabels; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.