Skip to content

Commit

Permalink
mod: sort collected bangumi
Browse files Browse the repository at this point in the history
Signed-off-by: bggRGjQaUbCoE <[email protected]>
  • Loading branch information
bggRGjQaUbCoE committed Dec 19, 2024
1 parent b2973b0 commit 2761158
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 2761158

Please sign in to comment.