diff --git a/modules/ensemble/lib/action/action_invokable.dart b/modules/ensemble/lib/action/action_invokable.dart index c4a26de4d..420c38169 100644 --- a/modules/ensemble/lib/action/action_invokable.dart +++ b/modules/ensemble/lib/action/action_invokable.dart @@ -67,6 +67,7 @@ abstract class ActionInvokable with Invokable { ActionType.disconnectSSE, ActionType.openFaceCamera, ActionType.executeAction, + ActionType.connectToWifi, ]); } diff --git a/modules/ensemble/lib/action/wifi_action.dart b/modules/ensemble/lib/action/wifi_action.dart new file mode 100644 index 000000000..0c65df10f --- /dev/null +++ b/modules/ensemble/lib/action/wifi_action.dart @@ -0,0 +1,97 @@ +import 'package:ensemble/framework/action.dart'; +import 'package:ensemble/framework/event.dart'; +import 'package:ensemble/framework/scope.dart'; +import 'package:ensemble/framework/stub/wifi_manager.dart'; +import 'package:ensemble/screen_controller.dart'; +import 'package:ensemble/util/utils.dart'; +import 'package:ensemble_ts_interpreter/invokables/invokable.dart'; +import 'package:flutter/material.dart'; +import 'package:get_it/get_it.dart'; + +class ConnectToWifiAction extends EnsembleAction { + ConnectToWifiAction({ + super.initiator, + required this.ssid, + required this.password, + this.joinOnce, + this.rememberNetwork, + this.onSuccess, + this.onError, + }); + + final dynamic ssid; + final dynamic password; + final dynamic joinOnce; + final dynamic rememberNetwork; + final EnsembleAction? onSuccess; + final EnsembleAction? onError; + + factory ConnectToWifiAction.fromYaml({Invokable? initiator, Map? payload}) { + if (payload == null || payload['ssid'] == null) { + throw Exception("connectToWifi requires 'ssid' parameter."); + } + + return ConnectToWifiAction( + initiator: initiator, + ssid: payload['ssid'], + password: payload['password'] ?? '', + joinOnce: payload['joinOnce'], + rememberNetwork: payload['rememberNetwork'], + onSuccess: + EnsembleAction.from(payload['onSuccess'], initiator: initiator), + onError: EnsembleAction.from(payload['onError'], initiator: initiator), + ); + } + + @override + Future execute(BuildContext context, ScopeManager scopeManager) async { + try { + final wifiManager = GetIt.I(); + + final evaluatedSsid = + Utils.getString(scopeManager.dataContext.eval(ssid), fallback: ''); + final evaluatedPassword = + Utils.getString(scopeManager.dataContext.eval(password), fallback: ''); + final evaluatedJoinOnce = + Utils.optionalBool(scopeManager.dataContext.eval(joinOnce)) ?? false; + final evaluatedRememberNetwork = + Utils.optionalBool(scopeManager.dataContext.eval(rememberNetwork)) ?? + true; + + final result = await wifiManager.connect( + ssid: evaluatedSsid, + password: evaluatedPassword, + joinOnce: evaluatedJoinOnce, + rememberNetwork: evaluatedRememberNetwork, + ); + + if (result.success && onSuccess != null) { + await ScreenController().executeAction( + context, + onSuccess!, + event: EnsembleEvent(initiator, data: { + 'status': result.status, + 'message': result.message, + }), + ); + } else if (!result.success && onError != null) { + await ScreenController().executeAction( + context, + onError!, + event: EnsembleEvent(initiator, error: result.message, data: { + 'status': result.status, + 'platformCode': result.platformCode, + }), + ); + } + } catch (e) { + if (onError != null) { + await ScreenController().executeAction( + context, + onError!, + event: EnsembleEvent(initiator, error: e.toString()), + ); + } + } + } +} diff --git a/modules/ensemble/lib/framework/action.dart b/modules/ensemble/lib/framework/action.dart index 8c9f5b847..0a6fe59f4 100644 --- a/modules/ensemble/lib/framework/action.dart +++ b/modules/ensemble/lib/framework/action.dart @@ -30,6 +30,7 @@ import 'package:ensemble/action/secure_storage.dart'; import 'package:ensemble/action/sign_in_out_action.dart'; import 'package:ensemble/action/sign_in_with_verification_code_actions.dart'; import 'package:ensemble/action/stripe_actions.dart'; +import 'package:ensemble/action/wifi_action.dart'; import 'package:ensemble/action/toast_actions.dart'; import 'package:ensemble/action/take_screenshot.dart'; import 'package:ensemble/action/disable_hardware_navigation.dart'; @@ -1059,6 +1060,9 @@ enum ActionType { // Stripe actions initializeStripe, showPaymentSheet, + + // Wi-Fi actions + connectToWifi, } /// payload representing an Action to do (navigateToScreen, InvokeAPI, ..) @@ -1318,6 +1322,9 @@ abstract class EnsembleAction { } else if (actionType == ActionType.showPaymentSheet) { return ShowPaymentSheetAction.fromYaml( initiator: initiator, payload: payload); + } else if (actionType == ActionType.connectToWifi) { + return ConnectToWifiAction.fromYaml( + initiator: initiator, payload: payload); } else { throw LanguageError("Invalid action.", recovery: "Make sure to use one of Ensemble-provided actions."); diff --git a/modules/ensemble/lib/framework/stub/wifi_manager.dart b/modules/ensemble/lib/framework/stub/wifi_manager.dart new file mode 100644 index 000000000..41286d3e0 --- /dev/null +++ b/modules/ensemble/lib/framework/stub/wifi_manager.dart @@ -0,0 +1,37 @@ +import 'package:ensemble/framework/error_handling.dart'; + +abstract class WifiManager { + Future connect({ + required String ssid, + required String password, + bool joinOnce = false, + bool rememberNetwork = true, + }); +} + +class WifiManagerStub implements WifiManager { + @override + Future connect({ + required String ssid, + required String password, + bool joinOnce = false, + bool rememberNetwork = true, + }) { + throw ConfigError( + "Wi-Fi module is not enabled. Please review the Ensemble documentation."); + } +} + +class WifiConnectResult { + final bool success; + final String status; + final String? message; + final String? platformCode; + + const WifiConnectResult({ + required this.success, + required this.status, + this.message, + this.platformCode, + }); +} diff --git a/modules/ensemble/lib/module/wifi_module.dart b/modules/ensemble/lib/module/wifi_module.dart new file mode 100644 index 000000000..259ff26b2 --- /dev/null +++ b/modules/ensemble/lib/module/wifi_module.dart @@ -0,0 +1,10 @@ +import 'package:ensemble/framework/stub/wifi_manager.dart'; +import 'package:get_it/get_it.dart'; + +abstract class WifiModule {} + +class WifiModuleStub implements WifiModule { + WifiModuleStub() { + GetIt.I.registerSingleton(WifiManagerStub()); + } +} diff --git a/modules/ensemble_wifi/lib/ensemble_wifi.dart b/modules/ensemble_wifi/lib/ensemble_wifi.dart new file mode 100644 index 000000000..c54be5a56 --- /dev/null +++ b/modules/ensemble_wifi/lib/ensemble_wifi.dart @@ -0,0 +1,2 @@ +export 'package:ensemble_wifi/wifi_module.dart'; +export 'package:ensemble_wifi/wifi_manager_impl.dart'; diff --git a/modules/ensemble_wifi/lib/wifi_manager_impl.dart b/modules/ensemble_wifi/lib/wifi_manager_impl.dart new file mode 100644 index 000000000..c4c803add --- /dev/null +++ b/modules/ensemble_wifi/lib/wifi_manager_impl.dart @@ -0,0 +1,26 @@ +import 'package:ensemble/framework/stub/wifi_manager.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect.dart'; + +class WifiManagerImpl implements WifiManager { + @override + Future connect({ + required String ssid, + required String password, + bool joinOnce = false, + bool rememberNetwork = true, + }) async { + final result = await SmartWifiConnect.connect( + ssid: ssid, + password: password, + joinOnce: joinOnce, + rememberNetwork: rememberNetwork, + ); + + return WifiConnectResult( + success: result.success, + status: result.status.name, + message: result.message, + platformCode: result.platformCode, + ); + } +} diff --git a/modules/ensemble_wifi/lib/wifi_module.dart b/modules/ensemble_wifi/lib/wifi_module.dart new file mode 100644 index 000000000..764616a46 --- /dev/null +++ b/modules/ensemble_wifi/lib/wifi_module.dart @@ -0,0 +1,10 @@ +import 'package:ensemble/framework/stub/wifi_manager.dart'; +import 'package:ensemble/module/wifi_module.dart'; +import 'package:ensemble_wifi/wifi_manager_impl.dart'; +import 'package:get_it/get_it.dart'; + +class WifiModuleImpl implements WifiModule { + WifiModuleImpl() { + GetIt.I.registerSingleton(WifiManagerImpl()); + } +} diff --git a/modules/ensemble_wifi/pubspec.yaml b/modules/ensemble_wifi/pubspec.yaml new file mode 100644 index 000000000..511febbd5 --- /dev/null +++ b/modules/ensemble_wifi/pubspec.yaml @@ -0,0 +1,28 @@ +name: ensemble_wifi +description: Ensemble Wi-Fi connect module +version: 0.1.0 +homepage: https://github.com/EnsembleUI/ensemble/tree/main/modules/ensemble_wifi + +environment: + sdk: ">=3.5.0" + flutter: ">=3.24.0" + +dependencies: + flutter: + sdk: flutter + ensemble: + git: + url: https://github.com/EnsembleUI/ensemble.git + ref: ensemble-v1.2.41 + path: modules/ensemble + smart_wifi_connect: + git: + url: https://github.com/EnsembleUI/ensemble.git + ref: main + path: packages/smart_wifi_connect + get_it: ^8.0.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 diff --git a/packages/smart_wifi_connect/CHANGELOG.md b/packages/smart_wifi_connect/CHANGELOG.md new file mode 100644 index 000000000..41cc7d819 --- /dev/null +++ b/packages/smart_wifi_connect/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/smart_wifi_connect/LICENSE b/packages/smart_wifi_connect/LICENSE new file mode 100644 index 000000000..ba75c69f7 --- /dev/null +++ b/packages/smart_wifi_connect/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/packages/smart_wifi_connect/README.md b/packages/smart_wifi_connect/README.md new file mode 100644 index 000000000..4f7a1fcea --- /dev/null +++ b/packages/smart_wifi_connect/README.md @@ -0,0 +1,106 @@ +# smart_wifi_connect + +A lightweight Flutter plugin that allows apps to connect to a known Wi-Fi network using SSID and password. + +## Features + +- Connect to a Wi-Fi network by SSID and password +- Structured result with success/failure status +- Platform-appropriate APIs (iOS: `NEHotspotConfigurationManager`, Android: `WifiNetworkSpecifier`) +- No Wi-Fi scanning, no location inference, no background monitoring + +## Usage + +```dart +import 'package:smart_wifi_connect/smart_wifi_connect.dart'; + +final result = await SmartWifiConnect.connect( + ssid: 'MyNetwork', + password: 'MyPassword', + joinOnce: false, + rememberNetwork: true, +); + +if (result.success) { + print('Connected!'); +} else { + print('Failed: ${result.status} - ${result.message}'); +} +``` + +## Parameters + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `ssid` | `String` | required | The Wi-Fi network name | +| `password` | `String` | required | The Wi-Fi password | +| `joinOnce` | `bool` | `false` | If true, the network is session-based (iOS only) | +| `rememberNetwork` | `bool` | `true` | If true, the device remembers the network | + +## Status Values + +| Status | Description | +|--------|-------------| +| `connected` | Successfully connected | +| `permissionDenied` | Required permissions were denied | +| `userCancelled` | User cancelled the connection prompt | +| `unsupported` | Platform does not support this feature | +| `invalidArguments` | Invalid parameters (e.g. empty SSID) | +| `failed` | Connection failed for another reason | + +## Platform Setup + +### Android + +Add the following permissions to your app's `AndroidManifest.xml`: + +```xml + + + + + + + + + + +``` + +**Why each permission is needed:** + +- `CHANGE_WIFI_STATE` — Required to initiate Wi-Fi connections +- `NEARBY_WIFI_DEVICES` — Android 13+ replacement for location-based Wi-Fi access; `neverForLocation` flag ensures no location data is inferred +- `ACCESS_FINE_LOCATION` — Required on Android 12 and below for Wi-Fi connection APIs (capped at SDK 32) +- `INTERNET` / `ACCESS_NETWORK_STATE` — Required to use the connected network + +**Minimum Android version:** API 29 (Android 10). On older devices, the plugin returns `unsupported`. + +### iOS + +Add the **Hotspot Configuration** capability to your app: + +1. In Xcode, select your Runner target +2. Go to Signing & Capabilities +3. Click "+" and add **Hotspot Configuration** + +This adds the entitlement: + +```xml +com.apple.developer.networking.hotspotconfiguration + +``` + +iOS will show a native confirmation prompt when connecting. The plugin handles this and returns the appropriate result. + +## Security & Privacy + +- Wi-Fi passwords are never logged +- No Wi-Fi scanning is performed +- No location data is collected +- `neverForLocation` flag is used on Android 13+ +- Permissions are requested only when `connect()` is called diff --git a/packages/smart_wifi_connect/android/build.gradle b/packages/smart_wifi_connect/android/build.gradle new file mode 100644 index 000000000..7ab8b64c6 --- /dev/null +++ b/packages/smart_wifi_connect/android/build.gradle @@ -0,0 +1,66 @@ +group = "com.ensembleui.smart_wifi_connect" +version = "1.0-SNAPSHOT" + +buildscript { + ext.kotlin_version = "2.2.20" + repositories { + google() + mavenCentral() + } + + dependencies { + classpath("com.android.tools.build:gradle:8.11.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: "com.android.library" +apply plugin: "kotlin-android" + +android { + namespace = "com.ensembleui.smart_wifi_connect" + + compileSdk = 36 + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17 + } + + sourceSets { + main.java.srcDirs += "src/main/kotlin" + test.java.srcDirs += "src/test/kotlin" + } + + defaultConfig { + minSdk = 24 + } + + dependencies { + testImplementation("org.jetbrains.kotlin:kotlin-test") + testImplementation("org.mockito:mockito-core:5.0.0") + } + + testOptions { + unitTests.all { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true + } + } + } +} diff --git a/packages/smart_wifi_connect/android/settings.gradle b/packages/smart_wifi_connect/android/settings.gradle new file mode 100644 index 000000000..6c43294cb --- /dev/null +++ b/packages/smart_wifi_connect/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'smart_wifi_connect' diff --git a/packages/smart_wifi_connect/android/src/main/AndroidManifest.xml b/packages/smart_wifi_connect/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8cd9631e0 --- /dev/null +++ b/packages/smart_wifi_connect/android/src/main/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/packages/smart_wifi_connect/android/src/main/kotlin/com/ensembleui/smart_wifi_connect/SmartWifiConnectPlugin.kt b/packages/smart_wifi_connect/android/src/main/kotlin/com/ensembleui/smart_wifi_connect/SmartWifiConnectPlugin.kt new file mode 100644 index 000000000..c953b5c79 --- /dev/null +++ b/packages/smart_wifi_connect/android/src/main/kotlin/com/ensembleui/smart_wifi_connect/SmartWifiConnectPlugin.kt @@ -0,0 +1,226 @@ +package com.ensembleui.smart_wifi_connect + +import android.Manifest +import android.app.Activity +import android.content.Context +import android.content.pm.PackageManager +import android.net.ConnectivityManager +import android.net.Network +import android.net.NetworkCapabilities +import android.net.NetworkRequest +import android.net.wifi.WifiNetworkSpecifier +import android.os.Build +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry + +class SmartWifiConnectPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, + PluginRegistry.RequestPermissionsResultListener { + + private lateinit var channel: MethodChannel + private var activity: Activity? = null + private var context: Context? = null + private var pendingResult: Result? = null + private var pendingCall: MethodCall? = null + + companion object { + private const val PERMISSION_REQUEST_CODE = 9571 + } + + override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { + context = binding.applicationContext + channel = MethodChannel(binding.binaryMessenger, "smart_wifi_connect") + channel.setMethodCallHandler(this) + } + + override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + context = null + } + + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + activity = binding.activity + binding.addRequestPermissionsResultListener(this) + } + + override fun onDetachedFromActivityForConfigChanges() { + activity = null + } + + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + activity = binding.activity + binding.addRequestPermissionsResultListener(this) + } + + override fun onDetachedFromActivity() { + activity = null + } + + override fun onMethodCall(call: MethodCall, result: Result) { + when (call.method) { + "connect" -> handleConnect(call, result) + else -> result.notImplemented() + } + } + + private fun handleConnect(call: MethodCall, result: Result) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + result.success(mapOf( + "success" to false, + "status" to "unsupported", + "message" to "Wi-Fi connect requires Android 10 (API 29) or higher" + )) + return + } + + if (!hasRequiredPermissions()) { + pendingResult = result + pendingCall = call + requestPermissions() + return + } + + performConnect(call, result) + } + + private fun hasRequiredPermissions(): Boolean { + val act = activity ?: return false + + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + ContextCompat.checkSelfPermission(act, Manifest.permission.NEARBY_WIFI_DEVICES) == + PackageManager.PERMISSION_GRANTED + } else { + ContextCompat.checkSelfPermission(act, Manifest.permission.ACCESS_FINE_LOCATION) == + PackageManager.PERMISSION_GRANTED && + ContextCompat.checkSelfPermission(act, Manifest.permission.CHANGE_WIFI_STATE) == + PackageManager.PERMISSION_GRANTED + } + } + + private fun requestPermissions() { + val act = activity ?: run { + pendingResult?.success(mapOf( + "success" to false, + "status" to "failed", + "message" to "No activity available to request permissions" + )) + pendingResult = null + pendingCall = null + return + } + + val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + arrayOf(Manifest.permission.NEARBY_WIFI_DEVICES) + } else { + arrayOf( + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.CHANGE_WIFI_STATE + ) + } + + ActivityCompat.requestPermissions(act, permissions, PERMISSION_REQUEST_CODE) + } + + override fun onRequestPermissionsResult( + requestCode: Int, permissions: Array, grantResults: IntArray + ): Boolean { + if (requestCode != PERMISSION_REQUEST_CODE) return false + + val result = pendingResult ?: return true + val call = pendingCall ?: return true + + pendingResult = null + pendingCall = null + + val allGranted = grantResults.isNotEmpty() && grantResults.all { + it == PackageManager.PERMISSION_GRANTED + } + + if (allGranted) { + performConnect(call, result) + } else { + result.success(mapOf( + "success" to false, + "status" to "permissionDenied", + "message" to "Required Wi-Fi permissions were denied" + )) + } + + return true + } + + private fun performConnect(call: MethodCall, result: Result) { + val ssid = call.argument("ssid") ?: run { + result.success(mapOf( + "success" to false, + "status" to "invalidArguments", + "message" to "SSID is required" + )) + return + } + val password = call.argument("password") ?: "" + + val ctx = context ?: run { + result.success(mapOf( + "success" to false, + "status" to "failed", + "message" to "Context not available" + )) + return + } + + try { + val specifierBuilder = WifiNetworkSpecifier.Builder() + .setSsid(ssid) + + if (password.isNotEmpty()) { + specifierBuilder.setWpa2Passphrase(password) + } + + val specifier = specifierBuilder.build() + + val networkRequest = NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + .setNetworkSpecifier(specifier) + .build() + + val connectivityManager = ctx.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + + val callback = object : ConnectivityManager.NetworkCallback() { + override fun onAvailable(network: Network) { + connectivityManager.bindProcessToNetwork(network) + result.success(mapOf( + "success" to true, + "status" to "connected", + "message" to "Connected to $ssid" + )) + connectivityManager.unregisterNetworkCallback(this) + } + + override fun onUnavailable() { + result.success(mapOf( + "success" to false, + "status" to "userCancelled", + "message" to "Connection request was cancelled or network unavailable" + )) + } + } + + connectivityManager.requestNetwork(networkRequest, callback) + } catch (e: Exception) { + result.success(mapOf( + "success" to false, + "status" to "failed", + "message" to "Failed to connect: ${e.message}", + "platformCode" to (e::class.simpleName ?: "unknown") + )) + } + } +} diff --git a/packages/smart_wifi_connect/example/README.md b/packages/smart_wifi_connect/example/README.md new file mode 100644 index 000000000..ee06b185a --- /dev/null +++ b/packages/smart_wifi_connect/example/README.md @@ -0,0 +1,16 @@ +# smart_wifi_connect_example + +Demonstrates how to use the smart_wifi_connect plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/packages/smart_wifi_connect/example/android/app/build.gradle.kts b/packages/smart_wifi_connect/example/android/app/build.gradle.kts new file mode 100644 index 000000000..0d2a09c8a --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.example.smart_wifi_connect_example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.smart_wifi_connect_example" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/packages/smart_wifi_connect/example/android/app/src/debug/AndroidManifest.xml b/packages/smart_wifi_connect/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 000000000..399f6981d --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/main/AndroidManifest.xml b/packages/smart_wifi_connect/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..7e0cc2e4c --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/main/kotlin/com/example/smart_wifi_connect_example/MainActivity.kt b/packages/smart_wifi_connect/example/android/app/src/main/kotlin/com/example/smart_wifi_connect_example/MainActivity.kt new file mode 100644 index 000000000..15bf3ac86 --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/kotlin/com/example/smart_wifi_connect_example/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.smart_wifi_connect_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/drawable-v21/launch_background.xml b/packages/smart_wifi_connect/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 000000000..f74085f3f --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/drawable/launch_background.xml b/packages/smart_wifi_connect/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..db77bb4b7 Binary files /dev/null and b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..17987b79b Binary files /dev/null and b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..09d439148 Binary files /dev/null and b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..d5f1c8d34 Binary files /dev/null and b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/packages/smart_wifi_connect/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/values-night/styles.xml b/packages/smart_wifi_connect/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/main/res/values/styles.xml b/packages/smart_wifi_connect/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..cb1ef8805 --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/smart_wifi_connect/example/android/app/src/profile/AndroidManifest.xml b/packages/smart_wifi_connect/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 000000000..399f6981d --- /dev/null +++ b/packages/smart_wifi_connect/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/smart_wifi_connect/example/android/build.gradle.kts b/packages/smart_wifi_connect/example/android/build.gradle.kts new file mode 100644 index 000000000..dbee657bb --- /dev/null +++ b/packages/smart_wifi_connect/example/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/packages/smart_wifi_connect/example/android/gradle.properties b/packages/smart_wifi_connect/example/android/gradle.properties new file mode 100644 index 000000000..fbee1d8cd --- /dev/null +++ b/packages/smart_wifi_connect/example/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/packages/smart_wifi_connect/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/smart_wifi_connect/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..e4ef43fb9 --- /dev/null +++ b/packages/smart_wifi_connect/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/packages/smart_wifi_connect/example/android/settings.gradle.kts b/packages/smart_wifi_connect/example/android/settings.gradle.kts new file mode 100644 index 000000000..ca7fe065c --- /dev/null +++ b/packages/smart_wifi_connect/example/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/packages/smart_wifi_connect/example/integration_test/plugin_integration_test.dart b/packages/smart_wifi_connect/example/integration_test/plugin_integration_test.dart new file mode 100644 index 000000000..f8e912029 --- /dev/null +++ b/packages/smart_wifi_connect/example/integration_test/plugin_integration_test.dart @@ -0,0 +1,17 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('connect with empty SSID returns invalidArguments', + (WidgetTester tester) async { + final result = await SmartWifiConnect.connect( + ssid: '', + password: 'test', + ); + expect(result.success, false); + expect(result.status, SmartWifiConnectStatus.invalidArguments); + }); +} diff --git a/packages/smart_wifi_connect/example/ios/Flutter/AppFrameworkInfo.plist b/packages/smart_wifi_connect/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..1dc6cf765 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 13.0 + + diff --git a/packages/smart_wifi_connect/example/ios/Flutter/Debug.xcconfig b/packages/smart_wifi_connect/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/packages/smart_wifi_connect/example/ios/Flutter/Release.xcconfig b/packages/smart_wifi_connect/example/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.pbxproj b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..97f443935 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,616 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartWifiConnectExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..e3773d42e --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner/AppDelegate.swift b/packages/smart_wifi_connect/example/ios/Runner/AppDelegate.swift new file mode 100644 index 000000000..626664468 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d36b1fab2 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 000000000..dc9ada472 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..7353c41ec Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..6ed2d933e Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..4cd7b0099 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..fe730945a Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..321773cd8 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..797d452e4 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..502f463a9 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..0ec303439 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..e9f5fea27 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..84ac32ae7 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..8953cba09 Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..0467bf12a Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000..0bedcf2fd --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000..89c2725b7 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f2e259c7c --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/Main.storyboard b/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f3c28516f --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner/Info.plist b/packages/smart_wifi_connect/example/ios/Runner/Info.plist new file mode 100644 index 000000000..9ddac3f93 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Smart Wifi Connect + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + smart_wifi_connect_example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/packages/smart_wifi_connect/example/ios/Runner/Runner-Bridging-Header.h b/packages/smart_wifi_connect/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 000000000..308a2a560 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/packages/smart_wifi_connect/example/ios/RunnerTests/RunnerTests.swift b/packages/smart_wifi_connect/example/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 000000000..086bcb087 --- /dev/null +++ b/packages/smart_wifi_connect/example/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,27 @@ +import Flutter +import UIKit +import XCTest + + +@testable import smart_wifi_connect + +// This demonstrates a simple unit test of the Swift portion of this plugin's implementation. +// +// See https://developer.apple.com/documentation/xctest for more information about using XCTest. + +class RunnerTests: XCTestCase { + + func testGetPlatformVersion() { + let plugin = SmartWifiConnectPlugin() + + let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: []) + + let resultExpectation = expectation(description: "result block must be called.") + plugin.handle(call) { result in + XCTAssertEqual(result as! String, "iOS " + UIDevice.current.systemVersion) + resultExpectation.fulfill() + } + waitForExpectations(timeout: 1) + } + +} diff --git a/packages/smart_wifi_connect/example/lib/main.dart b/packages/smart_wifi_connect/example/lib/main.dart new file mode 100644 index 000000000..63c829bed --- /dev/null +++ b/packages/smart_wifi_connect/example/lib/main.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: const WifiConnectDemo(), + ); + } +} + +class WifiConnectDemo extends StatefulWidget { + const WifiConnectDemo({super.key}); + + @override + State createState() => _WifiConnectDemoState(); +} + +class _WifiConnectDemoState extends State { + final _ssidController = TextEditingController(); + final _passwordController = TextEditingController(); + String _status = 'Not connected'; + + Future _connect() async { + setState(() => _status = 'Connecting...'); + + final result = await SmartWifiConnect.connect( + ssid: _ssidController.text, + password: _passwordController.text, + ); + + setState(() { + _status = result.success + ? 'Connected! (${result.status.name})' + : 'Failed: ${result.status.name} - ${result.message}'; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('Wi-Fi Connect Demo')), + body: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + TextField( + controller: _ssidController, + decoration: const InputDecoration(labelText: 'SSID'), + ), + const SizedBox(height: 8), + TextField( + controller: _passwordController, + decoration: const InputDecoration(labelText: 'Password'), + obscureText: true, + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: _connect, + child: const Text('Connect'), + ), + const SizedBox(height: 16), + Text(_status), + ], + ), + ), + ); + } +} diff --git a/packages/smart_wifi_connect/example/pubspec.yaml b/packages/smart_wifi_connect/example/pubspec.yaml new file mode 100644 index 000000000..4623d8cc0 --- /dev/null +++ b/packages/smart_wifi_connect/example/pubspec.yaml @@ -0,0 +1,85 @@ +name: smart_wifi_connect_example +description: "Demonstrates how to use the smart_wifi_connect plugin." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: ">=3.5.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + smart_wifi_connect: + # When depending on this package from a real application you should use: + # smart_wifi_connect: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + +dev_dependencies: + integration_test: + sdk: flutter + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^6.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/packages/smart_wifi_connect/example/test/widget_test.dart b/packages/smart_wifi_connect/example/test/widget_test.dart new file mode 100644 index 000000000..9df430808 --- /dev/null +++ b/packages/smart_wifi_connect/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:smart_wifi_connect_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/packages/smart_wifi_connect/ios/Classes/SmartWifiConnectPlugin.swift b/packages/smart_wifi_connect/ios/Classes/SmartWifiConnectPlugin.swift new file mode 100644 index 000000000..3f871bafc --- /dev/null +++ b/packages/smart_wifi_connect/ios/Classes/SmartWifiConnectPlugin.swift @@ -0,0 +1,102 @@ +import Flutter +import UIKit +import NetworkExtension + +public class SmartWifiConnectPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "smart_wifi_connect", binaryMessenger: registrar.messenger()) + let instance = SmartWifiConnectPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "connect": + handleConnect(call: call, result: result) + default: + result(FlutterMethodNotImplemented) + } + } + + private func handleConnect(call: FlutterMethodCall, result: @escaping FlutterResult) { + guard let args = call.arguments as? [String: Any], + let ssid = args["ssid"] as? String, !ssid.isEmpty else { + result([ + "success": false, + "status": "invalidArguments", + "message": "SSID is required" + ] as [String: Any]) + return + } + + let password = args["password"] as? String ?? "" + let joinOnce = args["joinOnce"] as? Bool ?? false + + let configuration: NEHotspotConfiguration + if password.isEmpty { + configuration = NEHotspotConfiguration(ssid: ssid) + } else { + configuration = NEHotspotConfiguration(ssid: ssid, passphrase: password, isWEP: false) + } + + configuration.joinOnce = joinOnce + + NEHotspotConfigurationManager.shared.apply(configuration) { error in + if let error = error as NSError? { + let nsError = error as NSError + if nsError.domain == NEHotspotConfigurationErrorDomain { + switch nsError.code { + case NEHotspotConfigurationError.userDenied.rawValue: + result([ + "success": false, + "status": "userCancelled", + "message": "User denied the Wi-Fi configuration", + "platformCode": "userDenied" + ] as [String: Any]) + case NEHotspotConfigurationError.alreadyAssociated.rawValue: + result([ + "success": true, + "status": "connected", + "message": "Already connected to \(ssid)", + "platformCode": "alreadyAssociated" + ] as [String: Any]) + case NEHotspotConfigurationError.applicationIsNotInForeground.rawValue: + result([ + "success": false, + "status": "failed", + "message": "App must be in foreground to configure Wi-Fi", + "platformCode": "applicationIsNotInForeground" + ] as [String: Any]) + case NEHotspotConfigurationError.invalid.rawValue: + result([ + "success": false, + "status": "invalidArguments", + "message": "Invalid Wi-Fi configuration", + "platformCode": "invalid" + ] as [String: Any]) + default: + result([ + "success": false, + "status": "failed", + "message": error.localizedDescription, + "platformCode": String(nsError.code) + ] as [String: Any]) + } + } else { + result([ + "success": false, + "status": "failed", + "message": error.localizedDescription, + "platformCode": nsError.domain + ] as [String: Any]) + } + } else { + result([ + "success": true, + "status": "connected", + "message": "Connected to \(ssid)" + ] as [String: Any]) + } + } + } +} diff --git a/packages/smart_wifi_connect/ios/smart_wifi_connect.podspec b/packages/smart_wifi_connect/ios/smart_wifi_connect.podspec new file mode 100644 index 000000000..0af4a715d --- /dev/null +++ b/packages/smart_wifi_connect/ios/smart_wifi_connect.podspec @@ -0,0 +1,29 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint smart_wifi_connect.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'smart_wifi_connect' + s.version = '0.0.1' + s.summary = 'A new Flutter plugin project.' + s.description = <<-DESC +A new Flutter plugin project. + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Your Company' => 'email@example.com' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'Flutter' + s.platform = :ios, '13.0' + + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } + s.swift_version = '5.0' + + # If your plugin requires a privacy manifest, for example if it uses any + # required reason APIs, update the PrivacyInfo.xcprivacy file to describe your + # plugin's privacy impact, and then uncomment this line. For more information, + # see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files + # s.resource_bundles = {'smart_wifi_connect_privacy' => ['Resources/PrivacyInfo.xcprivacy']} +end diff --git a/packages/smart_wifi_connect/lib/smart_wifi_connect.dart b/packages/smart_wifi_connect/lib/smart_wifi_connect.dart new file mode 100644 index 000000000..21f771c77 --- /dev/null +++ b/packages/smart_wifi_connect/lib/smart_wifi_connect.dart @@ -0,0 +1,68 @@ +import 'package:flutter/services.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect_result.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect_status.dart'; + +export 'package:smart_wifi_connect/smart_wifi_connect_result.dart'; +export 'package:smart_wifi_connect/smart_wifi_connect_status.dart'; + +class SmartWifiConnect { + static const MethodChannel _channel = MethodChannel('smart_wifi_connect'); + + static Future connect({ + required String ssid, + required String password, + bool joinOnce = false, + bool rememberNetwork = true, + }) async { + if (ssid.isEmpty) { + return const SmartWifiConnectResult( + success: false, + status: SmartWifiConnectStatus.invalidArguments, + message: 'SSID cannot be empty', + ); + } + + try { + final result = await _channel.invokeMethod('connect', { + 'ssid': ssid, + 'password': password, + 'joinOnce': joinOnce, + 'rememberNetwork': rememberNetwork, + }); + + if (result == null) { + return const SmartWifiConnectResult( + success: false, + status: SmartWifiConnectStatus.failed, + message: 'No response from platform', + ); + } + + final statusStr = result['status'] as String? ?? 'failed'; + final status = SmartWifiConnectStatus.values.firstWhere( + (e) => e.name == statusStr, + orElse: () => SmartWifiConnectStatus.failed, + ); + + return SmartWifiConnectResult( + success: result['success'] as bool? ?? false, + status: status, + message: result['message'] as String?, + platformCode: result['platformCode'] as String?, + ); + } on PlatformException catch (e) { + return SmartWifiConnectResult( + success: false, + status: SmartWifiConnectStatus.failed, + message: e.message ?? 'Platform error', + platformCode: e.code, + ); + } on MissingPluginException { + return const SmartWifiConnectResult( + success: false, + status: SmartWifiConnectStatus.unsupported, + message: 'Wi-Fi connect is not supported on this platform', + ); + } + } +} diff --git a/packages/smart_wifi_connect/lib/smart_wifi_connect_result.dart b/packages/smart_wifi_connect/lib/smart_wifi_connect_result.dart new file mode 100644 index 000000000..05c2e806f --- /dev/null +++ b/packages/smart_wifi_connect/lib/smart_wifi_connect_result.dart @@ -0,0 +1,22 @@ +import 'package:smart_wifi_connect/smart_wifi_connect_status.dart'; + +class SmartWifiConnectResult { + final bool success; + final SmartWifiConnectStatus status; + final String? message; + final String? platformCode; + + const SmartWifiConnectResult({ + required this.success, + required this.status, + this.message, + this.platformCode, + }); + + Map toMap() => { + 'success': success, + 'status': status.name, + 'message': message, + 'platformCode': platformCode, + }; +} diff --git a/packages/smart_wifi_connect/lib/smart_wifi_connect_status.dart b/packages/smart_wifi_connect/lib/smart_wifi_connect_status.dart new file mode 100644 index 000000000..dd47df97d --- /dev/null +++ b/packages/smart_wifi_connect/lib/smart_wifi_connect_status.dart @@ -0,0 +1,8 @@ +enum SmartWifiConnectStatus { + connected, + permissionDenied, + userCancelled, + unsupported, + invalidArguments, + failed, +} diff --git a/packages/smart_wifi_connect/pubspec.yaml b/packages/smart_wifi_connect/pubspec.yaml new file mode 100644 index 000000000..0bc49e761 --- /dev/null +++ b/packages/smart_wifi_connect/pubspec.yaml @@ -0,0 +1,26 @@ +name: smart_wifi_connect +description: A lightweight Flutter plugin to connect to a Wi-Fi network using SSID and password. +version: 0.1.0 +homepage: https://github.com/EnsembleUI/ensemble/tree/main/packages/smart_wifi_connect + +environment: + sdk: ">=3.5.0" + flutter: ">=3.24.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + plugin: + platforms: + android: + package: com.ensembleui.smart_wifi_connect + pluginClass: SmartWifiConnectPlugin + ios: + pluginClass: SmartWifiConnectPlugin diff --git a/packages/smart_wifi_connect/test/smart_wifi_connect_test.dart b/packages/smart_wifi_connect/test/smart_wifi_connect_test.dart new file mode 100644 index 000000000..d86204e7b --- /dev/null +++ b/packages/smart_wifi_connect/test/smart_wifi_connect_test.dart @@ -0,0 +1,118 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:smart_wifi_connect/smart_wifi_connect.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const channel = MethodChannel('smart_wifi_connect'); + final log = []; + + setUp(() { + log.clear(); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { + log.add(methodCall); + return { + 'success': true, + 'status': 'connected', + 'message': 'Connected to TestNetwork', + }; + }); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); + }); + + test('connect returns invalidArguments for empty SSID', () async { + final result = await SmartWifiConnect.connect( + ssid: '', + password: 'pass123', + ); + expect(result.success, false); + expect(result.status, SmartWifiConnectStatus.invalidArguments); + expect(log, isEmpty); + }); + + test('connect sends correct arguments via method channel', () async { + final result = await SmartWifiConnect.connect( + ssid: 'MyNetwork', + password: 'secret123', + joinOnce: true, + rememberNetwork: false, + ); + + expect(result.success, true); + expect(result.status, SmartWifiConnectStatus.connected); + expect(log, hasLength(1)); + expect(log.first.method, 'connect'); + expect(log.first.arguments, { + 'ssid': 'MyNetwork', + 'password': 'secret123', + 'joinOnce': true, + 'rememberNetwork': false, + }); + }); + + test('connect handles platform exception', () async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { + throw PlatformException(code: 'ERROR', message: 'Something went wrong'); + }); + + final result = await SmartWifiConnect.connect( + ssid: 'MyNetwork', + password: 'pass', + ); + expect(result.success, false); + expect(result.status, SmartWifiConnectStatus.failed); + expect(result.message, 'Something went wrong'); + expect(result.platformCode, 'ERROR'); + }); + + test('connect handles missing plugin', () async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); + + final result = await SmartWifiConnect.connect( + ssid: 'MyNetwork', + password: 'pass', + ); + expect(result.success, false); + expect(result.status, SmartWifiConnectStatus.unsupported); + }); + + test('connect returns permission denied status', () async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { + return { + 'success': false, + 'status': 'permissionDenied', + 'message': 'Permission denied', + }; + }); + + final result = await SmartWifiConnect.connect( + ssid: 'MyNetwork', + password: 'pass', + ); + expect(result.success, false); + expect(result.status, SmartWifiConnectStatus.permissionDenied); + }); + + test('SmartWifiConnectResult toMap returns correct data', () { + const result = SmartWifiConnectResult( + success: true, + status: SmartWifiConnectStatus.connected, + message: 'OK', + platformCode: 'alreadyAssociated', + ); + final map = result.toMap(); + expect(map['success'], true); + expect(map['status'], 'connected'); + expect(map['message'], 'OK'); + expect(map['platformCode'], 'alreadyAssociated'); + }); +} diff --git a/starter/lib/generated/ensemble_modules.dart b/starter/lib/generated/ensemble_modules.dart index 61f61c1e6..edfb44b5d 100644 --- a/starter/lib/generated/ensemble_modules.dart +++ b/starter/lib/generated/ensemble_modules.dart @@ -18,7 +18,9 @@ import 'package:ensemble/module/location_module.dart'; import 'package:ensemble/framework/stub/moengage_manager.dart'; import 'package:ensemble/framework/stub/remote_config.dart'; import 'package:ensemble/module/stripe_module.dart'; +import 'package:ensemble/module/wifi_module.dart'; // import 'package:ensemble_stripe/ensemble_stripe.dart'; +// import 'package:ensemble_wifi/ensemble_wifi.dart'; //import 'package:ensemble_bluetooth/ensemble_bluetooth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; @@ -102,6 +104,7 @@ class EnsembleModules { static const useStripe = false; static const useRemoteConfig = false; + static const useWifi = false; // widgets static const enableChat = false; @@ -257,5 +260,12 @@ class EnsembleModules { } else { GetIt.I.registerSingleton(RemoteConfigStub()); } + + if (useWifi) { + // Uncomment to enable Wi-Fi connect module + // GetIt.I.registerSingleton(WifiModuleImpl()); + } else { + GetIt.I.registerSingleton(WifiModuleStub()); + } } } diff --git a/starter/pubspec.yaml b/starter/pubspec.yaml index 40fd275f3..59cd4fc5e 100644 --- a/starter/pubspec.yaml +++ b/starter/pubspec.yaml @@ -163,6 +163,13 @@ dependencies: # ref: main # path: modules/ensemble_stripe + # Uncomment to enable Wi-Fi connect module + # ensemble_wifi: + # git: + # url: https://github.com/EnsembleUI/ensemble.git + # ref: main + # path: modules/ensemble_wifi + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2