This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _bundle: UInt8 = 0 | |
class BundleEx: Bundle { | |
override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String { | |
let bundle: Bundle? = objc_getAssociatedObject(self, &_bundle) as? Bundle | |
if let temp = bundle { | |
return temp.localizedString(forKey: key, value: value, table: tableName) | |
} else { | |
return super.localizedString(forKey: key, value: value, table: tableName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class AppLanguageManager { | |
static let shared = AppLanguageManager() | |
private(set) var currentLanguage: String | |
private(set) var currentBundle: Bundle = Bundle.main | |
var bundle: Bundle { | |
return currentBundle | |
} | |
private init() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let serviceOneJSON = """ | |
{ | |
"user_name": "Mukesh", | |
"user_tagline": "Experience is the name everyone gives to their mistakes", | |
"id": 1 | |
} | |
""".data(using: .utf8)! | |
let serviceTwoJSON = """ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct CodableUserDefaultsBacked<T: Codable> { | |
let key: String | |
let defaultValue: T | |
var storage: UserDefaults = .standard | |
var wrappedValue: T { | |
get { | |
return CodableStorageHelper<T>.getValueFor(key: key, storage: storage) ?? defaultValue | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LottieAnimationCache: AnimationCacheProvider { | |
fileprivate var cacheAnimation: Animation! | |
public init() {} | |
/// Clears the Cache. | |
public func clearCache() { | |
} | |
/// The global shared Cache. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UISearchBar { | |
public var textField: UITextField? { | |
if #available(iOS 13, *) { | |
return searchTextField | |
} | |
let subViews = subviews.flatMap { $0.subviews } | |
guard let textField = (subViews.filter { $0 is UITextField }).first as? UITextField else { | |
return nil | |
} | |
return textField |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct Localizable { | |
var wrappedValue: String { | |
didSet { wrappedValue = NSLocalizedString(wrappedValue, comment: "") } | |
} | |
init(wrappedValue: String) { | |
self.wrappedValue = NSLocalizedString(wrappedValue, comment: "") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ThemeProtocol { | |
func addThemeChangeObserver() | |
func configureSubviewsColors() | |
} | |
extension ThemeProtocol { | |
func addThemeChangeObserver() { | |
if #available(iOS 13, *) { | |
} else { | |
NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "themeChange"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIColor { | |
@Theme(light: UIColor.white, | |
dark: UIColor.safeSystemBackground) | |
static var background: UIColor | |
@Theme(light: UIColor(hex: "333333"), | |
dark: UIColor.safeLabel) | |
static var primaryText: UIColor | |
@Theme(light: UIColor(hex: "EEEFF2"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct Theme { | |
let light: UIColor | |
let dark: UIColor | |
var wrappedValue: UIColor { | |
if #available(iOS 13, *) { | |
return UIColor { (traitCollection: UITraitCollection) -> UIColor in | |
if traitCollection.userInterfaceStyle == .dark { | |
return self.dark |
NewerOlder