Refactor disable_animation setting
Pass it down from the top instead of using a function which goes around our settings store
This commit is contained in:
@@ -9,7 +9,7 @@ import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct InnerBannerImageView: View {
|
||||
|
||||
let disable_animation: Bool
|
||||
let url: URL?
|
||||
let defaultImage = UIImage(named: "profile-banner") ?? UIImage()
|
||||
|
||||
@@ -19,7 +19,7 @@ struct InnerBannerImageView: View {
|
||||
|
||||
if (url != nil) {
|
||||
KFAnimatedImage(url)
|
||||
.imageContext(.banner)
|
||||
.imageContext(.banner, disable_animation: disable_animation)
|
||||
.configure { view in
|
||||
view.framePreloadCount = 3
|
||||
}
|
||||
@@ -35,19 +35,21 @@ struct InnerBannerImageView: View {
|
||||
}
|
||||
|
||||
struct BannerImageView: View {
|
||||
let disable_animation: Bool
|
||||
let pubkey: String
|
||||
let profiles: Profiles
|
||||
|
||||
@State var banner: String?
|
||||
|
||||
init (pubkey: String, profiles: Profiles, banner: String? = nil) {
|
||||
init (pubkey: String, profiles: Profiles, disable_animation: Bool, banner: String? = nil) {
|
||||
self.pubkey = pubkey
|
||||
self.profiles = profiles
|
||||
self._banner = State(initialValue: banner)
|
||||
self.disable_animation = disable_animation
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
InnerBannerImageView(url: get_banner_url(banner: banner, pubkey: pubkey, profiles: profiles))
|
||||
InnerBannerImageView(disable_animation: disable_animation, url: get_banner_url(banner: banner, pubkey: pubkey, profiles: profiles))
|
||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||
let updated = notif.object as! ProfileUpdate
|
||||
|
||||
@@ -76,7 +78,9 @@ struct BannerImageView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
BannerImageView(
|
||||
pubkey: pubkey,
|
||||
profiles: make_preview_profiles(pubkey))
|
||||
profiles: make_preview_profiles(pubkey),
|
||||
disable_animation: false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user