Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)setupDataAdapter
  2. {
  3.     NSArray<PTUMoreMenuActionItem *> *actionItems = [self actionItems];
  4.    
  5.     self.dataSource = [[PTUMoreTableViewDataSource alloc] initWithActionItems:actionItems middleLayerController:self.middleLayerController];
  6.     self.dataSource.delegate = self;
  7.     self.dataAdapter = [[PTUMoreTableViewDataAdapter alloc] initWithDataSource:self.dataSource
  8.                                                                       delegate:self
  9.                                                                 moreLayoutInfo:self.menuLayoutInfo
  10.                                                         layoutConfigController:self.layoutConfigController];
  11.    
  12.     self.moreTableView.dataSource = self.dataAdapter;
  13.     self.moreTableView.delegate = self.dataAdapter;
  14. }
  15.  
  16. - (NSArray<PTUMoreMenuActionItem *> *)actionItems
  17. {
  18.     __weak typeof(self) weakSelf = self;
  19.    
  20.     NSArray<PTUMoreMenuActionItem *> *actionItems = [PTUMoreMenuActionItem actionsWithLayoutElements:self.menuLayoutInfo.content openURLBlock:^(PTUButtonLayoutInfo *buttonLayoutInfo) {
  21.        
  22.         weakSelf.selectedItem = buttonLayoutInfo;
  23.         [weakSelf performSegueWithIdentifier:PTUPresentCommonWebViewControllerSegueIdentifier sender:weakSelf];
  24.     } openMenuBlock:^(PTUButtonLayoutInfo *buttonLayoutInfo) {
  25.        
  26.         PTUMoreViewController *controller = [PTUMoreViewController controller];
  27.         controller.menuLayoutInfo = buttonLayoutInfo.buttonActionData.screenLayoutInfo;
  28.         controller.middleLayerController = weakSelf.middleLayerController;
  29.         controller.layoutConfigController = weakSelf.layoutConfigController;
  30.        
  31.         controller.title = PTULocalizedString(buttonLayoutInfo.buttonTitle, nil);
  32.        
  33.         [weakSelf.navigationController pushViewController:controller animated:YES];
  34.     } openGameManagementBlock:^(PTUButtonLayoutInfo *buttonLayoutInfo) {
  35.        
  36.         [weakSelf performSegueWithIdentifier:PTUPresentGamesManagementViewControllerSegueIdentifier sender:weakSelf];
  37.     } openAboutBlock:^(PTUButtonLayoutInfo *buttonLayoutInfo) {
  38.        
  39.         [weakSelf performSegueWithIdentifier:PTUPresentAboutViewControllerSegueIdentifier sender:weakSelf];
  40.     } logoutBlock:^(PTUButtonLayoutInfo *buttonLayoutInfo) {
  41.        
  42.         __strong typeof(self) strongSelf = weakSelf;
  43.        
  44.         if (!strongSelf)
  45.         {
  46.             return;
  47.         }
  48.        
  49.         PTUNamedAction *confirmAction = [PTUNamedAction actionWithViewType:PTUNamedActionViewTypePositive
  50.                                                                      title:[PTULocalizedString(@"LOBBY_MENU_LOGOUT", nil) uppercaseString]
  51.                                                                     action:^(id sender){
  52.            
  53.             [strongSelf.mainLobbyTabBarController.middleLayerController.coreNetworkController logout];
  54.             strongSelf.mainLobbyTabBarController.selectedIndex = 0;
  55.         }];
  56.        
  57.         PTUNamedAction *cancelAction = [PTUNamedAction actionWithViewType:PTUNamedActionViewTypeNegative
  58.                                                                     title:[PTULocalizedString(@"LOBBY_POPUP_NO", nil) uppercaseString]];
  59.        
  60.         PTUAlertViewController *alertController =
  61.         [PTUAlertViewController alertViewControllerWithTitle:nil
  62.                                                      message:PTULocalizedString(@"LOBBY_LOGOUT_MESSAGE", nil)
  63.                                                   completion:nil];
  64.        
  65.         alertController.layoutConfigController = strongSelf.layoutConfigController;
  66.         alertController.middleLayerController = strongSelf.middleLayerController;
  67.         alertController.mainLobbyRouting = strongSelf.mainLobbyTabBarController.mainLobbyRouting;
  68.        
  69.         [alertController addActions:@[cancelAction, confirmAction]];
  70.        
  71.         [strongSelf.mainLobbyTabBarController.mainLobbyRouting showAlertController:alertController
  72.                                                                           animated:YES
  73.                                                                         completion:nil];
  74.     }];
  75.    
  76.     return actionItems;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement