Add option to disable image animation
Changelog-Added: Add option to disable image animation Closes: #707
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import Vault
|
import Vault
|
||||||
|
import UIKit
|
||||||
|
|
||||||
func should_show_wallet_selector(_ pubkey: String) -> Bool {
|
func should_show_wallet_selector(_ pubkey: String) -> Bool {
|
||||||
return UserDefaults.standard.object(forKey: "show_wallet_selector") as? Bool ?? true
|
return UserDefaults.standard.object(forKey: "show_wallet_selector") as? Bool ?? true
|
||||||
@@ -34,6 +35,10 @@ func get_default_zap_amount(pubkey: String) -> Int? {
|
|||||||
return amt
|
return amt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func should_disable_image_animation() -> Bool {
|
||||||
|
return (UserDefaults.standard.object(forKey: "disable_animation") as? Bool)
|
||||||
|
?? UIAccessibility.isReduceMotionEnabled
|
||||||
|
}
|
||||||
|
|
||||||
func get_default_wallet(_ pubkey: String) -> Wallet {
|
func get_default_wallet(_ pubkey: String) -> Wallet {
|
||||||
if let defaultWalletName = UserDefaults.standard.string(forKey: "default_wallet"),
|
if let defaultWalletName = UserDefaults.standard.string(forKey: "default_wallet"),
|
||||||
@@ -160,6 +165,12 @@ class UserSettingsStore: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Published var disable_animation: Bool {
|
||||||
|
didSet {
|
||||||
|
UserDefaults.standard.set(disable_animation, forKey: "disable_animation")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// TODO: pubkey-scoped settings
|
// TODO: pubkey-scoped settings
|
||||||
let pubkey = ""
|
let pubkey = ""
|
||||||
@@ -167,6 +178,7 @@ class UserSettingsStore: ObservableObject {
|
|||||||
show_wallet_selector = should_show_wallet_selector(pubkey)
|
show_wallet_selector = should_show_wallet_selector(pubkey)
|
||||||
|
|
||||||
left_handed = UserDefaults.standard.object(forKey: "left_handed") as? Bool ?? false
|
left_handed = UserDefaults.standard.object(forKey: "left_handed") as? Bool ?? false
|
||||||
|
disable_animation = should_disable_image_animation()
|
||||||
|
|
||||||
// Note from @tyiu:
|
// Note from @tyiu:
|
||||||
// Default translation service is disabled by default for now until we gain some confidence that it is working well in production.
|
// Default translation service is disabled by default for now until we gain some confidence that it is working well in production.
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ extension KFOptionSetter {
|
|||||||
options.backgroundDecode = true
|
options.backgroundDecode = true
|
||||||
options.cacheOriginalImage = true
|
options.cacheOriginalImage = true
|
||||||
options.scaleFactor = UIScreen.main.scale
|
options.scaleFactor = UIScreen.main.scale
|
||||||
|
options.onlyLoadFirstFrame = should_disable_image_animation()
|
||||||
|
|
||||||
options.processor = CustomImageProcessor(
|
options.processor = CustomImageProcessor(
|
||||||
maxSize: imageContext.maxMebibyteSize(),
|
maxSize: imageContext.maxMebibyteSize(),
|
||||||
|
|||||||
@@ -199,11 +199,15 @@ struct ConfigView: View {
|
|||||||
.toggleStyle(.switch)
|
.toggleStyle(.switch)
|
||||||
}
|
}
|
||||||
|
|
||||||
Section(NSLocalizedString("Clear Cache", comment: "Section title for clearing cached data.")) {
|
Section(NSLocalizedString("Images", comment: "Section title for images configuration.")) {
|
||||||
Button(NSLocalizedString("Clear", comment: "Button for clearing cached data.")) {
|
Toggle(NSLocalizedString("Disable animations", comment: "Button to disable image animation"), isOn: $settings.disable_animation)
|
||||||
KingfisherManager.shared.cache.clearMemoryCache()
|
.toggleStyle(.switch)
|
||||||
KingfisherManager.shared.cache.clearDiskCache()
|
.onChange(of: settings.disable_animation) { _ in
|
||||||
KingfisherManager.shared.cache.cleanExpiredDiskCache()
|
clear_kingfisher_cache()
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(NSLocalizedString("Clear Cache", comment: "Button to clear image cache.")) {
|
||||||
|
clear_kingfisher_cache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,3 +384,9 @@ func handle_string_amount(new_value: String) -> Int? {
|
|||||||
|
|
||||||
return amt
|
return amt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clear_kingfisher_cache() -> Void {
|
||||||
|
KingfisherManager.shared.cache.clearMemoryCache()
|
||||||
|
KingfisherManager.shared.cache.clearDiskCache()
|
||||||
|
KingfisherManager.shared.cache.cleanExpiredDiskCache()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user