Skip to content

Commit

Permalink
Adds sort extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Jan 4, 2024
1 parent cca15e8 commit 1477085
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
25 changes: 25 additions & 0 deletions src/App/ViewModels/Utils/Sort+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import enum MonsterAnalyzerCore.Sort

extension Sort {
var label: String {
switch self {
case .inGame:
String(localized: "In Game", comment: "Sort/In Game")
case .name:
String(localized: "Name", comment: "Sort/Name")
case .type:
String(localized: "Type", comment: "Sort/Type")
}
}
}

// MARK: - Identifiable

extension Sort: Identifiable {
public var id: String {
@inline(__always)
get {
rawValue
}
}
}
6 changes: 3 additions & 3 deletions src/App/Views/Modifiers/SharedMonsterListModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ struct SharedMonsterListModifier: ViewModifier {
ToolbarItem(placement: .primaryAction) {
Menu("Sort", systemImage: "arrow.up.arrow.down.circle") {
Picker(selection: sort) {
Text("In Game", comment: "Sort/In Game").tag(Sort.inGame)
Text("Name", comment: "Sort/Name").tag(Sort.name)
Text("Type", comment: "Sort/Type").tag(Sort.type)
ForEach(Sort.allCases) { item in
Text(verbatim: item.label).tag(item)
}
} label: {
EmptyView()
}
Expand Down
1 change: 0 additions & 1 deletion src/Core/StarSwings/Enums/Sort.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Foundation

public enum Sort: String, CaseIterable, Hashable, UserDefaultable {
case inGame = "in_game"
Expand Down
6 changes: 6 additions & 0 deletions src/MonsterAnalyzer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
EBBBAAB92B3FDE8D00BBAB23 /* Publishers+CombineLatestCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBBAAB82B3FDE8D00BBAB23 /* Publishers+CombineLatestCollection.swift */; };
EBBBAABA2B3FE27000BBAB23 /* GameGroupViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBDFD8502B3C112A00AF1832 /* GameGroupViewModel.swift */; };
EBBF861E2B46546400F76D03 /* JapaneseTextProcessorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBF861D2B46546400F76D03 /* JapaneseTextProcessorTests.swift */; };
EBBF86202B4692D500F76D03 /* Sort+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBF861F2B4692D500F76D03 /* Sort+Extensions.swift */; };
EBBF86212B4692D500F76D03 /* Sort+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBF861F2B4692D500F76D03 /* Sort+Extensions.swift */; };
EBBF86242B46D4F000F76D03 /* FavoriteSwipeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBF86232B46D4F000F76D03 /* FavoriteSwipeButton.swift */; };
EBBF86252B46D4F000F76D03 /* FavoriteSwipeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBBF86232B46D4F000F76D03 /* FavoriteSwipeButton.swift */; };
EBC85C612B201939008A16C6 /* InfoPlist.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = EBC85C602B201939008A16C6 /* InfoPlist.xcstrings */; };
Expand Down Expand Up @@ -453,6 +455,7 @@
EBBBAAB62B3FCB0200BBAB23 /* libswiftWatchKit.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libswiftWatchKit.tbd; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.2.sdk/usr/lib/swift/libswiftWatchKit.tbd; sourceTree = DEVELOPER_DIR; };
EBBBAAB82B3FDE8D00BBAB23 /* Publishers+CombineLatestCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Publishers+CombineLatestCollection.swift"; sourceTree = "<group>"; };
EBBF861D2B46546400F76D03 /* JapaneseTextProcessorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JapaneseTextProcessorTests.swift; sourceTree = "<group>"; };
EBBF861F2B4692D500F76D03 /* Sort+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sort+Extensions.swift"; sourceTree = "<group>"; };
EBBF86232B46D4F000F76D03 /* FavoriteSwipeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSwipeButton.swift; sourceTree = "<group>"; };
EBC85C602B201939008A16C6 /* InfoPlist.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = InfoPlist.xcstrings; sourceTree = "<group>"; };
EBC85C702B2053B6008A16C6 /* WatchDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchDevice.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -796,6 +799,7 @@
children = (
EBB4B1E42B16A6D4004D63EA /* Attack+Extensions.swift */,
EBDEEF392B3E3E5800835CBC /* DebounceNotifier.swift */,
EBBF861F2B4692D500F76D03 /* Sort+Extensions.swift */,
EB693EA62B3B9F9700CDEC6F /* StarSwingsError+Extensions.swift */,
EB6437932B46EF5400E8D02B /* SwipeAction+Extensions.swift */,
EB99DBCC2B36D16B00A43552 /* WeaknessDisplayMode+Extensions.swift */,
Expand Down Expand Up @@ -1319,6 +1323,7 @@
EB97F6A62B31B60700E31602 /* SharedMonsterListModifier.swift in Sources */,
EB3B49232B35EAD100E89711 /* SharedSettingsContainerModifier.swift in Sources */,
EB6ADE752B3660340010BD64 /* SharedSettingsPaneModifier.swift in Sources */,
EBBF86212B4692D500F76D03 /* Sort+Extensions.swift in Sources */,
EB693EA82B3B9F9700CDEC6F /* StarSwingsError+Extensions.swift in Sources */,
EB967A4C2B2AC7100041A491 /* StateView.swift in Sources */,
EB560BD52B4386D700E91E01 /* StatusOverlayModifier.swift in Sources */,
Expand Down Expand Up @@ -1479,6 +1484,7 @@
EB3B49222B35EAD100E89711 /* SharedSettingsContainerModifier.swift in Sources */,
EB6ADE742B3660340010BD64 /* SharedSettingsPaneModifier.swift in Sources */,
EB645A642B2685D500D27500 /* Sidebar.swift in Sources */,
EBBF86202B4692D500F76D03 /* Sort+Extensions.swift in Sources */,
EB693EA72B3B9F9700CDEC6F /* StarSwingsError+Extensions.swift in Sources */,
EB967A4B2B2AC7100041A491 /* StateView.swift in Sources */,
EB560BD42B4386D700E91E01 /* StatusOverlayModifier.swift in Sources */,
Expand Down

0 comments on commit 1477085

Please sign in to comment.