Skip to content

Instantly share code, notes, and snippets.

@BandarHL
Created February 22, 2020 22:27
Show Gist options
  • Save BandarHL/61e0edcd02636256bbf6da87e88464e9 to your computer and use it in GitHub Desktop.
Save BandarHL/61e0edcd02636256bbf6da87e88464e9 to your computer and use it in GitHub Desktop.
CCFLEXible
#import "CCFLEXible.h"
#import <objc/runtime.h>
#include <dlfcn.h>
@interface FLEXManager : NSObject
+ (instancetype)sharedManager;
- (void)showExplorer;
- (void)hideExplorer;
- (void)toggleExplorer;
@end
@implementation CCFLEXible
//Return the icon of your module here
- (UIImage *)iconGlyph
{
return [UIImage imageNamed:@"FLEXibleIcon" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
}
//Return the color selection color of your module here
- (UIColor *)selectedColor
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
return window.tintColor;
}
- (BOOL)isSelected
{
return _selected;
}
- (void)setSelected:(BOOL)selected
{
_selected = selected;
[super refreshState];
if(_selected)
{
//Your module got selected, do something
void *handle = dlopen("/usr/lib/CCFLEXible/FLEX.dylib", RTLD_LAZY);
if (handle != NULL) {
[[objc_getClass("FLEXManager") sharedManager] showExplorer];
dlclose(handle);
}
}
else
{
//Your module got unselected, do something
void *handle = dlopen("/usr/lib/CCFLEXible/FLEX.dylib", RTLD_LAZY);
if (handle != NULL) {
[[objc_getClass("FLEXManager") sharedManager] hideExplorer];
dlclose(handle);
}
}
}
@end
CCFLEXible_CFLAGS = -fobjc-arc -Wno-error -Wno-deprecated-declarations -Wimplicit-function-declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment