From 9bbd8f31cc41ba3dbc826aa808b2aba81a971a8f Mon Sep 17 00:00:00 2001 From: Ryan Zhao <ryanzhaors@qq.com> Date: Thu, 13 Jul 2023 17:06:33 +1000 Subject: [PATCH] WIP: message detail screen with swiftui --- Scripts/build_libSession_util.sh | 1 + Session.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/Session.xcscheme | 1 - .../MessageInfoView.swift | 184 ++++++++++++------ .../ProfilePictureView+SwiftUI.swift | 22 +-- 5 files changed, 138 insertions(+), 74 deletions(-) diff --git a/Scripts/build_libSession_util.sh b/Scripts/build_libSession_util.sh index 998c8f462..41dcbf108 100755 --- a/Scripts/build_libSession_util.sh +++ b/Scripts/build_libSession_util.sh @@ -171,3 +171,4 @@ fi # Move the target-specific libSession-util build to the parent build directory (so XCode can have a reference to a single build) rm -rf "${BUILD_DIR}/libsession-util.xcframework" cp -r "${TARGET_BUILD_DIR}/libsession-util.xcframework" "${BUILD_DIR}/libsession-util.xcframework" +#cp -r "${TARGET_BUILD_DIR}/libsession-util.xcframework" "${TEMP_ROOT}/Previews/Session/Products/libsession-util.xcframework" diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 8168f7477..98f581d5a 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -5550,8 +5550,8 @@ inputFileListPaths = ( ); inputPaths = ( - $BUILT_PRODUCTS_DIR/$INFOPLIST_PATH, - $TARGET_BUILD_DIR/$INFOPLIST_PATH, + "$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH", + "$TARGET_BUILD_DIR/$INFOPLIST_PATH", ); name = "Add Commit Hash To Build Info Plist"; outputFileListPaths = ( diff --git a/Session.xcodeproj/xcshareddata/xcschemes/Session.xcscheme b/Session.xcodeproj/xcshareddata/xcschemes/Session.xcscheme index f2e5c8744..b33e893b8 100644 --- a/Session.xcodeproj/xcshareddata/xcschemes/Session.xcscheme +++ b/Session.xcodeproj/xcshareddata/xcschemes/Session.xcscheme @@ -59,7 +59,6 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "NO" - codeCoverageEnabled = "YES" onlyGenerateCoverageForSpecifiedTargets = "YES"> <MacroExpansion> <BuildableReference diff --git a/Session/Media Viewing & Editing/MessageInfoView.swift b/Session/Media Viewing & Editing/MessageInfoView.swift index 5b131c8e8..86779f8ca 100644 --- a/Session/Media Viewing & Editing/MessageInfoView.swift +++ b/Session/Media Viewing & Editing/MessageInfoView.swift @@ -2,79 +2,123 @@ import SwiftUI import SessionUIKit +import SessionSnodeKit struct MessageInfoView: View { var actions: [ContextMenuVC.Action] var messageViewModel: MessageViewModel var body: some View { - VStack( - alignment: .center, - spacing: 10 - ) { - // Message bubble snapshot - Image("snapshot") - - // TODO: Attachment carousel view + ZStack { + if #available(iOS 14.0, *) { + Color.black.ignoresSafeArea() + } else { + Color.black + } - // Message Info - ZStack { - RoundedRectangle(cornerRadius: 8) - VStack( - alignment: .leading, - spacing: 10 - ) { - VStack( - alignment: .leading - ) { - Text("Sent:") - .bold() - Text(messageViewModel.dateForUI.fromattedForMessageInfo) - } - - VStack( - alignment: .leading - ) { - Text("Received:") - .bold() - Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo) - } - + VStack( + alignment: .center, + spacing: 10 + ) { + // Message bubble snapshot + Image("snapshot") + + // TODO: Attachment carousel view + + // Message Info + ZStack { + RoundedRectangle(cornerRadius: 17) + .fill(Color(red: 27.0/255, green: 27.0/255, blue: 27.0/255)) + VStack( - alignment: .leading + alignment: .leading, + spacing: 10 ) { - Text("From:") - .bold() - HStack( - spacing: 5 + VStack( + alignment: .leading, + spacing: 4 + ) { + Text("Sent:") + .bold() + .foregroundColor(.white) + Text(messageViewModel.dateForUI.fromattedForMessageInfo) + .foregroundColor(.white) + } + + VStack( + alignment: .leading, + spacing: 4 + ) { + Text("Received:") + .bold() + .foregroundColor(.white) + Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo) + .foregroundColor(.white) + } + + VStack( + alignment: .leading, + spacing: 4 ) { - ProfilePictureView(size: .message) - VStack( - alignment: .leading + Text("From:") + .bold() + .foregroundColor(.white) + HStack( + spacing: 5 ) { - Text(messageViewModel.authorName) - .bold() - Text(messageViewModel.authorId) + VStack( + alignment: .leading, + spacing: 4 + ) { + Text(messageViewModel.senderName ?? "Tester") + .bold() + .foregroundColor(.white) + Text(messageViewModel.authorId) + .foregroundColor(.white) + } } } } + .frame( + maxWidth: .infinity, + maxHeight: .infinity, + alignment: .topLeading + ) + .padding( + EdgeInsets( + top: 16, + leading: 16, + bottom: 16, + trailing: 16 + ) + ) } - } - - // Actions - ZStack { - RoundedRectangle(cornerRadius: 8) - VStack { - ForEach( - 0...(actions.count - 1), - id: \.self - ) { index in - HStack { - Image(uiImage: actions[index].icon!) - Text(actions[index].title) - } - } - } + .frame(maxHeight: .infinity) + .fixedSize(horizontal: false, vertical: true) + .padding( + EdgeInsets( + top: 10, + leading: 30, + bottom: 10, + trailing: 30 + ) + ) + + // Actions + // ZStack { + // RoundedRectangle(cornerRadius: 8) + // VStack { + // ForEach( + // 0...(actions.count - 1), + // id: \.self + // ) { index in + // HStack { + // Image(uiImage: actions[index].icon!) + // Text(actions[index].title) + // } + // } + // } + // } } } } @@ -84,6 +128,28 @@ struct MessageInfoView_Previews: PreviewProvider { static var previews: some View { MessageInfoView( actions: [], - messageViewModel: nil) + messageViewModel: MessageViewModel( + threadId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", + threadVariant: .contact, + threadHasDisappearingMessagesEnabled: false, + threadOpenGroupServer: nil, + threadOpenGroupPublicKey: nil, + threadContactNameInternal: "Test", + timestampMs: SnodeAPI.currentOffsetTimestampMs(), + receivedAtTimestampMs: SnodeAPI.currentOffsetTimestampMs(), + authorId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", + authorNameInternal: "Test", + body: "Test Message", + expiresStartedAtMs: nil, + expiresInSeconds: nil, + isSenderOpenGroupModerator: false, + currentUserProfile: Profile.fetchOrCreateCurrentUser(), + quote: nil, + quoteAttachment: nil, + linkPreview: nil, + linkPreviewAttachment: nil, + attachments: nil + ) + ) } } diff --git a/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift b/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift index 62334f8dc..7f3ffd5e5 100644 --- a/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift +++ b/SessionUIKit/Components/ProfilePictureView+SwiftUI.swift @@ -2,22 +2,20 @@ import SwiftUI -struct ProfilePictureView_SwiftUI: UIViewRepresentable { -// typealias UIViewType = ProfilePictureView - - @Binding var info: ProfilePictureView.Info - @Binding var additionalInfo: ProfilePictureView.Info? - +public struct ProfilePictureSwiftUI: UIViewRepresentable { + public typealias UIViewType = ProfilePictureView + var size: ProfilePictureView.Size - func makeUIView(context: Context) -> ProfilePictureView { + public init(size: ProfilePictureView.Size) { + self.size = size + } + + public func makeUIView(context: Context) -> ProfilePictureView { ProfilePictureView(size: size) } - func updateUIView(_ uiView: ProfilePictureView, context: Context) { - uiView.update( - info, - additionalInfo: additionalInfo - ) + public func updateUIView(_ uiView: ProfilePictureView, context: Context) { + } }