TF-37 Sort mailbox in alphabet

This commit is contained in:
Dat PHAM HOANG
2021-08-31 18:09:36 +07:00
committed by Dat H. Pham
parent e63298bc29
commit 63702035c8
6 changed files with 70 additions and 55 deletions
@@ -1,7 +1,9 @@
import 'dart:collection';
import 'package:collection/collection.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/features/mailbox/domain/extensions/mailbox_name_extension.dart';
import 'mailbox_node.dart';
import 'mailbox_tree.dart';
@@ -21,8 +23,16 @@ class TreeBuilder {
if (node != null) {
if (parentNode != null) {
parentNode.addChildNode(node);
parentNode.childrenItems?.sortByCompare<MailboxName?>(
(node) => node.item.name,
(name, other) => name?.compareAlphabetically(other) ?? -1
);
} else {
tree.root.addChildNode(node);
tree.root.childrenItems?.sortByCompare<MailboxName?>(
(node) => node.item.name,
(name, other) => name?.compareAlphabetically(other) ?? -1
);
}
}
});