import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:fun_selfie_app/pages/home/index.dart';
import 'package:fun_selfie_app/pages/login/login.dart';
import 'package:fun_selfie_app/pages/login/not_found.dart';
import 'package:fun_selfie_app/pages/home/add_news.dart';
import 'package:fun_selfie_app/pages/home/news_detail.dart';
import 'package:fun_selfie_app/pages/photography/index.dart';
import 'package:fun_selfie_app/pages/photography/take_photo.dart';
import 'package:fun_selfie_app/pages/photography/photo_over.dart';

class RouterFluro {
  static FluroRouter fluroRouter = FluroRouter();

  static final Handler _homeHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const HomePage();
  });
  static final Handler _loginHandler = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const LoginPage();
  });

  static final Handler _addNews = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const AddNewsPage();
  });

  static final Handler _newsDetail = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return NewsDetailPage(ids: params['ids']![0]);
  });

  static final Handler _photography = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const PhotographyPage();
  });
  static final Handler _takePhoto = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const TakePhotoPage();
  });
  static final Handler _photoOver = Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    return const PhotoOverPage();
  });

  static initRoues() {
    fluroRouter.notFoundHandler = Handler(
        handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
      return const NotFoundPage();
    });
    fluroRouter.define("/",
        handler: _homeHandler, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/login",
        handler: _loginHandler, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/addNews",
        handler: _addNews, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/newsDetail/:ids",
        handler: _newsDetail, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/photography",
        handler: _photography, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/takePhoto",
        handler: _takePhoto, transitionType: TransitionType.fadeIn);
    fluroRouter.define("/photo_over",
        handler: _photoOver, transitionType: TransitionType.fadeIn);
  }
}
