Skip to content

Commit

Permalink
Add carbs entry field as first responder when opening meal view
Browse files Browse the repository at this point in the history
  • Loading branch information
dsnallfot committed Mar 31, 2024
1 parent 0a525d9 commit ce64162
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 9 additions & 4 deletions LoopFollow/Application/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qqQ-Pz-Pqc" userLabel="Bolus">
<rect key="frame" x="0.0" y="201.00000000000003" width="343" height="58.999999999999972"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="1MG-ka-WeC">
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="58.999999999999972"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FKe-UD-Eyg">
Expand Down Expand Up @@ -1165,11 +1165,16 @@
<toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="bolusEntryField" destination="w60-pI-Fq0" id="B1y-LA-ZYi"/>
<outlet property="bolusRow" destination="1MG-ka-WeC" id="mBu-Yw-aqz"/>
<outlet property="bolusUnits" destination="w60-pI-Fq0" id="fzb-I7-3Q9"/>
<outlet property="carbGrams" destination="4O6-tP-VAz" id="h4d-TM-Wbc"/>
<outlet property="carbsEntryField" destination="4O6-tP-VAz" id="e4g-rY-clb"/>
<outlet property="fatEntryField" destination="ic7-Xb-WJk" id="1SU-6r-qtW"/>
<outlet property="fatGrams" destination="ic7-Xb-WJk" id="pYE-nL-A3C"/>
<outlet property="mealNotes" destination="nEW-4g-bv5" id="0sT-1i-gc6"/>
<outlet property="notesEntryField" destination="nEW-4g-bv5" id="OvQ-Op-sbG"/>
<outlet property="proteinEntryField" destination="9FK-17-HsT" id="UJM-DJ-yd8"/>
<outlet property="proteinGrams" destination="9FK-17-HsT" id="7fI-xl-d9D"/>
<outlet property="sendMealButton" destination="2mm-PR-C91" id="Hn3-MJ-5OU"/>
</connections>
Expand Down Expand Up @@ -1398,7 +1403,7 @@
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BEz-I9-sPs" userLabel="Override">
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="wxu-lS-OVn">
<rect key="frame" x="0.0" y="0.0" width="359" height="320"/>
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jzQ-mu-Jca">
Expand Down Expand Up @@ -1525,7 +1530,7 @@
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RtX-oO-1fw" userLabel="Temp Target">
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="znN-mf-lmp">
<rect key="frame" x="0.0" y="0.0" width="359" height="320"/>
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hXU-kG-KPd">
Expand Down Expand Up @@ -1620,7 +1625,7 @@
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ijq-aN-c3Y" userLabel="Temp Target">
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="TAK-9Y-biG">
<rect key="frame" x="0.0" y="0.0" width="359" height="320"/>
<rect key="frame" x="0.0" y="0.0" width="359" height="319.66666666666669"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CBe-w4-hJR">
Expand Down
12 changes: 11 additions & 1 deletion LoopFollow/ViewControllers/MealViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -28,13 +33,18 @@ 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 {
hideBolusRow()
}
}

func focusCarbsEntryField() {
self.carbsEntryField.becomeFirstResponder()
}

@IBAction func presetButtonTapped(_ sender: Any) {
let customActionViewController = storyboard!.instantiateViewController(withIdentifier: "remoteCustomAction") as! CustomActionViewController
Expand Down

0 comments on commit ce64162

Please sign in to comment.