import 'package:flutter/material.dart';
import '../../presentation/features/call/call_page.dart';
import '../../presentation/features/call/incoming_call_page.dart';
import '../../presentation/features/home/home_page.dart';
import '../../presentation/features/settings/settings.dart';  // Updated import
import '../../presentation/features/contacts/contact_page.dart';
import '../../presentation/features/composition/composition.dart';
import 'dart:typed_data';

class AppRouter {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case '/':
        return MaterialPageRoute(builder: (_) => const MyHomePage());
        
      case '/settings':
        return MaterialPageRoute(builder: (_) => const SettingsPage());  // Now correctly imported
        
      case '/composition':
        return MaterialPageRoute(builder: (_) => const CompositionPage());
        
      case '/contacts':
        return MaterialPageRoute(builder: (_) => const ContactPage());
        
      case '/call':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(
          settings: settings,
          builder: (_) => CallPage(
            displayName: args['displayName'] as String,
            phoneNumber: args['phoneNumber'] as String,
            thumbnail: args['thumbnail'] as Uint8List?,
          ),
        );
        
      case '/incoming_call':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(
          settings: settings,
          builder: (_) => IncomingCallPage(
            displayName: args['displayName'] as String,
            phoneNumber: args['phoneNumber'] as String,
            thumbnail: args['thumbnail'] as Uint8List?,
          ),
        );
        
      default:
        return MaterialPageRoute(
          builder: (_) => Scaffold(
            body: Center(
              child: Text('No route defined for ${settings.name}'),
            ),
          ),
        );
    }
  }
}
