Skip to content

Commit

Permalink
feat(connectivity)!: rename apple plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
suquant committed Mar 4, 2024
1 parent 1cf52b9 commit 474b154
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Tue Feb 20 19:54:18 GST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
#import <FlutterMacOS/FlutterMacOS.h>
#endif

@interface ConnectivityPlugin : NSObject <FlutterPlugin>
@interface ConnectivityPlusPlugin : NSObject <FlutterPlugin>
@end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "ConnectivityPlugin.h"
#import "ConnectivityPlusPlugin.h"
#if __has_include(<connectivity_plus/connectivity_plus-Swift.h>)
#import <connectivity_plus/connectivity_plus-Swift.h>
#else
Expand All @@ -8,8 +8,8 @@
#import "connectivity_plus-Swift.h"
#endif

@implementation ConnectivityPlugin
@implementation ConnectivityPlusPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
[SwiftConnectivityPlugin registerWithRegistrar:registrar];
[SwiftConnectivityPlusPlugin registerWithRegistrar:registrar];
}
@end
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Network

@available(iOS 12, macOS 10.14, *)
public class PathMonitorConnectivityProvider: NSObject, ConnectivityProvider {

private let queue = DispatchQueue.global(qos: .background)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Cocoa
import FlutterMacOS
#endif

public class SwiftConnectivityPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
public class SwiftConnectivityPlusPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
private let connectivityProvider: ConnectivityProvider
private var eventSink: FlutterEventSink?

Expand Down Expand Up @@ -41,7 +41,7 @@ public class SwiftConnectivityPlugin: NSObject, FlutterPlugin, FlutterStreamHand
connectivityProvider = ReachabilityConnectivityProvider()
}

let instance = SwiftConnectivityPlugin(connectivityProvider: connectivityProvider)
let instance = SwiftConnectivityPlusPlugin(connectivityProvider: connectivityProvider)
streamChannel.setStreamHandler(instance)

registrar.addMethodCallDelegate(instance, channel: channel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class DartHtmlConnectivityPlugin extends ConnectivityPlusWebPlugin {
/// Checks the connection status of the device.
@override
Future<List<ConnectivityResult>> checkConnectivity() async {
return (window.navigator.onLine) ? [ConnectivityResult.wifi] : [ConnectivityResult.none];
return (window.navigator.onLine)
? [ConnectivityResult.wifi]
: [ConnectivityResult.none];
}

StreamController<List<ConnectivityResult>>? _connectivityResult;
Expand All @@ -23,7 +25,8 @@ class DartHtmlConnectivityPlugin extends ConnectivityPlusWebPlugin {
@override
Stream<List<ConnectivityResult>> get onConnectivityChanged {
if (_connectivityResult == null) {
_connectivityResult = StreamController<List<ConnectivityResult>>.broadcast();
_connectivityResult =
StreamController<List<ConnectivityResult>>.broadcast();
const EventStreamProvider<Event>('online').forTarget(window).listen((_) {
_connectivityResult!.add([ConnectivityResult.wifi]);
});
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/connectivity_plus/connectivity_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ flutter:
package: dev.fluttercommunity.plus.connectivity
pluginClass: ConnectivityPlugin
ios:
pluginClass: ConnectivityPlugin
pluginClass: ConnectivityPlusPlugin
sharedDarwinSource: true

linux:
dartPluginClass: ConnectivityPlusLinuxPlugin
macos:
pluginClass: ConnectivityPlugin
pluginClass: ConnectivityPlusPlugin
sharedDarwinSource: true
web:
pluginClass: ConnectivityPlusWebPlugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';

/// Convert a comma-separated String to a list of ConnectivityResult values.
/// Parses the given list of states to a list of [ConnectivityResult].
List<ConnectivityResult> parseConnectivityResults(List<String> states) {
return states.map((state) {
switch (state.trim()) {
Expand Down

0 comments on commit 474b154

Please sign in to comment.