Skip to content

Instantly share code, notes, and snippets.

View mukyasa's full-sized avatar
🎯
Focusing

Mukesh Mandora mukyasa

🎯
Focusing
View GitHub Profile
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)
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() {
let serviceOneJSON = """
{
"user_name": "Mukesh",
"user_tagline": "Experience is the name everyone gives to their mistakes",
"id": 1
}
""".data(using: .utf8)!
let serviceTwoJSON = """
{
@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
}
public class LottieAnimationCache: AnimationCacheProvider {
fileprivate var cacheAnimation: Animation!
public init() {}
/// Clears the Cache.
public func clearCache() {
}
/// The global shared Cache.
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
@propertyWrapper
struct Localizable {
var wrappedValue: String {
didSet { wrappedValue = NSLocalizedString(wrappedValue, comment: "") }
}
init(wrappedValue: String) {
self.wrappedValue = NSLocalizedString(wrappedValue, comment: "")
}
}
protocol ThemeProtocol {
func addThemeChangeObserver()
func configureSubviewsColors()
}
extension ThemeProtocol {
func addThemeChangeObserver() {
if #available(iOS 13, *) {
} else {
NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "themeChange"),
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"),
@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