Post view improvements
Changelog-Changed: Improve look of post view Closes: #561
This commit is contained in:
committed by
William Casarin
parent
7c563cb0ae
commit
3e764e75e4
@@ -80,28 +80,41 @@ struct PostView: View {
|
|||||||
self.send_post()
|
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)
|
.padding([.top, .bottom], 4)
|
||||||
|
|
||||||
ZStack(alignment: .topLeading) {
|
HStack(alignment: .top) {
|
||||||
TextEditor(text: $post)
|
|
||||||
.focused($focus)
|
ProfilePicView(pubkey: damus_state.pubkey, size: 45.0, highlight: .none, profiles: damus_state.profiles)
|
||||||
.textInputAutocapitalization(.sentences)
|
|
||||||
.onChange(of: post) { _ in
|
VStack(alignment: .leading) {
|
||||||
if let replying_to {
|
ZStack(alignment: .topLeading) {
|
||||||
damus_state.drafts.replies[replying_to] = post
|
|
||||||
} else {
|
TextEditor(text: $post)
|
||||||
damus_state.drafts.post = 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())
|
return String(last_word.dropFirst())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PostView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
PostView(replying_to: nil, references: [], damus_state: test_damus_state())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user