diff --git a/DemoAppSwiftUI/CustomChannelHeader.swift b/DemoAppSwiftUI/CustomChannelHeader.swift index a3475303..0f635de1 100644 --- a/DemoAppSwiftUI/CustomChannelHeader.swift +++ b/DemoAppSwiftUI/CustomChannelHeader.swift @@ -2,7 +2,6 @@ // Copyright © 2023 Stream.io Inc. All rights reserved. // -import NukeUI import StreamChat import StreamChatSwiftUI import SwiftUI @@ -42,13 +41,7 @@ public struct CustomChannelHeader: ToolbarContent { Button { logoutAlertShown = true } label: { - LazyImage(url: currentUserController.currentUser?.imageURL) - .onDisappear(.cancel) - .clipShape(Circle()) - .frame( - width: 30, - height: 30 - ) + StreamLazyImage(url: currentUserController.currentUser?.imageURL) } } } diff --git a/DemoAppSwiftUI/LoginView.swift b/DemoAppSwiftUI/LoginView.swift index 780e0103..f2cfbaa2 100644 --- a/DemoAppSwiftUI/LoginView.swift +++ b/DemoAppSwiftUI/LoginView.swift @@ -2,7 +2,6 @@ // Copyright © 2023 Stream.io Inc. All rights reserved. // -import NukeUI import StreamChatSwiftUI import SwiftUI @@ -57,13 +56,10 @@ struct DemoUserView: View { var body: some View { HStack { - LazyImage(url: user.avatarURL) - .onDisappear(.cancel) - .clipShape(Circle()) - .frame( - width: imageSize, - height: imageSize - ) + StreamLazyImage( + url: user.avatarURL, + size: CGSize(width: imageSize, height: imageSize) + ) VStack(alignment: .leading, spacing: 4) { Text(user.name) diff --git a/Sources/StreamChatSwiftUI/Utils/LazyImageExtensions.swift b/Sources/StreamChatSwiftUI/Utils/LazyImageExtensions.swift index f6462007..b4b3b150 100644 --- a/Sources/StreamChatSwiftUI/Utils/LazyImageExtensions.swift +++ b/Sources/StreamChatSwiftUI/Utils/LazyImageExtensions.swift @@ -6,7 +6,7 @@ import SwiftUI extension LazyImage { - public init(imageURL: URL?) where Content == NukeImage { + init(imageURL: URL?) where Content == NukeImage { let imageCDN = InjectedValues[\.utils].imageCDN guard let imageURL = imageURL else { #if COCOAPODS @@ -25,7 +25,7 @@ extension LazyImage { #endif } - public init(imageURL: URL?, @ViewBuilder content: @escaping (LazyImageState) -> Content) { + init(imageURL: URL?, @ViewBuilder content: @escaping (LazyImageState) -> Content) { let imageCDN = InjectedValues[\.utils].imageCDN guard let imageURL = imageURL else { #if COCOAPODS diff --git a/Sources/StreamChatSwiftUI/Utils/StreamLazyImage.swift b/Sources/StreamChatSwiftUI/Utils/StreamLazyImage.swift new file mode 100644 index 00000000..9b0cf480 --- /dev/null +++ b/Sources/StreamChatSwiftUI/Utils/StreamLazyImage.swift @@ -0,0 +1,26 @@ +// +// Copyright © 2023 Stream.io Inc. All rights reserved. +// + +import SwiftUI + +public struct StreamLazyImage: View { + + var url: URL? + var size: CGSize + + public init(url: URL?, size: CGSize = CGSize(width: 30, height: 30)) { + self.url = url + self.size = size + } + + public var body: some View { + LazyImage(url: url) + .onDisappear(.cancel) + .clipShape(Circle()) + .frame( + width: size.width, + height: size.height + ) + } +} diff --git a/StreamChatSwiftUI.xcodeproj/project.pbxproj b/StreamChatSwiftUI.xcodeproj/project.pbxproj index 12420e4d..ae54f21c 100644 --- a/StreamChatSwiftUI.xcodeproj/project.pbxproj +++ b/StreamChatSwiftUI.xcodeproj/project.pbxproj @@ -151,8 +151,6 @@ 84289BEB2807239B00282ABE /* MediaAttachmentsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84289BEA2807239B00282ABE /* MediaAttachmentsViewModel.swift */; }; 84289BED2807244E00282ABE /* FileAttachmentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84289BEC2807244E00282ABE /* FileAttachmentsView.swift */; }; 84289BEF2807246E00282ABE /* FileAttachmentsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84289BEE2807246E00282ABE /* FileAttachmentsViewModel.swift */; }; - 842ADEA428EADC6600F2BE36 /* Nuke in Frameworks */ = {isa = PBXBuildFile; productRef = 842ADEA328EADC6600F2BE36 /* Nuke */; }; - 842ADEA628EADC6600F2BE36 /* NukeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 842ADEA528EADC6600F2BE36 /* NukeUI */; }; 842ADEA928EB018C00F2BE36 /* LazyImageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842ADEA828EB018C00F2BE36 /* LazyImageExtensions.swift */; }; 842F036D288E93BF00496D49 /* ChatMessage_AdjustedText_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842F036C288E93BF00496D49 /* ChatMessage_AdjustedText_Tests.swift */; }; 842F0BB8276B3518002C400C /* QuotedMessageView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842F0BB7276B3518002C400C /* QuotedMessageView_Tests.swift */; }; @@ -424,6 +422,7 @@ 84E95A77284A486600699FD3 /* StreamChat in Frameworks */ = {isa = PBXBuildFile; productRef = 84E95A76284A486600699FD3 /* StreamChat */; }; 84E95A7D284A491000699FD3 /* StreamChatTestTools in Frameworks */ = {isa = PBXBuildFile; productRef = 84E95A7C284A491000699FD3 /* StreamChatTestTools */; }; 84EDBC37274FE5CD0057218D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84EDBC36274FE5CD0057218D /* Localizable.strings */; }; + 84F130C12AEAA957006E7B52 /* StreamLazyImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F130C02AEAA957006E7B52 /* StreamLazyImage.swift */; }; 84F2908A276B90610045472D /* GalleryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F29089276B90610045472D /* GalleryView.swift */; }; 84F2908C276B91700045472D /* ZoomableScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2908B276B91700045472D /* ZoomableScrollView.swift */; }; 84F2908E276B92A40045472D /* GalleryHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2908D276B92A40045472D /* GalleryHeaderView.swift */; }; @@ -931,6 +930,7 @@ 84E6EC24279AEE9F0017207B /* StreamChatTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChatTestCase.swift; sourceTree = ""; }; 84E6EC26279B0C930017207B /* ReactionsUsersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionsUsersView.swift; sourceTree = ""; }; 84EDBC36274FE5CD0057218D /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; + 84F130C02AEAA957006E7B52 /* StreamLazyImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamLazyImage.swift; sourceTree = ""; }; 84F29089276B90610045472D /* GalleryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GalleryView.swift; sourceTree = ""; }; 84F2908B276B91700045472D /* ZoomableScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomableScrollView.swift; sourceTree = ""; }; 84F2908D276B92A40045472D /* GalleryHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GalleryHeaderView.swift; sourceTree = ""; }; @@ -982,9 +982,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 842ADEA628EADC6600F2BE36 /* NukeUI in Frameworks */, 84E95A77284A486600699FD3 /* StreamChat in Frameworks */, - 842ADEA428EADC6600F2BE36 /* Nuke in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1654,6 +1652,7 @@ 841B64C92775BBC10016FF3B /* Errors.swift */, 847CEFED27C38ABE00606257 /* MessageCachingUtils.swift */, 84733EC527FDBF82006926E0 /* NetworkReachability.swift */, + 84F130C02AEAA957006E7B52 /* StreamLazyImage.swift */, 842ADEA828EB018C00F2BE36 /* LazyImageExtensions.swift */, 8465FD382746A95600AF091E /* Common */, ); @@ -2064,8 +2063,6 @@ name = StreamChatSwiftUI; packageProductDependencies = ( 84E95A76284A486600699FD3 /* StreamChat */, - 842ADEA328EADC6600F2BE36 /* Nuke */, - 842ADEA528EADC6600F2BE36 /* NukeUI */, ); productName = StreamChatSwiftUI; productReference = 8465FBB52746873A00AF091E /* StreamChatSwiftUI.framework */; @@ -2160,7 +2157,6 @@ 8400A346282C06F90067D3A0 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */, A3571601283E9D9F0014E3B0 /* XCRemoteSwiftPackageReference "swifter" */, 84E95A75284A486600699FD3 /* XCRemoteSwiftPackageReference "stream-chat-swift" */, - 842ADEA228EADC6600F2BE36 /* XCRemoteSwiftPackageReference "Nuke" */, 82543C7B2AD41B0400D5F6CD /* XCRemoteSwiftPackageReference "stream-chat-swift-test-helpers" */, ); productRefGroup = 8465FBB62746873A00AF091E /* Products */; @@ -2372,6 +2368,7 @@ 82D64BE02AD7E5B700C5C79E /* LazyImage.swift in Sources */, 82D64C052AD7E5B700C5C79E /* Deprecated.swift in Sources */, 84DEC8EC27611CAE00172876 /* SendInChannelView.swift in Sources */, + 84F130C12AEAA957006E7B52 /* StreamLazyImage.swift in Sources */, 82D64BD12AD7E5B700C5C79E /* Image.swift in Sources */, 82D64BD52AD7E5B700C5C79E /* AnimatedFrame.swift in Sources */, 8465FD9F2746A95700AF091E /* ChatChannelExtensions.swift in Sources */, @@ -3240,14 +3237,6 @@ minimumVersion = 9.0.0; }; }; - 842ADEA228EADC6600F2BE36 /* XCRemoteSwiftPackageReference "Nuke" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/kean/Nuke.git"; - requirement = { - kind = exactVersion; - version = 11.3.1; - }; - }; 8465FCB227468A8D00AF091E /* XCRemoteSwiftPackageReference "stream-chat-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/GetStream/stream-chat-swift.git"; @@ -3298,16 +3287,6 @@ package = 8400A346282C06F90067D3A0 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */; productName = OHHTTPStubs; }; - 842ADEA328EADC6600F2BE36 /* Nuke */ = { - isa = XCSwiftPackageProductDependency; - package = 842ADEA228EADC6600F2BE36 /* XCRemoteSwiftPackageReference "Nuke" */; - productName = Nuke; - }; - 842ADEA528EADC6600F2BE36 /* NukeUI */ = { - isa = XCSwiftPackageProductDependency; - package = 842ADEA228EADC6600F2BE36 /* XCRemoteSwiftPackageReference "Nuke" */; - productName = NukeUI; - }; 8465FCE32746954F00AF091E /* StreamChat */ = { isa = XCSwiftPackageProductDependency; package = 8465FCB227468A8D00AF091E /* XCRemoteSwiftPackageReference "stream-chat-swift" */; diff --git a/StreamChatSwiftUITestsApp/CustomChannelHeader.swift b/StreamChatSwiftUITestsApp/CustomChannelHeader.swift index e6daae4a..b7e6c012 100644 --- a/StreamChatSwiftUITestsApp/CustomChannelHeader.swift +++ b/StreamChatSwiftUITestsApp/CustomChannelHeader.swift @@ -2,7 +2,6 @@ // Copyright © 2023 Stream.io Inc. All rights reserved. // -import NukeUI import StreamChat import StreamChatSwiftUI import SwiftUI @@ -28,13 +27,7 @@ public struct CustomChannelHeader: ToolbarContent { Button { logoutAlertShown = true } label: { - LazyImage(url: currentUserController.currentUser?.imageURL) - .onDisappear(.cancel) - .clipShape(Circle()) - .frame( - width: 30, - height: 30 - ) + StreamLazyImage(url: currentUserController.currentUser?.imageURL) } .accessibilityAddTraits(.isButton) .accessibilityIdentifier("LogoutButton")