This commit is contained in:
Balazs Perlaki-Horvath 2023-12-17 15:12:46 +01:00
parent aad7a8b423
commit 05384c581f
2 changed files with 28 additions and 6 deletions

View File

@ -71,8 +71,13 @@ final class CompactViewController: UIHostingController<AnyView>, UISearchControl
func willPresentSearchController(_ searchController: UISearchController) {
navigationController?.setToolbarHidden(true, animated: true)
navigationItem.setRightBarButton(
UIBarButtonItem(title: "common.button.cancel".localized, style: .done, target: self, action: #selector(onSearchCancelled))
, animated: true
UIBarButtonItem(
title: "common.button.cancel".localized,
style: .done,
target: self,
action: #selector(onSearchCancelled)
),
animated: true
)
}
@objc func onSearchCancelled() {

View File

@ -11,15 +11,33 @@ import Foundation
extension String {
var localized: String {
return NSLocalizedString(self, tableName: nil, bundle: DefaultLanguages.currentBundle, value: "", comment: "")
NSLocalizedString(
self,
tableName: nil,
bundle: DefaultLanguages.currentBundle,
value: "",
comment: ""
)
}
func localized(withComment: String) -> String {
return NSLocalizedString(self, tableName: nil, bundle: DefaultLanguages.currentBundle, value: "", comment: withComment)
return NSLocalizedString(
self,
tableName: nil,
bundle: DefaultLanguages.currentBundle,
value: "",
comment: withComment
)
}
func localizedWithFormat(withArgs: CVarArg...) -> String {
let format = NSLocalizedString(self, tableName: nil, bundle: DefaultLanguages.currentBundle, value: "", comment: "")
let format = NSLocalizedString(
self,
tableName: nil,
bundle: DefaultLanguages.currentBundle,
value: "",
comment: ""
)
switch withArgs.count {
case 1: return String.localizedStringWithFormat(format, withArgs[0])
@ -27,5 +45,4 @@ extension String {
default: return String.localizedStringWithFormat(format, withArgs)
}
}
}