mirror of
				https://github.com/SoPat712/YTLitePlus.git
				synced 2025-10-30 20:34:04 -04:00 
			
		
		
		
	Fix home contents bug
This commit is contained in:
		| @@ -94,6 +94,14 @@ | ||||
| @property (nonatomic, assign, readwrite) BOOL enableSnapToChapter; | ||||
| @end | ||||
|  | ||||
| // Hide Home Tab - @bhackel | ||||
| @interface YTPivotBarViewController : UIViewController | ||||
| @property NSString *selectedPivotIdentifier; | ||||
| @property YTIPivotBarRenderer *renderer; | ||||
| - (void)selectItemWithPivotIdentifier:(NSString *)pivotIdentifier; | ||||
| - (void)resetViewControllersCache; | ||||
| @end | ||||
|  | ||||
| // SponsorBlock button in Nav bar | ||||
| @interface MDCButton : UIButton | ||||
| @end | ||||
|   | ||||
| @@ -182,7 +182,7 @@ static BOOL IsEnabled(NSString *key) { | ||||
|  | ||||
| // Hide Home Tab - @bhackel | ||||
| %group gHideHomeTab | ||||
| %hook YTPivotBarViewController | ||||
| %hook YTPivotBarView | ||||
| - (void)setRenderer:(YTIPivotBarRenderer *)renderer { | ||||
|     // Iterate over each renderer item | ||||
|     NSUInteger indexToRemove = -1; | ||||
| @@ -204,6 +204,35 @@ static BOOL IsEnabled(NSString *key) { | ||||
|     %orig; | ||||
| } | ||||
| %end | ||||
| // Fix bug where contents of leftmost tab is replaced by Home tab | ||||
| BOOL isTabSelected = NO; | ||||
| %hook YTPivotBarViewController | ||||
| - (void)viewDidAppear:(BOOL)animated { | ||||
|     %orig; | ||||
|     if (!isTabSelected) { | ||||
|         // Get the identifier of the selected pivot | ||||
|         NSString *selectedPivotIdentifier = self.selectedPivotIdentifier; | ||||
|         // Find any different tab to switch from by looping through the renderer items | ||||
|         YTIPivotBarRenderer *renderer = self.renderer; | ||||
|         NSArray <YTIPivotBarSupportedRenderers *> *itemsArray = renderer.itemsArray; | ||||
|         for (YTIPivotBarSupportedRenderers *item in itemsArray) { | ||||
|             YTIPivotBarItemRenderer *pivotBarItemRenderer = item.pivotBarItemRenderer; | ||||
|             NSString *pivotIdentifier = pivotBarItemRenderer.pivotIdentifier; | ||||
|             if (![pivotIdentifier isEqualToString:selectedPivotIdentifier]) { | ||||
|                 // Switch to this tab | ||||
|                 [self selectItemWithPivotIdentifier:pivotIdentifier]; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         // Clear any cached controllers to delete the broken home tab | ||||
|         [self resetViewControllersCache]; | ||||
|         // Switch back to the original tab | ||||
|         [self selectItemWithPivotIdentifier:selectedPivotIdentifier]; | ||||
|         // Update flag to not do it again | ||||
|         isTabSelected = YES; | ||||
|     } | ||||
| } | ||||
| %end | ||||
| %end | ||||
|  | ||||
| // YTNoModernUI - @arichorn | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Bryce Hackel
					Bryce Hackel