GCWizard icon indicating copy to clipboard operation
GCWizard copied to clipboard

GCWDropDownButton: Automatically order items

Open S-Man42 opened this issue 3 years ago • 0 comments

Add an option to order the items.

E.g.: Numeral Words: Currently all items are unordered. So just add a

if (widget.ordered)
   items.sort((a, b) => a.child.compareTo(b.child));

Interesting point is that there are items, which need to be ordered top nonetheless. For example the "All languages" entry at the numeral words text search. So this GCWDropDownItem must get a flag for orderedTop. That make the order algorithm a bit more complicated. Like this:

if (widget.ordered)
   items.sort((a,b) {
      if (a.orderedTop) return -1;
      if (b.orderedTop) return 1;
      return a.child.compareTo(b.child);
   })

S-Man42 avatar Apr 24 '21 18:04 S-Man42