From ce641629cc22530fdd085ed97a8212753f1092f8 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Mon, 1 Apr 2024 00:56:51 +0200 Subject: [PATCH] Add carbs entry field as first responder when opening meal view --- LoopFollow/Application/Base.lproj/Main.storyboard | 13 +++++++++---- LoopFollow/ViewControllers/MealViewController.swift | 12 +++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index d69e72f4..f47a79a8 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -1059,7 +1059,7 @@ - + @@ -1165,11 +1165,16 @@ + + + + + @@ -1398,7 +1403,7 @@ - + @@ -1525,7 +1530,7 @@ - + @@ -1620,7 +1625,7 @@ - + diff --git a/LoopFollow/ViewControllers/MealViewController.swift b/LoopFollow/ViewControllers/MealViewController.swift index 98970103..0f7652c8 100644 --- a/LoopFollow/ViewControllers/MealViewController.swift +++ b/LoopFollow/ViewControllers/MealViewController.swift @@ -9,8 +9,13 @@ import UIKit import LocalAuthentication -class MealViewController: UIViewController { +class MealViewController: UIViewController, UITextFieldDelegate { + @IBOutlet weak var carbsEntryField: UITextField! + @IBOutlet weak var fatEntryField: UITextField! + @IBOutlet weak var proteinEntryField: UITextField! + @IBOutlet weak var notesEntryField: UITextField! + @IBOutlet weak var bolusEntryField: UITextField! @IBOutlet weak var bolusRow: UIView! @IBOutlet weak var sendMealButton: UIButton! @IBOutlet weak var carbGrams: UITextField! @@ -28,6 +33,8 @@ class MealViewController: UIViewController { if UserDefaultsRepository.forceDarkMode.value { overrideUserInterfaceStyle = .dark } + carbsEntryField.delegate = self + self.focusCarbsEntryField() // Check the value of hideRemoteBolus and hide the bolusRow accordingly if UserDefaultsRepository.hideRemoteBolus.value { @@ -35,6 +42,9 @@ class MealViewController: UIViewController { } } + func focusCarbsEntryField() { + self.carbsEntryField.becomeFirstResponder() + } @IBAction func presetButtonTapped(_ sender: Any) { let customActionViewController = storyboard!.instantiateViewController(withIdentifier: "remoteCustomAction") as! CustomActionViewController