From 3e764e75e4c3a8be9c006136bac1a3d09d34994e Mon Sep 17 00:00:00 2001 From: ericholguin Date: Wed, 8 Feb 2023 22:42:00 -0700 Subject: [PATCH] Post view improvements Changelog-Changed: Improve look of post view Closes: #561 --- damus/Views/PostView.swift | 53 ++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift index 15ff5604..cd5b7b6d 100644 --- a/damus/Views/PostView.swift +++ b/damus/Views/PostView.swift @@ -80,28 +80,41 @@ struct PostView: View { self.send_post() } } + .font(.system(size: 14, weight: .bold)) + .frame(width: 80, height: 30) + .foregroundColor(.white) + .background(LINEAR_GRADIENT) + .clipShape(Capsule()) } } .padding([.top, .bottom], 4) - - ZStack(alignment: .topLeading) { - TextEditor(text: $post) - .focused($focus) - .textInputAutocapitalization(.sentences) - .onChange(of: post) { _ in - if let replying_to { - damus_state.drafts.replies[replying_to] = post - } else { - damus_state.drafts.post = post + + HStack(alignment: .top) { + + ProfilePicView(pubkey: damus_state.pubkey, size: 45.0, highlight: .none, profiles: damus_state.profiles) + + VStack(alignment: .leading) { + ZStack(alignment: .topLeading) { + + TextEditor(text: $post) + .focused($focus) + .textInputAutocapitalization(.sentences) + .onChange(of: post) { _ in + if let replying_to { + damus_state.drafts.replies[replying_to] = post + } else { + damus_state.drafts.post = post + } + } + + if post.isEmpty { + Text(POST_PLACEHOLDER) + .padding(.top, 8) + .padding(.leading, 4) + .foregroundColor(Color(uiColor: .placeholderText)) + .allowsHitTesting(false) } } - - if post.isEmpty { - Text(POST_PLACEHOLDER) - .padding(.top, 8) - .padding(.leading, 4) - .foregroundColor(Color(uiColor: .placeholderText)) - .allowsHitTesting(false) } } @@ -168,3 +181,9 @@ func get_searching_string(_ post: String) -> String? { return String(last_word.dropFirst()) } + +struct PostView_Previews: PreviewProvider { + static var previews: some View { + PostView(replying_to: nil, references: [], damus_state: test_damus_state()) + } +}