mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-22 08:17:28 +00:00
add confirm and a trusted-confirmation badge to urgent notice rows
Urgent board posts from someone else get a shield button, a leading swipe action, and an accessibility action to endorse them. Once people we trust have endorsed a post, the row shows "confirmed (N)" next to the urgent badge, and VoiceOver reads it too. NoticesList now observes the board so the badge updates as endorsements sync in. Non-English strings are marked needs_review.
This commit is contained in:
parent
5eccfaba3e
commit
14f5e5d732
@ -373,6 +373,192 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"board.action.confirm" : {
|
||||
"comment" : "Action to vouch for someone else's urgent board post; people who verified you see it as a confirmation",
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"ar" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "تأكيد"
|
||||
}
|
||||
},
|
||||
"bn" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "নিশ্চিত করো"
|
||||
}
|
||||
},
|
||||
"de" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bestätigen"
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "confirm"
|
||||
}
|
||||
},
|
||||
"es" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmar"
|
||||
}
|
||||
},
|
||||
"fa" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "تأیید"
|
||||
}
|
||||
},
|
||||
"fil" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "kumpirmahin"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmer"
|
||||
}
|
||||
},
|
||||
"he" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "אישור"
|
||||
}
|
||||
},
|
||||
"hi" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "पुष्टि करो"
|
||||
}
|
||||
},
|
||||
"id" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "konfirmasi"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "conferma"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "確認する"
|
||||
}
|
||||
},
|
||||
"ko" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "확인"
|
||||
}
|
||||
},
|
||||
"ms" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "sahkan"
|
||||
}
|
||||
},
|
||||
"ne" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "पुष्टि गर्नुहोस्"
|
||||
}
|
||||
},
|
||||
"nl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bevestigen"
|
||||
}
|
||||
},
|
||||
"pl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "potwierdź"
|
||||
}
|
||||
},
|
||||
"pt" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmar"
|
||||
}
|
||||
},
|
||||
"pt-BR" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmar"
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "подтвердить"
|
||||
}
|
||||
},
|
||||
"sv" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bekräfta"
|
||||
}
|
||||
},
|
||||
"ta" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "உறுதிப்படுத்து"
|
||||
}
|
||||
},
|
||||
"th" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "ยืนยัน"
|
||||
}
|
||||
},
|
||||
"tr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "onayla"
|
||||
}
|
||||
},
|
||||
"uk" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "підтвердити"
|
||||
}
|
||||
},
|
||||
"ur" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "تصدیق کریں"
|
||||
}
|
||||
},
|
||||
"vi" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "xác nhận"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "确认"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "確認"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"board.action.delete" : {
|
||||
"comment" : "Delete action for own board posts",
|
||||
"extractionState" : "manual",
|
||||
@ -1303,6 +1489,192 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"board.confirmed_badge" : {
|
||||
"comment" : "Badge on an urgent board post endorsed by people the user verified or vouched for; placeholder is how many",
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"ar" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "مؤكَّد (%lld)"
|
||||
}
|
||||
},
|
||||
"bn" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "নিশ্চিত (%lld)"
|
||||
}
|
||||
},
|
||||
"de" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bestätigt (%lld)"
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "confirmed (%lld)"
|
||||
}
|
||||
},
|
||||
"es" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmado (%lld)"
|
||||
}
|
||||
},
|
||||
"fa" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "تأییدشده (%lld)"
|
||||
}
|
||||
},
|
||||
"fil" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "kumpirmado (%lld)"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmé (%lld)"
|
||||
}
|
||||
},
|
||||
"he" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "מאושר (%lld)"
|
||||
}
|
||||
},
|
||||
"hi" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "पुष्टि (%lld)"
|
||||
}
|
||||
},
|
||||
"id" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "terkonfirmasi (%lld)"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confermato (%lld)"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "確認済み (%lld)"
|
||||
}
|
||||
},
|
||||
"ko" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "확인됨 (%lld)"
|
||||
}
|
||||
},
|
||||
"ms" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "disahkan (%lld)"
|
||||
}
|
||||
},
|
||||
"ne" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "पुष्टि भयो (%lld)"
|
||||
}
|
||||
},
|
||||
"nl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bevestigd (%lld)"
|
||||
}
|
||||
},
|
||||
"pl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "potwierdzone (%lld)"
|
||||
}
|
||||
},
|
||||
"pt" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmado (%lld)"
|
||||
}
|
||||
},
|
||||
"pt-BR" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "confirmado (%lld)"
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "подтверждено (%lld)"
|
||||
}
|
||||
},
|
||||
"sv" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "bekräftad (%lld)"
|
||||
}
|
||||
},
|
||||
"ta" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "உறுதிசெய்யப்பட்டது (%lld)"
|
||||
}
|
||||
},
|
||||
"th" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "ยืนยันแล้ว (%lld)"
|
||||
}
|
||||
},
|
||||
"tr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "onaylandı (%lld)"
|
||||
}
|
||||
},
|
||||
"uk" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "підтверджено (%lld)"
|
||||
}
|
||||
},
|
||||
"ur" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "تصدیق شدہ (%lld)"
|
||||
}
|
||||
},
|
||||
"vi" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "đã xác nhận (%lld)"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "已确认 (%lld)"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "已確認 (%lld)"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"board.empty_subtitle" : {
|
||||
"comment" : "Subtitle shown when the board has no posts",
|
||||
"extractionState" : "manual",
|
||||
|
||||
@ -248,6 +248,7 @@ struct NoticesView: View {
|
||||
static let placeholder = String(localized: "board.compose.placeholder", defaultValue: "post a notice…", comment: "Placeholder for the board composer text field")
|
||||
static let send = String(localized: "board.accessibility.post", defaultValue: "Post notice", comment: "Accessibility label for the board post button")
|
||||
static let deleteAction = String(localized: "board.action.delete", defaultValue: "delete", comment: "Delete action for own board posts")
|
||||
static let confirmAction = String(localized: "board.action.confirm", defaultValue: "confirm", comment: "Action to vouch for someone else's urgent board post; people who verified you see it as a confirmation")
|
||||
static let expiryLabel = String(localized: "board.compose.expiry", defaultValue: "expires in", comment: "Label for the board post expiry picker")
|
||||
static let permanentOption = String(localized: "notices.expiry.permanent", defaultValue: "permanent", comment: "Accessibility label for the ∞ (never expires) option in the geo notes expiry picker")
|
||||
static let closeHint = String(localized: "notices.accessibility.close", defaultValue: "Close notices", comment: "Accessibility label for the notices close button")
|
||||
@ -282,13 +283,24 @@ struct NoticesView: View {
|
||||
)
|
||||
}
|
||||
|
||||
static func rowAccessibilityLabel(author: String, content: String, urgent: Bool) -> String {
|
||||
static func confirmedBadge(_ count: Int) -> String {
|
||||
String(
|
||||
format: String(localized: "board.confirmed_badge", defaultValue: "confirmed (%lld)", comment: "Badge on an urgent board post endorsed by people the user verified or vouched for; placeholder is how many"),
|
||||
locale: .current,
|
||||
count
|
||||
)
|
||||
}
|
||||
|
||||
static func rowAccessibilityLabel(author: String, content: String, urgent: Bool, confirmations: Int = 0) -> String {
|
||||
let base = String(
|
||||
format: String(localized: "board.accessibility.post_row", defaultValue: "Notice from %@: %@", comment: "Accessibility label for a board post row"),
|
||||
locale: .current,
|
||||
author, content
|
||||
)
|
||||
return urgent ? "\(urgentBadge), \(base)" : base
|
||||
var prefix: [String] = []
|
||||
if urgent { prefix.append(urgentBadge) }
|
||||
if confirmations > 0 { prefix.append(confirmedBadge(confirmations)) }
|
||||
return prefix.isEmpty ? base : (prefix + [base]).joined(separator: ", ")
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,7 +611,7 @@ private struct GeoNoticesList: View {
|
||||
private struct NoticesList: View {
|
||||
let items: [NoticeItem]
|
||||
let showsSource: Bool
|
||||
let board: BoardManager
|
||||
@ObservedObject var board: BoardManager
|
||||
let notesManager: LocationNotesManager?
|
||||
|
||||
@ThemedPalette private var palette
|
||||
@ -722,8 +734,25 @@ private struct NoticesList: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmations(_ item: NoticeItem) -> Int {
|
||||
guard case .board(let post) = item.source else { return 0 }
|
||||
return board.confirmationCount(for: post)
|
||||
}
|
||||
|
||||
private func canEndorse(_ item: NoticeItem) -> Bool {
|
||||
guard case .board(let post) = item.source else { return false }
|
||||
return board.canEndorse(post)
|
||||
}
|
||||
|
||||
private func endorse(_ item: NoticeItem) {
|
||||
guard case .board(let post) = item.source else { return }
|
||||
board.endorsePost(post)
|
||||
}
|
||||
|
||||
private func row(_ item: NoticeItem) -> some View {
|
||||
let isOwn = canDelete(item)
|
||||
let confirmed = confirmations(item)
|
||||
let endorsable = canEndorse(item)
|
||||
return VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 6) {
|
||||
if item.isUrgent {
|
||||
@ -734,6 +763,14 @@ private struct NoticesList: View {
|
||||
.bitchatFont(size: 11, weight: .semibold)
|
||||
.foregroundColor(palette.alertRed)
|
||||
}
|
||||
if confirmed > 0 {
|
||||
Image(systemName: "checkmark.shield.fill")
|
||||
.font(.bitchatSystem(size: 11))
|
||||
.foregroundColor(palette.accent)
|
||||
Text(Strings.confirmedBadge(confirmed))
|
||||
.bitchatFont(size: 11, weight: .semibold)
|
||||
.foregroundColor(palette.accent)
|
||||
}
|
||||
Text(verbatim: "@\(item.author)")
|
||||
.bitchatFont(size: 12, weight: .semibold)
|
||||
Text(Self.timestampText(for: item.createdAt))
|
||||
@ -748,6 +785,17 @@ private struct NoticesList: View {
|
||||
if showsSource {
|
||||
sourceBadge(item)
|
||||
}
|
||||
if endorsable {
|
||||
Button {
|
||||
endorse(item)
|
||||
} label: {
|
||||
Image(systemName: "checkmark.shield")
|
||||
.font(.bitchatSystem(size: 12))
|
||||
.foregroundColor(palette.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel(Strings.confirmAction)
|
||||
}
|
||||
if isOwn {
|
||||
Button {
|
||||
delete(item)
|
||||
@ -766,12 +814,25 @@ private struct NoticesList: View {
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(Strings.rowAccessibilityLabel(author: item.author, content: item.content, urgent: item.isUrgent))
|
||||
.accessibilityLabel(Strings.rowAccessibilityLabel(author: item.author, content: item.content, urgent: item.isUrgent, confirmations: confirmed))
|
||||
.accessibilityActions {
|
||||
if endorsable {
|
||||
Button(Strings.confirmAction) { endorse(item) }
|
||||
}
|
||||
if isOwn {
|
||||
Button(Strings.deleteAction) { delete(item) }
|
||||
}
|
||||
}
|
||||
.swipeActions(edge: .leading, allowsFullSwipe: true) {
|
||||
if endorsable {
|
||||
Button {
|
||||
endorse(item)
|
||||
} label: {
|
||||
Label(Strings.confirmAction, systemImage: "checkmark.shield")
|
||||
}
|
||||
.tint(palette.accent)
|
||||
}
|
||||
}
|
||||
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
|
||||
if isOwn {
|
||||
Button(role: .destructive) {
|
||||
|
||||
@ -209,4 +209,20 @@ struct BoardManagerTests {
|
||||
let manager = makeManager(trusted: [Curve25519.Signing.PrivateKey().publicKey.rawRepresentation])
|
||||
#expect(manager.confirmationCount(for: try makePost()) == 0)
|
||||
}
|
||||
|
||||
// MARK: - Notices row label
|
||||
|
||||
@Test func rowLabelAnnouncesConfirmationAfterUrgency() {
|
||||
let label = NoticesView.Strings.rowAccessibilityLabel(author: "scout", content: "bridge out", urgent: true, confirmations: 2)
|
||||
let urgent = NoticesView.Strings.urgentBadge
|
||||
let confirmed = NoticesView.Strings.confirmedBadge(2)
|
||||
#expect(label.hasPrefix("\(urgent), \(confirmed), "))
|
||||
#expect(label.contains("bridge out"))
|
||||
}
|
||||
|
||||
@Test func rowLabelOmitsConfirmationWhenNobodyTrustedConfirmed() {
|
||||
let label = NoticesView.Strings.rowAccessibilityLabel(author: "scout", content: "bridge out", urgent: true)
|
||||
#expect(!label.contains(NoticesView.Strings.confirmedBadge(0)))
|
||||
#expect(label.hasPrefix("\(NoticesView.Strings.urgentBadge), "))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user