import 'package:flutter/material.dart';
import 'app/theme/app_theme.dart';
import 'app/main_shell.dart';
import 'features/auth/presentation/pages/login_page.dart';
import 'features/auth/presentation/pages/welcome_page.dart';
import 'features/auth/presentation/pages/register_page.dart';
import 'features/auth/presentation/pages/forgot_password_page.dart';
import 'features/coupons/presentation/pages/coupon_detail_page.dart';
import 'features/coupons/presentation/pages/order_confirm_page.dart';
import 'features/coupons/presentation/pages/payment_page.dart';
import 'features/coupons/presentation/pages/payment_success_page.dart';
import 'features/coupons/presentation/pages/search_page.dart';
import 'features/coupons/presentation/pages/my_coupon_detail_page.dart';
import 'features/coupons/presentation/pages/redeem_qr_page.dart';
import 'features/trading/presentation/pages/trading_page.dart';
import 'features/trading/presentation/pages/transfer_page.dart';
import 'features/trading/presentation/pages/sell_order_page.dart';
import 'features/wallet/presentation/pages/wallet_page.dart';
import 'features/wallet/presentation/pages/deposit_page.dart';
import 'features/wallet/presentation/pages/withdraw_page.dart';
import 'features/wallet/presentation/pages/transaction_records_page.dart';
import 'features/profile/presentation/pages/kyc_page.dart';
import 'features/profile/presentation/pages/settings_page.dart';
import 'features/profile/presentation/pages/payment_management_page.dart';
import 'features/profile/presentation/pages/pro_mode_page.dart';
import 'features/ai_agent/presentation/pages/agent_chat_page.dart';
import 'features/message/presentation/pages/message_detail_page.dart';
import 'features/issuer/presentation/pages/issuer_main_page.dart';
import 'features/merchant/presentation/pages/merchant_home_page.dart';

void main() {
  runApp(const GenexConsumerApp());
}

/// Genex 消费者App
///
/// 用户使用的券金融平台客户端
/// 浏览/购买/持有/交易/核销数字券
class GenexConsumerApp extends StatelessWidget {
  const GenexConsumerApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Genex',
      theme: AppTheme.light,
      debugShowCheckedModeBanner: false,
      initialRoute: '/',
      onGenerateRoute: _generateRoute,
    );
  }

  Route<dynamic> _generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case '/':
        return MaterialPageRoute(builder: (_) => const WelcomePage());
      case '/login':
        return MaterialPageRoute(builder: (_) => const LoginPage());
      case '/register':
        return MaterialPageRoute(builder: (_) => const RegisterPage());
      case '/forgot-password':
        return MaterialPageRoute(builder: (_) => const ForgotPasswordPage());
      case '/main':
        return MaterialPageRoute(builder: (_) => const MainShell());
      case '/coupon/detail':
        return MaterialPageRoute(builder: (_) => const CouponDetailPage());
      case '/order/confirm':
        return MaterialPageRoute(builder: (_) => const OrderConfirmPage());
      case '/payment':
        return MaterialPageRoute(builder: (_) => const PaymentPage());
      case '/payment/success':
        return MaterialPageRoute(builder: (_) => const PaymentSuccessPage());
      case '/search':
        return MaterialPageRoute(builder: (_) => const SearchPage());
      case '/coupon/mine/detail':
        return MaterialPageRoute(builder: (_) => const MyCouponDetailPage());
      case '/redeem':
        return MaterialPageRoute(builder: (_) => const RedeemQrPage());
      case '/trading':
        return MaterialPageRoute(builder: (_) => const TradingPage());
      case '/transfer':
        return MaterialPageRoute(builder: (_) => const TransferPage());
      case '/sell':
        return MaterialPageRoute(builder: (_) => const SellOrderPage());
      case '/wallet':
        return MaterialPageRoute(builder: (_) => const WalletPage());
      case '/wallet/deposit':
        return MaterialPageRoute(builder: (_) => const DepositPage());
      case '/wallet/withdraw':
        return MaterialPageRoute(builder: (_) => const WithdrawPage());
      case '/wallet/records':
        return MaterialPageRoute(builder: (_) => const TransactionRecordsPage());
      case '/kyc':
        return MaterialPageRoute(builder: (_) => const KycPage());
      case '/settings':
        return MaterialPageRoute(builder: (_) => const SettingsPage());
      case '/payment/manage':
        return MaterialPageRoute(builder: (_) => const PaymentManagementPage());
      case '/pro-mode':
        return MaterialPageRoute(builder: (_) => const ProModePage());
      case '/ai-chat':
        return MaterialPageRoute(builder: (_) => const AgentChatPage());
      case '/message/detail':
        return MaterialPageRoute(builder: (_) => const MessageDetailPage());
      case '/issuer':
        return MaterialPageRoute(builder: (_) => const IssuerMainPage());
      case '/merchant':
        return MaterialPageRoute(builder: (_) => const MerchantHomePage());
      default:
        return MaterialPageRoute(
          builder: (_) => Scaffold(
            body: Center(child: Text('Route not found: ${settings.name}')),
          ),
        );
    }
  }
}
