Compare commits

...

1 Commits

Author SHA1 Message Date
16f6bbb5be Disable post button when media upload in progress
Changelog-Fixed: Disable post button when media upload in progress
2023-06-25 20:27:10 -04:00

View File

@@ -111,6 +111,14 @@ struct PostView: View {
var is_post_empty: Bool { var is_post_empty: Bool {
return post.string.allSatisfy { $0.isWhitespace } && uploadedMedias.isEmpty return post.string.allSatisfy { $0.isWhitespace } && uploadedMedias.isEmpty
} }
var uploading_disabled: Bool {
return image_upload.progress != nil
}
var posting_disabled: Bool {
return is_post_empty || uploading_disabled
}
var ImageButton: some View { var ImageButton: some View {
Button(action: { Button(action: {
@@ -135,7 +143,7 @@ struct PostView: View {
ImageButton ImageButton
CameraButton CameraButton
} }
.disabled(image_upload.progress != nil) .disabled(uploading_disabled)
} }
var PostButton: some View { var PostButton: some View {
@@ -146,12 +154,12 @@ struct PostView: View {
self.send_post() self.send_post()
} }
} }
.disabled(is_post_empty) .disabled(posting_disabled)
.font(.system(size: 14, weight: .bold)) .font(.system(size: 14, weight: .bold))
.frame(width: 80, height: 30) .frame(width: 80, height: 30)
.foregroundColor(.white) .foregroundColor(.white)
.background(LINEAR_GRADIENT) .background(LINEAR_GRADIENT)
.opacity(is_post_empty ? 0.5 : 1.0) .opacity(posting_disabled ? 0.5 : 1.0)
.clipShape(Capsule()) .clipShape(Capsule())
} }