Disable post button when media upload in progress

Changelog-Fixed: Disable post button when media upload in progress
Closes: #1324
This commit is contained in:
2023-06-25 20:27:07 -04:00
committed by William Casarin
parent 14accd222e
commit 25b3df8b89

View File

@@ -130,6 +130,14 @@ struct PostView: View {
var is_post_empty: Bool {
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 {
Button(action: {
@@ -154,7 +162,7 @@ struct PostView: View {
ImageButton
CameraButton
}
.disabled(image_upload.progress != nil)
.disabled(uploading_disabled)
}
var PostButton: some View {
@@ -165,12 +173,12 @@ struct PostView: View {
self.send_post()
}
}
.disabled(is_post_empty)
.disabled(posting_disabled)
.font(.system(size: 14, weight: .bold))
.frame(width: 80, height: 30)
.foregroundColor(.white)
.background(LINEAR_GRADIENT)
.opacity(is_post_empty ? 0.5 : 1.0)
.opacity(posting_disabled ? 0.5 : 1.0)
.clipShape(Capsule())
}