// // URLNavigationMap.swift // SwiftBilibili // // Created by 罗文 on 2021/1/16. // Copyright © 2021年 罗文. All rights reserved. // import UIKit import URLNavigator final class URLNavigationMap { static func initialize(navigator:NavigatorType) { navigator.register(NYSwPushType.trainee_info.path) { (url, values, context) -> UIViewController? in guard let context = context as? Int else { return nil } let meTraineeDetailsPageViewController = MeTraineeDetailsPageViewController(nibName: "MeTraineeDetailsPageViewController") meTraineeDetailsPageViewController.stuId = context return meTraineeDetailsPageViewController } navigator.register(NYSwPushType.trainee_search.path) { (url, values, context) -> UIViewController? in let meTraineeSearchPageViewController = MeTraineeSearchPageViewController(nibName: "MeTraineeSearchPageViewController") return meTraineeSearchPageViewController } navigator.register(NYSwPushType.trainee_statistics.path) { (url, values, context) -> UIViewController? in let statisticsPageController = StatisticsPageController(type: .normal) return statisticsPageController } navigator.register(NYSwPushType.trainee_statistics_official.path) { (url, values, context) -> UIViewController? in let statisticsPageController = StatisticsPageController(type: .presell) return statisticsPageController } navigator.register(NYSwPushType.trainee_list.path) { (url, values, context) -> UIViewController? in let meTraineeListViewController = MeTraineeListViewController(type: .none) return meTraineeListViewController } navigator.register(NYSwPushType.trainee_list_biand.path) { (url, values, context) -> UIViewController? in let meTraineeListViewController = MeTraineeListViewController(type: .biandstu) return meTraineeListViewController } navigator.register(NYSwPushType.trainee_list_school.path) { (url, values, context) -> UIViewController? in let meTraineeListViewController = MeTraineeListViewController(type: .none) meTraineeListViewController.schoolId = context as! Int return meTraineeListViewController } navigator.register(NYSwPushType.mine_uppassword.path) { (url, values, context) -> UIViewController? in let updatePasswordViewController = UpdatePasswordViewController(nibName: "UpdatePasswordViewController") return updatePasswordViewController } navigator.register(NYSwPushType.mine_center.path) { (url, values, context) -> UIViewController? in let mineViewController = MineViewController(nibName: "MineViewController") return mineViewController } navigator.register(NYSwPushType.coach_qrcode.path) { (url, values, context) -> UIViewController? in let coachQRPageController = CoachQRPageController(nibName: "CoachQRPageController") return coachQRPageController } navigator.register(NYSwPushType.coach_qrcode_download.path) { (url, values, context) -> UIViewController? in let coachAppdownloadPageController = CoachAppdownloadPageController(nibName: "CoachAppdownloadPageController") coachAppdownloadPageController.type = (context as! Int)==1 ? .ios : .android return coachAppdownloadPageController } //open api navigator.register("http://",self.webViewControllerFactory) navigator.register("https://",self.webViewControllerFactory) // navigator.handle(NYSwOpenType.area.rawValue, self.area(navigator: navigator)) // navigator.handle(NYSwOpenType.all.rawValue, self.all(navigator: navigator)) navigator.handle(NYSwOpenType.login.rawValue, self.login(navigator: navigator)) navigator.handle(NYSwOpenType.traineetab.rawValue, self.meTraineeTab(navigator: navigator)) } private static func webViewControllerFactory( url: URLConvertible, values: [String: Any], context: Any? ) -> UIViewController? { let link = url.urlStringValue if link.contains("read") { return NYArticleViewController(link: link) } else { return NYWebViewController(link: url.urlStringValue) } } private static func area(navigator: NavigatorType) -> URLOpenHandlerFactory { return { url, values, context in let parent_area_id = url.queryParameters["parent_area_id"]! let parent_area_name = url.queryParameters["parent_area_name"]! let area_id = url.queryParameters["area_id"]! let area_name = url.queryParameters["area_name"]! let partitionController = UIViewController() // LivePartitionViewController(parent_area_id: parent_area_id, // parent_area_name: parent_area_name, // area_id: area_id, // area_name: area_name) navigator.push(partitionController) return true } } private static func all(navigator: NavigatorType) -> URLOpenHandlerFactory { return { url, values, context in let allParentVc = UIViewController() // LiveAllParentViewController(service: HomeService(networking: HomeNetworking())) navigator.push(allParentVc) return true } } private static func login(navigator: NavigatorType) -> URLOpenHandlerFactory { return { url, values, context in let loginController = LoginViewController(nibName: "LoginViewController") navigator.present(loginController, wrap: MainNavigationController.self) return true } } private static func meTraineeTab(navigator: NavigatorType) -> URLOpenHandlerFactory { return { url, values, context in let meTabBarController = MeTabBarController(reactor: MainTabBarViewReactor(), advancetViewController: MeTraineeListViewController(type: .advancet), officialViewController: MeTraineeListViewController(type: .official) ) meTabBarController.modalPresentationStyle = .fullScreen navigator.present(meTabBarController) return true } } }