damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 72b51a81deba4dffd4bbba64a8fba553da3bb99b
parent 8ec1fa29b1442902094c358068596d8bfcfc8864
Author: OlegAba <mail@olegaba.com>
Date:   Wed, 29 Mar 2023 18:57:50 -0400

Move and rename pfp image view

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 8++++----
Adamus/Views/Images/ProfilePicImageView.swift | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddamus/Views/ProfileZoomView.swift | 94-------------------------------------------------------------------------------
3 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -234,7 +234,7 @@ 5C513FBA297F72980072348F /* CustomPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C513FB9297F72980072348F /* CustomPicker.swift */; }; 5C513FCC2984ACA60072348F /* QRCodeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C513FCB2984ACA60072348F /* QRCodeView.swift */; }; 5CF72FC229B9142F00124A13 /* ShareAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF72FC129B9142F00124A13 /* ShareAction.swift */; }; - 6439E014296790CF0020672B /* ProfileZoomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6439E013296790CF0020672B /* ProfileZoomView.swift */; }; + 6439E014296790CF0020672B /* ProfilePicImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6439E013296790CF0020672B /* ProfilePicImageView.swift */; }; 643EA5C8296B764E005081BB /* RelayFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643EA5C7296B764E005081BB /* RelayFilterView.swift */; }; 647D9A8D2968520300A295DE /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647D9A8C2968520300A295DE /* SideMenuView.swift */; }; 64FBD06F296255C400D9D3B2 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64FBD06E296255C400D9D3B2 /* Theme.swift */; }; @@ -623,7 +623,7 @@ 5C513FB9297F72980072348F /* CustomPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPicker.swift; sourceTree = "<group>"; }; 5C513FCB2984ACA60072348F /* QRCodeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeView.swift; sourceTree = "<group>"; }; 5CF72FC129B9142F00124A13 /* ShareAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareAction.swift; sourceTree = "<group>"; }; - 6439E013296790CF0020672B /* ProfileZoomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileZoomView.swift; sourceTree = "<group>"; }; + 6439E013296790CF0020672B /* ProfilePicImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilePicImageView.swift; sourceTree = "<group>"; }; 643EA5C7296B764E005081BB /* RelayFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayFilterView.swift; sourceTree = "<group>"; }; 647D9A8C2968520300A295DE /* SideMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = "<group>"; }; 64FBD06E296255C400D9D3B2 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; }; @@ -875,7 +875,6 @@ 647D9A8C2968520300A295DE /* SideMenuView.swift */, 9609F057296E220800069BF3 /* BannerImageView.swift */, 4CB8838E296F781C00DC99E7 /* ReactionsView.swift */, - 6439E013296790CF0020672B /* ProfileZoomView.swift */, 4CF0ABD529817F5B00D66079 /* ReportView.swift */, 4CF0ABE42981EE0C00D66079 /* EULAView.swift */, 3AA247FE297E3D900090C62D /* RepostsView.swift */, @@ -1210,6 +1209,7 @@ children = ( 4CFF8F6229CC9AD7008DB934 /* ImageContextMenuModifier.swift */, 4CFF8F6629CC9E3A008DB934 /* ImageView.swift */, + 6439E013296790CF0020672B /* ProfilePicImageView.swift */, 4CFF8F6829CC9ED1008DB934 /* ImageContainerView.swift */, ); path = Images; @@ -1565,7 +1565,7 @@ 4C8EC52529D1FA6C0085D9A8 /* DamusColors.swift in Sources */, 4C5C7E6A284EDE2E00A22DF5 /* SearchResultsView.swift in Sources */, 7C60CAEF298471A1009C80D6 /* CoreSVG.swift in Sources */, - 6439E014296790CF0020672B /* ProfileZoomView.swift in Sources */, + 6439E014296790CF0020672B /* ProfilePicImageView.swift in Sources */, 4CE6DF1627F8DEBF00C66700 /* RelayConnection.swift in Sources */, 4C3BEFD6281D995700B3DE84 /* ActionBarModel.swift in Sources */, 4C363AA428296DEE006E126D /* SearchModel.swift in Sources */, diff --git a/damus/Views/Images/ProfilePicImageView.swift b/damus/Views/Images/ProfilePicImageView.swift @@ -0,0 +1,94 @@ +// +// ProfileZoomView.swift +// damus +// +// Created by scoder1747 on 12/27/22. +// +import SwiftUI +import Kingfisher + +struct ProfileImageContainerView: View { + + let url: URL? + + @State private var image: UIImage? + @State private var showShareSheet = false + + private struct ImageHandler: ImageModifier { + @Binding var handler: UIImage? + + func modify(_ image: UIImage) -> UIImage { + handler = image + return image + } + } + + var body: some View { + + KFAnimatedImage(url) + .imageContext(.pfp) + .configure { view in + view.framePreloadCount = 3 + } + .imageModifier(ImageHandler(handler: $image)) + .clipShape(Circle()) + .modifier(ImageContextMenuModifier(url: url, image: image, showShareSheet: $showShareSheet)) + .sheet(isPresented: $showShareSheet) { + ShareSheet(activityItems: [url]) + } + } +} + +struct ProfilePicImageView: View { + + let pubkey: String + let profiles: Profiles + + @Environment(\.presentationMode) var presentationMode + + var navBarView: some View { + HStack { + Button(action: { + presentationMode.wrappedValue.dismiss() + }, label: { + Image(systemName: "xmark") + .frame(width: 33, height: 33) + .background(.regularMaterial) + .clipShape(Circle()) + }) + + Spacer() + } + .padding() + } + + var body: some View { + ZStack { + Color(.systemBackground) + .ignoresSafeArea() + + ZoomableScrollView { + ProfileImageContainerView(url: get_profile_url(picture: nil, pubkey: pubkey, profiles: profiles)) + .aspectRatio(contentMode: .fit) + .padding(.top, Theme.safeAreaInsets?.top) + .padding(.bottom, Theme.safeAreaInsets?.bottom) + .padding(.horizontal) + } + .ignoresSafeArea() + .modifier(SwipeToDismissModifier(minDistance: 50, onDismiss: { + presentationMode.wrappedValue.dismiss() + })) + } + .overlay(navBarView, alignment: .top) + } +} + +struct ProfileZoomView_Previews: PreviewProvider { + static let pubkey = "ca48854ac6555fed8e439ebb4fa2d928410e0eef13fa41164ec45aaaa132d846" + + static var previews: some View { + ProfilePicImageView( + pubkey: pubkey, + profiles: make_preview_profiles(pubkey)) + } +} diff --git a/damus/Views/ProfileZoomView.swift b/damus/Views/ProfileZoomView.swift @@ -1,94 +0,0 @@ -// -// ProfileZoomView.swift -// damus -// -// Created by scoder1747 on 12/27/22. -// -import SwiftUI -import Kingfisher - -struct ProfileImageContainerView: View { - - let url: URL? - - @State private var image: UIImage? - @State private var showShareSheet = false - - private struct ImageHandler: ImageModifier { - @Binding var handler: UIImage? - - func modify(_ image: UIImage) -> UIImage { - handler = image - return image - } - } - - var body: some View { - - KFAnimatedImage(url) - .imageContext(.pfp) - .configure { view in - view.framePreloadCount = 3 - } - .imageModifier(ImageHandler(handler: $image)) - .clipShape(Circle()) - .modifier(ImageContextMenuModifier(url: url, image: image, showShareSheet: $showShareSheet)) - .sheet(isPresented: $showShareSheet) { - ShareSheet(activityItems: [url]) - } - } -} - -struct ProfileZoomView: View { - - let pubkey: String - let profiles: Profiles - - @Environment(\.presentationMode) var presentationMode - - var navBarView: some View { - HStack { - Button(action: { - presentationMode.wrappedValue.dismiss() - }, label: { - Image(systemName: "xmark") - .frame(width: 33, height: 33) - .background(.regularMaterial) - .clipShape(Circle()) - }) - - Spacer() - } - .padding() - } - - var body: some View { - ZStack { - Color(.systemBackground) - .ignoresSafeArea() - - ZoomableScrollView { - ProfileImageContainerView(url: get_profile_url(picture: nil, pubkey: pubkey, profiles: profiles)) - .aspectRatio(contentMode: .fit) - .padding(.top, Theme.safeAreaInsets?.top) - .padding(.bottom, Theme.safeAreaInsets?.bottom) - .padding(.horizontal) - } - .ignoresSafeArea() - .modifier(SwipeToDismissModifier(minDistance: 50, onDismiss: { - presentationMode.wrappedValue.dismiss() - })) - } - .overlay(navBarView, alignment: .top) - } -} - -struct ProfileZoomView_Previews: PreviewProvider { - static let pubkey = "ca48854ac6555fed8e439ebb4fa2d928410e0eef13fa41164ec45aaaa132d846" - - static var previews: some View { - ProfileZoomView( - pubkey: pubkey, - profiles: make_preview_profiles(pubkey)) - } -}