#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() await self.sendToServer()
return return
} }
let notAllImagesHaveAltText = self.photosAttachment.contains(where: { ($0.uploadedAttachment?.description ?? "").isEmpty }) let notAllImagesHaveAltText = self.photosAttachment.contains(where: { ($0.uploadedAttachment?.description ?? "").isEmpty })
if notAllImagesHaveAltText == false { if notAllImagesHaveAltText == false {
await self.sendToServer() await self.sendToServer()

View File

@ -6,8 +6,10 @@
import SwiftUI import SwiftUI
import ServicesKit import ServicesKit
import EnvironmentKit
public struct ImageUploadView: View { public struct ImageUploadView: View {
@EnvironmentObject var applicationState: ApplicationState
@ObservedObject public var photoAttachment: PhotoAttachment @ObservedObject public var photoAttachment: PhotoAttachment
private let size: Double private let size: Double
@ -96,34 +98,36 @@ public struct ImageUploadView: View {
Spacer() Spacer()
} }
HStack { if self.applicationState.warnAboutMissingAlt {
Spacer()
HStack { HStack {
Group { Spacer()
if (self.photoAttachment.uploadedAttachment?.description ?? "").isEmpty { HStack {
Image(systemName: "exclamationmark.circle.fill") Group {
.symbolRenderingMode(.palette) if (self.photoAttachment.uploadedAttachment?.description ?? "").isEmpty {
.foregroundStyle(Color.white, Color.dangerColor) Image(systemName: "exclamationmark.circle.fill")
} else { .symbolRenderingMode(.palette)
Image(systemName: "checkmark.circle.fill") .foregroundStyle(Color.white, Color.dangerColor)
.symbolRenderingMode(.palette) } else {
.foregroundStyle(Color.white, Color.systemGreen) 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)) .padding(.vertical, 4)
.shadow(color: .black, radius: 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)
} }
} }
} }