Skip to content

Commit

Permalink
feat: sort by favourite, then installed, then others in library view
Browse files Browse the repository at this point in the history
  • Loading branch information
vapidinfinity committed Jun 18, 2024
1 parent a7af8d0 commit 9a87117
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2766;
CURRENT_PROJECT_VERSION = 2773;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down Expand Up @@ -748,7 +748,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2766;
CURRENT_PROJECT_VERSION = 2773;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down
17 changes: 15 additions & 2 deletions Mythic/Views/Unified/GameListEvoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ struct GameListEvo: View {
searchString.isEmpty ||
$0.title.localizedCaseInsensitiveContains(searchString)
}
.sorted(by: { $0.title < $1.title })
.sorted(by: { $0.isFavourited && !$1.isFavourited })
.sorted {
if $0.isFavourited != $1.isFavourited {
return $0.isFavourited && !$1.isFavourited
}

if let games = try? Legendary.getInstalledGames(), games.contains($0) != games.contains($1) {
return games.contains($0)
}

if let games = LocalGames.library, games.contains($0) != games.contains($1) {
return games.contains($0)
}

return $0.title < $1.title
}
}

var body: some View {
Expand Down

0 comments on commit 9a87117

Please sign in to comment.