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:
@@ -46,19 +46,22 @@ struct ImageCarousel: View {
|
|||||||
let evid: String
|
let evid: String
|
||||||
let previews: PreviewCache
|
let previews: PreviewCache
|
||||||
|
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
@State private var open_sheet: Bool = false
|
@State private var open_sheet: Bool = false
|
||||||
@State private var current_url: URL? = nil
|
@State private var current_url: URL? = nil
|
||||||
@State private var image_fill: ImageFill? = nil
|
@State private var image_fill: ImageFill? = nil
|
||||||
@State private var fillHeight: CGFloat = 350
|
@State private var fillHeight: CGFloat = 350
|
||||||
@State private var maxHeight: CGFloat = UIScreen.main.bounds.height * 0.85
|
@State private var maxHeight: CGFloat = UIScreen.main.bounds.height * 0.85
|
||||||
|
|
||||||
init(previews: PreviewCache, evid: String, urls: [URL]) {
|
init(previews: PreviewCache, evid: String, urls: [URL], disable_animation: Bool) {
|
||||||
_open_sheet = State(initialValue: false)
|
_open_sheet = State(initialValue: false)
|
||||||
_current_url = State(initialValue: nil)
|
_current_url = State(initialValue: nil)
|
||||||
_image_fill = State(initialValue: previews.lookup_image_meta(evid))
|
_image_fill = State(initialValue: previews.lookup_image_meta(evid))
|
||||||
self.urls = urls
|
self.urls = urls
|
||||||
self.evid = evid
|
self.evid = evid
|
||||||
self.previews = previews
|
self.previews = previews
|
||||||
|
self.disable_animation = disable_animation
|
||||||
}
|
}
|
||||||
|
|
||||||
var filling: Bool {
|
var filling: Bool {
|
||||||
@@ -79,7 +82,7 @@ struct ImageCarousel: View {
|
|||||||
KFAnimatedImage(url)
|
KFAnimatedImage(url)
|
||||||
.callbackQueue(.dispatch(.global(qos:.background)))
|
.callbackQueue(.dispatch(.global(qos:.background)))
|
||||||
.backgroundDecode(true)
|
.backgroundDecode(true)
|
||||||
.imageContext(.note)
|
.imageContext(.note, disable_animation: disable_animation)
|
||||||
.cancelOnDisappear(true)
|
.cancelOnDisappear(true)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
view.framePreloadCount = 3
|
view.framePreloadCount = 3
|
||||||
@@ -98,7 +101,7 @@ struct ImageCarousel: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.fullScreenCover(isPresented: $open_sheet) {
|
.fullScreenCover(isPresented: $open_sheet) {
|
||||||
ImageView(urls: urls)
|
ImageView(urls: urls, disable_animation: disable_animation)
|
||||||
}
|
}
|
||||||
.frame(height: height)
|
.frame(height: height)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
@@ -169,7 +172,7 @@ public struct ImageFill {
|
|||||||
|
|
||||||
struct ImageCarousel_Previews: PreviewProvider {
|
struct ImageCarousel_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ImageCarousel(previews: test_damus_state().previews, evid: "evid", urls: [URL(string: "https://jb55.com/red-me.jpg")!,URL(string: "https://jb55.com/red-me.jpg")!])
|
ImageCarousel(previews: test_damus_state().previews, evid: "evid", urls: [URL(string: "https://jb55.com/red-me.jpg")!,URL(string: "https://jb55.com/red-me.jpg")!], disable_animation: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ struct UserView: View {
|
|||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ struct ContentView: View {
|
|||||||
Button {
|
Button {
|
||||||
isSideBarOpened.toggle()
|
isSideBarOpened.toggle()
|
||||||
} label: {
|
} label: {
|
||||||
ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles)
|
ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles, disable_animation: damus_state!.settings.disable_animation)
|
||||||
.opacity(isSideBarOpened ? 0 : 1)
|
.opacity(isSideBarOpened ? 0 : 1)
|
||||||
.animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
|
.animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import Kingfisher
|
|||||||
|
|
||||||
extension KFOptionSetter {
|
extension KFOptionSetter {
|
||||||
|
|
||||||
func imageContext(_ imageContext: ImageContext) -> Self {
|
func imageContext(_ imageContext: ImageContext, disable_animation: Bool) -> Self {
|
||||||
options.callbackQueue = .dispatch(.global(qos: .background))
|
options.callbackQueue = .dispatch(.global(qos: .background))
|
||||||
options.processingQueue = .dispatch(.global(qos: .background))
|
options.processingQueue = .dispatch(.global(qos: .background))
|
||||||
options.downloader = CustomImageDownloader.shared
|
options.downloader = CustomImageDownloader.shared
|
||||||
@@ -26,7 +26,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.onlyLoadFirstFrame = disable_animation
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import SwiftUI
|
|||||||
import Kingfisher
|
import Kingfisher
|
||||||
|
|
||||||
struct InnerBannerImageView: View {
|
struct InnerBannerImageView: View {
|
||||||
|
let disable_animation: Bool
|
||||||
let url: URL?
|
let url: URL?
|
||||||
let defaultImage = UIImage(named: "profile-banner") ?? UIImage()
|
let defaultImage = UIImage(named: "profile-banner") ?? UIImage()
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ struct InnerBannerImageView: View {
|
|||||||
|
|
||||||
if (url != nil) {
|
if (url != nil) {
|
||||||
KFAnimatedImage(url)
|
KFAnimatedImage(url)
|
||||||
.imageContext(.banner)
|
.imageContext(.banner, disable_animation: disable_animation)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
view.framePreloadCount = 3
|
view.framePreloadCount = 3
|
||||||
}
|
}
|
||||||
@@ -35,19 +35,21 @@ struct InnerBannerImageView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct BannerImageView: View {
|
struct BannerImageView: View {
|
||||||
|
let disable_animation: Bool
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let profiles: Profiles
|
let profiles: Profiles
|
||||||
|
|
||||||
@State var banner: String?
|
@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.pubkey = pubkey
|
||||||
self.profiles = profiles
|
self.profiles = profiles
|
||||||
self._banner = State(initialValue: banner)
|
self._banner = State(initialValue: banner)
|
||||||
|
self.disable_animation = disable_animation
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
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
|
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||||
let updated = notif.object as! ProfileUpdate
|
let updated = notif.object as! ProfileUpdate
|
||||||
|
|
||||||
@@ -76,7 +78,9 @@ struct BannerImageView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
BannerImageView(
|
BannerImageView(
|
||||||
pubkey: pubkey,
|
pubkey: pubkey,
|
||||||
profiles: make_preview_profiles(pubkey))
|
profiles: make_preview_profiles(pubkey),
|
||||||
|
disable_animation: false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,11 +71,15 @@ struct ChatView: View {
|
|||||||
|
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
|
var disable_animation: Bool {
|
||||||
|
self.damus_state.settings.disable_animation
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
VStack {
|
VStack {
|
||||||
if is_active || just_started {
|
if is_active || just_started {
|
||||||
ProfilePicView(pubkey: event.pubkey, size: 32, highlight: is_active ? .main : .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: event.pubkey, size: 32, highlight: is_active ? .main : .none, profiles: damus_state.profiles, disable_animation: disable_animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct DMChatView: View {
|
|||||||
let profile_page = ProfileView(damus_state: damus_state, pubkey: pubkey)
|
let profile_page = ProfileView(damus_state: damus_state, pubkey: pubkey)
|
||||||
return NavigationLink(destination: profile_page) {
|
return NavigationLink(destination: profile_page) {
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: pubkey, size: 24, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: pubkey, size: 24, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
|
||||||
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: true)
|
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,15 @@ struct EventProfile: View {
|
|||||||
eventview_pfp_size(size)
|
eventview_pfp_size(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var disable_animation: Bool {
|
||||||
|
damus_state.settings.disable_animation
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
VStack {
|
VStack {
|
||||||
NavigationLink(destination: ProfileView(damus_state: damus_state, pubkey: pubkey)) {
|
NavigationLink(destination: ProfileView(damus_state: damus_state, pubkey: pubkey)) {
|
||||||
ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles, disable_animation: disable_animation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ import Kingfisher
|
|||||||
|
|
||||||
// lots of overlap between this and ImageContainerView
|
// lots of overlap between this and ImageContainerView
|
||||||
struct ImageContainerView: View {
|
struct ImageContainerView: View {
|
||||||
|
|
||||||
let url: URL?
|
let url: URL?
|
||||||
|
|
||||||
@State private var image: UIImage?
|
@State private var image: UIImage?
|
||||||
@State private var showShareSheet = false
|
@State private var showShareSheet = false
|
||||||
|
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
private struct ImageHandler: ImageModifier {
|
private struct ImageHandler: ImageModifier {
|
||||||
@Binding var handler: UIImage?
|
@Binding var handler: UIImage?
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ struct ImageContainerView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
KFAnimatedImage(url)
|
KFAnimatedImage(url)
|
||||||
.imageContext(.note)
|
.imageContext(.note, disable_animation: disable_animation)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
view.framePreloadCount = 3
|
view.framePreloadCount = 3
|
||||||
}
|
}
|
||||||
@@ -46,6 +47,6 @@ let test_image_url = URL(string: "https://jb55.com/red-me.jpg")!
|
|||||||
|
|
||||||
struct ImageContainerView_Previews: PreviewProvider {
|
struct ImageContainerView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ImageContainerView(url: test_image_url)
|
ImageContainerView(url: test_image_url, disable_animation: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ struct ImageView: View {
|
|||||||
@State private var selectedIndex = 0
|
@State private var selectedIndex = 0
|
||||||
@State var showMenu = true
|
@State var showMenu = true
|
||||||
|
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
var tabViewIndicator: some View {
|
var tabViewIndicator: some View {
|
||||||
HStack(spacing: 10) {
|
HStack(spacing: 10) {
|
||||||
ForEach(urls.indices, id: \.self) { index in
|
ForEach(urls.indices, id: \.self) { index in
|
||||||
@@ -37,7 +39,7 @@ struct ImageView: View {
|
|||||||
TabView(selection: $selectedIndex) {
|
TabView(selection: $selectedIndex) {
|
||||||
ForEach(urls.indices, id: \.self) { index in
|
ForEach(urls.indices, id: \.self) { index in
|
||||||
ZoomableScrollView {
|
ZoomableScrollView {
|
||||||
ImageContainerView(url: urls[index])
|
ImageContainerView(url: urls[index], disable_animation: disable_animation)
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.padding(.top, Theme.safeAreaInsets?.top)
|
.padding(.top, Theme.safeAreaInsets?.top)
|
||||||
.padding(.bottom, Theme.safeAreaInsets?.bottom)
|
.padding(.bottom, Theme.safeAreaInsets?.bottom)
|
||||||
@@ -77,6 +79,6 @@ struct ImageView: View {
|
|||||||
|
|
||||||
struct ImageView_Previews: PreviewProvider {
|
struct ImageView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ImageView(urls: [URL(string: "https://jb55.com/red-me.jpg")])
|
ImageView(urls: [URL(string: "https://jb55.com/red-me.jpg")], disable_animation: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import SwiftUI
|
|||||||
import Kingfisher
|
import Kingfisher
|
||||||
|
|
||||||
struct ProfileImageContainerView: View {
|
struct ProfileImageContainerView: View {
|
||||||
|
|
||||||
let url: URL?
|
let url: URL?
|
||||||
|
|
||||||
@State private var image: UIImage?
|
@State private var image: UIImage?
|
||||||
@State private var showShareSheet = false
|
@State private var showShareSheet = false
|
||||||
|
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
private struct ImageHandler: ImageModifier {
|
private struct ImageHandler: ImageModifier {
|
||||||
@Binding var handler: UIImage?
|
@Binding var handler: UIImage?
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ struct ProfileImageContainerView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
KFAnimatedImage(url)
|
KFAnimatedImage(url)
|
||||||
.imageContext(.pfp)
|
.imageContext(.pfp, disable_animation: disable_animation)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
view.framePreloadCount = 3
|
view.framePreloadCount = 3
|
||||||
}
|
}
|
||||||
@@ -61,9 +62,9 @@ struct NavDismissBarView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ProfilePicImageView: View {
|
struct ProfilePicImageView: View {
|
||||||
|
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let profiles: Profiles
|
let profiles: Profiles
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ struct ProfilePicImageView: View {
|
|||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
|
||||||
ZoomableScrollView {
|
ZoomableScrollView {
|
||||||
ProfileImageContainerView(url: get_profile_url(picture: nil, pubkey: pubkey, profiles: profiles))
|
ProfileImageContainerView(url: get_profile_url(picture: nil, pubkey: pubkey, profiles: profiles), disable_animation: disable_animation)
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.padding(.top, Theme.safeAreaInsets?.top)
|
.padding(.top, Theme.safeAreaInsets?.top)
|
||||||
.padding(.bottom, Theme.safeAreaInsets?.bottom)
|
.padding(.bottom, Theme.safeAreaInsets?.bottom)
|
||||||
@@ -94,6 +95,8 @@ struct ProfileZoomView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ProfilePicImageView(
|
ProfilePicImageView(
|
||||||
pubkey: pubkey,
|
pubkey: pubkey,
|
||||||
profiles: make_preview_profiles(pubkey))
|
profiles: make_preview_profiles(pubkey),
|
||||||
|
disable_animation: false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ struct NoteContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if show_images && artifacts.images.count > 0 {
|
if show_images && artifacts.images.count > 0 {
|
||||||
ImageCarousel(previews: damus_state.previews, evid: event.id, urls: artifacts.images)
|
ImageCarousel(previews: damus_state.previews, evid: event.id, urls: artifacts.images, disable_animation: damus_state.settings.disable_animation)
|
||||||
} else if !show_images && artifacts.images.count > 0 {
|
} else if !show_images && artifacts.images.count > 0 {
|
||||||
ZStack {
|
ZStack {
|
||||||
ImageCarousel(previews: damus_state.previews, evid: event.id, urls: artifacts.images)
|
ImageCarousel(previews: damus_state.previews, evid: event.id, urls: artifacts.images, disable_animation: damus_state.settings.disable_animation)
|
||||||
Blur()
|
Blur()
|
||||||
.disabled(true)
|
.disabled(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ struct ProfilePicturesView: View {
|
|||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(events.prefix(8)) { ev in
|
ForEach(events.prefix(8)) { ev in
|
||||||
ProfilePicView(pubkey: ev.pubkey, size: 32.0, highlight: .none, profiles: state.profiles)
|
ProfilePicView(pubkey: ev.pubkey, size: 32.0, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
nav_target = ev.pubkey
|
nav_target = ev.pubkey
|
||||||
navigating = true
|
navigating = true
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct ParticipantsView: View {
|
|||||||
ForEach(originalReferences.pRefs) { participant in
|
ForEach(originalReferences.pRefs) { participant in
|
||||||
let pubkey = participant.id
|
let pubkey = participant.id
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ struct PostView: View {
|
|||||||
func Editor(deviceSize: GeometryProxy) -> some View {
|
func Editor(deviceSize: GeometryProxy) -> some View {
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
ProfilePicView(pubkey: damus_state.pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: damus_state.pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
|
||||||
TextEntry
|
TextEntry
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ struct EditMetadataView: View {
|
|||||||
var TopSection: some View {
|
var TopSection: some View {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
GeometryReader { geo in
|
GeometryReader { geo in
|
||||||
BannerImageView(pubkey: damus_state.pubkey, profiles: damus_state.profiles)
|
BannerImageView(pubkey: damus_state.pubkey, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: geo.size.width, height: BANNER_HEIGHT)
|
.frame(width: geo.size.width, height: BANNER_HEIGHT)
|
||||||
.clipped()
|
.clipped()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ struct MaybeAnonPfpView: View {
|
|||||||
.frame(width: size, height: size)
|
.frame(width: size, height: size)
|
||||||
} else {
|
} else {
|
||||||
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pubkey)) {
|
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pubkey)) {
|
||||||
ProfilePicView(pubkey: pubkey, size: size, highlight: .none, profiles: state.profiles)
|
ProfilePicView(pubkey: pubkey, size: size, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,13 +53,17 @@ struct EditProfilePictureView: View {
|
|||||||
.overlay(Circle().stroke(highlight_color(highlight), lineWidth: pfp_line_width(highlight)))
|
.overlay(Circle().stroke(highlight_color(highlight), lineWidth: pfp_line_width(highlight)))
|
||||||
.padding(2)
|
.padding(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var disable_animation: Bool {
|
||||||
|
damus_state?.settings.disable_animation ?? false
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(uiColor: .systemBackground)
|
Color(uiColor: .systemBackground)
|
||||||
|
|
||||||
KFAnimatedImage(get_profile_url())
|
KFAnimatedImage(get_profile_url())
|
||||||
.imageContext(.pfp)
|
.imageContext(.pfp, disable_animation: disable_animation)
|
||||||
.cancelOnDisappear(true)
|
.cancelOnDisappear(true)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
view.framePreloadCount = 3
|
view.framePreloadCount = 3
|
||||||
@@ -87,12 +91,12 @@ struct EditProfilePictureView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct InnerProfilePicView: View {
|
struct InnerProfilePicView: View {
|
||||||
|
|
||||||
let url: URL?
|
let url: URL?
|
||||||
let fallbackUrl: URL?
|
let fallbackUrl: URL?
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let size: CGFloat
|
let size: CGFloat
|
||||||
let highlight: Highlight
|
let highlight: Highlight
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
var PlaceholderColor: Color {
|
var PlaceholderColor: Color {
|
||||||
return id_to_color(pubkey)
|
return id_to_color(pubkey)
|
||||||
@@ -111,7 +115,7 @@ struct InnerProfilePicView: View {
|
|||||||
Color(uiColor: .systemBackground)
|
Color(uiColor: .systemBackground)
|
||||||
|
|
||||||
KFAnimatedImage(url)
|
KFAnimatedImage(url)
|
||||||
.imageContext(.pfp)
|
.imageContext(.pfp, disable_animation: disable_animation)
|
||||||
.onFailure(fallbackUrl: fallbackUrl, cacheKey: url?.absoluteString)
|
.onFailure(fallbackUrl: fallbackUrl, cacheKey: url?.absoluteString)
|
||||||
.cancelOnDisappear(true)
|
.cancelOnDisappear(true)
|
||||||
.configure { view in
|
.configure { view in
|
||||||
@@ -133,19 +137,21 @@ struct ProfilePicView: View {
|
|||||||
let size: CGFloat
|
let size: CGFloat
|
||||||
let highlight: Highlight
|
let highlight: Highlight
|
||||||
let profiles: Profiles
|
let profiles: Profiles
|
||||||
|
let disable_animation: Bool
|
||||||
|
|
||||||
@State var picture: String?
|
@State var picture: String?
|
||||||
|
|
||||||
init (pubkey: String, size: CGFloat, highlight: Highlight, profiles: Profiles, picture: String? = nil) {
|
init (pubkey: String, size: CGFloat, highlight: Highlight, profiles: Profiles, disable_animation: Bool, picture: String? = nil) {
|
||||||
self.pubkey = pubkey
|
self.pubkey = pubkey
|
||||||
self.profiles = profiles
|
self.profiles = profiles
|
||||||
self.size = size
|
self.size = size
|
||||||
self.highlight = highlight
|
self.highlight = highlight
|
||||||
self._picture = State(initialValue: picture)
|
self._picture = State(initialValue: picture)
|
||||||
|
self.disable_animation = disable_animation
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
InnerProfilePicView(url: get_profile_url(picture: picture, pubkey: pubkey, profiles: profiles), fallbackUrl: URL(string: robohash(pubkey)), pubkey: pubkey, size: size, highlight: highlight)
|
InnerProfilePicView(url: get_profile_url(picture: picture, pubkey: pubkey, profiles: profiles), fallbackUrl: URL(string: robohash(pubkey)), pubkey: pubkey, size: size, highlight: highlight, disable_animation: disable_animation)
|
||||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||||
let updated = notif.object as! ProfileUpdate
|
let updated = notif.object as! ProfileUpdate
|
||||||
|
|
||||||
@@ -185,7 +191,9 @@ struct ProfilePicView_Previews: PreviewProvider {
|
|||||||
pubkey: pubkey,
|
pubkey: pubkey,
|
||||||
size: 100,
|
size: 100,
|
||||||
highlight: .none,
|
highlight: .none,
|
||||||
profiles: make_preview_profiles(pubkey))
|
profiles: make_preview_profiles(pubkey),
|
||||||
|
disable_animation: false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ struct ProfileView: View {
|
|||||||
return AnyView(
|
return AnyView(
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
ZStack {
|
ZStack {
|
||||||
BannerImageView(pubkey: profile.pubkey, profiles: damus_state.profiles)
|
BannerImageView(pubkey: profile.pubkey, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: proxy.size.width, height: minY > 0 ? bannerHeight + minY : bannerHeight)
|
.frame(width: proxy.size.width, height: minY > 0 ? bannerHeight + minY : bannerHeight)
|
||||||
.clipped()
|
.clipped()
|
||||||
@@ -332,7 +332,7 @@ struct ProfileView: View {
|
|||||||
func nameSection(profile_data: Profile?) -> some View {
|
func nameSection(profile_data: Profile?) -> some View {
|
||||||
return Group {
|
return Group {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles)
|
ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
.padding(.top, -(pfp_size / 2.0))
|
.padding(.top, -(pfp_size / 2.0))
|
||||||
.offset(y: pfpOffset())
|
.offset(y: pfpOffset())
|
||||||
.scaleEffect(pfpScale())
|
.scaleEffect(pfpScale())
|
||||||
@@ -340,7 +340,8 @@ struct ProfileView: View {
|
|||||||
is_zoomed.toggle()
|
is_zoomed.toggle()
|
||||||
}
|
}
|
||||||
.fullScreenCover(isPresented: $is_zoomed) {
|
.fullScreenCover(isPresented: $is_zoomed) {
|
||||||
ProfilePicImageView(pubkey: profile.pubkey, profiles: damus_state.profiles) }
|
ProfilePicImageView(pubkey: profile.pubkey, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ struct QRCodeView: View {
|
|||||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||||
|
|
||||||
if (damus_state.profiles.lookup(id: pubkey)?.picture) != nil {
|
if (damus_state.profiles.lookup(id: pubkey)?.picture) != nil {
|
||||||
ProfilePicView(pubkey: pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles)
|
ProfilePicView(pubkey: pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
.padding(.top, 50)
|
.padding(.top, 50)
|
||||||
} else {
|
} else {
|
||||||
Image(systemName: "person.fill")
|
Image(systemName: "person.fill")
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ struct SideMenuView: View {
|
|||||||
NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) {
|
NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) {
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
ProfilePicView(pubkey: damus_state.pubkey, size: 60, highlight: .none, profiles: damus_state.profiles)
|
ProfilePicView(pubkey: damus_state.pubkey, size: 60, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
if let display_name = profile?.display_name {
|
if let display_name = profile?.display_name {
|
||||||
|
|||||||
Reference in New Issue
Block a user