-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improved language switching, fixed transparent navigation bar bug #179
Changes from 1 commit
1e31f07
9bc34ce
696cea9
d71a016
9e5309d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool | ||
{ | ||
UINavigationBar.appearance().tintColor = .darkText | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TYVM |
||
|
||
if #available(iOS 15, *) { | ||
let appearance = UINavigationBarAppearance() | ||
appearance.configureWithOpaqueBackground() | ||
appearance.titleTextAttributes = [.foregroundColor: UIColor.darkText] | ||
UINavigationBar.appearance().standardAppearance = appearance | ||
UINavigationBar.appearance().scrollEdgeAppearance = appearance | ||
} | ||
|
||
setFirebaseConfiguration() | ||
|
||
updateCurrentUserLocale(localeId: Locale.current.identifier) | ||
|
@@ -24,6 +34,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
|
||
LWAnalytics.logEventWithParameters(itemName: ._20191105_AL) | ||
|
||
Bundle.setLanguage(UserDefaults.selectedLanguage) | ||
|
||
return true | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Foundation | ||
|
||
var _bundle: UInt8 = 0 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love this solution. If I understand correctly, BundleEx does the heavy lifting of converting all the strings to the chosen language in a DQ? Its quite smooth Only thing is I generally prefer Can we do :
Maybe it will never be called but it will help us sleep a little better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing, looks like i missed it after I finished prototyping. On it. |
||
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) | ||
} | ||
} | ||
} | ||
|
||
public extension Bundle { | ||
class func setLanguage(_ language: String?) { | ||
let oneToken = "com.litecoin.loafwallet" | ||
|
||
DispatchQueue.once(token: oneToken) { | ||
object_setClass(Bundle.main, BundleEx.self as AnyClass) | ||
} | ||
|
||
if let temp = language { | ||
objc_setAssociatedObject(Bundle.main, &_bundle, Bundle(path: Bundle.main.path(forResource: temp, ofType: "lproj")!), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
} else { | ||
objc_setAssociatedObject(Bundle.main, &_bundle, nil, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
} | ||
} | ||
} | ||
|
||
extension DispatchQueue { | ||
private static var _onceTracker = [String]() | ||
|
||
class func once(token: String, block: () -> Void) { | ||
objc_sync_enter(self); defer { objc_sync_exit(self) } | ||
|
||
if _onceTracker.contains(token) { | ||
return | ||
} | ||
|
||
_onceTracker.append(token) | ||
block() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought I .gitignored xcshareddata? @Iferencak . Is this a new setting? Should I migrate with it? Whats the benefit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I'm not sure how this got tracked.. I didn't touch .gitignore 🤷