Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 33 additions & 40 deletions FiveCalls/FiveCalls/IssueFeature/IssueContactDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct IssueContactDetail: View {
@State private var copiedPhoneNumber: String?
@AccessibilityFocusState private var isCopiedPhoneNumberFocused: Bool
@State private var isPresentingOutcomeHelpSheet = false
@State private var lastDialedPhone: String = ""

var body: some View {
ScrollView {
Expand Down Expand Up @@ -106,13 +107,7 @@ struct IssueContactDetail: View {
if currentContact.fieldOffices.count >= 1 {
Menu {
ForEach(currentContact.fieldOffices) { office in
// ControlGroup doesn't render < 16.4 (https://github.com/5calls/ios/pull/446)
if #available(iOS 16.4, *) {
ControlGroup {
MenuButtonsView(office: office, copiedPhoneNumber: $copiedPhoneNumber,
isCopiedPhoneNumberFocused: _isCopiedPhoneNumberFocused, call: call)
}
} else {
ControlGroup {
MenuButtonsView(office: office, copiedPhoneNumber: $copiedPhoneNumber,
isCopiedPhoneNumberFocused: _isCopiedPhoneNumberFocused, call: call)
}
Expand All @@ -132,7 +127,7 @@ struct IssueContactDetail: View {
.padding(.bottom)

OutcomesView(outcomes: issue.outcomeModels, report: { outcome in
let log = ContactLog(issueId: String(issue.id), contactId: currentContact.id, phone: "", outcome: outcome.status, date: Date(), reported: true)
let log = ContactLog(issueId: String(issue.id), contactId: currentContact.id, phone: lastDialedPhone, outcome: outcome.status, date: Date(), reported: true)
store.dispatch(action: .ReportOutcome(issue, log, outcome))
store.dispatch(action: .GoToNext(issue, nextContacts))
})
Expand Down Expand Up @@ -160,6 +155,7 @@ struct IssueContactDetail: View {
}

private func call(phoneNumber: String) {
lastDialedPhone = phoneNumber
let telephone = "tel://"
let formattedString = telephone + phoneNumber
guard let url = URL(string: formattedString) else { return }
Expand Down Expand Up @@ -198,44 +194,41 @@ struct MenuButtonsView: View {
)
)

// disable copy < 16.4 for rationale see https://github.com/5calls/ios/pull/446
if #available(iOS 16.4, *) {
Button {
UIPasteboard.general.string = office.phone
withAnimation {
copiedPhoneNumber = office.phone
if UIAccessibility.isVoiceOverRunning {
isCopiedPhoneNumberFocused = true
}
Button {
UIPasteboard.general.string = office.phone
withAnimation {
copiedPhoneNumber = office.phone
if UIAccessibility.isVoiceOverRunning {
isCopiedPhoneNumberFocused = true
}
}

DispatchQueue.main.asyncAfter(wallDeadline: .now() + 3) {
withAnimation {
isCopiedPhoneNumberFocused = false
copiedPhoneNumber = nil
}
}
} label: {
if dynamicTypeSize >= .accessibility1 {
Text("Copy \(office.city) \(office.phone)", comment: "Copy phone numbers text")
} else {
Image(systemName: "doc.on.doc")
Text("Copy", comment: "Copy phone number short text")
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 3) {
withAnimation {
isCopiedPhoneNumberFocused = false
copiedPhoneNumber = nil
}
}
.accessibilityLabel(
String(
localized: "Copy \(office.city) \(office.phone)",
comment: "Copy phone numbers accessibility label"
)
} label: {
if dynamicTypeSize >= .accessibility1 {
Text("Copy \(office.city) \(office.phone)", comment: "Copy phone numbers text")
} else {
Image(systemName: "doc.on.doc")
Text("Copy", comment: "Copy phone number short text")
}
}
.accessibilityLabel(
String(
localized: "Copy \(office.city) \(office.phone)",
comment: "Copy phone numbers accessibility label"
)
.accessibilityHint(
String(
localized: "Triple tap to copy",
comment: "Copy phone number accessibility hint"
)
)
.accessibilityHint(
String(
localized: "Triple tap to copy",
comment: "Copy phone number accessibility hint"
)
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ReportOutcomeOperation: BaseOperation, @unchecked Sendable {
"result": outcome.label,
"contactid": log.contactId,
"issueid": log.issueId,
"phone": log.phone,
"phone": log.phone.filter(\.isNumber),
"via": via,
"callerid": AnalyticsManager.shared.callerID,
]
Expand Down