Add post attachment bar for images and future things

This commit is contained in:
William Casarin
2023-03-15 15:32:51 -06:00
parent a574dcb27c
commit bc58686016

View File

@@ -69,24 +69,21 @@ struct PostView: View {
return post.string.allSatisfy { $0.isWhitespace } return post.string.allSatisfy { $0.isWhitespace }
} }
var body: some View { var ImageButton: some View {
VStack { Button(action: {
HStack {
Button(NSLocalizedString("Cancel", comment: "Button to cancel out of posting a note.")) {
self.cancel()
}
.foregroundColor(.primary)
Spacer()
.frame(width: 70)
Button(NSLocalizedString("Attach image", comment: "Button to attach image.")) {
attach_media = true attach_media = true
}.foregroundColor(.primary) }, label: {
Image(systemName: "photo")
})
}
Spacer() var AttachmentBar: some View {
HStack(alignment: .center) {
ImageButton
}
}
if !is_post_empty { var PostButton: some View {
Button(NSLocalizedString("Post", comment: "Button to post a note.")) { Button(NSLocalizedString("Post", comment: "Button to post a note.")) {
showPrivateKeyWarning = contentContainsPrivateKey(self.post.string) showPrivateKeyWarning = contentContainsPrivateKey(self.post.string)
@@ -100,17 +97,9 @@ struct PostView: View {
.background(LINEAR_GRADIENT) .background(LINEAR_GRADIENT)
.clipShape(Capsule()) .clipShape(Capsule())
} }
}
.frame(height: 30)
.padding([.top, .bottom], 4)
HStack(alignment: .top) { var TextEntry: some View {
ProfilePicView(pubkey: damus_state.pubkey, size: 45.0, highlight: .none, profiles: damus_state.profiles)
VStack(alignment: .leading) {
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
TextViewWrapper(attributedText: $post) TextViewWrapper(attributedText: $post)
.focused($focus) .focused($focus)
.textInputAutocapitalization(.sentences) .textInputAutocapitalization(.sentences)
@@ -131,6 +120,32 @@ struct PostView: View {
} }
} }
} }
var TopBar: some View {
HStack {
Button(NSLocalizedString("Cancel", comment: "Button to cancel out of posting a note.")) {
self.cancel()
}
.foregroundColor(.primary)
Spacer()
if !is_post_empty {
PostButton
}
}
.frame(height: 30)
.padding([.top, .bottom], 4)
}
var body: some View {
VStack(alignment: .leading) {
TopBar
HStack(alignment: .top) {
ProfilePicView(pubkey: damus_state.pubkey, size: 45.0, highlight: .none, profiles: damus_state.profiles)
TextEntry
} }
// This if-block observes @ for tagging // This if-block observes @ for tagging
@@ -140,6 +155,11 @@ struct PostView: View {
UserSearch(damus_state: damus_state, search: searching, post: $post) UserSearch(damus_state: damus_state, search: searching, post: $post)
}.zIndex(1) }.zIndex(1)
} }
Divider()
.padding([.bottom], 10)
AttachmentBar
} }
.sheet(isPresented: $attach_media) { .sheet(isPresented: $attach_media) {
ImagePicker(sourceType: .photoLibrary) { image in ImagePicker(sourceType: .photoLibrary) { image in