Skip to content

Commit

Permalink
Fix: Bring back dropdown on insta settings click, to still show entry…
Browse files Browse the repository at this point in the history
…point for BHInsta settings
  • Loading branch information
SoCuul committed Mar 11, 2024
1 parent 58aa295 commit 4c418af
Showing 1 changed file with 68 additions and 9 deletions.
77 changes: 68 additions & 9 deletions src/Features/General/BHSettingsMenuEntry.x
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#import "../../InstagramHeaders.h"
#import "../../Manager.h"
#import "../../Controllers/SettingsViewController.h"

/* %hook IGProfileHeaderNavigationView
- _rightButtonsLayout.(id)initWithDirection:(NSInteger)arg1 children:(id)arg2 {
return nil;
// Workaround to display dropdown settings menu, to still show BHInsta settings
%hook IGProfileViewController
- (BOOL)_shouldOpenSettingsDirectly {
return false;
}
- _rightButtonsLayout.(id).initWithChildren:(id)arg1 {
return nil;
}
%end */
%end

/* Legacy (as of March 8th 2023) */
// Being phased out by insta (as of March 8th 2023)
%hook IGProfileMenuSheetViewController
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 9;
Expand Down Expand Up @@ -41,4 +40,64 @@
return %orig;
}
}
%end
%end

// TODO: Add BHInsta settings button to profile header navbar icons
/* %hook IGStackLayout
// Display Settings Modal
%new - (void)displaySettingsModal:(id)sender {
// Display settings modal
NSLog(@"[BHInsta] Displaying BHInsta settings modal");
UIViewController *rootController = [[UIApplication sharedApplication] delegate].window.rootViewController;
SettingsViewController *settingsViewController = [SettingsViewController new];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
[rootController presentViewController:navigationController animated:YES completion:nil];
return;
}
// test to get icon info
- (id)initWithIcon:(id)arg1 target:(id)arg2 action:(SEL)arg3 buttonType:(NSUInteger)arg4 {
NSLog(@"[BHInsta] Icon: %@", arg1);
return %orig;
}
- (id)initWithChildren:(id)children {
// Check if children contain badged icons (only used on profile page)
BOOL containsClass = NO;
for (id child in children) {
if ([child isKindOfClass:%c(IGBadgedNavigationButton)]) {
containsClass = YES;
break;
}
}
if (!containsClass) {
return %orig;
}
NSMutableArray *newChildren = [children mutableCopy];
// Add button to children array
//UIBarButtonItem *bhSettingsButton = [[UIBarButtonItem alloc] initWithImage:[UIImage systemImageNamed:@"gear.circle"] style:UIBarButtonItemStylePlain target:self action:@selector(displaySettingsModal)];
/* IGBadgedNavigationButton *badgedNavButton = [IGBadgedNavigationButton new]; */

//UIButton *newButton = [UIButton buttonWithType:UIButtonTypeSystem];
//[badgedNavButton ]

//[newChildren addObject:badgedNavButton];

// Make children array immutable
//NSArray *immutableNewChildren = [newChildren copy];

NSLog(@"[BHInsta] Old Children: %@", children);
NSLog(@"[BHInsta] New Children: %@", newChildren);


return %orig(newChildren);
}
%end */

0 comments on commit 4c418af

Please sign in to comment.