# 🧪 Local Testing Guide for Onairos Flutter Integration

## Method 1: Direct Package Testing (Fastest)

Since you have a complete Flutter package, test directly:

```bash
cd /Users/anushkajogalekar/projects/onairos-flutter
flutter run test_complete_integration.dart
```

This runs the complete NPM integration test immediately.

## Method 2: Consumer App Testing (Like internship-demo)

### Step 1: Create a Test Consumer App

```bash
# Create a new Flutter app for testing
flutter create onairos_test_app
cd onairos_test_app
```

### Step 2: Add Local Path Dependency

Edit `onairos_test_app/pubspec.yaml`:

```yaml
name: onairos_test_app
description: Test app for Onairos package

dependencies:
  flutter:
    sdk: flutter

  # LOCAL PATH DEPENDENCY - This is the key!
  onairos:
    path: /Users/anushkajogalekar/projects/onairos-flutter

  # Add other dependencies your app needs
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.0

flutter:
  uses-material-design: true
```

### Step 3: Create Test Implementation

Create `onairos_test_app/lib/main.dart`:

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

void main() => runApp(OnairosTestApp());

class OnairosTestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Onairos Integration Test',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: TestHomeScreen(),
    );
  }
}

class TestHomeScreen extends StatefulWidget {
  @override
  State<TestHomeScreen> createState() => _TestHomeScreenState();
}

class _TestHomeScreenState extends State<TestHomeScreen> {
  bool _showOnairosModal = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Onairos Test App'),
        backgroundColor: Colors.black,
        foregroundColor: Colors.white,
      ),
      body: Stack(
        children: [
          // Main app content
          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text(
                  '🚀 Testing NPM → Flutter Integration',
                  style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
                  textAlign: TextAlign.center,
                ),

                const SizedBox(height: 32),

                ElevatedButton(
                  onPressed: () {
                    setState(() {
                      _showOnairosModal = true;
                    });
                  },
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.black,
                    foregroundColor: Colors.white,
                    minimumSize: const Size(200, 50),
                  ),
                  child: const Text('Open Onairos Modal'),
                ),

                const SizedBox(height: 16),

                const Text(
                  'This will show your complete NPM integration:\nWelcome → Sign In → Verification → Platforms',
                  textAlign: TextAlign.center,
                  style: TextStyle(color: Colors.grey),
                ),
              ],
            ),
          ),

          // Onairos Modal Overlay
          if (_showOnairosModal)
            EnhancedWelcomeScreen(
              visible: _showOnairosModal,
              onClose: () {
                setState(() {
                  _showOnairosModal = false;
                });
              },
              appName: 'Test Consumer App',
              onResolved: (apiUrl, token, userData) {
                print('Onairos resolved: $apiUrl, $token, $userData');
                setState(() {
                  _showOnairosModal = false;
                });

                // Show success message
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(
                    content: Text('✅ Onairos integration successful!'),
                    backgroundColor: Colors.green,
                  ),
                );
              },
            ),
        ],
      ),
    );
  }
}
```

### Step 4: Run the Test

```bash
cd onairos_test_app
flutter pub get  # Downloads your local package
flutter run       # Runs the test app
```

## Method 3: Using Existing Consumer App

If you have an existing app (like internship-demo), just add the path dependency:

```yaml
# In your existing app's pubspec.yaml
dependencies:
  # ... other dependencies

  onairos:
    path: /Users/anushkajogalekar/projects/onairos-flutter
```

Then run:

```bash
flutter pub get
flutter run
```

## 🔄 Development Workflow

### Hot Reload During Development

1. **Make changes** to your Onairos package files
2. **Hot reload** in the consumer app (`r` in terminal or Cmd+R in IDE)
3. **Changes appear instantly** - no need to republish!

### Path Dependency Benefits

✅ **Instant updates** - changes reflect immediately  
✅ **No publishing** required during development  
✅ **Full debugging** - breakpoints work in package code  
✅ **Real integration testing** - exactly like production

### When Ready to Publish

Replace path dependency with version:

```yaml
dependencies:
  onairos: ^0.3.0 # Instead of path: /Users/...
```

## 🎯 Key Testing Points

Test these specific NPM → Flutter integrations:

1. **Modal animations** (400ms slide + 300ms fade)
2. **Step navigation** (welcome → signin → verification → platforms)
3. **Email input validation**
4. **6-digit code input** with auto-focus
5. **Platform connection toggles**
6. **Haptic feedback** on button presses
7. **Back button navigation**
8. **Loading states** and error handling

## 🐛 Troubleshooting

**Issue**: `Package not found`
**Fix**: Ensure path is absolute: `/Users/anushkajogalekar/projects/onairos-flutter`

**Issue**: `Dependency conflicts`  
**Fix**: Run `flutter pub deps` to check dependency tree

**Issue**: `Hot reload not working`  
**Fix**: Restart with `R` or `flutter run` again

---

This setup gives you **instant feedback** on your NPM → Flutter integration! 🚀
