Skip to content

Commit 85e93a7

Browse files
authored
Merge branch 'master' into bugfix/stepper-starts-with-wrong-value
2 parents fe60c20 + 745cf98 commit 85e93a7

File tree

15 files changed

+63
-64
lines changed

15 files changed

+63
-64
lines changed

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Summary
2+
*Provide an overview of what this PR has changed, and the motivation for why the change was made.*
3+
4+
*For UI changes including screenshots of before and after is great.*
5+
6+
## Validation
7+
*Outline how you have confirmed that your changes are correct. Please describe the concrete things you did to validate, not something generic like "tested changes".*
8+
9+
* *For simple refactorings it is usually sufficient to confirm the code compiles and the app launches on device or in simulator.*
10+
* *For functionality changes, make sure you have exercised the relevant parts of the app.*
11+
* *For code with different cases (e.g. future vs past) outline the different cases you have tested.*

BeeKit/GoalExtensions.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ extension Goal {
66
if self.autodata == "ifttt" { return "IFTTT" }
77
if self.autodata == "api" { return "API" }
88
if self.autodata == "apple" {
9-
let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
10-
metric.databaseString == self.healthKitMetric
11-
})
9+
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == self.healthKitMetric })
1210
return self.healthKitMetric == nil ? "Apple" : metric?.humanText
1311
}
1412
if let autodata = self.autodata, autodata.count > 0 { return autodata.capitalized }
@@ -57,17 +55,18 @@ extension Goal {
5755
}
5856

