From 1055517650ff84c2df14c630e01681c77deaeaa4 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 7 Dec 2019 17:00:23 +0800 Subject: [PATCH] fix: sort files --- lib/screens/object.dart | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/screens/object.dart b/lib/screens/object.dart index 1584cb0..af13013 100644 --- a/lib/screens/object.dart +++ b/lib/screens/object.dart @@ -78,22 +78,21 @@ class ObjectScreen extends StatelessWidget { expression: _expression, ), )); - return res.data.repository.object; + final data = res.data.repository.object; - // if (type == 'tree') { - // var entries = data['repository']['object']['entries'] as List; - // entries.sort((a, b) { - // if (a['type'] == 'tree' && b['type'] == 'blob') { - // return -1; - // } - // if (a['type'] == 'blob' && b['type'] == 'tree') { - // return 1; - // } - // return 0; - // }); - // } + if (data.resolveType == 'Tree') { + (data as GithubObjectTree).entries.sort((a, b) { + if (a.type == 'tree' && b.type == 'blob') { + return -1; + } + if (a.type == 'blob' && b.type == 'tree') { + return 1; + } + return 0; + }); + } - // return data['repository']['object']; + return data; }, actionBuilder: (data, _) { if (data == null) return null;