123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // RQRouter.m
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/16.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #import "RQRouter.h"
- @interface RQRouter ()
- /// viewModel到viewController的映射
- @property (nonatomic, copy) NSDictionary *viewModelViewMappings;
- @end
- @implementation RQRouter
- static RQRouter *sharedInstance_ = nil;
- + (id)allocWithZone:(struct _NSZone *)zone
- {
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedInstance_ = [super allocWithZone:zone];
- });
- return sharedInstance_;
- }
- - (id)copyWithZone:(NSZone *)zone
- {
- return sharedInstance_;
- }
- + (instancetype)sharedInstance {
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedInstance_ = [[self alloc] init];
- });
- return sharedInstance_;
- }
- - (RQBaseViewController *)viewControllerForViewModel:(RQBaseViewModel *)viewModel {
- NSString *viewController = self.viewModelViewMappings[NSStringFromClass(viewModel.class)];
-
- NSParameterAssert([NSClassFromString(viewController) isSubclassOfClass:[RQBaseViewController class]]);
- NSParameterAssert([NSClassFromString(viewController) instancesRespondToSelector:@selector(initWithViewModel:)]);
-
- return [[NSClassFromString(viewController) alloc] initWithViewModel:viewModel];
- }
- /// 这里是viewModel -> ViewController的映射
- /// If You Use Push 、 Present 、 ResetRootViewController ,You Must Config This Dict
- - (NSDictionary *)viewModelViewMappings {
- return @{/*MainModule*/
- @"RQNewFeatureViewModel" : @"RQNewFeatureViewController",
- @"RQMainTabBarViewModel" : @"RQMainTabBarViewController",
- /*Base*/
- @"RQWebViewModel" : @"RQWebViewViewController",
- /*LoginModule*/
- @"RQLoginViewModel" : @"RQLoginViewController",
- @"RQRegisterViewModel" : @"RQRegisterViewController",
- @"RQVerificationSmsCodeViewModel" : @"RQVerificationSmsCodeViewController",
- @"RQUpdatePasswordViewModel" : @"RQUpdatePasswordViewController",
- /*HomePageModular*/
- @"RQHomePageViewModel" : @"RQHomePageViewController",
- @"RQStrongViewModel" : @"StrongVC",
- @"LightingAndSoundViewModel" : @"LightingAndSoundVC",
- @"RQHomeSubPageViewModel" : @"RQHomeSubPageViewController",
- @"RQHomePageSubjectOneOrFourViewModel" : @"RQHomePageSubjectOneOrFourViewController",
- @"RQErrorAndCollectViewModel" : @"RQErrorAndCollectViewController",
- @"RQErrorViewModel" : @"RQErrorViewController",
- @"RQCollectViewModel" : @"RQCollectViewController",
- @"RQHomePageTeachVideoViewModel" : @"RQHomePageTeachVideoViewController",
- @"RQHomePageTeachVideoListViewModel" : @"RQHomePageTeachVideoListViewController",
- @"RQPlaceListViewModel" : @"RQPlaceListViewController",
- @"RQPlaceDetailViewModel" : @"RQPlaceDetailViewController",
-
-
- @"RQExerciseViewModel" : @"RQExerciseViewController",
- @"RQExerciseSubViewModel" : @"RQExerciseSubViewController",
- @"RQSimulateExamViewModel" : @"RQSimulateExamViewController",
- @"RQCatalogueViewModel" : @"RQCatalogueViewController",
- @"RQExamResultViewModel" : @"RQExamResultViewController",
- @"RQExamProbabilityViewModel" : @"RQExamProbabilityViewController",
-
- @"RQSpecialPractiseViewModel" : @"RQSpecialPractiseViewController",
- @"RQChapterAndPointListViewModel" : @"RQChapterAndPointListViewController",
- @"RQHoursBeforeExamHomeViewModel" : @"RQHoursBeforeExamHomeViewController",
- /*TimeModule*/
- @"RQTimeViewModel" : @"RQTimeViewController",
- @"NYTheoryTimeViewModel" : @"NYTheoryTimeVC",
- // @"RQTimeViewModel" : @"TimingBaseVC",
- /*DiscoverModule*/
- // @"RQDiscoverViewModel" : @"RQDiscoverViewController",
- @"RQDiscoverViewModel" : @"SearchBase",
- /*ProfileModule*/
- //#if DEBUG
- // @"RQProfileViewModel" : @"RQProfileViewController",
- //#else
- @"RQProfileViewModel" : @"FunctionVC",
- //#endif
- @"RQSettingViewModel" : @"RQSettingViewController",
- @"RQAboutViewModel" : @"RQAboutViewController",
- @"RQChooseCarTypeViewModel" : @"RQChooseCarTypeViewController",
- @"RQSynchronizationViewModel" : @"RQSynchronizationViewController",
-
- @"RQUserInfoViewModel" : @"RQUserInfoViewController",
- @"RQActivateVIPViewModel" : @"RQActivateVIPViewController",
-
- /*OtherModule*/
- @"RQVideoCatalogueViewModel" : @"RQVideoCatalogueViewController",
- @"RQVideoDetailViewModel" : @"RQVideoDetailViewController",
- @"RQVideoDetailSubPageViewModel" : @"RQVideoDetailSubPageViewController",
- @"RQVipViewModel" : @"RQVipViewController",
- @"RQPayViewModel" : @"RQPayViewController",
- @"RQVipCenterViewModel" : @"RQVipCenterViewController",
- @"RQVipCenterSubViewModel" : @"RQVipCenterSubViewController",
- @"RQVipCenterSubListViewModel" : @"RQVipCenterSubListViewController",
- @"RQDspVideoDetailViewModel" : @"RQDspVideoDetailViewController",
- @"RQRetrainViewModel" : @"RQRetrainViewController",
- @"RQRetrainOrderViewModel" : @"RQRetrainOrderViewController",
- @"RQStudentChangeSchoolViewModel" : @"StudentChangeSchoolVC",
- @"RQExplainVideoViewModel" : @"RQExplainVideoViewController",
- };
- }
- @end
|