5957
public var countdownColor :UIColor {
60-
let buf = self.safeBuf
61-
if buf < 1 {
62-
return UIColor.Beeminder.red
58+
switch self.safeBuf {
59+
case ..<1:
60+
return UIColor.Beeminder.SafetyBuffer.red
61+
case ..<2:
62+
return UIColor.Beeminder.SafetyBuffer.orange
63+
case ..<3:
64+
return UIColor.Beeminder.SafetyBuffer.blue
65+
case ..<7:
66+
return UIColor.Beeminder.SafetyBuffer.green
67+
default:
68+
return UIColor.Beeminder.SafetyBuffer.forestGreen
6369
}
64-
else if buf < 2 {
65-
return UIColor.Beeminder.orange
66-
}
67-
else if buf < 3 {
68-
return UIColor.Beeminder.blue
69-
}
70-
return UIColor.Beeminder.green
7170
}
7271

7372
public var hideDataEntry: Bool {

BeeKit/HeathKit/HealthKitConfig.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
import Foundation
1010
import HealthKit
1111

12-
13-
public class HealthKitConfig : NSObject {
14-
public static let shared = HealthKitConfig()
15-
16-
public let metrics : [HealthKitMetric] = {
17-
var allMetrics : [HealthKitMetric] = [
12+
public enum HealthKitConfig {
13+
public static var metrics: [HealthKitMetric] {
14+
[
1815
// Activity
1916
QuantityHealthKitMetric(humanText: "Active energy", databaseString: "activeEnergy", category: .Activity, hkQuantityTypeIdentifier: .activeEnergyBurned, precision: [HKUnit.largeCalorie(): 0]),
2017
QuantityHealthKitMetric(humanText: "Cycling distance", databaseString: "cyclingDistance", category: .Activity, hkQuantityTypeIdentifier: .distanceCycling),
@@ -57,11 +54,9 @@ public class HealthKitConfig : NSObject {
5754
// Sleep
5855
TimeInBedHealthKitMetric(humanText: "Time in bed", databaseString: "timeInBed", category: .Sleep),
5956
TimeAsleepHealthKitMetric(humanText: "Time asleep", databaseString: "timeAsleep", category: .Sleep),
60-
57+
6158
// Other
6259
QuantityHealthKitMetric(humanText: "Time in Daylight", databaseString: "timeInDaylight", category: .Other, hkQuantityTypeIdentifier: .timeInDaylight),
6360
]
64-
65-
return allMetrics
66-
}()
61+
}
6762
}

BeeKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>6.7</string>
1919
<key>CFBundleVersion</key>
20-
<string>51</string>
20+
<string>53</string>
2121
</dict>
2222
</plist>

BeeKit/Managers/HealthStoreManager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ public actor HealthStoreManager {
149149

150150
for metricName in metricNames {
151151
if monitors[metricName] == nil {
152-
guard let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
153-
metric.databaseString == metricName
154-
}) else {
152+
guard
153+
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == metricName })
154+
else {
155155
logger.error("No metric found for \(metricName, privacy: .public)")
156156
continue
157157
}
@@ -195,9 +195,9 @@ public actor HealthStoreManager {
195195
}
196196

197197
private func updateWithRecentData(goal: Goal, days: Int) async throws {
198-
guard let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
199-
metric.databaseString == goal.healthKitMetric
200-
}) else {
198+
guard
199+
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == goal.healthKitMetric })
200+
else {
201201
throw HealthKitError("No metric found for goal \(goal.slug) with metric \(goal.healthKitMetric ?? "nil")")
202202
}
203203
let newDataPoints = try await metric.recentDataPoints(days: days, deadline: goal.deadline, healthStore: healthStore)

BeeKit/UI/UIColorExtension.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ import UIKit
1212
extension UIColor {
1313

1414
public struct Beeminder {
15-
public static let green = UIColor(red: 81.0/255.0,
16-
green: 163.0/255.0,
17-
blue: 81.0/255.0,
18-
alpha: 1)
19-
20-
public static let blue: UIColor = .systemBlue
21-
public static let orange: UIColor = .systemOrange
2215
public static let red: UIColor = .systemRed
2316

24-
public static let gray = UIColor(white: 0.7, alpha: 1.0)
17+
public static let gray = UIColor.systemGray
2518

2619
public static let yellow = UIColor(red: 255.0/255.0,
2720
green: 217.0/255.0,
2821
blue: 17.0/255.0,
2922
alpha: 1)
23+
24+
public struct SafetyBuffer {
25+
public static let red: UIColor = .systemRed // .init(red: 1, green: 0, blue: 0, alpha: 1)
26+
public static let orange: UIColor = .systemOrange // .init(red: 1, green: 165/255.0, blue: 00, alpha: 1)
27+
public static let blue: UIColor = .systemBlue // .init(red: 63/255.0, green: 63/255.0, blue: 1, alpha: 1)
28+
public static let green: UIColor = .systemGreen // .init(red: 0, green: 170/255.0, blue: 0, alpha: 1)
29+
public static let forestGreen: UIColor = .init(red: 34/255.0, green: 139/255.0, blue: 34/255.0, alpha: 1)
30+
}
3031
}
3132
}

BeeKitTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>6.7</string>
1919
<key>CFBundleVersion</key>
20-
<string>51</string>
20+
<string>53</string>
2121
</dict>
2222
</plist>

BeeSwift.xcodeproj/project.pbxproj

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@
170170
remoteGlobalIDString = A196CB131AE4142E00B90A3E;
171171
remoteInfo = BeeSwift;
172172
};
173-
E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */ = {
174-
isa = PBXContainerItemProxy;
175-
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
176-
proxyType = 1;
177-
remoteGlobalIDString = E57BE6DF2655EBD900BA540B;
178-
remoteInfo = BeeKit;
179-
};
180173
E57BE7122655F00200BA540B /* PBXContainerItemProxy */ = {
181174
isa = PBXContainerItemProxy;
182175
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
@@ -738,7 +731,6 @@
738731
);
739732
dependencies = (
740733
E5F7C4A9260FC5300095684F /* PBXTargetDependency */,
741-
E57BE6F42655EBE000BA540B /* PBXTargetDependency */,
742734
E57BE7132655F00200BA540B /* PBXTargetDependency */,
743735
);
744736
name = BeeSwift;
@@ -1176,11 +1168,6 @@
11761168
target = A196CB131AE4142E00B90A3E /* BeeSwift */;
11771169
targetProxy = E57BE6EC2655EBE000BA540B /* PBXContainerItemProxy */;
11781170
};
1179-
E57BE6F42655EBE000BA540B /* PBXTargetDependency */ = {
1180-
isa = PBXTargetDependency;
1181-
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
1182-
targetProxy = E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */;
1183-
};
11841171
E57BE7132655F00200BA540B /* PBXTargetDependency */ = {
11851172
isa = PBXTargetDependency;
11861173
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
@@ -1243,7 +1230,7 @@
12431230
CODE_SIGN_IDENTITY = "iPhone Developer";
12441231
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
12451232
COPY_PHASE_STRIP = NO;
1246-
CURRENT_PROJECT_VERSION = 51;
1233+
CURRENT_PROJECT_VERSION = 53;
12471234
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
12481235
ENABLE_STRICT_OBJC_MSGSEND = YES;
12491236
ENABLE_TESTABILITY = YES;
@@ -1308,7 +1295,7 @@
13081295
CODE_SIGN_IDENTITY = "iPhone Distribution";
13091296
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
13101297
COPY_PHASE_STRIP = NO;
1311-
CURRENT_PROJECT_VERSION = 51;
1298+
CURRENT_PROJECT_VERSION = 53;
13121299
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
13131300
ENABLE_NS_ASSERTIONS = NO;
13141301
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -1475,7 +1462,7 @@
14751462
DEFINES_MODULE = YES;
14761463
DEVELOPMENT_TEAM = 8TW9V9HVES;
14771464
DYLIB_COMPATIBILITY_VERSION = 1;
1478-
DYLIB_CURRENT_VERSION = 51;
1465+
DYLIB_CURRENT_VERSION = 53;
14791466
DYLIB_INSTALL_NAME_BASE = "@rpath";
14801467
ENABLE_MODULE_VERIFIER = YES;
14811468
EXCLUDED_ARCHS = "";
@@ -1522,7 +1509,7 @@
15221509
DEFINES_MODULE = YES;
15231510
DEVELOPMENT_TEAM = 8TW9V9HVES;
15241511
DYLIB_COMPATIBILITY_VERSION = 1;
1525-
DYLIB_CURRENT_VERSION = 51;
1512+
DYLIB_CURRENT_VERSION = 53;
15261513
DYLIB_INSTALL_NAME_BASE = "@rpath";
15271514
ENABLE_MODULE_VERIFIER = YES;
15281515
EXCLUDED_ARCHS = "";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>FILEHEADER</key>
6+
<string> Part of BeeSwift. Copyright Beeminder</string>
7+
</dict>
8+
</plist>

BeeSwift/Gallery/GalleryViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class GalleryViewController: UIViewController, UICollectionViewDelegateFlowLayou
147147
make.top.equalTo(self.searchBar.snp.bottom)
148148
make.left.equalTo(self.view.safeAreaLayoutGuide.snp.leftMargin)
149149
make.right.equalTo(self.view.safeAreaLayoutGuide.snp.rightMargin)
150-
make.bottom.equalTo(0)
150+
make.bottom.equalTo(self.collectionView!.keyboardLayoutGuide.snp.top)
151151
}
152152

153153
self.view.addSubview(self.noGoalsLabel)

0 commit comments

Comments
 (0)