Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/stepper-starts-with-wrong-value
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk authored Dec 6, 2024
2 parents fe60c20 + 745cf98 commit 85e93a7
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 64 deletions.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Summary
*Provide an overview of what this PR has changed, and the motivation for why the change was made.*

*For UI changes including screenshots of before and after is great.*

## Validation
*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".*

* *For simple refactorings it is usually sufficient to confirm the code compiles and the app launches on device or in simulator.*
* *For functionality changes, make sure you have exercised the relevant parts of the app.*
* *For code with different cases (e.g. future vs past) outline the different cases you have tested.*
25 changes: 12 additions & 13 deletions BeeKit/GoalExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ extension Goal {
if self.autodata == "ifttt" { return "IFTTT" }
if self.autodata == "api" { return "API" }
if self.autodata == "apple" {
let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
metric.databaseString == self.healthKitMetric
})
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == self.healthKitMetric })
return self.healthKitMetric == nil ? "Apple" : metric?.humanText
}
if let autodata = self.autodata, autodata.count > 0 { return autodata.capitalized }
Expand Down Expand Up @@ -57,17 +55,18 @@ extension Goal {
}

public var countdownColor :UIColor {
let buf = self.safeBuf
if buf < 1 {
return UIColor.Beeminder.red
switch self.safeBuf {
case ..<1:
return UIColor.Beeminder.SafetyBuffer.red
case ..<2:
return UIColor.Beeminder.SafetyBuffer.orange
case ..<3:
return UIColor.Beeminder.SafetyBuffer.blue
case ..<7:
return UIColor.Beeminder.SafetyBuffer.green
default:
return UIColor.Beeminder.SafetyBuffer.forestGreen
}
else if buf < 2 {
return UIColor.Beeminder.orange
}
else if buf < 3 {
return UIColor.Beeminder.blue
}
return UIColor.Beeminder.green
}

public var hideDataEntry: Bool {
Expand Down
15 changes: 5 additions & 10 deletions BeeKit/HeathKit/HealthKitConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
import Foundation
import HealthKit


public class HealthKitConfig : NSObject {
public static let shared = HealthKitConfig()

public let metrics : [HealthKitMetric] = {
var allMetrics : [HealthKitMetric] = [
public enum HealthKitConfig {
public static var metrics: [HealthKitMetric] {
[
// Activity
QuantityHealthKitMetric(humanText: "Active energy", databaseString: "activeEnergy", category: .Activity, hkQuantityTypeIdentifier: .activeEnergyBurned, precision: [HKUnit.largeCalorie(): 0]),
QuantityHealthKitMetric(humanText: "Cycling distance", databaseString: "cyclingDistance", category: .Activity, hkQuantityTypeIdentifier: .distanceCycling),
Expand Down Expand Up @@ -57,11 +54,9 @@ public class HealthKitConfig : NSObject {
// Sleep
TimeInBedHealthKitMetric(humanText: "Time in bed", databaseString: "timeInBed", category: .Sleep),
TimeAsleepHealthKitMetric(humanText: "Time asleep", databaseString: "timeAsleep", category: .Sleep),

// Other
QuantityHealthKitMetric(humanText: "Time in Daylight", databaseString: "timeInDaylight", category: .Other, hkQuantityTypeIdentifier: .timeInDaylight),
]

return allMetrics
}()
}
}
2 changes: 1 addition & 1 deletion BeeKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
</dict>
</plist>
12 changes: 6 additions & 6 deletions BeeKit/Managers/HealthStoreManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public actor HealthStoreManager {

for metricName in metricNames {
if monitors[metricName] == nil {
guard let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
metric.databaseString == metricName
}) else {
guard
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == metricName })
else {
logger.error("No metric found for \(metricName, privacy: .public)")
continue
}
Expand Down Expand Up @@ -195,9 +195,9 @@ public actor HealthStoreManager {
}

private func updateWithRecentData(goal: Goal, days: Int) async throws {
guard let metric = HealthKitConfig.shared.metrics.first(where: { (metric) -> Bool in
metric.databaseString == goal.healthKitMetric
}) else {
guard
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == goal.healthKitMetric })
else {
throw HealthKitError("No metric found for goal \(goal.slug) with metric \(goal.healthKitMetric ?? "nil")")
}
let newDataPoints = try await metric.recentDataPoints(days: days, deadline: goal.deadline, healthStore: healthStore)
Expand Down
17 changes: 9 additions & 8 deletions BeeKit/UI/UIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ import UIKit
extension UIColor {

public struct Beeminder {
public static let green = UIColor(red: 81.0/255.0,
green: 163.0/255.0,
blue: 81.0/255.0,
alpha: 1)

public static let blue: UIColor = .systemBlue
public static let orange: UIColor = .systemOrange
public static let red: UIColor = .systemRed

public static let gray = UIColor(white: 0.7, alpha: 1.0)
public static let gray = UIColor.systemGray

public static let yellow = UIColor(red: 255.0/255.0,
green: 217.0/255.0,
blue: 17.0/255.0,
alpha: 1)

public struct SafetyBuffer {
public static let red: UIColor = .systemRed // .init(red: 1, green: 0, blue: 0, alpha: 1)
public static let orange: UIColor = .systemOrange // .init(red: 1, green: 165/255.0, blue: 00, alpha: 1)
public static let blue: UIColor = .systemBlue // .init(red: 63/255.0, green: 63/255.0, blue: 1, alpha: 1)
public static let green: UIColor = .systemGreen // .init(red: 0, green: 170/255.0, blue: 0, alpha: 1)
public static let forestGreen: UIColor = .init(red: 34/255.0, green: 139/255.0, blue: 34/255.0, alpha: 1)
}
}
}
2 changes: 1 addition & 1 deletion BeeKitTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
</dict>
</plist>
21 changes: 4 additions & 17 deletions BeeSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@
remoteGlobalIDString = A196CB131AE4142E00B90A3E;
remoteInfo = BeeSwift;
};
E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
proxyType = 1;
remoteGlobalIDString = E57BE6DF2655EBD900BA540B;
remoteInfo = BeeKit;
};
E57BE7122655F00200BA540B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
Expand Down Expand Up @@ -738,7 +731,6 @@
);
dependencies = (
E5F7C4A9260FC5300095684F /* PBXTargetDependency */,
E57BE6F42655EBE000BA540B /* PBXTargetDependency */,
E57BE7132655F00200BA540B /* PBXTargetDependency */,
);
name = BeeSwift;
Expand Down Expand Up @@ -1176,11 +1168,6 @@
target = A196CB131AE4142E00B90A3E /* BeeSwift */;
targetProxy = E57BE6EC2655EBE000BA540B /* PBXContainerItemProxy */;
};
E57BE6F42655EBE000BA540B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
targetProxy = E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */;
};
E57BE7132655F00200BA540B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
Expand Down Expand Up @@ -1243,7 +1230,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 53;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -1308,7 +1295,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 53;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -1475,7 +1462,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8TW9V9HVES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 51;
DYLIB_CURRENT_VERSION = 53;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
EXCLUDED_ARCHS = "";
Expand Down Expand Up @@ -1522,7 +1509,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8TW9V9HVES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 51;
DYLIB_CURRENT_VERSION = 53;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
EXCLUDED_ARCHS = "";
Expand Down
8 changes: 8 additions & 0 deletions BeeSwift.xcodeproj/xcshareddata/IDETemplateMacros.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string> Part of BeeSwift. Copyright Beeminder</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion BeeSwift/Gallery/GalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class GalleryViewController: UIViewController, UICollectionViewDelegateFlowLayou
make.top.equalTo(self.searchBar.snp.bottom)
make.left.equalTo(self.view.safeAreaLayoutGuide.snp.leftMargin)
make.right.equalTo(self.view.safeAreaLayoutGuide.snp.rightMargin)
make.bottom.equalTo(0)
make.bottom.equalTo(self.collectionView!.keyboardLayoutGuide.snp.top)
}

self.view.addSubview(self.noGoalsLabel)
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
4 changes: 1 addition & 3 deletions BeeSwift/Settings/ChooseHKMetricViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class ChooseHKMetricViewController: UIViewController {

extension ChooseHKMetricViewController : UITableViewDelegate, UITableViewDataSource {
var sortedHKMetrics: [HealthKitMetric] {
HealthKitConfig.shared.metrics.sorted { (lhs, rhs) -> Bool in
lhs.humanText < rhs.humanText
}
HealthKitConfig.metrics.sorted(using: SortDescriptor(\.humanText))
}

var sortedMetricsByCategory: Dictionary<HealthKitCategory, [HealthKitMetric]> {
Expand Down
2 changes: 1 addition & 1 deletion BeeSwiftIntents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion BeeSwiftTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion BeeSwiftUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>53</string>
</dict>
</plist>

0 comments on commit 85e93a7

Please sign in to comment.