Always sort the tags

Fixes 
This commit is contained in:
Vishesh Handa
2020-12-27 11:00:20 +01:00
parent 3b5a0d64e5
commit a2e8f629df
2 changed files with 6 additions and 8 deletions

@ -1,3 +1,4 @@
import 'dart:collection';
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
@ -497,8 +498,8 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
return NotesFolderConfig.fromSettings(this, settings);
}
Set<String> getNoteTagsRecursively() {
return _fetchTags(this, {});
SplayTreeSet<String> getNoteTagsRecursively() {
return _fetchTags(this, SplayTreeSet<String>());
}
Future<List<Note>> matchNotes(NoteMatcherAsync pred) async {
@ -527,7 +528,7 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
typedef NoteMatcherAsync = Future<bool> Function(Note n);
Set<String> _fetchTags(NotesFolder folder, Set<String> tags) {
SplayTreeSet<String> _fetchTags(NotesFolder folder, SplayTreeSet<String> tags) {
for (var note in folder.notes) {
tags.addAll(note.tags);
tags.addAll(note.inlineTags);

@ -1,5 +1,3 @@
import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
@ -21,13 +19,12 @@ class TagListingScreen extends StatelessWidget {
Widget build(BuildContext context) {
var rootFolder = Provider.of<NotesFolderFS>(context);
var allTags = rootFolder.getNoteTagsRecursively();
var allTagsSorted = SplayTreeSet<String>.from(allTags);
Widget body;
if (allTagsSorted.isNotEmpty) {
if (allTags.isNotEmpty) {
body = ListView(
children: <Widget>[
for (var tag in allTagsSorted) _buildTagTile(context, tag),
for (var tag in allTags) _buildTagTile(context, tag),
],
);
} else {