From ddf4c5b5ad036b39491870e6b8633851f2a38444 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 12 Jul 2023 17:05:58 +1000 Subject: [PATCH] WIP: wrap profile picture view with swift ui --- Session.xcodeproj/project.pbxproj | 4 ++++ .../MessageInfoView.swift | 3 ++- .../ProfilePictureView+SwiftUI.swift | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 SessionUIKit/Components/ProfilePictureView+SwiftUI.swift diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index a0e9adacb..8168f7477 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -162,6 +162,7 @@ 7BCD116C27016062006330F1 /* WebRTCSession+DataChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BCD116B27016062006330F1 /* WebRTCSession+DataChannel.swift */; }; 7BD477A827EC39F5004E2822 /* Atomic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD477A727EC39F5004E2822 /* Atomic.swift */; }; 7BD687D12A5D0D1200D8E455 /* MessageInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD687D02A5D0D1200D8E455 /* MessageInfoView.swift */; }; + 7BD687D42A5E852600D8E455 /* ProfilePictureView+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD687D32A5E852600D8E455 /* ProfilePictureView+SwiftUI.swift */; }; 7BDCFC08242186E700641C39 /* NotificationServiceExtensionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */; }; 7BDCFC0B2421EB7600641C39 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B6F509951AA53F760068F56A /* Localizable.strings */; }; 7BFA8AE32831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */; }; @@ -1279,6 +1280,7 @@ 7BD477A727EC39F5004E2822 /* Atomic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atomic.swift; sourceTree = ""; }; 7BD687D02A5D0D1200D8E455 /* MessageInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageInfoView.swift; sourceTree = ""; }; 7BD687D22A5D283200D8E455 /* build_libSession_util.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_libSession_util.sh; sourceTree = ""; }; + 7BD687D32A5E852600D8E455 /* ProfilePictureView+SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfilePictureView+SwiftUI.swift"; sourceTree = ""; }; 7BDCFC0424206E7300641C39 /* SessionNotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SessionNotificationServiceExtension.entitlements; sourceTree = ""; }; 7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtensionContext.swift; sourceTree = ""; }; 7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContextMenuVC+EmojiReactsView.swift"; sourceTree = ""; }; @@ -2941,6 +2943,7 @@ FD52090628B49738006098F6 /* ConfirmationModal.swift */, C38EF2A3255B6D93007E1867 /* PlaceholderIcon.swift */, C38EF2A4255B6D93007E1867 /* ProfilePictureView.swift */, + 7BD687D32A5E852600D8E455 /* ProfilePictureView+SwiftUI.swift */, FD71165A28E6DDBC00B47552 /* StyledNavigationController.swift */, FD0B77AF29B69A65009169BA /* TopBannerController.swift */, ); @@ -5654,6 +5657,7 @@ FD71162C28E1451400B47552 /* Position.swift in Sources */, FD52090328B4680F006098F6 /* RadioButton.swift in Sources */, C331FFE82558FB0000070591 /* TextView.swift in Sources */, + 7BD687D42A5E852600D8E455 /* ProfilePictureView+SwiftUI.swift in Sources */, FD71162028D97ABC00B47552 /* UIImage+Tinting.swift in Sources */, FD71162A28DA83DF00B47552 /* GradientView.swift in Sources */, FD37E9D728A20B5D003AE748 /* UIColor+Utilities.swift in Sources */, diff --git a/Session/Media Viewing & Editing/MessageInfoView.swift b/Session/Media Viewing & Editing/MessageInfoView.swift index 0f3df2164..5b131c8e8 100644 --- a/Session/Media Viewing & Editing/MessageInfoView.swift +++ b/Session/Media Viewing & Editing/MessageInfoView.swift @@ -1,6 +1,7 @@ // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. import SwiftUI +import SessionUIKit struct MessageInfoView: View { var actions: [ContextMenuVC.Action] @@ -47,7 +48,7 @@ struct MessageInfoView: View { HStack( spacing: 5 ) { - Image("avatar") + ProfilePictureView(size: .message) VStack( alignment: .leading ) { diff --git a/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift b/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift new file mode 100644 index 000000000..62334f8dc --- /dev/null +++ b/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift @@ -0,0 +1,23 @@ +// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. + +import SwiftUI + +struct ProfilePictureView_SwiftUI: UIViewRepresentable { +// typealias UIViewType = ProfilePictureView + + @Binding var info: ProfilePictureView.Info + @Binding var additionalInfo: ProfilePictureView.Info? + + var size: ProfilePictureView.Size + + func makeUIView(context: Context) -> ProfilePictureView { + ProfilePictureView(size: size) + } + + func updateUIView(_ uiView: ProfilePictureView, context: Context) { + uiView.update( + info, + additionalInfo: additionalInfo + ) + } +}