extra ranges for mini-chart
- added extra ranges to allow 24hr/48hr/3d and 7d options - time period selected is now always shown but faded out - when double tapped, the range changes to the next one and the label is turned white and then faded back out
This commit is contained in:
parent
34bae76168
commit
7cd23589e4
|
@ -245,6 +245,15 @@ enum ConstantsGlucoseChart {
|
|||
/// the amount of hours of bg readings that the mini-chart should show (second range)
|
||||
static let miniChartHoursToShow2: Double = 48
|
||||
|
||||
/// the amount of hours of bg readings that the mini-chart should show (third range)
|
||||
static let miniChartHoursToShow3: Double = 72
|
||||
|
||||
/// the amount of hours of bg readings that the mini-chart should show (fourth range)
|
||||
static let miniChartHoursToShow4: Double = 168
|
||||
|
||||
/// tthe standard alpha value of the label. It should be less than one in order to make it more greyed out
|
||||
static let miniChartHoursToShowLabelAlpha: Double = 0.4
|
||||
|
||||
/// the size of the glucose circles used in the mini-chart
|
||||
static let miniChartGlucoseCircleDiameter: CGFloat = 3
|
||||
|
||||
|
|
|
@ -392,21 +392,21 @@
|
|||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YJB-T6-p3Y" customClass="BloodGlucoseChartView" customModule="xdrip" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="369" width="390" height="70"/>
|
||||
<subviews>
|
||||
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" alpha="0.90000000000000002" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" 24h " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WIO-Oh-Z4T">
|
||||
<rect key="frame" x="15" y="50" width="32" height="20"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" alpha="0.40000000000000002" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" 24 hours" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WIO-Oh-Z4T">
|
||||
<rect key="frame" x="5.9999999999999964" y="50" width="58.666666666666657" height="20"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="20" id="ACV-EP-M2d"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="13"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<gestureRecognizers/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="WIO-Oh-Z4T" secondAttribute="trailing" symbolic="YES" id="1RU-Mc-elX"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="WIO-Oh-Z4T" secondAttribute="trailing" id="1RU-Mc-elX"/>
|
||||
<constraint firstAttribute="height" constant="70" id="40A-Zk-fOI"/>
|
||||
<constraint firstItem="WIO-Oh-Z4T" firstAttribute="leading" secondItem="YJB-T6-p3Y" secondAttribute="leading" constant="15" id="rea-6b-zUM"/>
|
||||
<constraint firstItem="WIO-Oh-Z4T" firstAttribute="leading" secondItem="YJB-T6-p3Y" secondAttribute="leading" constant="6" id="rea-6b-zUM"/>
|
||||
<constraint firstAttribute="bottom" secondItem="WIO-Oh-Z4T" secondAttribute="bottom" id="uJt-rF-x1l"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
|
|
|
@ -270,28 +270,52 @@ final class RootViewController: UIViewController {
|
|||
|
||||
@IBAction func miniChartDoubleTapGestureRecognizer(_ sender: UITapGestureRecognizer) {
|
||||
|
||||
// if the mini-chart is double tapped then toggle the hours to show
|
||||
UserDefaults.standard.miniChartHoursToShow = UserDefaults.standard.miniChartHoursToShow == ConstantsGlucoseChart.miniChartHoursToShow1 ? ConstantsGlucoseChart.miniChartHoursToShow2 : ConstantsGlucoseChart.miniChartHoursToShow1
|
||||
switch UserDefaults.standard.miniChartHoursToShow {
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow1:
|
||||
|
||||
UserDefaults.standard.miniChartHoursToShow = ConstantsGlucoseChart.miniChartHoursToShow2
|
||||
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow).description + " " + Texts_Common.hours
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow2:
|
||||
|
||||
UserDefaults.standard.miniChartHoursToShow = ConstantsGlucoseChart.miniChartHoursToShow3
|
||||
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow / 24).description + " " + Texts_Common.days
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow3:
|
||||
|
||||
UserDefaults.standard.miniChartHoursToShow = ConstantsGlucoseChart.miniChartHoursToShow4
|
||||
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow / 24).description + " " + Texts_Common.days
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow4:
|
||||
|
||||
UserDefaults.standard.miniChartHoursToShow = ConstantsGlucoseChart.miniChartHoursToShow1
|
||||
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow).description + " " + Texts_Common.hours
|
||||
|
||||
// this will never get resolved as there is always an expected value assigned, but we need to include it to keep the compiler happy
|
||||
default:
|
||||
|
||||
UserDefaults.standard.miniChartHoursToShow = ConstantsGlucoseChart.miniChartHoursToShow1
|
||||
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow).description + " " + Texts_Common.hours
|
||||
|
||||
}
|
||||
|
||||
miniChartHoursLabelOutlet.text = " " + Int(UserDefaults.standard.miniChartHoursToShow).description + Texts_Common.hourshort + " "
|
||||
|
||||
// restore the alpha of the label
|
||||
// change alpha to fuly brighten the label temporarily
|
||||
miniChartHoursLabelOutlet.alpha = 1.0
|
||||
|
||||
// now show the label
|
||||
miniChartHoursLabelOutlet.isHidden = false
|
||||
|
||||
// wait for a second (or two) and then fade the label out
|
||||
// wait for a second and then fade the label back out
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
|
||||
// make a animated transition with the label. Fade it out over a couple of seconds.
|
||||
UIView.transition(with: self.miniChartHoursLabelOutlet, duration: 2, options: .transitionCrossDissolve, animations: {
|
||||
self.miniChartHoursLabelOutlet.alpha = 0.0
|
||||
self.miniChartHoursLabelOutlet.alpha = ConstantsGlucoseChart.miniChartHoursToShowLabelAlpha
|
||||
})
|
||||
|
||||
// once faded out, just hide it properly so that it doesn't block the tap gesture of the chart in case the user clicks where the label is
|
||||
self.miniChartHoursLabelOutlet.isHidden = true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2034,6 +2058,19 @@ final class RootViewController: UIViewController {
|
|||
|
||||
if UserDefaults.standard.showMiniChart {
|
||||
|
||||
switch UserDefaults.standard.miniChartHoursToShow {
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow1, ConstantsGlucoseChart.miniChartHoursToShow2:
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow).description + " " + Texts_Common.hours
|
||||
|
||||
case ConstantsGlucoseChart.miniChartHoursToShow3, ConstantsGlucoseChart.miniChartHoursToShow4:
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow / 24).description + " " + Texts_Common.days
|
||||
|
||||
default:
|
||||
miniChartHoursLabelOutlet.text = Int(UserDefaults.standard.miniChartHoursToShow).description + " " + Texts_Common.hours
|
||||
|
||||
}
|
||||
|
||||
// update the chart
|
||||
glucoseMiniChartManager?.updateChartPoints(chartOutlet: miniChartOutlet, completionHandler: nil)
|
||||
|
||||
|
|
Loading…
Reference in New Issue