Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: sort collected bangumi #491

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading