This repository was archived by the owner on Dec 15, 2020. It is now read-only.
Enable or disable the “Add Sensors” button#60
Open
mattblair wants to merge 1 commit intogooglearchive:masterfrom
Open
Enable or disable the “Add Sensors” button#60mattblair wants to merge 1 commit intogooglearchive:masterfrom
mattblair wants to merge 1 commit intogooglearchive:masterfrom
Conversation
Based on whether there are unused sensors available for the device.
marcisme
reviewed
Oct 14, 2019
| stackView.addArrangedSubview(UIView()) | ||
| } | ||
|
|
||
| items.forEach { (item) in |
Contributor
There was a problem hiding this comment.
no parens around block args (item and enabled)
| items.forEach { (item) in | ||
| item.enabler?.observe({ (enabled) in | ||
| self.setButtonFor(item: item, enabled: enabled) | ||
| }) |
Contributor
There was a problem hiding this comment.
Do all the items need to be re-enabled here? It seems like if one were previously disabled, it may not get turned back on after a button change.
| button.isEnabled = enabled | ||
| let updatedAlpha: CGFloat = enabled ? 1.0 : BarViewController.Metrics.Bar.disabledAlpha | ||
| if animated { | ||
| UIView.animate(withDuration: 0.5) { |
Contributor
There was a problem hiding this comment.
I'd move the animation block up to the VC. It currently controls timings for animations, so it'll be easier to reason about with those in the same place. There's also some logic up there related to enabling/disabling the entire bar/detail era, and the alpha values there and here are likely related.
| return self.observeDataSource.availableSensorIDs | ||
| } | ||
|
|
||
| @objc dynamic private(set) var unusedSensors: Bool = false |
Contributor
There was a problem hiding this comment.
hasUnusedSensors would be more consistent with the property naming guidelines for boolean values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Motivation and Context
The "Add Sensor" button in the action area remains enabled, even when there are no additional sensors to add. This could be confusing for users. The visual characteristics and interactivity of the "Add Sensor" button should change based on whether there are unused sensors available for the device.
Description
unusedSensorsBooltoObserveViewControllerto store the current state of sensors that are available but not currently in use.enablerproperty toBarButtonItemto handle KVO observations ofBoolproperties.enablerfor the "Add Sensor" bar button item, to observe changes toObserveViewController'sunusedSensorsproperty.setButtonFor(item:enabled:animated:)method to theActionArea.Barto toggle enabled for buttons based on observations received by aBarButtonItem.setEnabled(_:animated:)method on theBarButtonto change the interactivity and alpha of its subviews.Tested in the simulator and on devices running iOS 12 and 13.