1
0
mirror of git://jb55.com/damus synced 2024-10-06 11:43:21 +00:00

Post view improvements

Changelog-Changed: Improve look of post view
Closes: #561
This commit is contained in:
ericholguin 2023-02-08 22:42:00 -07:00 committed by William Casarin
parent 7c563cb0ae
commit 3e764e75e4

View File

@ -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())
}
}