-
-
Notifications
You must be signed in to change notification settings - Fork 989
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
feat(sensors_plus)!: add barometer support for all platforms #3079
feat(sensors_plus)!: add barometer support for all platforms #3079
Conversation
…m in sensors_plus_platform_interface.dart
…/sensors_plus_platform_interface/test/
…sors_plus/example/
…/sensors_plus/test/
Oh wow, that's a lot! It will probably take a bit to review everything. But I think there should be no issues to incorporate these. I did a quick read, and I'd say we shouldn't include the deprecated methods, even if the other sensors have them. Removing them will also reduce the size of the PR. |
Started with thinking of just adding the android implementation and went down the rabbit hole haha after reading the contribution guide to try to get all 3. Thanks for the quick response! Great if it can be added 😄 but of course not a rush for me. Regarding the deprecated methods, they've been removed now. |
Should I also update the root REAMDE.md? From :
To :
|
Yep! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to test the iOS implementation on my test iPhone eventually.
I left a comment on the web implementation, which I think should be removed since it does nothing.
I have also pushed a small README change.
packages/sensors_plus/sensors_plus/lib/src/web_sensors_interop.dart
Outdated
Show resolved
Hide resolved
|
||
/// Returns a broadcast stream of events from the device barometer at the | ||
/// given sampling frequency. | ||
Stream<BarometerEvent> barometerEventStream({ | ||
Duration samplingPeriod = SensorInterval.normalInterval, | ||
}) { | ||
throw UnimplementedError('barometerEvents has not been implemented.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we modify the platform interface, this change has to be marked as a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was this will not affecting current users' implementations using the library and so not a breaking change. I'm happy to mark it as such if this is how its maintained, but out of curiosity, could you please elaborate why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sensor_plus
and sensor_plus_platform_interface
are in two different packages. If the signature of the method changes, but the client project doesn't pull the correct version, this leads to a compilation error.
This means that we either need to pin the exact version or do a major release.
We had this issue before with other packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @vbuberen is this assumption correct? Does Melos support pinning and updating the exact version of *_platform_interface
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not really sure here, but during our usual release routine I will check it myself that the constraints for *_platform_interface
are updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks both. I've flagged it as a breaking change as @miquelbeltran suggested. Is there anything further you need me to do in regards to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, nothing else needed. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me. Thanks a lot for this contribution.
packages/sensors_plus/sensors_plus/ios/Classes/FPPStreamHandlerPlus.swift
Outdated
Show resolved
Hide resolved
…nsors_plus.podspec Co-authored-by: Volodymyr Buberenko <[email protected]>
From my side everything is good. |
I want to test on iOS still. @aanas-sayed mentioned that the iOS implementation is not tested either. |
Well scratch that, I realized I no longer have an iOS dev account, so I cannot test this. |
I will test the PR on the iPhone. |
Did some testing on iOS and indeed there is a need to do some additional work.
|
Thanks for testing it. I'll look into these and try to fix them. |
In case it is hard to do due to not having a real iOS device I could try and fix everything myself. But will be able to do it not earlier than on weekend. |
I don't have an apple dev account but got Mac (fairly new to it) and iOS devices. Never tried to test an iOS app tbh. Heard you can get it going without an apple dev account so going to try that out. If it doesn't work, I might need your support to fix the issues. I'll let you know how I get along. Thanks! |
Fixed both the issues now I believe:
|
I will be able to retest everything on a real device in ~6-8 hours, so will get back with feedback soon. |
I have done testing on both Android and iOS devices. Everything seems to work fine. There are a few improvement points, which can be done in a follow-up PR:
@miquelbeltran Do you have something to add or I can merge this one? |
Nope, we can go ahead! |
Description
This PR implements barometer support for all platforms (Android, iOS, and web) within the
sensors_plus
plugin. The barometer sensor measures atmospheric pressure and can be used for various applications such as altimeters.Note: There are limitations for web platform, as according to MZN docs, there is no such support for barometer support. This has been implemented similarly to the magnetometer which is also not implemented on any modern browsers, so it handles and throws the right errors if used.
Changes Made:
Android Implementation (Tested): Updated Android specific methods and handlers for barometer sensor in:
...sensors_plus\android\src\main\kotlin\dev\fluttercommunity\plus\sensors\SensorsPlugin.kt
...sensors_plus\android\src\main\kotlin\dev\fluttercommunity\plus\sensors\StreamHandlerImpl.kt
iOS Implementation (Not Tested): Updated
packages\sensors_plus\sensors_plus\ios\sensors_plus.podspec
to include barometer reference.Added Android specific methods and handlers for barometer sensor in:
...sensors_plus\ios\Classes\FPPSensorsPlusPlugin.swift
...sensors_plus\ios\Classes\FPPStreamHandlerPlus.swift
Web Implementation (Tested): Added placeholder implementation and error handling for web platform. There is no plan for this to be implemented on the web from my understanding, but the implementation here will allow appropriate handling to be implemented by users.
Plugin Implementation (Tested): Added required implementations following the same pattern as used for other sensors for the barometer:
BarometerEvent
class in...sensors_plus_platform_interface\lib\src\barometer_event.dart
barometerEventStream
methods in...sensors_plus\lib\src\sensors_plus_web.dart
,...sensors_plus_platform_interface\lib\src\method_channel_sensors.dart
,...sensors_plus\lib\src\sensors.dart
,...sensors_plus\lib\src\web_sensors.dart
,...sensors_plus_platform_interface\lib\sensors_plus_platform_interface.dart
and...sensors_plus\lib\sensors_plus.dart
DeprecatedbarometerEvents
(not sure if this is needed, but there for consistency) in...sensors_plus_platform_interface\lib\sensors_plus_platform_interface.dart
and...sensors_plus\lib\sensors_plus.dart
JS Interoperability for non-existing Barometer API in...sensors_plus\lib\src\web_sensors_interop.dart
Tests (Tested): Unit tests have been written for the barometer in:
...sensors_plus\test\sensors_test.dart
...sensors_plus_platform_interface\test\sensors_plus_platform_interface_test.dart
Example App (Tested): Updated to include barometer readings in table in
...sensors_plus\example\lib\main.dart
.README.md
: Updated to show barometer in example and reference it.Related Issues
Implements required functionality for barometer (#955)
Checklist
CHANGELOG.md
nor the plugin version inpubspec.yaml
files.flutter analyze
) does not report any problems on my PR.Note:
flutter analyze
reports errors for deprecated constants for network_info_plus. Did not touch or modify these as it is not related to sensor_plus.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!
in the title as explained in Conventional Commits).