diff --git a/Loop/View Controllers/BolusViewController.swift b/Loop/View Controllers/BolusViewController.swift index 634aa91eaf..2e80ff9da3 100644 --- a/Loop/View Controllers/BolusViewController.swift +++ b/Loop/View Controllers/BolusViewController.swift @@ -22,7 +22,7 @@ final class BolusViewController: UITableViewController, IdentifiableClass, UITex bolusAmountTextField.accessibilityHint = String(format: NSLocalizedString("Recommended Bolus: %@ Units", comment: "Accessibility hint describing recommended bolus units"), spellOutFormatter.string(from: NSNumber(value: recommendedBolus)) ?? "0") bolusAmountTextField.becomeFirstResponder() - + AnalyticsManager.sharedManager.didDisplayBolusScreen() } @@ -42,10 +42,30 @@ final class BolusViewController: UITableViewController, IdentifiableClass, UITex } } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if (indexPath.row == 0) { + acceptRecommendedBolus(); + } + } + + override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + if (indexPath.row == 0) { + cell.accessibilityCustomActions = [ + UIAccessibilityCustomAction(name: NSLocalizedString("AcceptRecommendedBolus", comment: "Action to copy the recommended Bolus value to the actual Bolus Field"), target: self, selector: #selector(BolusViewController.acceptRecommendedBolus)) + ] + } + } + + @objc + func acceptRecommendedBolus() { + bolusAmountTextField?.text = recommendedBolusAmountLabel?.text + } + + @IBOutlet weak var bolusAmountTextField: UITextField! // MARK: - Actions - + @IBAction func authenticateBolus(_ sender: Any) { bolusAmountTextField.resignFirstResponder()