#59 Show ALT info only when settings is enabled

This commit is contained in:
Marcin Czachurski 2023-04-28 20:09:01 +02:00
parent 4ac4b6ed1a
commit f686d02d88
2 changed files with 29 additions and 25 deletions

View File

@ -688,7 +688,7 @@ public struct BaseComposeView: View {
await self.sendToServer()
return
}
let notAllImagesHaveAltText = self.photosAttachment.contains(where: { ($0.uploadedAttachment?.description ?? "").isEmpty })
if notAllImagesHaveAltText == false {
await self.sendToServer()

View File

@ -6,8 +6,10 @@
import SwiftUI
import ServicesKit
import EnvironmentKit
public struct ImageUploadView: View {
@EnvironmentObject var applicationState: ApplicationState
@ObservedObject public var photoAttachment: PhotoAttachment
private let size: Double
@ -96,34 +98,36 @@ public struct ImageUploadView: View {
Spacer()
}
HStack {
Spacer()
if self.applicationState.warnAboutMissingAlt {
HStack {
Group {
if (self.photoAttachment.uploadedAttachment?.description ?? "").isEmpty {
Image(systemName: "exclamationmark.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(Color.white, Color.dangerColor)
} else {
Image(systemName: "checkmark.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(Color.white, Color.systemGreen)
}
Spacer()
HStack {
Group {
if (self.photoAttachment.uploadedAttachment?.description ?? "").isEmpty {
Image(systemName: "exclamationmark.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(Color.white, Color.dangerColor)
} else {
Image(systemName: "checkmark.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(Color.white, Color.systemGreen)
}
Text("ALT", comment: "ALT")
Text("ALT", comment: "ALT")
}
.font(.system(size: 12))
.shadow(color: .black, radius: 4)
}
.font(.system(size: 12))
.shadow(color: .black, radius: 4)
.padding(.vertical, 4)
.padding(.horizontal, 8)
.background(RoundedRectangle(cornerRadius: 8).foregroundColor(.black.opacity(0.8)))
.padding(.bottom, 4)
.padding(.trailing, 12)
.opacity(0.75)
}
.if(blur) {
$0.blur(radius: 10)
}
.padding(.vertical, 4)
.padding(.horizontal, 8)
.background(RoundedRectangle(cornerRadius: 8).foregroundColor(.black.opacity(0.8)))
.padding(.bottom, 4)
.padding(.trailing, 12)
.opacity(0.75)
}
.if(blur) {
$0.blur(radius: 10)
}
}
}