-
Notifications
You must be signed in to change notification settings - Fork 183
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(wifi_basic): plugin added #201
base: master
Are you sure you want to change the base?
Conversation
- [format] formatted with melos
- [wifi_basic,test] "basic test" added with mocked MethodCallHandler - [wifi_basic,example] basic methods added to example app
…led` - [wifi_basic,test] `WiFiBasic.setEnabled`: arg name changed `state` -> `enabled`; returning if successful or not - [example,android] necessary permissions added to manifest file - [example] proper example code added
… removed `shouldOpenSettings` arg - [wifi_basic,android,test] `WiFiBasic`, `WifiBasicPlugin`: `openSettings` method added, implemented and test for it added - [wifi_basic,example] smaller example with just buttons
…ed`, `setEnabled` and `openSettings` - [ios,example] project files updated
import Flutter | ||
import UIKit | ||
|
||
public class SwiftWifiBasicPlugin: NSObject, FlutterPlugin { |
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.
@DominikStarke Can you review this file? esp. handling of isEnabled
(lifted code from SO!) - tested with iOS - iOS 15 simlulator (returns true), and iOS 12 device (it is working), will soon test on iOS 15 too - will let you know.
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 like it always returns true in iOS 15.
So may be wont go ahead with this unofficial API.
@DominikStarke Do you have any views on what best-case API to call if iOS does not allow it? Currently in wifi_iot
- it checks if currentSSID != null
- other forums suggest using SCNetworkReachability
(as used by connectivity_plus
plugin).
Both suggest that the mobile is "connected" to a WifiNetwork and not if the hw/service is "enabled" - but looks like this is the best we can achieve. My views are we should use SCNetworkReachability
as it does not require any additional permission from user. Le me know your view.
...ges/wifi_basic/android/src/main/kotlin/dev/flutternetwork/wifi/wifi_basic/WifiBasicPlugin.kt
Outdated
Show resolved
Hide resolved
...ges/wifi_basic/android/src/main/kotlin/dev/flutternetwork/wifi/wifi_basic/WifiBasicPlugin.kt
Show resolved
Hide resolved
- [wifi_basic] `WiFiBasic`: `getGeneration` method added; memoizing `isSupported` and `getGeneration` results - [wifi_basic,test] aaded `getGeneration` to basic test - [wifi_basic,example] added `getGeneration` to example app - [wifi_basic,ios] added `getGeneration` [incomplete implementation]; filled in info in podspec file - [wifi_basic,android] added `getGeneration` [incomplete implementation]
- [wifi_basic,test] fix - returning int instead of enum
…Basic.getCurrentInfo` method added - [wifi_basic,extension] `ToEnumExtension` extension added and integrated with `WiFiBasic` - [wifi_basic,example] `getCurrentInfo` added to example app - [wifi_basic,test] added proper unit tests
I took a look at the flutter code of this PR and I have some proposals: a) wifi_basic.dart
In case of
Maybe, instead of
b) extensions.dart Changing the current code to the below one would make much more clear which values are mapped to which enum extension WiFiGenerationsExtension on WiFiGenerations {
static WiFiGenerations fromInt(int? value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
return WiFiGenerations.legacy;
case 4:
return WiFiGenerations.wifi4;
case 5:
return WiFiGenerations.wifi5;
case 6:
return WiFiGenerations.wifi6;
default:
return WiFiGenerations.unknown;
}
}
}
extension WiFiNetworkSecurityExtension on WiFiNetworkSecurity {
static WiFiNetworkSecurity fromInt(int? value) {
switch (value) {
case 0:
return WiFiNetworkSecurity.unknown;
case 1:
return WiFiNetworkSecurity.none;
case 2:
return WiFiNetworkSecurity.wep;
case 3:
return WiFiNetworkSecurity.wpa;
case 4:
return WiFiNetworkSecurity.wpa2;
case 5:
return WiFiNetworkSecurity.wpa3;
default:
return WiFiNetworkSecurity.unknown;
}
}
} OBS: I can make those changes if necessary |
@fernando-s97 Looks like good suggestions - Except point 5. plugin name is unique enough to avoid name clashes + generated plugin scaffold does not add org name as prefix - will keep as it is. If you got time then can you file new PR with this changes against this branch? |
I have been first completing |
…obal options - [wifi_basic] remove unecessary imports
397aaa3
to
a527cb8
Compare
Related to #187