Skip to content

Commit

Permalink
Merge pull request #491 from bggRGjQaUbCoE/mod-collect-page
Browse files Browse the repository at this point in the history
mod: sort collected bangumi
  • Loading branch information
Predidit authored Dec 19, 2024
2 parents 0abc3b1 + 2761158 commit 17b56c2
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/pages/collect/collect_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ class _CollectPageState extends State<CollectPage>
),
body: Padding(
padding: const EdgeInsets.only(left: 8, right: 8, top: 8),
child: Observer(
builder: (context) {
return renderBody(orientation);
}
)),
child: Observer(builder: (context) {
return renderBody(orientation);
})),
),
);
});
Expand All @@ -113,13 +111,15 @@ class _CollectPageState extends State<CollectPage>
List<Widget> contentGrid(
List<CollectedBangumi> collectedBangumiList, Orientation orientation) {
List<Widget> gridViewList = [];
List<List<CollectedBangumi>> collectedBangumiRenderItemList = [
collectedBangumiList.where((element) => element.type == 1).toList(),
collectedBangumiList.where((element) => element.type == 2).toList(),
collectedBangumiList.where((element) => element.type == 3).toList(),
collectedBangumiList.where((element) => element.type == 4).toList(),
collectedBangumiList.where((element) => element.type == 5).toList(),
];
List<List<CollectedBangumi>> collectedBangumiRenderItemList =
List.generate(tabs.length, (_) => <CollectedBangumi>[]);
for (CollectedBangumi element in collectedBangumiList) {
collectedBangumiRenderItemList[element.type - 1].add(element);
}
for (List<CollectedBangumi> list in collectedBangumiRenderItemList) {
list.sort((a, b) => b.time.millisecondsSinceEpoch
.compareTo(a.time.millisecondsSinceEpoch));
}
int crossCount = orientation != Orientation.portrait ? 6 : 3;
for (List<CollectedBangumi> collectedBangumiRenderItem
in collectedBangumiRenderItemList) {
Expand Down Expand Up @@ -149,7 +149,10 @@ class _CollectPageState extends State<CollectPage>
right: 5,
bottom: 5,
child: showDelete
? CollectButton(bangumiItem: collectedBangumiRenderItem[index].bangumiItem)
? CollectButton(
bangumiItem:
collectedBangumiRenderItem[index]
.bangumiItem)
: Container(),
),
],
Expand Down

0 comments on commit 17b56c2

Please sign in to comment.