Skip to content

Commit

Permalink
Merge branch 'master' into feature/68-ios14-style-widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk authored Dec 5, 2024
2 parents 8649a39 + 3edd09d commit 8e6a768
Show file tree
Hide file tree
Showing 52 changed files with 99 additions and 473 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
22 changes: 7 additions & 15 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 @@ -53,18 +50,13 @@ public class HealthKitConfig : NSObject {
QuantityHealthKitMetric(humanText: "Vitamin E", databaseString: "dietaryVitaminE", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryVitaminE),
QuantityHealthKitMetric(humanText: "Vitamin K", databaseString: "dietaryVitaminK", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryVitaminK),
QuantityHealthKitMetric(humanText: "Water", databaseString: "water", category: .Nutrition, hkQuantityTypeIdentifier: .dietaryWater),

// Sleep
TimeInBedHealthKitMetric(humanText: "Time in bed", databaseString: "timeInBed", category: .Sleep),
TimeAsleepHealthKitMetric(humanText: "Time asleep", databaseString: "timeAsleep", category: .Sleep),

]

if #available(iOS 17, *) {
// Other
allMetrics.append(QuantityHealthKitMetric(humanText: "Time in Daylight", databaseString: "timeInDaylight", category: .Other, hkQuantityTypeIdentifier: .timeInDaylight))
}

return allMetrics
}()
QuantityHealthKitMetric(humanText: "Time in Daylight", databaseString: "timeInDaylight", category: .Other, hkQuantityTypeIdentifier: .timeInDaylight),
]
}
}
11 changes: 1 addition & 10 deletions BeeKit/HeathKit/TotalSleepMinutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@ enum SleepResolution {
}

func isRelevantToSleep(_ sample: HKCategorySample) -> Bool {
var relevantValues: [HKCategoryValueSleepAnalysis]
if #available(iOS 16.0, *) {
relevantValues = [
let relevantValues: [HKCategoryValueSleepAnalysis] = [
HKCategoryValueSleepAnalysis.awake,
HKCategoryValueSleepAnalysis.asleepUnspecified,
HKCategoryValueSleepAnalysis.asleepREM,
HKCategoryValueSleepAnalysis.asleepDeep,
HKCategoryValueSleepAnalysis.asleepCore,
HKCategoryValueSleepAnalysis.asleepUnspecified
]
} else {
// Fallback on earlier versions
relevantValues = [
HKCategoryValueSleepAnalysis.awake,
HKCategoryValueSleepAnalysis.asleep
]
}

return relevantValues.contains(HKCategoryValueSleepAnalysis(rawValue: sample.value)!)
}
Expand Down
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>
8 changes: 4 additions & 4 deletions BeeSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,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 @@ -1557,7 +1557,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 @@ -1724,7 +1724,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 @@ -1771,7 +1771,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>
1 change: 0 additions & 1 deletion BeeSwift/AddDataIntentHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
import Intents
import BeeKit

@available(iOS 14.0, *)
class AddDataIntentHandler: NSObject, AddDataIntentHandling {
func resolveValue(for intent: AddDataIntent) async -> AddDataValueResolutionResult {
if let value = intent.value {
Expand Down
4 changes: 2 additions & 2 deletions BeeSwift/EditDatapointViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class EditDatapointViewController: UIViewController, UITextFieldDelegate {
try await ServiceLocator.goalManager.refreshGoal(self.goal.objectID)

hud.mode = .customView
hud.customView = UIImageView(image: UIImage(named: "BasicCheckmark"))
hud.customView = UIImageView(image: UIImage(systemName: "checkmark"))
hud.hide(animated: true, afterDelay: 0.5)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.navigationController?.dismiss(animated: true)
Expand All @@ -238,7 +238,7 @@ class EditDatapointViewController: UIViewController, UITextFieldDelegate {
try await ServiceLocator.goalManager.refreshGoal(self.goal.objectID)

hud.mode = .customView
hud.customView = UIImageView(image: UIImage(named: "BasicCheckmark"))
hud.customView = UIImageView(image: UIImage(systemName: "checkmark"))
hud.hide(animated: true, afterDelay: 0.5)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.navigationController?.dismiss(animated: true)
Expand Down
4 changes: 2 additions & 2 deletions BeeSwift/Gallery/GalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GalleryViewController: UIViewController, UICollectionViewDelegateFlowLayou
self.view.backgroundColor = .systemBackground
self.title = "Goals"

let item = UIBarButtonItem(image: UIImage(named: "Settings"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(self.settingsButtonPressed))
let item = UIBarButtonItem(image: UIImage(systemName: "gearshape.fill"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(self.settingsButtonPressed))
self.navigationItem.rightBarButtonItem = item

self.view.addSubview(self.lastUpdatedView)
Expand Down 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/GoalViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl

self.navigationItem.rightBarButtonItems = [UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(self.actionButtonPressed))]
if !self.goal.hideDataEntry {
self.navigationItem.rightBarButtonItems?.append(UIBarButtonItem(image: UIImage(named: "Timer"), style: .plain, target: self, action: #selector(self.timerButtonPressed)))
self.navigationItem.rightBarButtonItems?.append(UIBarButtonItem(image: UIImage(systemName: "stopwatch"), style: .plain, target: self, action: #selector(self.timerButtonPressed)))
}

NotificationCenter.default.addObserver(self, selector: #selector(onGoalsUpdatedNotification), name: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: nil)
Expand Down
23 changes: 0 additions & 23 deletions BeeSwift/Images.xcassets/BasicCheckmark.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
52 changes: 0 additions & 52 deletions BeeSwift/Images.xcassets/Clock.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 8e6a768

Please sign in to comment.