Skip to content

Commit

Permalink
Merge pull request #345 from paulplant/develop
Browse files Browse the repository at this point in the history
Ignore invalid inputs to the treatments textfields to ensure that the…
  • Loading branch information
JohanDegraeve authored Apr 30, 2022
2 parents e7f0b9e + 131fdc1 commit ef1a48b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
26 changes: 13 additions & 13 deletions xdrip/Storyboards/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -162,41 +162,41 @@
<rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="XPB-uN-uCA">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="XPB-uN-uCA">
<rect key="frame" x="0.0" y="88" width="390" height="673"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="blue" indentationWidth="0.0" shouldIndentWhileEditing="NO" reuseIdentifier="TreatmentsCell" id="Gwu-WR-xta" customClass="TreatmentTableViewCell" customModule="xdrip" customModuleProvider="target">
<rect key="frame" x="0.0" y="44.666666030883789" width="390" height="45"/>
<rect key="frame" x="0.0" y="44.666666030883789" width="390" height="40.333332061767578"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Gwu-WR-xta" id="DBW-d4-0o5">
<rect key="frame" x="0.0" y="0.0" width="390" height="45"/>
<rect key="frame" x="0.0" y="0.0" width="390" height="40.333332061767578"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="3X4-8k-4dp">
<rect key="frame" x="30" y="10" width="330" height="25"/>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="3X4-8k-4dp">
<rect key="frame" x="30" y="9.9999999999999982" width="330" height="20.333333333333329"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JuE-mg-S0t">
<rect key="frame" x="0.0" y="1.6666666666666661" width="110" height="21.666666666666671"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<rect key="frame" x="0.0" y="1.6666666666666661" width="39" height="17"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Insulin" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="U6e-jp-cms">
<rect key="frame" x="110" y="1.6666666666666661" width="110" height="21.666666666666671"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<rect key="frame" x="155.33333333333334" y="1.6666666666666661" width="41.666666666666657" height="17"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="8u" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0na-qZ-kDB">
<rect key="frame" x="220" y="1.6666666666666661" width="110" height="21.666666666666671"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="8u" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0na-qZ-kDB">
<rect key="frame" x="313" y="1.6666666666666661" width="17" height="17"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="25" id="hTe-PH-KmG"/>
<constraint firstAttribute="height" constant="20" id="hTe-PH-KmG"/>
</constraints>
</stackView>
</subviews>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,25 @@ class TreatmentsInsertViewController : UIViewController {
UserDefaults.standard.nightScoutSyncTreatmentsRequired = true

}

} else {

// text is nil or "0", set treatmentdeleted to true
treatMentEntryToUpdate.treatmentdeleted = true
} else {

// set uploaded to false so that the entry is synced with NightScout
treatMentEntryToUpdate.uploaded = false

// trigger nightscoutsync
UserDefaults.standard.nightScoutSyncTreatmentsRequired = true
// even though there is not a valid/useable number entered, only delete the treatment if the user has really changed it to zero. If they didn't enter zero then just disregard the input.
if let text = textField.text, let value = Double(text.replacingOccurrences(of: ",", with: ".")), value == 0 {

// text is nil or "0", set treatmentdeleted to true
treatMentEntryToUpdate.treatmentdeleted = true

// set uploaded to false so that the entry is synced with NightScout
treatMentEntryToUpdate.uploaded = false

// trigger nightscoutsync
UserDefaults.standard.nightScoutSyncTreatmentsRequired = true

self.treatMentEntryToUpdate = nil

}

self.treatMentEntryToUpdate = nil

}

}
Expand Down

0 comments on commit ef1a48b

Please sign in to comment.