Skip to content

Commit 7bdc3f0

Browse files
committed
sort nodes in farm by status
1 parent 0773391 commit 7bdc3f0

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

app/lib/screens/farm_details.dart

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,13 @@ class _FarmDetailsState extends State<FarmDetails> {
343343
.text,
344344
wallets: widget.wallets
345345
.where((w) =>
346-
double.tryParse(w
347-
.stellarBalances['TFT']!) !=
346+
double.tryParse(
347+
w.stellarBalances[
348+
'TFT']!) !=
348349
null &&
349-
double.parse(w
350-
.stellarBalances['TFT']!) >=
350+
double.parse(
351+
w.stellarBalances[
352+
'TFT']!) >=
351353
0)
352354
.toList(),
353355
onSelectToAddress:
@@ -527,7 +529,20 @@ class _FarmDetailsState extends State<FarmDetails> {
527529
physics: const NeverScrollableScrollPhysics(),
528530
itemCount: widget.farm.nodes.length,
529531
itemBuilder: (context, index) {
530-
final node = widget.farm.nodes[index];
532+
final sortedNodes = List.from(widget.farm.nodes)
533+
..sort((a, b) {
534+
if (a.status == NodeStatus.Up &&
535+
b.status != NodeStatus.Up) {
536+
return -1;
537+
} else if (a.status != NodeStatus.Up &&
538+
b.status == NodeStatus.Up) {
539+
return 1;
540+
} else {
541+
return 0;
542+
}
543+
});
544+
545+
final node = sortedNodes[index];
531546
return Card(
532547
margin: const EdgeInsets.symmetric(
533548
vertical: 4.0, horizontal: 0.0),

0 commit comments

Comments
 (0)