[TF-1550] move extension to view

This commit is contained in:
gmc 2024-06-26 23:38:03 +02:00
parent a7353f24c7
commit 3bb58f2f96
2 changed files with 24 additions and 24 deletions

View File

@ -51,27 +51,3 @@ final class SortTokensPresenter: SortTokensPresenting {
currentSortType = sortType
}
}
extension SortType {
var localized: String {
switch self {
case .az: return T.Tokens.sortByAToZ
case .za: return T.Tokens.sortByZToA
case .manual: return T.Tokens.sortByManual
}
}
func image(forSelectedOption option: Self, configuration: UIImage.SymbolConfiguration) -> UIImage {
var image: UIImage?
switch self {
case .az: image = UIImage(systemName: "arrow.down")
case .za: image = UIImage(systemName: "arrow.up")
case .manual: image = UIImage(systemName: "line.3.horizontal")
}
if self == option {
image = image?.withConfiguration(configuration)
}
return image?.withRenderingMode(.alwaysTemplate) ?? UIImage()
}
}

View File

@ -71,6 +71,30 @@ struct SortTokensView<Presenter: SortTokensPresenting>: View {
}
}
extension SortType {
var localized: String {
switch self {
case .az: return T.Tokens.sortByAToZ
case .za: return T.Tokens.sortByZToA
case .manual: return T.Tokens.sortByManual
}
}
func image(forSelectedOption option: Self, configuration: UIImage.SymbolConfiguration) -> UIImage {
var image: UIImage?
switch self {
case .az: image = UIImage(systemName: "arrow.down")
case .za: image = UIImage(systemName: "arrow.up")
case .manual: image = UIImage(systemName: "line.3.horizontal")
}
if self == option {
image = image?.withConfiguration(configuration)
}
return image?.withRenderingMode(.alwaysTemplate) ?? UIImage()
}
}
#Preview {
final class SortTokensPresenterMock: SortTokensPresenting {
var currentSortType: CommonWatch.SortType = .manual