mirror of
https://github.com/twofas/2fas-ios.git
synced 2024-11-25 19:59:58 +01:00
[TF-1550] move extension to view
This commit is contained in:
parent
a7353f24c7
commit
3bb58f2f96
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user