Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset thresholds to default #426

Merged
merged 2 commits into from Nov 18, 2021
Merged

Reset thresholds to default #426

merged 2 commits into from Nov 18, 2021

Conversation

smialko
Copy link
Collaborator

@smialko smialko commented Nov 16, 2021

I renamed HeatmapSettingsView because I think this name would be confusing after implementing heatmap.

Copy link
Collaborator

@jankrzempek jankrzempek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working like a charm! I left some notes, but nothing you cannot skip I think.
Only those spaces in the first comment, please 😇

Comment on lines 53 to 54
[thresholdVeryLow, thresholdLow , thresholdMedium ,thresholdHigh, thresholdVeryHigh ]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[thresholdVeryLow, thresholdLow, thresholdMedium, thresholdHigh, thresholdVeryHigh]

Spaces 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, this looks AWFUL :D

Comment on lines 63 to 64
.padding(.horizontal)
.padding(.top)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use .paddding([.horizontal, .top]) please?

Comment on lines 64 to 68
thresholdSettingsViewModel.thresholdVeryLow = "\(Int(thresholdValues[0]))"
thresholdSettingsViewModel.thresholdLow = "\(Int(thresholdValues[1]))"
thresholdSettingsViewModel.thresholdMedium = "\(Int(thresholdValues[2]))"
thresholdSettingsViewModel.thresholdHigh = "\(Int(thresholdValues[3]))"
thresholdSettingsViewModel.thresholdVeryHigh = "\(Int(thresholdValues[4]))"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you say about sth like:

` .onAppear {
thresholdSettingsViewModel.thresholdVeryLow = string(using: thresholdValues[0])
thresholdSettingsViewModel.thresholdLow = string(using: thresholdValues[1])
thresholdSettingsViewModel.thresholdMedium = string(using: thresholdValues[2])
thresholdSettingsViewModel.thresholdHigh = string(using: thresholdValues[3])
thresholdSettingsViewModel.thresholdVeryHigh = string(using: thresholdValues[4])
}
}

func string(using thresholdValue: Float) -> String {
    return String(Int(thresholdValue))
}`

Just to consider: if not, then go below 😇

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! tbh I didn't give it much thought - just changed this code to use the view model.

Comment on lines 24 to 31
func resetToDefault() -> [Float] {
var newInitial: [Float] = []
for value in initialThresholds {
let newValue = Float(value)
newInitial.append(newValue)
}
return newInitial
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion time:

func resetToDefault() -> [Float] { var newInitial: [Float] = [] initialThresholds.forEach { value in newInitial.append(Float(value)) } return newInitial }

@smialko smialko merged commit 04b9c42 into develop Nov 18, 2021
@smialko smialko deleted the reset-thresholds branch November 18, 2021 09:47
@@ -49,6 +49,9 @@ public class MeasurementStreamEntity: NSManagedObject, Identifiable {
public var localID: MeasurementStreamLocalID {
MeasurementStreamLocalID(id: objectID)
}
public var thresholds: [Int32] {
[thresholdVeryLow, thresholdLow, thresholdMedium, thresholdHigh, thresholdVeryHigh]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be the thresholds struct and not an array? Using array in this case seems prone to error and we already know there can be only this limited set of 5 thresholds, so using a struct (or enum or dictionary) seems like a good fit. If that changes in the future, for example we will have 4 thresholds, it will be easier to edit without errors caused by thresholds[4].

@smialko smialko mentioned this pull request Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants