
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

import 'constants.dart';
import 'pages/blog.dart';
import 'pages/buy_service.dart';
import 'pages/change_mobile_or_email.dart';
import 'pages/change_password.dart';
import 'pages/checkout.dart';
import 'pages/contact_us.dart';
import 'pages/coupons.dart';
import 'pages/create_online_store_1.dart';
import 'pages/download.dart';
import 'pages/forgot_password.dart';
import 'pages/home.dart';
import 'pages/igoshow_learn_more.dart';
import 'pages/login.dart';
import 'pages/me.dart';
import 'pages/minipos_learn_more.dart';
import 'pages/my_addresses.dart';
import 'pages/my_cards.dart';
import 'pages/my_support.dart';
import 'pages/new_comment.dart';
import 'pages/new_ticket.dart';
import 'pages/new_user.dart';
import 'pages/order_detail.dart';
import 'pages/orders.dart';
import 'pages/pay_now.dart';
import 'pages/plain_page.dart';
import 'pages/renew_license.dart';
import 'pages/renew_minioffice.dart';
import 'pages/reset_password.dart';
import 'pages/search_place.dart';
import 'pages/set_password.dart';
import 'pages/shop.dart';
import 'pages/user_profile.dart';
import 'pages/view_blog.dart';
import 'pages/view_ticket.dart';
// import 'widgets/mobile/ocr_scan.dart';

class Routes {
  static final router = FluroRouter();

  static void configure() {
    router.define('/', handler: new Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return Home(title: Constants.APP_TITLE,);
      }),
      transitionType: TransitionType.fadeIn
    );
    router.define('/download', handler: new Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return Download();
      }),
      transitionType: TransitionType.inFromRight
    );
    router.define('/minipos-learn-more', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return MiniPosLearnMore();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/igoshow-learn-more', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return IGoShowLearnMore();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/login', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Login();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/me', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Me();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/change-password', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ChangePassword();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/user-profile', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return UserProfile();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/new-user', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return NewUser();
        }),
        transitionType: TransitionType.inFromRight
    );
    router.define('/set-password/:mobile/:code', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return SetPassword(params['mobile']![0], code: params['code']![0]);
        }
    ));
    router.define('/forgot-password', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ForgotPassword();
        }
    ));
    router.define('/reset-password/:mobile/:code', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ResetPassword(params['mobile']![0], code: params['code']![0]);
        }
    ));
    router.define('/change-mobile-email/:ismobile', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          if (params['ismobile']![0] == '1') {
            return ChangeMobileOrEmail(true);
          }
          return ChangeMobileOrEmail(false);
        }
    ));
    router.define('/my-addresses/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return MyAddresses(businessId: int.parse(params['business_id']![0]),);
        }
    ));
    router.define('/my-support/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return MySupport(businessId: int.parse(params['business_id']![0]),);
        }
    ));
    router.define('/new-ticket/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return NewTicket(businessId: int.parse(params['business_id']![0]),);
        }
    ));
    router.define('/search-place/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return SearchPlace(int.parse(params['business_id']![0]));
        }
    ));
    router.define('/view-ticket/:ticket_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ViewTicket(int.parse(params['ticket_id']![0]),);
        }
    ));
    router.define('/blog/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Blog(businessId: int.parse(params['business_id']![0]),);
        }
    ));
    router.define('/view-blog/:bid', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ViewBlog(int.parse(params['bid']![0]),);
        }
    ));
    router.define('/shop/:business_id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Shop(businessId: int.parse(params['business_id']![0]),);
        }
    ));
    router.define('/shop', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Shop();
        }
    ));
    // router.define('/ocr-scan', handler: new Handler(
    //     handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    //       return OCRScan();
    //     }
    // ));
    router.define('/checkout/:id', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Checkout(int.parse(params['id']![0]));
        }),
    );
    router.define('/paynow/:orderId', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PayNow(int.parse(params['orderId']![0]));
        }),
    );
    router.define('/orders', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Orders();
        }
    ));
    router.define('/my-cards', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return MyCards();
        }
    ));
    router.define('/orderdetail/:orderId', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return OrderDetail(int.parse(params['orderId']![0]));
        }),
    );
    router.define('/new-comment/:orderId', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return NewComment(int.parse(params['orderId']![0]));
        }),
    );
    router.define('/coupons/:contactId', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return Coupons(int.parse(params['contactId']![0]));
        }),
    );
    router.define('/service-policy', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PlainPage(
            'service-policy',
            // businessId: Constants.BUSINESS_ID,
            businessId: 310,
          );
        }),
    );
    router.define('/return-policy', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PlainPage(
            'return-policy',
            // businessId: Constants.BUSINESS_ID,
            businessId: 310,
          );
        }),
    );
    router.define('/privacy-policy', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PlainPage(
            'privacy-policy',
            // businessId: Constants.BUSINESS_ID,
            businessId: 310,
          );
        }),
    );
    router.define('/end-user-license-agreement', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PlainPage(
            'end-user-license-agreement',
            // businessId: Constants.BUSINESS_ID,
            businessId: 310,
          );
        }),
    );
    router.define('/about-us', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return PlainPage(
            'about-us',
            // businessId: Constants.BUSINESS_ID,
            businessId: 310,
          );
        }),
    );
    router.define('/contact-us', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return ContactUs(
            businessId: Constants.BUSINESS_ID,
          );
        }),
    );
    router.define('/renew-license', handler: new Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return RenewLicense();
      }
    ));
    router.define('/renew-minioffice/:gid', handler: new Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return RenewMiniOffice(int.parse(params['gid']![0]));
      }
    ));
    router.define('/buy-service/:gid/:servicename', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return BuyService(int.parse(params['gid']![0]), params['servicename']![0]);
        }
    ));
    router.define('/contact-stores', handler: new Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
          return CreateOnlineStore1();
        }
    ));
  }
}