diff --git a/src/Controllers/SettingsViewController.m b/src/Controllers/SettingsViewController.m index d43a022..9662d0e 100755 --- a/src/Controllers/SettingsViewController.m +++ b/src/Controllers/SettingsViewController.m @@ -90,12 +90,14 @@ - (NSArray *)specifiers { [self newSwitchCellWithTitle:@"Hide Meta AI" detailTitle:@"Hides the meta ai buttons within the app" key:@"hide_meta_ai" defaultValue:false changeAction:nil], [self newSwitchCellWithTitle:@"Copy description" detailTitle:@"Copy the post description with a long press" key:@"copy_description" defaultValue:true changeAction:nil], [self newSwitchCellWithTitle:@"Hide reels tab" detailTitle:@"Hides the reels tab on the bottom navbar" key:@"hide_reels_tab" defaultValue:false changeAction:nil], + [self newSwitchCellWithTitle:@"Hide Create tab" detailTitle:@"Hides the Create tab on the bottom navbar" key:@"hide_create_tab" defaultValue:false changeAction:nil], [self newSwitchCellWithTitle:@"Disable scrolling reels" detailTitle:@"Prevents reels from being scrolled to the next video" key:@"disable_scrolling_reels" defaultValue:false changeAction:nil], [self newSwitchCellWithTitle:@"Do not save recent searches" detailTitle:@"Search bars will no longer save your recent searches" key:@"no_recent_searches" defaultValue:false changeAction:nil], [self newSwitchCellWithTitle:@"Hide explore posts grid" detailTitle:@"Hides the grid of suggested posts on the explore/search tab" key:@"hide_explore_grid" defaultValue:false changeAction:nil], [self newSwitchCellWithTitle:@"Hide trending searches" detailTitle:@"Hides the trending searches under the explore search bar" key:@"hide_trending_searches" defaultValue:true changeAction:nil], [self newSwitchCellWithTitle:@"No suggested chats" detailTitle:@"Hides the suggested broadcast channels in direct messages" key:@"no_suggested_chats" defaultValue:true changeAction:nil], [self newSwitchCellWithTitle:@"No suggested users" detailTitle:@"Hides the suggested users for you to follow" key:@"no_suggested_users" defaultValue:false changeAction:nil], + [self newSwitchCellWithTitle:@"Show Control Hider Button" detailTitle:@"Adds button to hide Reel Controls" key:@"hide_controls" defaultValue:false changeAction:nil] // Section 2: Feed [self newSectionWithTitle:@"Feed" footer:nil], @@ -328,4 +330,4 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr } return self; } -@end \ No newline at end of file +@end diff --git a/src/Features/General/HideReelsAndCreateTab.x b/src/Features/General/HideReelsAndCreateTab.x new file mode 100644 index 0000000..91860db --- /dev/null +++ b/src/Features/General/HideReelsAndCreateTab.x @@ -0,0 +1,26 @@ +#import "../../InstagramHeaders.h" +#import "../../Manager.h" + +// Hide reels tab and create tab +%hook IGTabBarController + +- (id)initWithUserSession:(id)a tabBarSurfaces:(id)b accountSwitcherPresenter:(id)c initMode:(NSInteger)d { + + NSMutableArray *surfaces = [NSMutableArray arrayWithArray:b]; + + [surfaces enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(IGMainAppSurfaceIntent *surface, NSUInteger idx, BOOL *stop) { + + NSInteger subtype = [[surface valueForKey:@"_subtype"] integerValue]; + + if (subtype == 2 && [SCIManager getPref:@"hide_reels_tab"]) { + [surfaces removeObjectAtIndex:idx]; + } + + if (subtype == 3 && [SCIManager getPref:@"hide_create_tab"]) { + [surfaces removeObjectAtIndex:idx]; + } + }]; + return %orig(a, surfaces, c, d); +} + +%end diff --git a/src/Features/General/HideReelsTab.x b/src/Features/General/HideReelsTab.x deleted file mode 100644 index 60c5292..0000000 --- a/src/Features/General/HideReelsTab.x +++ /dev/null @@ -1,21 +0,0 @@ -#import "../../InstagramHeaders.h" -#import "../../Manager.h" - -// Hide reels tab -%hook IGTabBar -- (void)didMoveToWindow { - %orig; - - if ([SCIManager getPref:@"hide_reels_tab"]) { - NSMutableArray *tabButtons = [self valueForKey:@"_tabButtons"]; - - NSLog(@"[SCInsta] Hiding reels tab"); - - if ([tabButtons count] == 5) { - [tabButtons removeObjectAtIndex:3]; - } - - [self.subviews[4] setHidden:YES]; - } -} -%end \ No newline at end of file diff --git a/src/Features/General/hideReelControls.x b/src/Features/General/hideReelControls.x new file mode 100644 index 0000000..c8219ed --- /dev/null +++ b/src/Features/General/hideReelControls.x @@ -0,0 +1,65 @@ +#import "../../InstagramHeaders.h" +#import "../../Manager.h" + + +%hook IGSundialViewerVideoCell +%property(nonatomic, assign) BOOL controlsHidden; + +- (void)videoViewDidLoadVideo:(id)video { + %orig; + if ([SCIManager getPref:@"hide_controls"]) { + self.controlsHidden = false; + [self addControlsHiderButton]; + } +} + +- (void)prepareForReuse { + %orig; + if ([SCIManager getPref:@"hide_controls"]) { + self.controlsHidden = false; + UIButton *hideButton = [self viewWithTag:123]; + if (hideButton) { + [hideButton setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal]; + } + [self.viewController animateCurrentVideoControllerVideoCellControlsOverlayVisible:YES]; + } +} + +%new - (void)addControlsHiderButton { + UIButton *ControlsHiderButton = [UIButton buttonWithType:UIButtonTypeSystem]; + [ControlsHiderButton setTag:123]; + [ControlsHiderButton setTranslatesAutoresizingMaskIntoConstraints:false]; + [ControlsHiderButton addTarget:self action:@selector(ControlsHiderButtonHandler:) forControlEvents:UIControlEventTouchUpInside]; + if (self.controlsHidden) { + [ControlsHiderButton setImage:[UIImage systemImageNamed:@"eye.fill"] forState:UIControlStateNormal]; + } else { + [ControlsHiderButton setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal]; + } + + if (![self viewWithTag:123]) { + [ControlsHiderButton setTintColor:[UIColor whiteColor]]; + [self addSubview:ControlsHiderButton]; + [NSLayoutConstraint activateConstraints:@[ + [ControlsHiderButton.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor constant:70], + [ControlsHiderButton.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor constant:-10], + [ControlsHiderButton.widthAnchor constraintEqualToConstant:30], + [ControlsHiderButton.heightAnchor constraintEqualToConstant:30], + ]]; + } +} + +%new - (void)ControlsHiderButtonHandler:(UIButton *)sender { + IGSundialFeedViewController *rootVC = self.viewController; + if (self.controlsHidden) { + self.controlsHidden = false; + [rootVC animateCurrentVideoControllerVideoCellControlsOverlayVisible:YES]; + [sender setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal]; + } else { + self.controlsHidden = true; + [rootVC animateCurrentVideoControllerVideoCellControlsOverlayVisible:NO]; + [sender setImage:[UIImage systemImageNamed:@"eye.fill"] forState:UIControlStateNormal]; + } +} + + +%end \ No newline at end of file diff --git a/src/Features/Save/MediaSave.x b/src/Features/Save/MediaSave.x index 4483863..e9da0ae 100644 --- a/src/Features/Save/MediaSave.x +++ b/src/Features/Save/MediaSave.x @@ -30,7 +30,7 @@ NSLog(@"[SCInsta] Save media: Preparing alert"); IGFeedItemPagePhotoCell *currentCell = self.delegate; - IGPostItem *currentPost = [currentCell post]; + IGPostItem *currentPost = [currentCell post] ?: currentCell.pagePhotoPost; // Attempt to fix Carousel items download NSSet *knownImageURLIdentifiers = [currentPost.photo valueForKey:@"_knownImageURLIdentifiers"]; NSArray *knownImageURLIdentifiersArray = [knownImageURLIdentifiers allObjects]; diff --git a/src/InstagramHeaders.h b/src/InstagramHeaders.h index e19e643..7c78c60 100644 --- a/src/InstagramHeaders.h +++ b/src/InstagramHeaders.h @@ -122,11 +122,19 @@ @interface IGFeedPhotoView () @end -@interface IGSundialViewerVideoCell : UIView +@interface IGSundialFeedViewController : UIViewController +- (void)animateCurrentVideoControllerVideoCellControlsOverlayVisible:(BOOL)a; +@end + +@interface IGSundialViewerVideoCell : UICollectionViewCell - (void)addHandleLongPress; // new - (void)handleLongPress:(UILongPressGestureRecognizer *)sender; // new -@property (nonatomic, strong) JGProgressHUD *hud; +- (void)addControlsHiderButton; // new +- (void)ControlsHiderButtonHandler:(UIButton *)sender; // new +@property (nonatomic, strong) JGProgressHUD *hud; @property(readonly, nonatomic) IGMedia *video; +@property (nonatomic, assign, readonly) IGSundialFeedViewController *viewController; // new property +@property(nonatomic, assign) BOOL controlsHidden; // new property @end @interface IGSundialViewerVideoCell () @@ -337,6 +345,8 @@ @interface IGUnifiedVideoCollectionView : UIScrollView @end +@interface IGMainAppSurfaceIntent:NSObject +@end ///////////////////////////////////////////////////////////////////////////// @@ -457,4 +467,4 @@ typedef FLEXAlertAction * _Nonnull (^FLEXAlertActionHandler)(void(^handler)(NSAr - (void)showExplorer; - (void)hideExplorer; - (void)toggleExplorer; -@end \ No newline at end of file +@end