# Onairos SDK - Testing and Usage Guide

## Testing with Sample Data

The Universal Onboarding component now includes a `testMode` parameter that makes testing much easier without requiring actual API connections.

### Using Test Mode

```dart
UniversalOnboarding(
  appName: "Test App",
  valuablePlatform: "Instagram",
  testMode: true, // Enable test mode
  onAccountCreated: (username, pin) {
    print('Account created with username: $username and PIN: $pin');
  },
)
```

When `testMode` is enabled:
- All OAuth connections will automatically succeed without calling real APIs
- Biometric authentication will be bypassed
- Account creation will complete without API calls
- Email registration will show success without sending data

This allows for easy testing of the UI flow without setting up real OAuth configurations.

## Non-Breaking Integration

### For Existing Apps

The changes made to the Universal Onboarding component are backward compatible. All new parameters have default values, so existing code will continue to work.

**Old code (still works):**
```dart
UniversalOnboarding(
  appName: "My App",
  onAccountCreated: (username, pin) {
    // Handle account creation
  },
)
```

**Enhanced usage with new features:**
```dart
UniversalOnboarding(
  appName: "My App",
  valuablePlatform: "Instagram", // Optional: highlight a valuable platform
  testMode: false, // Optional: default is false
  onAccountCreated: (username, pin) {
    // Handle account creation
  },
  onConnectionUpdated: (platform, isConnected) {
    // Optional: handle platform connection updates
  },
)
```

### Usage in a Flutter App

1. **Include the Package**
   
   ```yaml
   dependencies:
     onairos: ^0.2.92
   ```

2. **Import the Necessary Files**
   
   ```dart
   import 'package:onairos/onairos_button.dart';
   ```

3. **Add the Onairos Button**
   
   ```dart
   OnairosButton(
     AppName: "My App",
     preferredPlatform: "Instagram", // Valuable platform
     onResolved: (apiUrl, token, userData) {
       // Handle successful authentication
       print('Authenticated with Onairos: $apiUrl');
     },
   )
   ```

## Sample Implementation

Here's a complete example of how to integrate the Onairos SDK in a Flutter app:

```dart
import 'package:flutter/material.dart';
import 'package:onairos/onairos_button.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Onairos Sample',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String? _apiUrl;
  String? _token;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Onairos Sample App'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (_apiUrl != null)
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: Text(
                  'Connected to Onairos!',
                  style: TextStyle(
                    fontSize: 18,
                    fontWeight: FontWeight.bold,
                    color: Colors.green,
                  ),
                ),
              )
            else
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: Text(
                  'Connect your accounts to enhance your experience',
                  textAlign: TextAlign.center,
                  style: TextStyle(fontSize: 16),
                ),
              ),
            SizedBox(height: 20),
            OnairosButton(
              AppName: "Sample App",
              preferredPlatform: "Instagram",
              onResolved: (apiUrl, token, userData) {
                setState(() {
                  _apiUrl = apiUrl;
                  _token = token;
                });
                print('Authenticated with Onairos: $apiUrl');
              },
            ),
          ],
        ),
      ),
    );
  }
}
```

This integration will work with both the old and new versions of the Onairos SDK.
