import 'package:fluro/fluro.dart';
import 'package:liftmanager/internal/yearly/model/yearly_list_entity.dart';
import 'package:liftmanager/internal/yearly/page/yearly_detail_page.dart';
import 'package:liftmanager/internal/yearly/page/yearly_list_page.dart';
import 'package:liftmanager/internal/yearly/page/yearly_upload_page.dart';
import 'package:liftmanager/routers/router_init.dart';
import 'dart:convert' as convert;
///年检
class YearlyRouter implements IRouterProvider{

  static String yearlyListPage = "/yearly/list";
  static String yearlyDetailPage = "/yearly/detail";
  static String yearlyUploadPage = "/yearly/upload";

  @override
  void initRouter(Router router) {
    router.define(yearlyListPage, handler: Handler(handlerFunc: (_, params){
      String topInto = params["top_into"]?.first??"0";
      return YearlyListPage(topInto: topInto=="1"?true:false,);
    }));
    router.define(yearlyDetailPage, handler: Handler(handlerFunc: (_, params){
      var item = params["item"].first;
      YearlyListItem yearly = YearlyListItem.fromJsonMap(convert.jsonDecode(item));
      return YearlyDetailPage(yearly);
    }));
    router.define(yearlyUploadPage, handler: Handler(handlerFunc: (_, params){
      var type = params["type"].first;
      var id = params["id"].first;
      return YearlyUploadPage(int.parse(type),id);
    }));
  }
}